Skip to content

Commit

Permalink
Adds publishing_request_cancellation mailer template and test
Browse files Browse the repository at this point in the history
  • Loading branch information
fherreazcue committed Aug 15, 2023
1 parent 830bffa commit 801b364
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/models/mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def request_publish_approval(gatekeeper, publisher, resources)
publish_notification gatekeeper, publisher, resources, "A #{Seek::Config.instance_name} member requested your approval to publish some items."
end

def publishing_request_cancellation(gatekeeper, publisher, resources)
def publishing_request_cancellation(gatekeeper, publisher, resources)
@gatekeeper = gatekeeper
publish_notification gatekeeper, publisher, resources, "A #{Seek::Config.instance_name} member cancelled a publishing approval request."
end
Expand Down
16 changes: 16 additions & 0 deletions app/views/mailer/publishing_request_cancellation.text.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Hi <%= @gatekeeper.name -%>,

The <%= Seek::Config.instance_name %> user <%= @publisher.name -%>, <%= person_url(@publisher) -%>, has cancelled a request previously sent to you to publish the following item(s):
<% @resources.each do |resource|%>
<% controller=resource.class.name.underscore.pluralize -%>
<%= resource.model_name.human -%>: <%= resource.title -%> - <%= url_for(:action=>:show,:controller=>controller,:id=>resource, :only_path => false) -%>
<% end %>

You do not need to take action.

You can contact <%= @publisher.first_name.capitalize -%> by replying to this email.

This is an automated email.

- <%= Seek::Config.instance_admins_name %> Team
13 changes: 13 additions & 0 deletions test/fixtures/mailer/publishing_request_cancellation
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Hi Gatekeeper Last,

The Sysmo SEEK user Aaron Spiggle, http://localhost:3000/people/-requester_id-, has cancelled a request previously sent to you to publish the following item(s):
Data file: Picture - http://localhost:3000/data_files/-df_id-
Model: Teusink - http://localhost:3000/models/-model_id-

You do not need to take action.

You can contact Aaron by replying to this email.

This is an automated email.

- SysMO-DB Team
22 changes: 22 additions & 0 deletions test/unit/mailer_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,28 @@ def setup
assert_equal expected_text, encode_mail(Mailer.request_publishing(owner, publisher, resources))
end

test 'cancel publishing request' do
gatekeeper = FactoryBot.create(:asset_gatekeeper, first_name: 'Gatekeeper', last_name: 'Last')
person = FactoryBot.create(:person, project: gatekeeper.projects.first)
resources = [FactoryBot.create(:data_file, projects: gatekeeper.projects, title: 'Picture', contributor:person), FactoryBot.create(:teusink_model, projects: gatekeeper.projects, title: 'Teusink', contributor:person)]
requester = FactoryBot.create(:person, first_name: 'Aaron', last_name: 'Spiggle')

@expected.subject = 'A Sysmo SEEK member cancelled a publishing approval request.'
@expected.to = gatekeeper.email_with_name
@expected.from = 'no-reply@sysmo-db.org'
@expected.reply_to = requester.person.email_with_name

@expected.body = read_fixture('publishing_request_cancellation')

expected_text = encode_mail(@expected)
expected_text.gsub!('-person_id-', gatekeeper.id.to_s)
expected_text.gsub!('-df_id-', resources[0].id.to_s)
expected_text.gsub!('-model_id-', resources[1].id.to_s)
expected_text.gsub!('-requester_id-', requester.person.id.to_s)

assert_equal expected_text, encode_mail(Mailer.publishing_request_cancellation(gatekeeper, requester, resources))
end

test 'gatekeeper approval feedback' do
gatekeeper = FactoryBot.create(:asset_gatekeeper, first_name: 'Gatekeeper', last_name: 'Last')
person = FactoryBot.create(:person, project: gatekeeper.projects.first)
Expand Down

0 comments on commit 801b364

Please sign in to comment.