Commit fe47b515599e428819d04d961a1540bda376ce23
1 parent
145f4745
Exists in
master
and in
29 other branches
[work-assignment] Setting user on work_assignment cache_key
Showing
2 changed files
with
17 additions
and
0 deletions
Show diff stats
plugins/work_assignment/lib/work_assignment_plugin/work_assignment.rb
... | ... | @@ -40,4 +40,9 @@ class WorkAssignmentPlugin::WorkAssignment < Folder |
40 | 40 | children.map(&:children).flatten.compact |
41 | 41 | end |
42 | 42 | |
43 | + def cache_key_with_person(params = {}, user = nil, language = 'en') | |
44 | + cache_key_without_person + (user && profile.members.include?(user) ? "-#{user.identifier}" : '') | |
45 | + end | |
46 | + alias_method_chain :cache_key, :person | |
47 | + | |
43 | 48 | end | ... | ... |
plugins/work_assignment/test/unit/work_assingment_plugin/work_assignment_test.rb
... | ... | @@ -40,4 +40,16 @@ class WorkAssignmentTest < ActiveSupport::TestCase |
40 | 40 | author_folder = work_assignment.find_or_create_author_folder(author) |
41 | 41 | assert author_folder, submission.parent |
42 | 42 | end |
43 | + | |
44 | + should 'add logged user on cache_key if is a member' do | |
45 | + organization = fast_create(Organization) | |
46 | + not_member = fast_create(Person) | |
47 | + member = fast_create(Person) | |
48 | + organization.add_member(member) | |
49 | + work_assignment = WorkAssignmentPlugin::WorkAssignment.create!(:name => 'Sample Work Assignment', :profile => organization) | |
50 | + | |
51 | + assert_no_match(/-#{not_member.identifier}/, work_assignment.cache_key({}, not_member)) | |
52 | + assert_match(/-#{member.identifier}/, work_assignment.cache_key({}, member)) | |
53 | + end | |
54 | + | |
43 | 55 | end | ... | ... |