diff --git a/src/api-umbrella/web-app/app/controllers/api/v1/users_controller.rb b/src/api-umbrella/web-app/app/controllers/api/v1/users_controller.rb index 0e46028f1..72c4c5363 100644 --- a/src/api-umbrella/web-app/app/controllers/api/v1/users_controller.rb +++ b/src/api-umbrella/web-app/app/controllers/api/v1/users_controller.rb @@ -60,7 +60,7 @@ def create send_welcome_email = true end - if(!send_notify_email && ApiUmbrellaConfig[:send_notify_email].to_s == "true") + if(!send_notify_email && ApiUmbrellaConfig[:web][:send_notify_email].to_s == "true") send_notify_email = true end diff --git a/src/api-umbrella/web-app/app/mailers/api_user_mailer.rb b/src/api-umbrella/web-app/app/mailers/api_user_mailer.rb index 8feb13c77..ba80d4f69 100644 --- a/src/api-umbrella/web-app/app/mailers/api_user_mailer.rb +++ b/src/api-umbrella/web-app/app/mailers/api_user_mailer.rb @@ -27,12 +27,12 @@ def signup_email(user, options) def notify_api_admin(user) @user = user - to = ApiUmbrellaConfig[:admin_notify_email].presence || ApiUmbrellaConfig[:web][:contact_form_email] + to = ApiUmbrellaConfig[:web][:admin_notify_email].presence || ApiUmbrellaConfig[:web][:contact_form_email] full_name = "#{@user.first_name} #{@user.last_name}" - + from = "noreply@#{ApiUmbrellaConfig[:web][:default_host]}" mail :subject => "#{full_name} just subscribed", - :from => MailSanitizer.sanitize_address(user.email), + :from => MailSanitizer.sanitize_address(from), :to => MailSanitizer.sanitize_address(to) end end diff --git a/src/api-umbrella/web-app/spec/controllers/api/v1/users_controller_spec.rb b/src/api-umbrella/web-app/spec/controllers/api/v1/users_controller_spec.rb index f885c6ff6..2e5e2bbf3 100644 --- a/src/api-umbrella/web-app/spec/controllers/api/v1/users_controller_spec.rb +++ b/src/api-umbrella/web-app/spec/controllers/api/v1/users_controller_spec.rb @@ -1005,9 +1005,9 @@ admin_token_auth(@admin) expect do p = params - ApiUmbrellaConfig[:send_notify_email] = true + ApiUmbrellaConfig[:web][:send_notify_email] = true post :create, p - ApiUmbrellaConfig[:send_notify_email] = false + ApiUmbrellaConfig[:web][:send_notify_email] = false end.to change { ActionMailer::Base.deliveries.count }.by(1) end diff --git a/src/api-umbrella/web-app/spec/mailers/api_user_mailer_spec.rb b/src/api-umbrella/web-app/spec/mailers/api_user_mailer_spec.rb index fdf94863b..031394e3e 100644 --- a/src/api-umbrella/web-app/spec/mailers/api_user_mailer_spec.rb +++ b/src/api-umbrella/web-app/spec/mailers/api_user_mailer_spec.rb @@ -91,6 +91,7 @@ describe "signup_email" do before(:each) do ApiUmbrellaConfig[:web][:contact_form_email] = "aaa@bbb.com" + ApiUmbrellaConfig[:web][:default_host] = "localhost.com" end let(:api_user) do @@ -114,7 +115,7 @@ end it "the receiver can be overwrited by the admin " do - ApiUmbrellaConfig[:admin_notify_email] = "ccc@ddd.com" + ApiUmbrellaConfig[:web][:admin_notify_email] = "ccc@ddd.com" subject expect(ActionMailer::Base.deliveries.first.to).to eq ["ccc@ddd.com"] end @@ -124,6 +125,11 @@ expect(ActionMailer::Base.deliveries.first.subject).to eq "aaa bbb just subscribed" end + it "send an email from the server name" do + subject + expect(ActionMailer::Base.deliveries.first.from).to eq ["noreply@localhost.com"] + end + it "send an email with usage in the body" do subject expect(ActionMailer::Base.deliveries.first.encoded).to include "I WANNA DO EVERYTHING"