mail_manager 3.0.0 → 3.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/.gitignore +5 -0
- data/.rspec +1 -0
- data/.ruby-version +1 -1
- data/Gemfile +27 -10
- data/LICENSE.txt +2 -2
- data/MIT-LICENSE +1 -1
- data/README.md +97 -15
- data/{features/bounce_management.feature → app/assets/images/mail_manager/.gitkeep} +0 -0
- data/app/assets/images/mail_manager/BottomRight.gif +0 -0
- data/app/assets/images/mail_manager/MidRight.gif +0 -0
- data/app/assets/images/mail_manager/TopCenter.gif +0 -0
- data/app/assets/images/mail_manager/TopRight.gif +0 -0
- data/app/assets/images/mail_manager/calendar_date_select/calendar.gif +0 -0
- data/app/assets/images/mail_manager/iReach_logo.gif +0 -0
- data/app/assets/images/mail_manager/spacer.gif +0 -0
- data/app/assets/images/mail_manager/topMid.gif +0 -0
- data/app/assets/javascripts/mail_manager/application.js +19 -1
- data/app/assets/javascripts/mail_manager/jquery-ui-timepicker-addon.js +2134 -0
- data/app/assets/stylesheets/mail_manager/admin.css +261 -0
- data/app/assets/stylesheets/mail_manager/application.css +3 -1
- data/app/assets/stylesheets/mail_manager/nav.css +68 -0
- data/app/assets/stylesheets/mail_manager/timepicker.css +11 -0
- data/app/controllers/mail_manager/application_controller.rb +7 -2
- data/app/controllers/mail_manager/bounces_controller.rb +5 -10
- data/app/controllers/mail_manager/contacts_controller.rb +42 -20
- data/app/controllers/mail_manager/mailing_lists_controller.rb +5 -12
- data/app/controllers/mail_manager/mailings_controller.rb +18 -18
- data/app/controllers/mail_manager/messages_controller.rb +3 -10
- data/app/controllers/mail_manager/subscriptions_controller.rb +16 -75
- data/app/helpers/mail_manager/layout_helper.rb +43 -0
- data/app/models/mail_manager/bounce.rb +16 -5
- data/app/models/mail_manager/contact.rb +64 -1
- data/app/models/mail_manager/mailable.rb +14 -0
- data/app/models/mail_manager/mailer.rb +48 -81
- data/app/models/mail_manager/mailing.rb +23 -42
- data/app/models/mail_manager/message.rb +52 -8
- data/app/models/mail_manager/subscription.rb +9 -3
- data/app/models/status_history.rb +3 -2
- data/app/views/layouts/mail_manager/application.html.erb +33 -5
- data/app/views/layouts/mail_manager/layout.html.erb +15 -0
- data/app/views/mail_manager/bounces/index.html.erb +6 -4
- data/app/views/mail_manager/bounces/show.html.erb +3 -3
- data/app/views/mail_manager/contacts/_form.html.erb +7 -23
- data/app/views/mail_manager/contacts/edit.html.erb +3 -3
- data/app/views/mail_manager/contacts/index.html.erb +14 -28
- data/app/views/mail_manager/contacts/new.html.erb +2 -2
- data/app/views/mail_manager/contacts/show.html.erb +5 -5
- data/app/views/mail_manager/contacts/subscribe.html.erb +1 -1
- data/app/views/mail_manager/mailer/double_opt_in.erb +1 -1
- data/app/views/mail_manager/mailer/double_opt_in.html.erb +6 -0
- data/app/views/mail_manager/mailer/unsubscribed.erb +1 -1
- data/app/views/mail_manager/mailer/unsubscribed.html.erb +1 -1
- data/app/views/mail_manager/mailing_lists/_form.html.erb +8 -17
- data/app/views/mail_manager/mailing_lists/edit.html.erb +4 -4
- data/app/views/mail_manager/mailing_lists/index.html.erb +6 -5
- data/app/views/mail_manager/mailing_lists/new.html.erb +3 -3
- data/app/views/mail_manager/mailings/_form.html.erb +22 -44
- data/app/views/mail_manager/mailings/edit.html.erb +3 -3
- data/app/views/mail_manager/mailings/index.html.erb +23 -27
- data/app/views/mail_manager/mailings/new.html.erb +2 -2
- data/app/views/mail_manager/mailings/test.html.erb +3 -3
- data/app/views/mail_manager/messages/index.html.erb +2 -2
- data/app/views/mail_manager/subscriptions/_form.html.erb +1 -1
- data/app/views/mail_manager/subscriptions/_subscriptions.html.erb +2 -2
- data/app/views/mail_manager/subscriptions/edit.html.erb +2 -2
- data/app/views/mail_manager/subscriptions/index.html.erb +3 -3
- data/app/views/mail_manager/subscriptions/new.html.erb +1 -1
- data/app/views/mail_manager/subscriptions/unsubscribe.html.erb +1 -1
- data/app/views/mail_manager/subscriptions/unsubscribe_by_email_address.html.erb +3 -3
- data/config/locales/en.yml +13 -0
- data/config/locales/mailings.en.yml +52 -0
- data/config/routes.rb +21 -19
- data/db/migrate/008_add_bounces_count_to_mailings.rb +14 -0
- data/db/migrate/009_add_messages_count_to_mailings.rb +14 -0
- data/db/migrate/010_add_login_token_to_contact.rb +11 -0
- data/db/migrate/011_add_deleted_at_to_mailing.rb +11 -0
- data/lib/delayed/mailer.rb +9 -5
- data/lib/delayed/status.rb +6 -2
- data/lib/delayed_overrides/worker.rb +21 -0
- data/lib/deleteable.rb +13 -14
- data/lib/mail_manager/config.rb +3 -3
- data/lib/mail_manager/engine.rb +136 -7
- data/lib/mail_manager/lock.rb +1 -0
- data/lib/mail_manager/version.rb +1 -1
- data/lib/tasks/mail_manager.rake +92 -56
- data/mail_manager.gemspec +4 -0
- data/spec/rails_helper.rb +50 -0
- data/spec/spec_helper.rb +87 -48
- data/spec/test_app/.env.development +3 -0
- data/spec/test_app/.env.test +2 -0
- data/spec/test_app/.rspec +1 -0
- data/spec/test_app/Procfile +3 -0
- data/spec/test_app/app/controllers/application_controller.rb +4 -0
- data/spec/test_app/app/models/ability.rb +7 -0
- data/spec/test_app/app/models/user.rb +8 -2
- data/spec/test_app/app/models/user_with_role.rb +22 -0
- data/spec/test_app/config/database.postgres.yml +21 -0
- data/spec/test_app/config/database.sqlite.yml +2 -2
- data/spec/test_app/config/environment.rb +2 -2
- data/spec/test_app/config/environments/test.rb +13 -0
- data/spec/test_app/config/mail_manager.yml +66 -2
- data/spec/test_app/config/routes.rb +0 -1
- data/spec/test_app/db/migrate/20150420163235_add_bounces_count_to_mailings.rb +14 -0
- data/spec/test_app/db/migrate/20150420163804_add_messages_count_to_mailings.rb +14 -0
- data/spec/test_app/db/migrate/20150421151457_add_login_token_to_contact.rb +11 -0
- data/spec/test_app/db/migrate/20150423143754_add_deleted_at_to_mailing.rb +11 -0
- data/spec/test_app/db/schema.rb +10 -5
- data/spec/test_app/db/structure.sql +150 -15
- data/spec/test_app/features/bounce_management.feature +11 -0
- data/spec/test_app/features/contact_management.feature +91 -0
- data/{features → spec/test_app/features}/mailable.feature +3 -1
- data/spec/test_app/features/mailing_list_management.feature +39 -0
- data/spec/test_app/features/mailing_management.feature +60 -0
- data/{features → spec/test_app/features}/message.feature +4 -4
- data/spec/test_app/features/message_management.feature +22 -0
- data/spec/test_app/features/step_definitions/bounce_steps.rb +4 -0
- data/spec/test_app/features/step_definitions/contact_steps.rb +63 -0
- data/spec/test_app/features/step_definitions/debugging_steps.rb +3 -0
- data/spec/test_app/features/step_definitions/email_steps.rb +6 -0
- data/spec/test_app/features/step_definitions/job_steps.rb +25 -0
- data/spec/test_app/features/step_definitions/login_steps.rb +4 -0
- data/spec/test_app/features/step_definitions/mailing_list.rb +17 -0
- data/spec/test_app/features/step_definitions/mailing_steps.rb +51 -0
- data/spec/test_app/features/step_definitions/subscription_steps.rb +26 -0
- data/{features → spec/test_app/features}/step_definitions/webrat_steps.rb +10 -6
- data/spec/test_app/features/subscription_management.feature +62 -0
- data/spec/test_app/features/support/env.rb +37 -0
- data/spec/test_app/features/support/paths.rb +36 -0
- data/spec/test_app/lib/debugging.rb +61 -0
- data/spec/test_app/lib/post_office_manager.rb +71 -0
- data/spec/test_app/public/subscribe.html +40 -0
- data/spec/test_app/script/full_suite +50 -0
- data/spec/test_app/script/post_office +25 -0
- data/spec/test_app/script/rails +20 -0
- data/spec/test_app/script/rspec_multi_db +34 -0
- data/spec/test_app/spec/controllers/mail_manager/bounces_controller_spec.rb +59 -0
- data/spec/test_app/spec/controllers/mail_manager/contacts_controller_spec.rb +178 -0
- data/spec/test_app/spec/controllers/mail_manager/mailing_lists_controller_spec.rb +164 -0
- data/spec/test_app/spec/controllers/mail_manager/mailings_controller_spec.rb +184 -0
- data/spec/test_app/spec/controllers/users_controller_spec.rb +47 -46
- data/spec/test_app/spec/factories/_functions.rb +27 -0
- data/spec/test_app/spec/factories/contacts.rb +7 -0
- data/spec/test_app/spec/factories/mail_manager_bounces.rb +13 -0
- data/spec/test_app/spec/factories/mailable.rb +8 -0
- data/spec/test_app/spec/factories/mailings.rb +7 -1
- data/spec/test_app/spec/factories/message.rb +7 -0
- data/spec/test_app/spec/factories/users.rb +19 -7
- data/spec/test_app/spec/features/mail_manager/bounce_spec.rb +73 -0
- data/spec/test_app/spec/features/mail_manager/double_opt_in_spec.rb +62 -0
- data/spec/test_app/spec/features/mail_manager/mailing_spec.rb +46 -0
- data/spec/test_app/spec/features/navigation_spec.rb +9 -0
- data/spec/test_app/spec/helpers/mail_manager/layout_helper_spec.rb +41 -0
- data/spec/test_app/spec/helpers/mail_manager/subscriptions_helper_spec.rb +14 -0
- data/spec/test_app/spec/models/delayed/mailer_spec.rb +27 -0
- data/spec/test_app/spec/models/delayed/status_job_spec.rb +13 -0
- data/spec/test_app/spec/models/delayed/status_spec.rb +37 -0
- data/spec/test_app/spec/models/mail_manager/bounce_spec.rb +23 -3
- data/spec/test_app/spec/models/mail_manager/engine_spec.rb +79 -0
- data/spec/test_app/spec/models/mail_manager/mailable_spec.rb +10 -0
- data/spec/test_app/spec/models/mail_manager/mailer_spec.rb +35 -3
- data/spec/test_app/spec/models/mail_manager/mailing_list_spec.rb +5 -5
- data/spec/test_app/spec/models/mail_manager/mailing_spec.rb +58 -0
- data/spec/test_app/spec/models/mail_manager/message_spec.rb +112 -0
- data/spec/test_app/spec/models/user_spec.rb +10 -8
- data/spec/test_app/spec/rails_helper.rb +86 -0
- data/spec/test_app/spec/requests/users_spec.rb +3 -3
- data/spec/test_app/spec/routing/mail_manager/bounces_routing_spec.rb +27 -0
- data/spec/test_app/spec/routing/mail_manager/contacts_routing_spec.rb +36 -0
- data/spec/test_app/spec/routing/mail_manager/mailing_lists_routing_spec.rb +36 -0
- data/spec/test_app/spec/routing/mail_manager/mailings_routing_spec.rb +36 -0
- data/spec/test_app/spec/spec_helper.rb +82 -32
- data/spec/test_app/spec/support/continuance.rb +18 -0
- data/spec/test_app/spec/support/custom_matchers.rb +17 -0
- data/spec/test_app/spec/support/database_cleaner.rb +10 -1
- data/spec/test_app/spec/views/mail_manager/bounces/index.html.erb_spec.rb +32 -0
- data/spec/test_app/spec/views/mail_manager/bounces/show.html.erb_spec.rb +12 -0
- data/spec/test_app/spec/views/users/edit.html.erb_spec.rb +8 -5
- data/spec/test_app/spec/views/users/index.html.erb_spec.rb +10 -19
- data/spec/test_app/spec/views/users/new.html.erb_spec.rb +9 -6
- data/spec/test_app/spec/views/users/show.html.erb_spec.rb +8 -9
- metadata +231 -75
- data/.DS_Store +0 -0
- data/README.rdoc +0 -3
- data/app/.DS_Store +0 -0
- data/app/controllers/mail_manager/base_controller.rb +0 -22
- data/app/models/.DS_Store +0 -0
- data/features/contact_management.feature +0 -24
- data/features/mailing_management.feature +0 -78
- data/features/step_definitions/email_steps.rb +0 -50
- data/features/step_definitions/mlm_steps.rb +0 -11
- data/features/step_definitions/pickle_steps.rb +0 -41
- data/features/subscription_management.feature +0 -17
- data/features/support/env.rb +0 -11
- data/features/support/paths.rb +0 -44
- data/lib/tasks/mail_manager_tasks.rake +0 -4
- data/lib/tasks/rspec.rake +0 -165
- data/spec/test_app/bin/cucumber +0 -7
- data/spec/test_app/bin/rails +0 -10
- data/spec/test_app/bin/rake +0 -7
- data/spec/test_app/bin/rspec +0 -7
- data/spec/test_app/bin/spring +0 -18
- data/spec/test_app/spec/routing/users_routing_spec.rb +0 -35
- data/spec/test_app/spec/support/post_office.rb +0 -13
@@ -3,7 +3,8 @@ Feature: Mailable Registration
|
|
3
3
|
As an object
|
4
4
|
I want be able to register as a mailable object
|
5
5
|
|
6
|
-
|
6
|
+
@wip
|
7
|
+
Scenario: reusable mailables will be available when I create a new mailing
|
7
8
|
Given the following mlm mailable records
|
8
9
|
| name | email_html | email_text | reusable |
|
9
10
|
| June Newsletter | <head><title>June Newsletter</title><body>June Newsletter</body></html> | June Newsletter | true |
|
@@ -13,6 +14,7 @@ Feature: Mailable Registration
|
|
13
14
|
Then I should see "June Newsletter"
|
14
15
|
And I should not see "July Newsletter"
|
15
16
|
|
17
|
+
@wip
|
16
18
|
Scenario: a new raw mailable can be created when creating a new mailing
|
17
19
|
When I go to the new mlm mailing page
|
18
20
|
And I select "New Mailable" from "mailing[mailable]"
|
@@ -0,0 +1,39 @@
|
|
1
|
+
Feature: Mailing List Management
|
2
|
+
In order have mailing lists
|
3
|
+
As a valid user
|
4
|
+
I want to create, modify and destroy mailing lists
|
5
|
+
|
6
|
+
Background:
|
7
|
+
Given I am logged in and authorized for everything
|
8
|
+
|
9
|
+
Scenario: Create a Mailing List
|
10
|
+
When I go to the mailing lists page
|
11
|
+
And I follow "New Mailing List"
|
12
|
+
And I fill in "Name" with "Bobo's Mailing List"
|
13
|
+
And I fill in "Description" with "Bobo's mailing list is Awesome!"
|
14
|
+
And I press "Submit"
|
15
|
+
Then I should see "Mailing List was successfully created"
|
16
|
+
And a mailing list named "Bobo's Mailing List" should exist
|
17
|
+
|
18
|
+
Scenario: Edit a Mailing List
|
19
|
+
Given a mailing list named "Funk" exists
|
20
|
+
When I go to the mailing lists page
|
21
|
+
And I follow "Edit"
|
22
|
+
And I fill in "Name" with "Junk"
|
23
|
+
And I press "Submit"
|
24
|
+
Then I should see "Mailing List was successfully updated"
|
25
|
+
And a mailing list named "Junk" should exist
|
26
|
+
|
27
|
+
Scenario: Mailing Lists can be destroyed
|
28
|
+
Given a mailing list named "Funk" exists
|
29
|
+
When I go to the mailing lists page
|
30
|
+
And I follow "Delete"
|
31
|
+
Then I should see "Mailing List was deleted."
|
32
|
+
And I should not see "Funk"
|
33
|
+
|
34
|
+
Scenario: Mailing lists paginate
|
35
|
+
Given 50 mailing lists exist
|
36
|
+
When I go to the mailing lists page
|
37
|
+
Then I should see "Previous"
|
38
|
+
And I should see "Next"
|
39
|
+
When I follow "Next"
|
@@ -0,0 +1,60 @@
|
|
1
|
+
Feature: Mailing Management
|
2
|
+
In order send mailings to my mailing list
|
3
|
+
As a valid user
|
4
|
+
I want to create, modify, schedule and cancel mailings
|
5
|
+
|
6
|
+
Background:
|
7
|
+
Given I am logged in and authorized for everything
|
8
|
+
And a mailing with subject "Buy my junk!" exists
|
9
|
+
And a mailing list named "Funk" exists
|
10
|
+
And I clear the job queue
|
11
|
+
And I set jobs to be delayed
|
12
|
+
|
13
|
+
Scenario: edit a mailing
|
14
|
+
When I go to the mailings page
|
15
|
+
And I follow "Edit"
|
16
|
+
Then I should see "Edit Buy my junk!"
|
17
|
+
When I check "Funk"
|
18
|
+
And I fill in "Email subject" with "Buy my Stuff!"
|
19
|
+
And I press "Submit"
|
20
|
+
Then the mailing with subject "Buy my Stuff!" should be sending to lists "Funk"
|
21
|
+
|
22
|
+
Scenario: schedule a mailing
|
23
|
+
When I go to the mailings page
|
24
|
+
And the "Schedule" link has a confirmation that includes "Are you sure you want to start the mailing at"
|
25
|
+
And I follow "Schedule"
|
26
|
+
Then I should see "Buy my junk!"
|
27
|
+
And the mailing with subject "Buy my junk!" should be scheduled
|
28
|
+
And I should see "scheduled"
|
29
|
+
And I should see "Edit"
|
30
|
+
And I should see "Cancel"
|
31
|
+
|
32
|
+
Scenario: Cancel a mailing
|
33
|
+
Given the mailing with subject "Buy my junk!" is scheduled
|
34
|
+
When I go to the mailings page
|
35
|
+
And I follow "Cancel"
|
36
|
+
Then I should see "Buy my junk!"
|
37
|
+
And the mailing with subject "Buy my junk!" should be canceled
|
38
|
+
And I should see "pending"
|
39
|
+
And I should see "Send Test"
|
40
|
+
And I should see "Edit"
|
41
|
+
|
42
|
+
Scenario: send a test message for mailing
|
43
|
+
When I go to the mailings page
|
44
|
+
And I follow "Send Test"
|
45
|
+
And I fill in "test_email_addresses" with "test@example.com"
|
46
|
+
And I press "Send Test Email"
|
47
|
+
Then I should see "Buy my junk!"
|
48
|
+
And I should see "Send Test"
|
49
|
+
And I should see "Edit"
|
50
|
+
And a test email job should exist for mailing with subject "Buy my junk!" and email "test@example.com"
|
51
|
+
When I run all jobs
|
52
|
+
Then an email is sent to "test@example.com" with subject "Buy my junk!"
|
53
|
+
|
54
|
+
Scenario: Many mailings existing will show pagination
|
55
|
+
Given 50 mailings exist
|
56
|
+
When I go to the mailings page
|
57
|
+
Then I should see "Previous"
|
58
|
+
And I should see "Next"
|
59
|
+
When I follow "Next"
|
60
|
+
|
@@ -3,9 +3,9 @@ Feature: Messages are tied to mailings even without subscriptions
|
|
3
3
|
As an administrator
|
4
4
|
I want to send messages for contacts that aren't subscribed
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
Scenario:
|
7
|
+
Given I am logged in and authorized for everything
|
8
|
+
And a mailing with subject "Mailing" exists
|
9
|
+
And a contact named "Bob Dole" exists with email_address "bob@example.com"
|
10
10
|
|
11
11
|
|
@@ -0,0 +1,22 @@
|
|
1
|
+
Feature: view messages for mailings
|
2
|
+
In order to see messages and their statuses for mailings
|
3
|
+
As a valid user
|
4
|
+
I want to search for messages by mailing and status
|
5
|
+
|
6
|
+
Background:
|
7
|
+
Given I am logged in and authorized for everything
|
8
|
+
And a mailing with subject "Buy my junk!" exists
|
9
|
+
And a mailing list named "Funk" exists
|
10
|
+
And the mailing with subject "Buy my junk!" is set to send to "Funk"
|
11
|
+
And a contact named "Bobo Clown" exists with email_address "bobo@example.com"
|
12
|
+
And contact "Bobo Clown" is subscribed to "Funk"
|
13
|
+
And I set jobs to run immediately
|
14
|
+
And the mailing with subject "Buy my junk!" is scheduled
|
15
|
+
|
16
|
+
@javascript
|
17
|
+
Scenario:
|
18
|
+
When I go to the mailings page
|
19
|
+
And I follow "Messages"
|
20
|
+
And I select "Any Status" from "Status"
|
21
|
+
Then I should see "bobo@example.com"
|
22
|
+
|
@@ -0,0 +1,63 @@
|
|
1
|
+
Given(/^a contact named "(.*?)" exists with email(?: |_)address "(.*?)"$/) do |contact, email|
|
2
|
+
first_name, last_name = contact.split(/\s+/,2)
|
3
|
+
FactoryGirl.create(:contact, email_address: email, first_name: first_name,
|
4
|
+
last_name: last_name
|
5
|
+
)
|
6
|
+
end
|
7
|
+
|
8
|
+
Given(/^(\d+) contacts exist$/) do |count|
|
9
|
+
count.to_i.times {FactoryGirl.create(:contact)}
|
10
|
+
end
|
11
|
+
|
12
|
+
Then(/^the contact "(.*?)" should be soft deleted$/) do |name|
|
13
|
+
first_name, last_name = name.split(/\s+/,2)
|
14
|
+
contact = MailManager::Contact.deleted.where(first_name: first_name, last_name: last_name).first
|
15
|
+
expect(contact.deleted?).to be true
|
16
|
+
expect(contact.deleted_at).not_to be nil
|
17
|
+
end
|
18
|
+
|
19
|
+
When(/^I undelete contact "(.*?)"$/) do |name|
|
20
|
+
first_name, last_name = name.split(/\s+/,2)
|
21
|
+
contact = MailManager::Contact.deleted.where(first_name: first_name, last_name: last_name).first
|
22
|
+
contact.undelete
|
23
|
+
end
|
24
|
+
|
25
|
+
Then(/^contact "(.*?)" should exist with email(?: |_)address "(.*?)"$/) do |name, email|
|
26
|
+
first_name, last_name = name.split(/\s+/,2)
|
27
|
+
contact = MailManager::Contact.where(first_name: first_name, last_name: last_name).first
|
28
|
+
expect(contact.email_address).to eq(email)
|
29
|
+
end
|
30
|
+
|
31
|
+
Given(/^(?:the )?contact (?:named )?"(.*?)" is subscribed to "(.*?)"$/) do |contact_name, mailing_lists|
|
32
|
+
first_name, last_name = contact_name.split(/\s+/,2)
|
33
|
+
contact = MailManager::Contact.where(first_name: first_name, last_name: last_name).first
|
34
|
+
mailing_lists.split(/\s*,\s*/).each do |list_name|
|
35
|
+
contact.subscribe(MailManager::MailingList.find_by_name(list_name))
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
When(/^I submit a static subscribe form for "(.*?)" with email(?: |_)address "(.*?)" and the mailing list named "(.*?)"$/) do |name, email, list|
|
40
|
+
mailing_list = MailManager::MailingList.where(name: name).first
|
41
|
+
contact = MailManager::Contact.where(email_address: email).first ||
|
42
|
+
MailManager::Contact.new
|
43
|
+
contact_attributes = {
|
44
|
+
mailing_list_id: mailing_list.id,
|
45
|
+
}
|
46
|
+
contact_attributes.merge(id: contact.id) unless contact.new_record?
|
47
|
+
visit mail_manager.subscribe_contact_path(contact: contact_attributes)
|
48
|
+
end
|
49
|
+
|
50
|
+
Then(/^contact "(.*?)" should be subscribed to "(.*?)" with the "(.*?)" status$/) do |name, list, status|
|
51
|
+
first_name, last_name = name.split(/\s+/,2)
|
52
|
+
contact = MailManager::Contact.where(first_name: first_name, last_name: last_name).first
|
53
|
+
subscription = contact.subscriptions.detect{|s| s.mailing_list.name.eql?(list)}
|
54
|
+
expect(subscription.status).to eq(status)
|
55
|
+
end
|
56
|
+
|
57
|
+
Then(/^contact "(.*?)" should be unsubscribed from "(.*?)"$/) do |name, list|
|
58
|
+
first_name, last_name = name.split(/\s+/,2)
|
59
|
+
contact = MailManager::Contact.where(first_name: first_name, last_name: last_name).first
|
60
|
+
subscription = contact.subscriptions.detect{|s| s.mailing_list.name.eql?(list)}
|
61
|
+
expect(subscription.status).to eq('unsubscribed')
|
62
|
+
end
|
63
|
+
|
@@ -0,0 +1,25 @@
|
|
1
|
+
Given(/^I clear the job queue$/) do
|
2
|
+
Delayed::Job.delete_all
|
3
|
+
end
|
4
|
+
|
5
|
+
Given(/^I set jobs to be delayed$/) do
|
6
|
+
Delayed::Worker.delay_jobs = true
|
7
|
+
end
|
8
|
+
|
9
|
+
Given(/^I set jobs to run immediately$/) do
|
10
|
+
Delayed::Worker.delay_jobs = false
|
11
|
+
end
|
12
|
+
|
13
|
+
|
14
|
+
Then(/^a test email job should exist for mailing with subject "(.*?)" and email "(.*?)"$/) do |subject, email|
|
15
|
+
mailing = MailManager::Mailing.where(subject: subject).first
|
16
|
+
test_message = MailManager::TestMessage.where(test_email_address: email, mailing_id: mailing.id).last
|
17
|
+
job = Delayed::Job.where("handler like '%MailManager::TestMessage%method_name: :deliver%'").first
|
18
|
+
expect(job.payload_object.object).to eq(test_message)
|
19
|
+
expect(job.payload_object.method_name).to eq(:deliver)
|
20
|
+
end
|
21
|
+
|
22
|
+
When(/^I run all jobs$/) do
|
23
|
+
Delayed::Worker.new(name: 'Bobo').work_off
|
24
|
+
end
|
25
|
+
|
@@ -0,0 +1,17 @@
|
|
1
|
+
Given(/^a mailing list named "(.*)" exists$/) do |name|
|
2
|
+
FactoryGirl.create(:mailing_list, name: name)
|
3
|
+
end
|
4
|
+
|
5
|
+
Given(/^(?:the)? mailing list named "(.*?)" is one of mailing "(.*?)"'s mailing_lists$/) do |list_name, subject|
|
6
|
+
mailing = MailManager::Mailing.where(subject: subject).first
|
7
|
+
mailing.mailing_lists << MailManager::MailingList.find_by_name(list_name)
|
8
|
+
end
|
9
|
+
|
10
|
+
Then(/^a mailing list named "(.*?)" should exist$/) do |name|
|
11
|
+
expect(MailManager::MailingList.find_by_name(name)).not_to be nil
|
12
|
+
end
|
13
|
+
|
14
|
+
Given(/^(\d+) mailing lists exist$/) do |count|
|
15
|
+
count.to_i.times{FactoryGirl.create(:mailing_list)}
|
16
|
+
end
|
17
|
+
|
@@ -0,0 +1,51 @@
|
|
1
|
+
Given(/^a mailing with subject "([^"]*?)" exists$/) do |subject|
|
2
|
+
mailing = FactoryGirl.create(:mailing, subject: subject)
|
3
|
+
end
|
4
|
+
|
5
|
+
Given(/^the mailing with subject "([^"]*?)" is set to send to "([^"]*?)"$/) do |subject, list_names|
|
6
|
+
mailing = MailManager::Mailing.where(subject: subject).first
|
7
|
+
mailing.mailing_lists.clear
|
8
|
+
list_names.split(/\s*,\s*/).each do |name|
|
9
|
+
mailing.mailing_lists << MailManager::MailingList.find_by_name(name)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
Given(/^the mailing with subject "(.*?)"'s messages are initialized$/) do |subject|
|
14
|
+
mailing = MailManager::Mailing.where(subject: subject).first
|
15
|
+
mailing.initialize_messages
|
16
|
+
end
|
17
|
+
|
18
|
+
Given(/^the mailing with subject "(.*?)" is scheduled$/) do |subject|
|
19
|
+
mailing = MailManager::Mailing.where(subject: subject).first
|
20
|
+
mailing.schedule
|
21
|
+
end
|
22
|
+
|
23
|
+
When(/^I deliver the mailing with subject "(.*?)"$/) do |subject|
|
24
|
+
mailing = MailManager::Mailing.where(subject: subject).first
|
25
|
+
mailing.deliver
|
26
|
+
end
|
27
|
+
|
28
|
+
Then(/^the mailing with subject "([^"]*?)" should be scheduled$/) do |subject|
|
29
|
+
mailing = MailManager::Mailing.where(subject: subject).first
|
30
|
+
expect(mailing.scheduled?).to be true
|
31
|
+
expect(mailing.job.handler).to match /MailManager::Mailing.*#{subject}/m
|
32
|
+
end
|
33
|
+
|
34
|
+
Then(/^the mailing with subject "([^"]*?)" should be canceled$/) do |subject|
|
35
|
+
mailing = MailManager::Mailing.where(subject: subject).first
|
36
|
+
expect(mailing.pending?).to be true
|
37
|
+
expect(mailing.job).to be nil
|
38
|
+
end
|
39
|
+
|
40
|
+
Then(/^the mailing with subject "(.*?)" should be sending to lists "(.*?)"$/) do |subject, list_names|
|
41
|
+
mailing = MailManager::Mailing.where(subject: subject).first
|
42
|
+
names = mailing.mailing_lists.map(&:name)
|
43
|
+
list_names.split(/\s*,\s*/).each do |name|
|
44
|
+
expect(names).to include (name)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
Given(/^(\d+) mailings exist$/) do |count|
|
49
|
+
count.to_i.times {FactoryGirl.create(:mailing)}
|
50
|
+
end
|
51
|
+
|
@@ -0,0 +1,26 @@
|
|
1
|
+
When(/^contact "(.*?)" uses the unsubscribe link$/) do |name|
|
2
|
+
first_name, last_name = name.split(/\s+/,2)
|
3
|
+
contact = MailManager::Contact.where(first_name: first_name, last_name: last_name).first
|
4
|
+
path = URI.parse(contact.messages.first.unsubscribe_url).path
|
5
|
+
visit path
|
6
|
+
end
|
7
|
+
|
8
|
+
Then(/^contact "(.*?)" should receive an email saying he unsubscribed$/) do |name|
|
9
|
+
first_name, last_name = name.split(/\s+/,2)
|
10
|
+
contact = MailManager::Contact.where(first_name: first_name, last_name: last_name).first
|
11
|
+
expect(ActionMailer::Base.deliveries.last.subject).to match /unsubscribe/i
|
12
|
+
ActionMailer::Base.deliveries.last.parts.map(&:body).each do |body|
|
13
|
+
expect(body).to match /Bob Dole/
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
When(/^I use the test email's unsubscribe link$/) do
|
18
|
+
unsubscribe_url = MailManager::TestMessage.last.unsubscribe_url
|
19
|
+
path = URI.parse(unsubscribe_url).path
|
20
|
+
visit path
|
21
|
+
end
|
22
|
+
|
23
|
+
When(/^I try to unsubscribe with an invalid guid$/) do
|
24
|
+
visit MailManager.unsubscribe_path + '/boboisaclown'
|
25
|
+
end
|
26
|
+
|
@@ -2,13 +2,17 @@ require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "pat
|
|
2
2
|
|
3
3
|
# Commonly used webrat steps
|
4
4
|
# http://github.com/brynary/webrat
|
5
|
+
When(/^the "(.*?)" link has a confirmation that includes "(.*?)"$/) do |link, confirmation_text|
|
6
|
+
expect(find_link("Schedule", match: :first)['data-confirm']).to match /#{confirmation_text}/
|
7
|
+
end
|
8
|
+
|
5
9
|
|
6
10
|
Given /^I am on (.+)$/ do |page_name|
|
7
|
-
visit path_to(page_name)
|
11
|
+
visit path_to(page_name,mail_manager)
|
8
12
|
end
|
9
13
|
|
10
14
|
When /^I go to (.+)$/ do |page_name|
|
11
|
-
visit path_to(page_name)
|
15
|
+
visit path_to(page_name,mail_manager)
|
12
16
|
end
|
13
17
|
|
14
18
|
When /^I press "([^\"]*)"$/ do |button|
|
@@ -16,7 +20,7 @@ When /^I press "([^\"]*)"$/ do |button|
|
|
16
20
|
end
|
17
21
|
|
18
22
|
When /^I follow "([^\"]*)"$/ do |link|
|
19
|
-
click_link(link)
|
23
|
+
click_link(link, match: :first)
|
20
24
|
end
|
21
25
|
|
22
26
|
When /^I fill in "([^\"]*)" with "([^\"]*)"$/ do |field, value|
|
@@ -91,11 +95,11 @@ When /^I attach the file at "([^\"]*)" to "([^\"]*)"$/ do |path, field|
|
|
91
95
|
end
|
92
96
|
|
93
97
|
Then /^I should see "([^\"]*)"$/ do |text|
|
94
|
-
|
98
|
+
expect(page.body).to have_content(text)
|
95
99
|
end
|
96
100
|
|
97
101
|
Then /^I should not see "([^\"]*)"$/ do |text|
|
98
|
-
|
102
|
+
expect(page.body).not_to have_content(text)
|
99
103
|
end
|
100
104
|
|
101
105
|
Then /^the "([^\"]*)" field should contain "([^\"]*)"$/ do |field, value|
|
@@ -111,5 +115,5 @@ Then /^the "([^\"]*)" checkbox should be checked$/ do |label|
|
|
111
115
|
end
|
112
116
|
|
113
117
|
Then /^I should be on (.+)$/ do |page_name|
|
114
|
-
URI.parse(current_url).path.should == path_to(page_name)
|
118
|
+
URI.parse(current_url).path.should == path_to(page_name,mail_manager)
|
115
119
|
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
Feature: Manage Subscriptions
|
2
|
+
In order to have a list of email addresses to send messages to
|
3
|
+
As an administrator
|
4
|
+
I want to manage a contact's subscriptions
|
5
|
+
|
6
|
+
Background:
|
7
|
+
Given a mailing with subject "Mailing" exists
|
8
|
+
And a mailing list named "List1" exists
|
9
|
+
And the mailing list named "List1" is one of mailing "Mailing"'s mailing_lists
|
10
|
+
And a mailing list named "List2" exists
|
11
|
+
And the mailing list named "List2" is one of mailing "Mailing"'s mailing_lists
|
12
|
+
And a mailing list named "List3" exists
|
13
|
+
And a mailing list named "List4" exists
|
14
|
+
And a contact named "Bob Dole" exists with email_address "bob@example.com"
|
15
|
+
And contact "Bob Dole" is subscribed to "List1, List3"
|
16
|
+
|
17
|
+
Scenario: Unsubscribe sends an email
|
18
|
+
When the mailing with subject "Mailing" is scheduled
|
19
|
+
# this is done when the job is created by scheduling
|
20
|
+
# And I deliver the mailing with subject "Mailing"
|
21
|
+
And contact "Bob Dole" uses the unsubscribe link
|
22
|
+
Then contact "Bob Dole" should receive an email saying he unsubscribed
|
23
|
+
And contact "Bob Dole" should be unsubscribed from "List1"
|
24
|
+
And contact "Bob Dole" should be subscribed to "List2" with the "pending" status
|
25
|
+
And contact "Bob Dole" should be unsubscribed from "List3"
|
26
|
+
And contact "Bob Dole" should be subscribed to "List4" with the "pending" status
|
27
|
+
|
28
|
+
Scenario: Unsubscribe from test message
|
29
|
+
When I go to the mailings page
|
30
|
+
And I follow "Send Test"
|
31
|
+
And I fill in "Test Email Address" with "bob@example.com"
|
32
|
+
And I press "Send Test Email"
|
33
|
+
And I use the test email's unsubscribe link
|
34
|
+
Then I should see "unsubscribed"
|
35
|
+
And I should see "bob@example.com"
|
36
|
+
And I should see "Test Mailing List"
|
37
|
+
|
38
|
+
Scenario: Unsubscribe from test message with no contact/subscription
|
39
|
+
When I go to the mailings page
|
40
|
+
And I follow "Send Test"
|
41
|
+
And I fill in "Test Email Address" with "bobo@example.com"
|
42
|
+
And I press "Send Test Email"
|
43
|
+
And I use the test email's unsubscribe link
|
44
|
+
Then I should see "unsubscribed"
|
45
|
+
And I should see "bobo@example.com"
|
46
|
+
And I should see "Test Mailing List"
|
47
|
+
|
48
|
+
Scenario: Unsubscribe by email address
|
49
|
+
When I go to the unsubscribe by email address page
|
50
|
+
And I fill in "Email Address" with "bob@example.com"
|
51
|
+
And I press "Unsubscribe"
|
52
|
+
Then I should see "Unsubscribed"
|
53
|
+
And I should see "bob@example.com"
|
54
|
+
And contact "Bob Dole" should be unsubscribed from "List1"
|
55
|
+
And contact "Bob Dole" should be subscribed to "List2" with the "pending" status
|
56
|
+
And contact "Bob Dole" should be unsubscribed from "List3"
|
57
|
+
And contact "Bob Dole" should be subscribed to "List4" with the "pending" status
|
58
|
+
|
59
|
+
Scenario: Unsubscribe with invalid guid
|
60
|
+
When I try to unsubscribe with an invalid guid
|
61
|
+
Then I should be on the unsubscribe by email address page
|
62
|
+
And I should see "We did not recognize that unsubscribe url! Please try unsubscribing with your email address."
|