Skip to content

Commit

Permalink
send notify mail from noreply
Browse files Browse the repository at this point in the history
  • Loading branch information
ThibautGery committed Jun 2, 2016
1 parent 3555317 commit 74fff46
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 3 additions & 3 deletions src/api-umbrella/web-app/app/mailers/api_user_mailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
describe "signup_email" do
before(:each) do
ApiUmbrellaConfig[:web][:contact_form_email] = "[email protected]"
ApiUmbrellaConfig[:web][:default_host] = "localhost.com"
end

let(:api_user) do
Expand All @@ -114,7 +115,7 @@
end

it "the receiver can be overwrited by the admin " do
ApiUmbrellaConfig[:admin_notify_email] = "[email protected]"
ApiUmbrellaConfig[:web][:admin_notify_email] = "[email protected]"
subject
expect(ActionMailer::Base.deliveries.first.to).to eq ["[email protected]"]
end
Expand All @@ -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 ["[email protected]"]
end

it "send an email with usage in the body" do
subject
expect(ActionMailer::Base.deliveries.first.encoded).to include "I WANNA DO EVERYTHING"
Expand Down

0 comments on commit 74fff46

Please sign in to comment.