From 195d34b09549df1cdd087dee9fa4194bf8144864 Mon Sep 17 00:00:00 2001 From: Martin Fenner Date: Tue, 14 Jul 2020 09:07:26 +0200 Subject: [PATCH] Use correct title (DataCite service name) for emails --- Gemfile.lock | 2 +- app/models/concerns/mailable.rb | 6 +++++- app/models/user.rb | 6 +++++- spec/concerns/crosscitable_spec.rb | 6 +++--- 4 files changed, 14 insertions(+), 6 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index dcc0d925c..c44e96c9d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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) diff --git a/app/models/concerns/mailable.rb b/app/models/concerns/mailable.rb index 486c49317..73e795541 100644 --- a/app/models/concerns/mailable.rb +++ b/app/models/concerns/mailable.rb @@ -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 diff --git a/app/models/user.rb b/app/models/user.rb index 3b44b04cf..2c63b07ca 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -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) diff --git a/spec/concerns/crosscitable_spec.rb b/spec/concerns/crosscitable_spec.rb index d62e15f2d..963cb7fdb 100644 --- a/spec/concerns/crosscitable_spec.rb +++ b/spec/concerns/crosscitable_spec.rb @@ -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 @@ -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