Commit 28912265 authored by Maxim Rydkin's avatar Maxim Rydkin

finish spec/finders/yet_another_users_finder_spec.rb

parent fbbb985a
...@@ -9,78 +9,66 @@ describe YetAnotherUsersFinder do ...@@ -9,78 +9,66 @@ describe YetAnotherUsersFinder do
let(:current_user) { create(:user) } let(:current_user) { create(:user) }
let(:params) { {} } let(:params) { {} }
it 'returns no users' do let(:users) { User.all }
users = described_class.new(params: params, current_user: current_user).execute subject { described_class.new(params: params, current_user: current_user, users: users).execute.to_a }
expect(users.size).to eq(0) context 'when users param not passed or nil' do
end let(:users) { nil }
# context 'with a normal user' do
# let(:user) { create(:user) }
# it 'returns all users' do
# users = described_class.new(user).execute
# expect(users).to contain_exactly(user, user1, user2, omniauth_user) it { is_expected.to match_array([]) }
# end end
# it 'filters by username' do
# users = described_class.new(user, username: 'johndoe').execute
# expect(users).to contain_exactly(user1) it { is_expected.to match_array([user1, external_user, omniauth_user, current_user]) }
# end
# it 'filters by search' do context 'when filtered by search' do
# users = described_class.new(user, search: 'orando').execute let(:params) { {search: 'johndoe' } }
# expect(users).to contain_exactly(user2) it { is_expected.to match_array([user1]) }
# end end
# it 'filters by blocked users' do context 'when filtered by skip_users' do
# users = described_class.new(user, blocked: true).execute let(:params) { {skip_users: [omniauth_user.id, current_user.id] } }
# expect(users).to contain_exactly(user2) it { is_expected.to match_array([user1, external_user]) }
# end end
# it 'filters by active users' do context 'when todos exist' do
# users = described_class.new(user, active: true).execute let!(:pending_todo1) { create(:todo, user: current_user, author: user1, state: :pending) }
let!(:pending_todo2) { create(:todo, user: external_user, author: omniauth_user, state: :pending) }
let!(:done_todo1) { create(:todo, user: current_user, author: external_user, state: :done) }
let!(:done_todo2) { create(:todo, user: user1, author: external_user, state: :done) }
# expect(users).to contain_exactly(user, user1, omniauth_user) context 'when filtered by todo_filter without todo_state_filter' do
# end let(:params) { {todo_filter: true} }
# it 'returns no external users' do it { is_expected.to match_array([]) }
# users = described_class.new(user, external: true).execute end
# expect(users).to contain_exactly(user, user1, user2, omniauth_user) context 'when filtered by todo_filter with pending todo_state_filter' do
# end let(:params) { {todo_filter: true, todo_state_filter: 'pending'} }
# it 'filters by created_at' do it { is_expected.to match_array([user1]) }
# filtered_user_before = create(:user, created_at: 3.days.ago) end
# filtered_user_after = create(:user, created_at: Time.now + 3.days)
# users = described_class.new(user,
# created_after: 2.days.ago,
# created_before: Time.now + 2.days).execute
# expect(users.map(&:username)).not_to include([filtered_user_before.username, filtered_user_after.username]) context 'when filtered by todo_filter with done todo_state_filter' do
# end let(:params) { {todo_filter: true, todo_state_filter: 'done'} }
# end
# context 'with an admin user' do it { is_expected.to match_array([external_user]) }
# let(:admin) { create(:admin) } end
end
# it 'filters by external users' do context 'when filtered by current_user' do
# users = described_class.new(admin, external: true).execute let(:current_user) { user2 }
let(:params) { {current_user: true } }
# expect(users).to contain_exactly(external_user) it { is_expected.to match_array([user2, user1, external_user, omniauth_user]) }
# end end
# it 'returns all users' do context 'when filtered by author_id' do
# users = described_class.new(admin).execute let(:params) { {author_id: user2.id } }
# expect(users).to contain_exactly(admin, user1, user2, external_user, omniauth_user) it { is_expected.to match_array([user2, user1, external_user, omniauth_user, current_user]) }
# end end
# end
end end
end end
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