Skip to content

Commit

Permalink
Use correct title (DataCite service name) for emails
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Jul 14, 2020
1 parent 3da3b36 commit 195d34b
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ GEM
nio4r (2.5.2)
nokogiri (1.10.10)
mini_portile2 (~> 2.4.0)
oj (3.10.6)
oj (3.10.7)
oj_mimic_json (1.0.1)
optimist (3.0.1)
pandoc-ruby (2.1.4)
Expand Down
6 changes: 5 additions & 1 deletion app/models/concerns/mailable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ def send_welcome_email(responsible_id: nil)
jwt = encode_token(payload.merge(iat: Time.now.to_i, exp: Time.now.to_i + 3600 * 24, aud: Rails.env))
url = ENV['BRACCO_URL'] + "?jwt=" + jwt
reset_url = ENV['BRACCO_URL'] + "/reset"
title = Rails.env.stage? ? "DataCite Fabrica Test" : "DataCite Fabrica"
if Rails.env == "stage"
title = ENV['ES_PREFIX'].present? ? "DataCite Fabrica Stage" : "DataCite Fabrica Test"
else
title = "DataCite Fabrica"
end
subject = "#{title}: New Account"
account_type = self.class.name == "Provider" ? member_type.humanize : client_type.humanize
responsible_id = (responsible_id || "admin").upcase
Expand Down
6 changes: 5 additions & 1 deletion app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,11 @@ def self.reset(username)
jwt = encode_token(payload.merge(iat: Time.now.to_i, exp: Time.now.to_i + 3600 * 24, aud: Rails.env))
url = ENV['BRACCO_URL'] + "?jwt=" + jwt
reset_url = ENV['BRACCO_URL'] + "/reset"
title = Rails.env.stage? ? "DataCite Fabrica Test" : "DataCite Fabrica"
if Rails.env == "stage"
title = ENV['ES_PREFIX'].present? ? "DataCite Fabrica Stage" : "DataCite Fabrica Test"
else
title = "DataCite Fabrica"
end
subject = "#{title}: Password Reset Request"
account_type = user.class.name == "Provider" ? user.member_type.humanize : user.client_type.humanize
text = User.format_message_text(template: "users/reset.text.erb", title: title, contact_name: user.name, name: user.symbol, url: url, reset_url: reset_url)
Expand Down
6 changes: 3 additions & 3 deletions spec/concerns/crosscitable_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@

it "from_json starts with unexpected character" do
string = file_fixture('datacite.xml').read
expect { subject.from_json(string) }.to raise_error(JSON::ParserError, /Empty input \(\) at line 1, column 1/)
expect { subject.from_json(string) }.to raise_error(JSON::ParserError, /Empty input \(after \) at line 1, column 1/)
end

it "from_json malformed" do
string = file_fixture('citeproc_malformed.json').read
expect { subject.from_json(string) }.to raise_error(JSON::ParserError, /expected comma, not a string \(id\) at line 4, column 9/)
expect { subject.from_json(string) }.to raise_error(JSON::ParserError, /expected comma, not a string \(after id\) at line 4, column 9/)
end

it "from_json duplicate keys" do
Expand All @@ -84,7 +84,7 @@

it "from_json starts with unexpected character" do
string = 'abc'
expect { subject.well_formed_xml(string) }.to raise_error(JSON::ParserError, /Empty input \(\) at line 1, column 1/)
expect { subject.well_formed_xml(string) }.to raise_error(JSON::ParserError, /Empty input \(after \) at line 1, column 1/)
end

it "from_json malformed" do
Expand Down

0 comments on commit 195d34b

Please sign in to comment.