summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2016-06-29 06:11:42 -0700
committerStan Hu <stanhu@gmail.com>2016-06-29 13:42:15 -0700
commit20688cdf0711f0d7d70abdf01db5a4f3a0671c6c (patch)
treed8eb4c8a17f2a2f19e1b3275f4aacf167796500f /spec
parent8c29b0b06554eb9549fe9bd2f33e80ce149752fd (diff)
downloadgitlab-ce-20688cdf0711f0d7d70abdf01db5a4f3a0671c6c.tar.gz
Be explicit which project and user ID are memoized
Diffstat (limited to 'spec')
-rw-r--r--spec/helpers/notes_helper_spec.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/spec/helpers/notes_helper_spec.rb b/spec/helpers/notes_helper_spec.rb
index 8325af0dcf8..08a93503258 100644
--- a/spec/helpers/notes_helper_spec.rb
+++ b/spec/helpers/notes_helper_spec.rb
@@ -22,11 +22,25 @@ describe NotesHelper do
end
it 'return human access levels' do
+ original_method = project.team.method(:human_max_access)
+ expect_any_instance_of(ProjectTeam).to receive(:human_max_access).exactly(3).times do |*args|
+ original_method.call(args[1])
+ end
+
expect(helper.note_max_access_for_user(owner_note)).to eq('Owner')
expect(helper.note_max_access_for_user(master_note)).to eq('Master')
expect(helper.note_max_access_for_user(reporter_note)).to eq('Reporter')
# Call it again to ensure value is cached
expect(helper.note_max_access_for_user(owner_note)).to eq('Owner')
end
+
+ it 'handles access in different projects' do
+ second_project = create(:empty_project)
+ second_project.team << [master, :reporter]
+ other_note = create(:note, author: master, project: second_project)
+
+ expect(helper.note_max_access_for_user(master_note)).to eq('Master')
+ expect(helper.note_max_access_for_user(other_note)).to eq('Reporter')
+ end
end
end