diff options
author | James Lopez <james@jameslopez.es> | 2017-07-06 16:59:40 +0200 |
---|---|---|
committer | James Lopez <james@jameslopez.es> | 2017-07-07 10:38:57 +0200 |
commit | b08df253ef16d635883451aafeb71b4a6f4ccd09 (patch) | |
tree | cac2529bde00206b7ab19fa9092da16cd25d5d37 /spec/requests | |
parent | d206bb3e608885a91f97a7c35a8cd00c69aa6e54 (diff) | |
download | gitlab-ce-b08df253ef16d635883451aafeb71b4a6f4ccd09.tar.gz |
add finder and users API spec
Diffstat (limited to 'spec/requests')
-rw-r--r-- | spec/requests/api/users_spec.rb | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/spec/requests/api/users_spec.rb b/spec/requests/api/users_spec.rb index 70b94a09e6b..18b11a77494 100644 --- a/spec/requests/api/users_spec.rb +++ b/spec/requests/api/users_spec.rb @@ -163,6 +163,35 @@ describe API::Users do expect(response).to have_http_status(400) end + + it "returns an user created before a specific date" do + user = create(:user, created_at: Date.new(2000,1,1)) + + get api("/users?created_before=2000-01-02T00:00:00.060Z", admin) + + expect(response).to have_http_status(200) + expect(json_response.size).to eq(1) + expect(json_response.first['username']).to eq(user.username) + end + + it "returns no users created before a specific date" do + create(:user, created_at: Date.new(2001,1,1)) + + get api("/users?created_before=2000-01-02T00:00:00.060Z", admin) + + expect(response).to have_http_status(200) + expect(json_response.size).to eq(0) + end + + it "returns users created before and after a specific date" do + user = create(:user, created_at: Date.new(2001,1,1)) + + get api("/users?created_before=2001-01-02T00:00:00.060Z&created_after=1999-01-02T00:00:00.060", admin) + + expect(response).to have_http_status(200) + expect(json_response.size).to eq(1) + expect(json_response.first['username']).to eq(user.username) + end end end |