Commit 15389851 authored by James Lopez's avatar James Lopez

add finder and users API spec

parent 9d3b8832
...@@ -61,6 +61,12 @@ describe UsersFinder do ...@@ -61,6 +61,12 @@ describe UsersFinder do
expect(users).to contain_exactly(user, user1, user2, omniauth_user) expect(users).to contain_exactly(user, user1, user2, omniauth_user)
end end
end end
it 'filters by created_at' do
users = described_class.new(user, created_after: 2.days.ago, created_before: Time.now + 2.days).execute
expect(users.count).to eq(4)
end
end end
context 'with an admin user' do context 'with an admin user' do
......
...@@ -163,6 +163,35 @@ describe API::Users do ...@@ -163,6 +163,35 @@ describe API::Users do
expect(response).to have_http_status(400) expect(response).to have_http_status(400)
end 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
context "when authenticated and ldap is enabled" do context "when authenticated and ldap is enabled" do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment