-
Notifications
You must be signed in to change notification settings - Fork 328
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
notify the admin from the controller
- Loading branch information
1 parent
b73f5ca
commit cbe9bf8
Showing
3 changed files
with
75 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -980,6 +980,64 @@ | |
end | ||
end | ||
end | ||
|
||
describe "notify e-mail" do | ||
before(:each) do | ||
Delayed::Worker.delay_jobs = false | ||
ActionMailer::Base.deliveries.clear | ||
ApiUmbrellaConfig[:web][:contact_form_email] = "[email protected]" | ||
end | ||
|
||
after(:each) do | ||
Delayed::Worker.delay_jobs = true | ||
end | ||
|
||
it "sends a notify e-mail to be sent when requested" do | ||
admin_token_auth(@admin) | ||
expect do | ||
p = params | ||
p[:options] = { :send_notify_email => true } | ||
post :create, p | ||
end.to change { ActionMailer::Base.deliveries.count }.by(1) | ||
end | ||
|
||
it "does not send notify e-mails when explicitly disabled" do | ||
admin_token_auth(@admin) | ||
expect do | ||
p = params | ||
p[:options] = { :send_notify_email => false } | ||
post :create, p | ||
end.to change { ActionMailer::Base.deliveries.count }.by(0) | ||
end | ||
|
||
it "does not send a notify e-mail when the option is an unknown value" do | ||
admin_token_auth(@admin) | ||
expect do | ||
p = params | ||
p[:options] = { :send_notify_email => 1 } | ||
post :create, p | ||
end.to change { ActionMailer::Base.deliveries.count }.by(0) | ||
end | ||
|
||
it "does not send notify e-mails by default" do | ||
admin_token_auth(@admin) | ||
expect do | ||
post :create, params | ||
end.to change { ActionMailer::Base.deliveries.count }.by(0) | ||
end | ||
|
||
it "queues a welcome e-mail to when delayed job is enabled" do | ||
Delayed::Worker.delay_jobs = true | ||
admin_token_auth(@admin) | ||
expect do | ||
expect do | ||
p = params | ||
p[:options] = { :send_notify_email => true } | ||
post :create, p | ||
end.to change { Delayed::Job.count }.by(1) | ||
end.to change { ActionMailer::Base.deliveries.count }.by(0) | ||
end | ||
end | ||
end | ||
|
||
describe "PUT update" do | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -93,11 +93,14 @@ | |
ApiUmbrellaConfig[:web][:contact_form_email] = "[email protected]" | ||
end | ||
|
||
let(:api_user) { FactoryGirl.create(:api_user, | ||
:first_name => "aaa", | ||
:last_name => "bbb", | ||
:use_description => "I WANNA DO EVERYTHING", | ||
:email => "[email protected]") } | ||
let(:api_user) do | ||
FactoryGirl.create( | ||
:api_user, | ||
:first_name => "aaa", | ||
:last_name => "bbb", | ||
:use_description => "I WANNA DO EVERYTHING", | ||
:email => "[email protected]") | ||
end | ||
|
||
subject { ApiUserMailer.notify_api_admin(api_user).deliver } | ||
|
||
|