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
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'rails_helper'
|
2
2
|
|
3
3
|
# This spec was generated by rspec-rails when you ran the scaffold generator.
|
4
4
|
# It demonstrates how one might use RSpec to specify the controller code that
|
@@ -18,51 +18,57 @@ require 'spec_helper'
|
|
18
18
|
# Message expectations are only used when there is no simpler way to specify
|
19
19
|
# that an instance is receiving a specific message.
|
20
20
|
|
21
|
-
describe UsersController do
|
21
|
+
RSpec.describe UsersController, :type => :controller do
|
22
22
|
|
23
23
|
# This should return the minimal set of attributes required to create a valid
|
24
24
|
# User. As you add validations to User, be sure to
|
25
25
|
# adjust the attributes here as well.
|
26
|
-
let(:valid_attributes) {
|
26
|
+
let(:valid_attributes) {
|
27
|
+
FactoryGirl.attributes_for(:user)
|
28
|
+
}
|
29
|
+
|
30
|
+
let(:invalid_attributes) {
|
31
|
+
FactoryGirl.attributes_for(:user, email: nil)
|
32
|
+
}
|
27
33
|
|
28
34
|
# This should return the minimal set of values that should be in the session
|
29
35
|
# in order to pass any filters (e.g. authentication) defined in
|
30
36
|
# UsersController. Be sure to keep this updated too.
|
31
37
|
let(:valid_session) { {} }
|
32
38
|
|
33
|
-
describe "GET index" do
|
39
|
+
describe "GET #index" do
|
34
40
|
it "assigns all users as @users" do
|
35
41
|
user = User.create! valid_attributes
|
36
42
|
get :index, {}, valid_session
|
37
|
-
assigns(:users).
|
43
|
+
expect(assigns(:users)).to eq([user])
|
38
44
|
end
|
39
45
|
end
|
40
46
|
|
41
|
-
describe "GET show" do
|
47
|
+
describe "GET #show" do
|
42
48
|
it "assigns the requested user as @user" do
|
43
49
|
user = User.create! valid_attributes
|
44
50
|
get :show, {:id => user.to_param}, valid_session
|
45
|
-
assigns(:user).
|
51
|
+
expect(assigns(:user)).to eq(user)
|
46
52
|
end
|
47
53
|
end
|
48
54
|
|
49
|
-
describe "GET new" do
|
55
|
+
describe "GET #new" do
|
50
56
|
it "assigns a new user as @user" do
|
51
57
|
get :new, {}, valid_session
|
52
|
-
assigns(:user).
|
58
|
+
expect(assigns(:user)).to be_a_new(User)
|
53
59
|
end
|
54
60
|
end
|
55
61
|
|
56
|
-
describe "GET edit" do
|
62
|
+
describe "GET #edit" do
|
57
63
|
it "assigns the requested user as @user" do
|
58
64
|
user = User.create! valid_attributes
|
59
65
|
get :edit, {:id => user.to_param}, valid_session
|
60
|
-
assigns(:user).
|
66
|
+
expect(assigns(:user)).to eq(user)
|
61
67
|
end
|
62
68
|
end
|
63
69
|
|
64
|
-
describe "POST create" do
|
65
|
-
|
70
|
+
describe "POST #create" do
|
71
|
+
context "with valid params" do
|
66
72
|
it "creates a new User" do
|
67
73
|
expect {
|
68
74
|
post :create, {:user => valid_attributes}, valid_session
|
@@ -71,78 +77,73 @@ describe UsersController do
|
|
71
77
|
|
72
78
|
it "assigns a newly created user as @user" do
|
73
79
|
post :create, {:user => valid_attributes}, valid_session
|
74
|
-
assigns(:user).
|
75
|
-
assigns(:user).
|
80
|
+
expect(assigns(:user)).to be_a(User)
|
81
|
+
expect(assigns(:user)).to be_persisted
|
76
82
|
end
|
77
83
|
|
78
84
|
it "redirects to the created user" do
|
79
85
|
post :create, {:user => valid_attributes}, valid_session
|
80
|
-
response.
|
86
|
+
expect(response).to redirect_to(User.last)
|
81
87
|
end
|
82
88
|
end
|
83
89
|
|
84
|
-
|
90
|
+
context "with invalid params" do
|
85
91
|
it "assigns a newly created but unsaved user as @user" do
|
86
|
-
|
87
|
-
|
88
|
-
post :create, {:user => { "first_name" => "invalid value" }}, valid_session
|
89
|
-
assigns(:user).should be_a_new(User)
|
92
|
+
post :create, {:user => invalid_attributes}, valid_session
|
93
|
+
expect(assigns(:user)).to be_a_new(User)
|
90
94
|
end
|
91
95
|
|
92
96
|
it "re-renders the 'new' template" do
|
93
|
-
|
94
|
-
|
95
|
-
post :create, {:user => { "first_name" => "invalid value" }}, valid_session
|
96
|
-
response.should render_template("new")
|
97
|
+
post :create, {:user => invalid_attributes}, valid_session
|
98
|
+
expect(response).to render_template("new")
|
97
99
|
end
|
98
100
|
end
|
99
101
|
end
|
100
102
|
|
101
|
-
describe "PUT update" do
|
102
|
-
|
103
|
+
describe "PUT #update" do
|
104
|
+
context "with valid params" do
|
105
|
+
let(:new_attributes) {
|
106
|
+
FactoryGirl.attributes_for(:user)
|
107
|
+
}
|
108
|
+
|
103
109
|
it "updates the requested user" do
|
104
110
|
user = User.create! valid_attributes
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
put :update, {:id => user.to_param, :user => { "first_name" => "MyString" }}, valid_session
|
111
|
+
put :update, {:id => user.to_param, :user => new_attributes}, valid_session
|
112
|
+
user = User.find(user.id)
|
113
|
+
new_attributes.each_pair do |key,value|
|
114
|
+
expect(user.send(key)).to eq(value)
|
115
|
+
end
|
111
116
|
end
|
112
117
|
|
113
118
|
it "assigns the requested user as @user" do
|
114
119
|
user = User.create! valid_attributes
|
115
120
|
put :update, {:id => user.to_param, :user => valid_attributes}, valid_session
|
116
|
-
assigns(:user).
|
121
|
+
expect(assigns(:user)).to eq(user)
|
117
122
|
end
|
118
123
|
|
119
124
|
it "redirects to the user" do
|
120
125
|
user = User.create! valid_attributes
|
121
126
|
put :update, {:id => user.to_param, :user => valid_attributes}, valid_session
|
122
|
-
response.
|
127
|
+
expect(response).to redirect_to(user)
|
123
128
|
end
|
124
129
|
end
|
125
130
|
|
126
|
-
|
131
|
+
context "with invalid params" do
|
127
132
|
it "assigns the user as @user" do
|
128
133
|
user = User.create! valid_attributes
|
129
|
-
|
130
|
-
|
131
|
-
put :update, {:id => user.to_param, :user => { "first_name" => "invalid value" }}, valid_session
|
132
|
-
assigns(:user).should eq(user)
|
134
|
+
put :update, {:id => user.to_param, :user => invalid_attributes}, valid_session
|
135
|
+
expect(assigns(:user)).to eq(user)
|
133
136
|
end
|
134
137
|
|
135
138
|
it "re-renders the 'edit' template" do
|
136
139
|
user = User.create! valid_attributes
|
137
|
-
|
138
|
-
|
139
|
-
put :update, {:id => user.to_param, :user => { "first_name" => "invalid value" }}, valid_session
|
140
|
-
response.should render_template("edit")
|
140
|
+
put :update, {:id => user.to_param, :user => invalid_attributes}, valid_session
|
141
|
+
expect(response).to render_template("edit")
|
141
142
|
end
|
142
143
|
end
|
143
144
|
end
|
144
145
|
|
145
|
-
describe "DELETE destroy" do
|
146
|
+
describe "DELETE #destroy" do
|
146
147
|
it "destroys the requested user" do
|
147
148
|
user = User.create! valid_attributes
|
148
149
|
expect {
|
@@ -153,7 +154,7 @@ describe UsersController do
|
|
153
154
|
it "redirects to the users list" do
|
154
155
|
user = User.create! valid_attributes
|
155
156
|
delete :destroy, {:id => user.to_param}, valid_session
|
156
|
-
response.
|
157
|
+
expect(response).to redirect_to(users_url)
|
157
158
|
end
|
158
159
|
end
|
159
160
|
|
@@ -0,0 +1,27 @@
|
|
1
|
+
def random_bool
|
2
|
+
Kernel.rand(2) == 1
|
3
|
+
end
|
4
|
+
|
5
|
+
def random_int(min,max)
|
6
|
+
count = max - min + 1
|
7
|
+
Kernel.rand(count) + min
|
8
|
+
end
|
9
|
+
|
10
|
+
def random_decimal(min,max,precision=2)
|
11
|
+
multiplier = 10 ** precision
|
12
|
+
count = max - min + 1
|
13
|
+
puts "multiplier: #{multiplier}"
|
14
|
+
(Kernel.rand(count * multiplier) + min * multiplier).to_f / multiplier
|
15
|
+
end
|
16
|
+
|
17
|
+
def random_value(values)
|
18
|
+
values[random_int(0,(values.length-1))]
|
19
|
+
end
|
20
|
+
|
21
|
+
def generate_plain_text_from_html(html)
|
22
|
+
IO.popen('lynx -stdin --dump','w+') do |lynx|
|
23
|
+
lynx.write html
|
24
|
+
lynx.close_write
|
25
|
+
lynx.readlines.join
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
FactoryGirl.define do
|
2
|
+
factory :bounce, :class => 'MailManager::Bounce' do
|
3
|
+
status {random_value([:needs_manual_intervention,:unprocessed,:dismissed,
|
4
|
+
:resolved,:invalid
|
5
|
+
])}
|
6
|
+
#status_changed_at {Time.now}
|
7
|
+
#bounce_message
|
8
|
+
#comments
|
9
|
+
#message nil
|
10
|
+
#mailing nil
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
FactoryGirl.define do
|
2
|
+
factory :mailable, class: MailManager::Mailable do
|
3
|
+
name {Faker::Company.bs.split(/\s+/).map(&:capitalize).join(" ")}
|
4
|
+
email_html {|a| %Q|<html><head><title>#{a.name}</title></head><body><h1>#{a.name}</h1><p><img src="file://#{MailManager::PLUGIN_ROOT}/app/assets/images/mail_manager/iReach_logo.gif"/><br/>#{Faker::Lorem.paragraphs.join("</p><p>")}</p></body></html>|}
|
5
|
+
email_text {|a| generate_plain_text_from_html(a.email_html)}
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
@@ -1,6 +1,12 @@
|
|
1
1
|
# Read about factories at https://github.com/thoughtbot/factory_girl
|
2
2
|
|
3
3
|
FactoryGirl.define do
|
4
|
-
factory :mailing do
|
4
|
+
factory :mailing, class: MailManager::Mailing do
|
5
|
+
subject {Faker::Company.bs.split(/\s+/).map(&:capitalize).join(' ')}
|
6
|
+
from_email_address {Faker::Internet.email}
|
7
|
+
scheduled_at {Time.now.utc}
|
8
|
+
mailable_type "MailManager::Mailable"
|
9
|
+
mailable_id {(MailManager::Mailable.first || FactoryGirl.create(:mailable)).id}
|
10
|
+
include_images {random_int(0,1)}
|
5
11
|
end
|
6
12
|
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
FactoryGirl.define do
|
2
|
+
factory :message, class: MailManager::Message do
|
3
|
+
mailing {MailManager::Mailing.first || FactoryGirl.create(:mailing)}
|
4
|
+
contact {MailManager::Contact.first || FactoryGirl.create(:contact)}
|
5
|
+
from_email_address {|a| a.contact.email_address}
|
6
|
+
end
|
7
|
+
end
|
@@ -1,10 +1,22 @@
|
|
1
1
|
# Read about factories at https://github.com/thoughtbot/factory_girl
|
2
|
-
|
3
|
-
FactoryGirl.define do
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
2
|
+
begin
|
3
|
+
FactoryGirl.define do
|
4
|
+
factory :user do
|
5
|
+
first_name {Faker::Name.first_name}
|
6
|
+
last_name {Faker::Name.last_name}
|
7
|
+
email {Faker::Internet.email}
|
8
|
+
phone {Faker::PhoneNumber.phone_number}
|
9
|
+
factory :admin_user do
|
10
|
+
last_name 'admin'
|
11
|
+
end
|
12
|
+
end
|
13
|
+
factory :admin_user_with_role, class: UserWithRole do
|
14
|
+
first_name {Faker::Name.first_name}
|
15
|
+
last_name 'admin'
|
16
|
+
email {Faker::Internet.email}
|
17
|
+
phone {Faker::PhoneNumber.phone_number}
|
18
|
+
end
|
9
19
|
end
|
20
|
+
rescue FactoryGirl::DuplicateDefinitionError => e
|
21
|
+
# this is ok ... duplicates when iReach uses it
|
10
22
|
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
RSpec.feature MailManager::Bounce do
|
4
|
+
context "without any bounces" do
|
5
|
+
it "should render the page" do
|
6
|
+
visit mail_manager.bounces_path
|
7
|
+
expect(page.status_code).to eq(200)
|
8
|
+
expect(page.body).to match /Listing Bounces/
|
9
|
+
end
|
10
|
+
it "should render the page when an unsent mailing exists" do
|
11
|
+
FactoryGirl.create(:mailing)
|
12
|
+
visit mail_manager.bounces_path
|
13
|
+
expect(page.status_code).to eq(200)
|
14
|
+
expect(page.body).to match /Listing Bounces/
|
15
|
+
end
|
16
|
+
context "when searching", js: true do
|
17
|
+
before(:each) do
|
18
|
+
@mailing1 = FactoryGirl.create(:mailing)
|
19
|
+
@mailing2 = FactoryGirl.create(:mailing)
|
20
|
+
@bounce1 = FactoryGirl.create(:bounce, mailing_id: @mailing1.id, status: 'needs_manual_intervention')
|
21
|
+
@bounce2 = FactoryGirl.create(:bounce, mailing_id: @mailing2.id, status: 'resolved')
|
22
|
+
@bounce3 = FactoryGirl.create(:bounce, status: 'invalid')
|
23
|
+
@mailing1.reload
|
24
|
+
@mailing2.reload
|
25
|
+
end
|
26
|
+
it "filters by mailing", js: true do
|
27
|
+
visit "/mail_manager/bounces"
|
28
|
+
select "#{@mailing1.subject} (#{I18n.l @mailing1.status_changed_at}) (#{@mailing1.bounces.size})", from: "Mailing:"
|
29
|
+
expect(page).to have_css("#view_bounce_#{@bounce1.id}", count: 1)
|
30
|
+
expect(page).to have_content("View",count: 1)
|
31
|
+
end
|
32
|
+
it "shows them all", js: true do
|
33
|
+
visit "/mail_manager/bounces"
|
34
|
+
expect(page).to have_css("#view_bounce_#{@bounce1.id}", count: 1)
|
35
|
+
expect(page).to have_css("#view_bounce_#{@bounce2.id}", count: 1)
|
36
|
+
expect(page).to have_css("#view_bounce_#{@bounce3.id}", count: 1)
|
37
|
+
expect(page).to have_content("View",count: 3)
|
38
|
+
end
|
39
|
+
it "filters by 'Needs Attention' status" do
|
40
|
+
visit "/mail_manager/bounces"
|
41
|
+
select "Needs Attention", from: "Status:"
|
42
|
+
expect(page).to have_css("#view_bounce_#{@bounce1.id}", count: 1)
|
43
|
+
expect(page).to have_content("View",count: 1)
|
44
|
+
end
|
45
|
+
it "filters by 'Resolved' status" do
|
46
|
+
visit "/mail_manager/bounces"
|
47
|
+
select "Resolved", from: "Status:"
|
48
|
+
expect(page).to have_css("#view_bounce_#{@bounce2.id}", count: 1)
|
49
|
+
expect(page).to have_content("View",count: 1)
|
50
|
+
end
|
51
|
+
it "doesn't show 'invalid' status" do
|
52
|
+
visit "/mail_manager/bounces"
|
53
|
+
expect{select "Invalid", from: "Status:"}.to raise_error
|
54
|
+
end
|
55
|
+
it "filters by 'Resolved' status and mailing" do
|
56
|
+
visit "/mail_manager/bounces"
|
57
|
+
select "Needs Attention", from: "Status:"
|
58
|
+
select "#{@mailing1.subject} (#{I18n.l @mailing1.status_changed_at}) (#{@mailing1.bounces.size})", from: "Mailing:"
|
59
|
+
expect(page).to have_css("#view_bounce_#{@bounce1.id}", count: 1)
|
60
|
+
expect(page).to have_content("View",count: 1)
|
61
|
+
end
|
62
|
+
it "filter by mailing and status can hide all bounces" do
|
63
|
+
visit "/mail_manager/bounces"
|
64
|
+
select "Resolved", from: "Status:"
|
65
|
+
Debugging::wait_until_success do
|
66
|
+
expect(page).to have_content("View",count: 1)
|
67
|
+
end
|
68
|
+
select "#{@mailing1.subject} (#{I18n.l @mailing1.status_changed_at}) (#{@mailing1.bounces.size})", from: "Mailing:"
|
69
|
+
expect(page).to have_content "No bounces"
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
RSpec.feature "Double Opt In Subscribe" do
|
4
|
+
before(:each) do
|
5
|
+
@mailing_list = FactoryGirl.create(:mailing_list)
|
6
|
+
MailManager::MailingList.update_all("id=1")
|
7
|
+
@mailing_list = MailManager::MailingList.find(1)
|
8
|
+
@other_mailing_list = FactoryGirl.create(:mailing_list)
|
9
|
+
end
|
10
|
+
it "creates a double opt in email when creating a new contact/subscription", truncate: true do
|
11
|
+
ActionMailer::Base.deliveries.clear
|
12
|
+
ActionMailer::Base.delivery_method = :test
|
13
|
+
Delayed::Worker.delay_jobs = false
|
14
|
+
visit "/subscribe.html"
|
15
|
+
fill_in "First Name", with: "Bobo"
|
16
|
+
fill_in "Last Name", with: "Clown"
|
17
|
+
fill_in "Email", with: "bobo@example.com"
|
18
|
+
click_button "Join"
|
19
|
+
Debugging::wait_until_success do
|
20
|
+
expect(MailManager::Contact.count).to eq 1
|
21
|
+
expect(MailManager::Subscription.count).to eq 1
|
22
|
+
end
|
23
|
+
contact = MailManager::Contact.first
|
24
|
+
subscription = MailManager::Subscription.first
|
25
|
+
expect(subscription.status).to eq 'pending'
|
26
|
+
email = ActionMailer::Base.deliveries.last
|
27
|
+
expect(ActionMailer::Base.deliveries.length).to eq 1
|
28
|
+
expect(email.to_s).to match /Confirm Newsletter Subscription/
|
29
|
+
and_it "email has the login token" do
|
30
|
+
expect(email.to_s).to match /#{contact.login_token}/
|
31
|
+
end
|
32
|
+
and_it "will give a new token if you try to opt in with a token that is more than 3 days old" do
|
33
|
+
Timecop.travel 3.days.from_now
|
34
|
+
old_token = contact.login_token
|
35
|
+
visit "#{MailManager.double_opt_in_path}/#{contact.login_token}"
|
36
|
+
contact = MailManager::Contact.find(contact.id)
|
37
|
+
expect(page).to have_content "Your token has expired"
|
38
|
+
expect(ActionMailer::Base.deliveries.length).to eq 2
|
39
|
+
expect(contact.login_token).not_to eq old_token
|
40
|
+
end
|
41
|
+
and_it "can confirm its subscription" do
|
42
|
+
visit "#{MailManager.double_opt_in_path}/#{contact.login_token}"
|
43
|
+
expect(MailManager::Subscription.count).to eq 1
|
44
|
+
subscription.reload
|
45
|
+
expect(subscription.status).to eq 'active'
|
46
|
+
end
|
47
|
+
Timecop.return
|
48
|
+
end
|
49
|
+
it "doesn't pay attention when the honeypot is submitted" do
|
50
|
+
ActionMailer::Base.deliveries.clear
|
51
|
+
ActionMailer::Base.delivery_method = :test
|
52
|
+
Delayed::Worker.delay_jobs = false
|
53
|
+
visit "/subscribe.html"
|
54
|
+
fill_in "First Name", with: "Bobo"
|
55
|
+
fill_in "Last Name", with: "Clown"
|
56
|
+
fill_in "Email", with: "bobo@example.com"
|
57
|
+
find(:css, "#company_name").set("FaSchizzle")
|
58
|
+
click_button "Join"
|
59
|
+
expect(MailManager::Contact.count).not_to eq 1
|
60
|
+
expect(MailManager::Subscription.count).not_to eq 1
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
RSpec.feature MailManager::Mailing, type: :feature do
|
4
|
+
context "a created mailing" do
|
5
|
+
before(:each) do
|
6
|
+
@mailing = FactoryGirl.create(:mailing)
|
7
|
+
end
|
8
|
+
it "soft deletes from the index page" do
|
9
|
+
visit "/mail_manager/mailings"
|
10
|
+
click_link "Delete"
|
11
|
+
expect(page).to have_content "Mailing successfully deleted"
|
12
|
+
expect(MailManager::Mailing.count).to eq 0
|
13
|
+
expect(MailManager::Mailing.deleted.count).to eq 1
|
14
|
+
end
|
15
|
+
it "doesn't blow up when trying to schedule a mailing with no scheduled_at" do
|
16
|
+
@mailing.update_attribute(:scheduled_at, nil)
|
17
|
+
visit "/mail_manager/mailings"
|
18
|
+
expect{click_link "Schedule"}.to raise_error
|
19
|
+
page.driver.put("/mail_manager/mailings/#{@mailing.id}/schedule")
|
20
|
+
expect(page.status_code).to eq 302
|
21
|
+
visit page.response_headers['Location']
|
22
|
+
expect(page.body).to have_content "Error! You must edit your mailing and set a time for your mailing to run."
|
23
|
+
end
|
24
|
+
it "can be scheduled" do
|
25
|
+
Delayed::Worker.delay_jobs = true
|
26
|
+
visit "/mail_manager/mailings"
|
27
|
+
click_link "Schedule"
|
28
|
+
expect(page).to have_content "Mailing scheduled"
|
29
|
+
@mailing = MailManager::Mailing.find(@mailing)
|
30
|
+
expect(@mailing.status).to eq "scheduled"
|
31
|
+
expect(Delayed::Job.count).to eq 1
|
32
|
+
and_it "can then be cancelled and its job removed" do
|
33
|
+
mailing2 = FactoryGirl.create(:mailing)
|
34
|
+
mailing2.schedule
|
35
|
+
expect(Delayed::Job.count).to eq 2
|
36
|
+
visit "/mail_manager/mailings"
|
37
|
+
click_link "cancel_mailing_#{@mailing.id}"
|
38
|
+
expect(page).to have_content "Mailing cancelled"
|
39
|
+
expect(Delayed::Job.count).to eq 1
|
40
|
+
expect(Delayed::Job.first.payload_object.object.id).to eql mailing2.id
|
41
|
+
end
|
42
|
+
Delayed::Worker.delay_jobs = false
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|