diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-01-20 12:16:11 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-01-20 12:16:11 +0300 |
commit | edaa33dee2ff2f7ea3fac488d41558eb5f86d68c (patch) | |
tree | 11f143effbfeba52329fb7afbd05e6e2a3790241 /spec/finders/user_recent_events_finder_spec.rb | |
parent | d8a5691316400a0f7ec4f83832698f1988eb27c1 (diff) |
Add latest changes from gitlab-org/gitlab@14-7-stable-eev14.7.0-rc42
Diffstat (limited to 'spec/finders/user_recent_events_finder_spec.rb')
-rw-r--r-- | spec/finders/user_recent_events_finder_spec.rb | 36 |
1 files changed, 34 insertions, 2 deletions
diff --git a/spec/finders/user_recent_events_finder_spec.rb b/spec/finders/user_recent_events_finder_spec.rb index 74c563b9bf6..6019d22059d 100644 --- a/spec/finders/user_recent_events_finder_spec.rb +++ b/spec/finders/user_recent_events_finder_spec.rb @@ -59,14 +59,46 @@ RSpec.describe UserRecentEventsFinder do expect(events.size).to eq(6) end + context 'selected events' do + let!(:push_event) { create(:push_event, project: public_project, author: project_owner) } + let!(:push_event_second_user) { create(:push_event, project: public_project_second_user, author: second_user) } + + it 'only includes selected events (PUSH) from all users', :aggregate_failures do + event_filter = EventFilter.new(EventFilter::PUSH) + events = described_class.new(current_user, [project_owner, second_user], event_filter, params).execute + + expect(events).to contain_exactly(push_event, push_event_second_user) + end + end + it 'does not include events from users with private profile', :aggregate_failures do allow(Ability).to receive(:allowed?).and_call_original allow(Ability).to receive(:allowed?).with(current_user, :read_user_profile, second_user).and_return(false) events = described_class.new(current_user, [project_owner, second_user], nil, params).execute - expect(events).to include(private_event, internal_event, public_event) - expect(events.size).to eq(3) + expect(events).to contain_exactly(private_event, internal_event, public_event) + end + + context 'with pagination params' do + using RSpec::Parameterized::TableSyntax + + where(:limit, :offset, :ordered_expected_events) do + nil | nil | lazy { [public_event_second_user, internal_event_second_user, private_event_second_user, public_event, internal_event, private_event] } + 2 | nil | lazy { [public_event_second_user, internal_event_second_user] } + nil | 4 | lazy { [internal_event, private_event] } + 2 | 2 | lazy { [private_event_second_user, public_event] } + end + + with_them do + let(:params) { { limit: limit, offset: offset }.compact } + + it 'returns paginated events sorted by id (DESC)' do + events = described_class.new(current_user, [project_owner, second_user], nil, params).execute + + expect(events).to eq(ordered_expected_events) + end + end end end |