|
1 | 1 | describe EmailsController do
|
2 | 2 | let(:mailgun_params) { {
|
3 |
| - "domain" => ENV['MAILGUN_DOMAIN'], |
4 |
| - "tag" => "*", |
5 |
| - "recipient" => "someone@example.com", |
6 |
| - "event" => "unsubscribed", |
7 |
| - "email_type" => Notifier::ACTIVITY_EVENT, |
8 |
| - "timestamp" => "1327043027", |
9 |
| - "token" => ENV['MAILGUN_TOKEN'], |
10 |
| - "signature" => ENV['MAILGUN_SIGNATURE'], |
11 |
| - "controller" => "emails", |
12 |
| - "action" => "unsubscribe"} } |
| 3 | + 'domain' => ENV['MAILGUN_DOMAIN'], |
| 4 | + 'tag' => '*', |
| 5 | + 'recipient' => 'someone@example.com', |
| 6 | + 'event' => 'unsubscribed', |
| 7 | + 'email_type' => Notifier::ACTIVITY_EVENT, |
| 8 | + 'timestamp' => '1327043027', |
| 9 | + 'token' => ENV['MAILGUN_TOKEN'], |
| 10 | + 'signature' => ENV['MAILGUN_SIGNATURE'], |
| 11 | + 'controller' => 'emails', |
| 12 | + 'action' => 'unsubscribe'} |
| 13 | + } |
13 | 14 |
|
14 | 15 | it 'unsubscribes member from notifications when they unsubscribe from a notification email on mailgun' do
|
15 | 16 | user = Fabricate(:user, email: 'someone@example.com')
|
16 | 17 | user.notify_on_award.should == true
|
| 18 | + EmailsController.any_instance.should_receive(:encrypt_signature).and_return(ENV['MAILGUN_SIGNATURE']) |
17 | 19 | post :unsubscribe, mailgun_params
|
18 | 20 | user.reload
|
19 | 21 | user.notify_on_award.should == false
|
|
24 | 26 | user = Fabricate(:user, email: 'someone@example.com')
|
25 | 27 | new_params = mailgun_params
|
26 | 28 | new_params["email_type"] = Notifier::WELCOME_EVENT
|
| 29 | + EmailsController.any_instance.should_receive(:encrypt_signature).and_return(ENV['MAILGUN_SIGNATURE']) |
27 | 30 | post :unsubscribe, mailgun_params
|
28 | 31 | user.reload
|
29 | 32 | user.notify_on_award.should == true
|
|
0 commit comments