Skip to content

Commit

Permalink
send note creation notification to also the admins (#137)
Browse files Browse the repository at this point in the history
  • Loading branch information
syphax-bouazzouni authored Apr 29, 2024
1 parent 135b0df commit d35265c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
1 change: 1 addition & 0 deletions lib/ontologies_linked_data/utils/notifications.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def self.new_note(note)

note.relatedOntology.each do |ont|
Notifier.notify_subscribed_separately subject, body, ont, 'NOTES'
Notifier.notify_mails_grouped subject, body, Notifier.support_mails + Notifier.admin_mails(ont)
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/ontologies_linked_data/utils/notifier.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def self.notify_subscribed_separately(subject, body, ontology, notification_type
end

def self.notify_administrators_grouped(subject, body, ontology)
notify_support_grouped subject, body, admin_mails(ontology)
notify_support_grouped subject, body
end

def self.notify_mails_separately(subject, body, mails)
Expand Down
14 changes: 10 additions & 4 deletions test/util/test_notifications.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,14 @@ def self.before_suite
@@ont = LinkedData::SampleData::Ontology.create_ontologies_and_submissions(ont_count: 1, submission_count: 1)[2].first
@@ont.bring_remaining
@@user = @@ont.administeredBy.first
@@subscription = self.new("before_suite")._subscription(@@ont)
@@user.bring_remaining
@@user.subscription = [@@subscription]
@@user.save

@@subscription = self.new("before_suite")._subscription(@@ont)

@@user2 = LinkedData::Models::User.new(username: "tim2", email: "[email protected]", password: "password").save
@@user2.bring_remaining
@@user2.subscription = [@@subscription]
@@user2.save
end

def self.after_suite
Expand Down Expand Up @@ -79,7 +83,9 @@ def test_new_note_notification
note.relatedOntology = [@@ont]
note.save
assert last_email_sent.subject.include?("[#{@@ui_name} Notes]")
assert_equal [@@user.email], last_email_sent.to
last_emails = all_emails[-2..]
assert_equal [@@user.email, LinkedData.settings.admin_emails].flatten.sort, last_emails.last.to.sort
assert_equal [@@user2.email].sort, last_emails.first.to.sort
ensure
note.delete if note
end
Expand Down

0 comments on commit d35265c

Please sign in to comment.