Skip to content

Commit

Permalink
Include link to work in curator notification (#1687)
Browse files Browse the repository at this point in the history
* add hyperlink

* Include the link to the work in the notification

Co-authored-by: Claudia Lee <[email protected]>

* added tests for curator notification

* fixed typo

---------

Co-authored-by: Claudia Lee <[email protected]>
Co-authored-by: Claudia Lee <[email protected]>
  • Loading branch information
3 people authored Mar 11, 2024
1 parent 68eee06 commit 7087ead
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
8 changes: 5 additions & 3 deletions app/models/work.rb
Original file line number Diff line number Diff line change
Expand Up @@ -239,10 +239,12 @@ def update_curator(curator_user_id, current_user)

# ...and log the activity
new_curator = User.find(curator_user_id)
message = if curator_user_id == current_user.id
"Self-assigned as curator"

work_url = "[#{title}](#{Rails.application.routes.url_helpers.work_url(self)})"
message = if curator_user_id.to_i == current_user.id
"Self-assigned @#{current_user.uid} as curator for work #{work_url}"
else
"Set curator to @#{new_curator.uid}"
"Set curator to @#{new_curator.uid} for work #{work_url}"
end
WorkActivity.add_work_activity(id, message, current_user.id, activity_type: WorkActivity::SYSTEM)
end
Expand Down
2 changes: 1 addition & 1 deletion app/models/work_activity.rb
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def to_html
def created_by_user_html
return UNKNOWN_USER unless @work_activity.created_by_user

@work_activity.created_by_user.given_name_safe
"#{@work_activity.created_by_user.given_name_safe} (@#{@work_activity.created_by_user.uid})"
end

def created_sortable_html
Expand Down
5 changes: 3 additions & 2 deletions spec/models/work_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -406,13 +406,14 @@

work.change_curator(curator_user.id, user)
activity = WorkActivity.changes_for_work(work.id).last
expect(activity.message).to eq("Set curator to @#{curator_user.uid}")
work_url = "http://www.example.com/works/#{work.id}"
expect(activity.message).to eq("Set curator to @#{curator_user.uid} for work [#{work.title}](#{work_url})")
expect(work.curator.id).to be curator_user.id
expect(activity.created_by_user.id).to eq user.id

work.change_curator(user.id, user)
activity = WorkActivity.changes_for_work(work.id).last
expect(activity.message).to eq("Self-assigned as curator")
expect(activity.message).to eq("Self-assigned @#{user.uid} as curator for work [#{work.title}](#{work_url})")
expect(work.curator.id).to be user.id
expect(activity.created_by_user.id).to eq user.id

Expand Down

0 comments on commit 7087ead

Please sign in to comment.