Skip to content

Commit

Permalink
humanize account_type text. #475
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Apr 20, 2020
1 parent f5a58cd commit 076915e
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 12 deletions.
4 changes: 2 additions & 2 deletions app/models/concerns/mailable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def send_welcome_email
reset_url = ENV['BRACCO_URL'] + "/reset"
title = Rails.env.stage? ? "DataCite Fabrica Test" : "DataCite Fabrica"
subject = "#{title}: New Account"
account_type = self.class.name == "Provider" ? member_type : client_type
account_type = self.class.name == "Provider" ? member_type.humanize : client_type.humanize
text = User.format_message_text(template: "users/welcome.text.erb", title: title, contact_name: name, name: symbol, url: url, reset_url: reset_url)
html = User.format_message_html(template: "users/welcome.html.erb", title: title, contact_name: name, name: symbol, url: url, reset_url: reset_url)

Expand All @@ -48,7 +48,7 @@ def send_welcome_email
def send_delete_email
title = Rails.env.stage? ? "DataCite Fabrica Test" : "DataCite Fabrica"
subject = "#{title}: Account Deleted"
account_type = self.class.name == "Provider" ? member_type : client_type
account_type = self.class.name == "Provider" ? member_type.humanize : client_type.humanize
text = User.format_message_text(template: "users/delete.text.erb", title: title, contact_name: name, name: symbol)
html = User.format_message_html(template: "users/delete.html.erb", title: title, contact_name: name, name: symbol)

Expand Down
10 changes: 9 additions & 1 deletion spec/concerns/mailable_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

describe "Mailable", type: :model, vcr: true do
let(:token) { User.generate_token }
let(:provider) { create(:provider, symbol: "DATACITE") }
let(:provider) { create(:provider, symbol: "DATACITE", name: "DataCite", system_email: "[email protected]") }
let(:client) { create(:client, symbol: "DATACITE.DATACITE", name: "DataCite Repository", system_email: "[email protected]", provider: provider) }
let(:title) { "DataCite Fabrica" }

Expand Down Expand Up @@ -55,4 +55,12 @@
expect(Client.send_notification_to_slack(text, options)).to eq("ok")
end
end

context "send_notification_to_slack provider" do
it "succeeds" do
text = "Using system email #{provider.system_email}."
options = { title: "TEST: new provider account #{provider.symbol} created." }
expect(Client.send_notification_to_slack(text, options)).to eq("ok")
end
end
end

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions spec/fixtures/vcr_cassettes/Mailable/send_welcome_email.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 076915e

Please sign in to comment.