summaryrefslogtreecommitdiff
path: root/spec/finders/user_recent_events_finder_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/finders/user_recent_events_finder_spec.rb')
-rw-r--r--spec/finders/user_recent_events_finder_spec.rb46
1 files changed, 11 insertions, 35 deletions
diff --git a/spec/finders/user_recent_events_finder_spec.rb b/spec/finders/user_recent_events_finder_spec.rb
index 58470f4c84d..c5fcd68eb4c 100644
--- a/spec/finders/user_recent_events_finder_spec.rb
+++ b/spec/finders/user_recent_events_finder_spec.rb
@@ -13,49 +13,25 @@ describe UserRecentEventsFinder do
subject(:finder) { described_class.new(current_user, project_owner) }
describe '#execute' do
- context 'current user does not have access to projects' do
- it 'returns public and internal events' do
- records = finder.execute
-
- expect(records).to include(public_event, internal_event)
- expect(records).not_to include(private_event)
+ context 'when profile is public' do
+ it 'returns all the events' do
+ expect(finder.execute).to include(private_event, internal_event, public_event)
end
end
- context 'when current user has access to the projects' do
- before do
- private_project.add_developer(current_user)
- internal_project.add_developer(current_user)
- public_project.add_developer(current_user)
- end
-
- context 'when profile is public' do
- it 'returns all the events' do
- expect(finder.execute).to include(private_event, internal_event, public_event)
- end
- end
-
- context 'when profile is private' do
- it 'returns no event' do
- allow(Ability).to receive(:allowed?).and_call_original
- allow(Ability).to receive(:allowed?).with(current_user, :read_user_profile, project_owner).and_return(false)
- expect(finder.execute).to be_empty
- end
- end
+ context 'when profile is private' do
+ it 'returns no event' do
+ allow(Ability).to receive(:allowed?).and_call_original
+ allow(Ability).to receive(:allowed?).with(current_user, :read_user_profile, project_owner).and_return(false)
- it 'does not include the events if the user cannot read cross project' do
- expect(Ability).to receive(:allowed?).and_call_original
- expect(Ability).to receive(:allowed?).with(current_user, :read_cross_project) { false }
expect(finder.execute).to be_empty
end
end
- context 'when current user is anonymous' do
- let(:current_user) { nil }
-
- it 'returns public events only' do
- expect(finder.execute).to eq([public_event])
- end
+ it 'does not include the events if the user cannot read cross project' do
+ expect(Ability).to receive(:allowed?).and_call_original
+ expect(Ability).to receive(:allowed?).with(current_user, :read_cross_project) { false }
+ expect(finder.execute).to be_empty
end
end
end