mail_manager 3.0.0 → 3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
require 'rails_helper'
|
|
2
|
+
|
|
3
|
+
# This spec was generated by rspec-rails when you ran the scaffold generator.
|
|
4
|
+
# It demonstrates how one might use RSpec to specify the controller code that
|
|
5
|
+
# was generated by Rails when you ran the scaffold generator.
|
|
6
|
+
#
|
|
7
|
+
# It assumes that the implementation code is generated by the rails scaffold
|
|
8
|
+
# generator. If you are using any extension libraries to generate different
|
|
9
|
+
# controller code, this generated spec may or may not pass.
|
|
10
|
+
#
|
|
11
|
+
# It only uses APIs available in rails and/or rspec-rails. There are a number
|
|
12
|
+
# of tools you can use to make these specs even more expressive, but we're
|
|
13
|
+
# sticking to rails and rspec-rails APIs to keep things simple and stable.
|
|
14
|
+
#
|
|
15
|
+
# Compared to earlier versions of this generator, there is very limited use of
|
|
16
|
+
# stubs and message expectations in this spec. Stubs are only used when there
|
|
17
|
+
# is no simpler way to get a handle on the object needed for the example.
|
|
18
|
+
# Message expectations are only used when there is no simpler way to specify
|
|
19
|
+
# that an instance is receiving a specific message.
|
|
20
|
+
|
|
21
|
+
RSpec.describe MailManager::ContactsController, :type => :controller do
|
|
22
|
+
render_views
|
|
23
|
+
routes {MailManager::Engine.routes}
|
|
24
|
+
|
|
25
|
+
# This should return the minimal set of attributes required to create a valid
|
|
26
|
+
# MailManager::Contact. As you add validations to MailManager::Contact, be sure to
|
|
27
|
+
# adjust the attributes here as well.
|
|
28
|
+
let(:valid_attributes) {
|
|
29
|
+
FactoryGirl.attributes_for(:contact)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
let(:invalid_attributes) {
|
|
33
|
+
FactoryGirl.attributes_for(:contact, email_address: nil)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
# This should return the minimal set of values that should be in the session
|
|
37
|
+
# in order to pass any filters (e.g. authentication) defined in
|
|
38
|
+
# MailManager::ContactsController. Be sure to keep this updated too.
|
|
39
|
+
let(:valid_session) { {} }
|
|
40
|
+
|
|
41
|
+
describe "GET #index" do
|
|
42
|
+
it "assigns all contacts as @contacts" do
|
|
43
|
+
contact = MailManager::Contact.create! valid_attributes
|
|
44
|
+
get :index, {}, valid_session
|
|
45
|
+
expect(assigns(:contacts)).to eq([contact])
|
|
46
|
+
expect(response.body).to have_content 'Listing Contacts'
|
|
47
|
+
end
|
|
48
|
+
it "assigns all mailing lists as @mailing_lists" do
|
|
49
|
+
mailing_list = FactoryGirl.create(:mailing_list)
|
|
50
|
+
get :index, {}, valid_session
|
|
51
|
+
expect(assigns(:mailing_lists)).to eq([[mailing_list.name,mailing_list.id]])
|
|
52
|
+
expect(response.body).to have_content 'Listing Contacts'
|
|
53
|
+
end
|
|
54
|
+
it "assigns all statuses as @statuses" do
|
|
55
|
+
get :index, {}, valid_session
|
|
56
|
+
expect(assigns(:statuses)).to eq([['Any',''],['Active','active'],
|
|
57
|
+
['Unsubscribed','unsubscribed'],['Failed Address','failed_address'],
|
|
58
|
+
['Pending','pending']
|
|
59
|
+
])
|
|
60
|
+
expect(response.body).to have_content 'Listing Contacts'
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
describe "GET #show" do
|
|
65
|
+
it "assigns the requested contact as @contact" do
|
|
66
|
+
contact = MailManager::Contact.create! valid_attributes
|
|
67
|
+
get :show, {:id => contact.to_param}, valid_session
|
|
68
|
+
expect(assigns(:contact)).to eq(contact)
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
describe "GET #new" do
|
|
73
|
+
it "assigns a new contact as @contact" do
|
|
74
|
+
get :new, {}, valid_session
|
|
75
|
+
expect(assigns(:contact)).to be_a_new(MailManager::Contact)
|
|
76
|
+
expect(response.body).to have_content 'New Contact'
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
describe "GET #edit" do
|
|
81
|
+
it "assigns the requested contact as @contact" do
|
|
82
|
+
contact = MailManager::Contact.create! valid_attributes
|
|
83
|
+
get :edit, {:id => contact.to_param}, valid_session
|
|
84
|
+
expect(assigns(:contact)).to eq(contact)
|
|
85
|
+
expect(response.body).to have_content "Edit Contact"
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
describe "POST #create" do
|
|
90
|
+
context "with valid params" do
|
|
91
|
+
it "creates a new MailManager::Contact" do
|
|
92
|
+
expect {
|
|
93
|
+
post :create, {:contact => valid_attributes}, valid_session
|
|
94
|
+
}.to change(MailManager::Contact, :count).by(1)
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
it "assigns a newly created contact as @contact" do
|
|
98
|
+
post :create, {:contact => valid_attributes}, valid_session
|
|
99
|
+
expect(assigns(:contact)).to be_a(MailManager::Contact)
|
|
100
|
+
expect(assigns(:contact)).to be_persisted
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
it "redirects to the created contact" do
|
|
104
|
+
post :create, {:contact => valid_attributes}, valid_session
|
|
105
|
+
expect(response).to redirect_to(contacts_path)
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
context "with invalid params" do
|
|
110
|
+
it "assigns a newly created but unsaved contact as @contact" do
|
|
111
|
+
post :create, {:contact => invalid_attributes}, valid_session
|
|
112
|
+
expect(assigns(:contact)).to be_a_new(MailManager::Contact)
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
it "re-renders the 'new' template" do
|
|
116
|
+
post :create, {:contact => invalid_attributes}, valid_session
|
|
117
|
+
expect(response).to render_template("new")
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
describe "PUT #update" do
|
|
123
|
+
context "with valid params" do
|
|
124
|
+
let(:new_attributes) {
|
|
125
|
+
FactoryGirl.attributes_for(:contact)
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
it "updates the requested contact" do
|
|
129
|
+
contact = MailManager::Contact.create! valid_attributes
|
|
130
|
+
put :update, {:id => contact.to_param, :contact => new_attributes}, valid_session
|
|
131
|
+
contact = MailManager::Contact.find(contact.id)
|
|
132
|
+
expect(contact).to match_attributes(new_attributes)
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
it "assigns the requested contact as @contact" do
|
|
136
|
+
contact = MailManager::Contact.create! valid_attributes
|
|
137
|
+
put :update, {:id => contact.to_param, :contact => valid_attributes}, valid_session
|
|
138
|
+
expect(assigns(:contact)).to eq(contact)
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
it "redirects to the contact" do
|
|
142
|
+
contact = MailManager::Contact.create! valid_attributes
|
|
143
|
+
put :update, {:id => contact.to_param, :contact => valid_attributes}, valid_session
|
|
144
|
+
expect(response).to redirect_to(contacts_path)
|
|
145
|
+
end
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
context "with invalid params" do
|
|
149
|
+
it "assigns the contact as @contact" do
|
|
150
|
+
contact = MailManager::Contact.create! valid_attributes
|
|
151
|
+
put :update, {:id => contact.to_param, :contact => invalid_attributes}, valid_session
|
|
152
|
+
expect(assigns(:contact)).to eq(contact)
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
it "re-renders the 'edit' template" do
|
|
156
|
+
contact = MailManager::Contact.create! valid_attributes
|
|
157
|
+
put :update, {:id => contact.to_param, :contact => invalid_attributes}, valid_session
|
|
158
|
+
expect(response).to render_template("edit")
|
|
159
|
+
end
|
|
160
|
+
end
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
describe "DELETE #destroy" do
|
|
164
|
+
it "destroys the requested contact" do
|
|
165
|
+
contact = MailManager::Contact.create! valid_attributes
|
|
166
|
+
expect {
|
|
167
|
+
delete :destroy, {:id => contact.to_param}, valid_session
|
|
168
|
+
}.to change(MailManager::Contact, :count).by(-1)
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
it "redirects to the contact list" do
|
|
172
|
+
contact = MailManager::Contact.create! valid_attributes
|
|
173
|
+
delete :destroy, {:id => contact.to_param}, valid_session
|
|
174
|
+
expect(response).to redirect_to(contacts_url)
|
|
175
|
+
end
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
end
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
require 'rails_helper'
|
|
2
|
+
|
|
3
|
+
# This spec was generated by rspec-rails when you ran the scaffold generator.
|
|
4
|
+
# It demonstrates how one might use RSpec to specify the controller code that
|
|
5
|
+
# was generated by Rails when you ran the scaffold generator.
|
|
6
|
+
#
|
|
7
|
+
# It assumes that the implementation code is generated by the rails scaffold
|
|
8
|
+
# generator. If you are using any extension libraries to generate different
|
|
9
|
+
# controller code, this generated spec may or may not pass.
|
|
10
|
+
#
|
|
11
|
+
# It only uses APIs available in rails and/or rspec-rails. There are a number
|
|
12
|
+
# of tools you can use to make these specs even more expressive, but we're
|
|
13
|
+
# sticking to rails and rspec-rails APIs to keep things simple and stable.
|
|
14
|
+
#
|
|
15
|
+
# Compared to earlier versions of this generator, there is very limited use of
|
|
16
|
+
# stubs and message expectations in this spec. Stubs are only used when there
|
|
17
|
+
# is no simpler way to get a handle on the object needed for the example.
|
|
18
|
+
# Message expectations are only used when there is no simpler way to specify
|
|
19
|
+
# that an instance is receiving a specific message.
|
|
20
|
+
|
|
21
|
+
RSpec.describe MailManager::MailingListsController, :type => :controller do
|
|
22
|
+
render_views
|
|
23
|
+
routes {MailManager::Engine.routes}
|
|
24
|
+
|
|
25
|
+
# This should return the minimal set of attributes required to create a valid
|
|
26
|
+
# MailManager::MailingList. As you add validations to MailManager::MailingList, be sure to
|
|
27
|
+
# adjust the attributes here as well.
|
|
28
|
+
let(:valid_attributes) {
|
|
29
|
+
FactoryGirl.attributes_for(:mailing_list)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
let(:invalid_attributes) {
|
|
33
|
+
FactoryGirl.attributes_for(:mailing_list, name: nil)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
# This should return the minimal set of values that should be in the session
|
|
37
|
+
# in order to pass any filters (e.g. authentication) defined in
|
|
38
|
+
# MailManager::MailingListsController. Be sure to keep this updated too.
|
|
39
|
+
let(:valid_session) { {} }
|
|
40
|
+
|
|
41
|
+
describe "GET #index" do
|
|
42
|
+
it "assigns all mailing_lists as @mailing_lists" do
|
|
43
|
+
mailing_list = MailManager::MailingList.create! valid_attributes
|
|
44
|
+
get :index, {}, valid_session
|
|
45
|
+
expect(assigns(:mailing_lists)).to eq([mailing_list])
|
|
46
|
+
expect(response.body).to have_content "Listing Mailing Lists"
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
describe "GET #show" do
|
|
51
|
+
it "assigns the requested mailing_list as @mailing_list" do
|
|
52
|
+
mailing_list = MailManager::MailingList.create! valid_attributes
|
|
53
|
+
get :show, {:id => mailing_list.to_param}, valid_session
|
|
54
|
+
expect(assigns(:mailing_list)).to eq(mailing_list)
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
describe "GET #new" do
|
|
59
|
+
it "assigns a new mailing_list as @mailing_list" do
|
|
60
|
+
get :new, {}, valid_session
|
|
61
|
+
expect(assigns(:mailing_list)).to be_a_new(MailManager::MailingList)
|
|
62
|
+
expect(response.body).to have_content "New Mailing List"
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
describe "GET #edit" do
|
|
67
|
+
it "assigns the requested mailing_list as @mailing_list" do
|
|
68
|
+
mailing_list = MailManager::MailingList.create! valid_attributes
|
|
69
|
+
get :edit, {:id => mailing_list.to_param}, valid_session
|
|
70
|
+
expect(assigns(:mailing_list)).to eq(mailing_list)
|
|
71
|
+
expect(response.body).to have_content "Editing #{mailing_list.name}"
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
describe "POST #create" do
|
|
76
|
+
context "with valid params" do
|
|
77
|
+
it "creates a new MailManager::MailingList" do
|
|
78
|
+
expect {
|
|
79
|
+
post :create, {:mailing_list => valid_attributes}, valid_session
|
|
80
|
+
}.to change(MailManager::MailingList, :count).by(1)
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
it "assigns a newly created mailing_list as @mailing_list" do
|
|
84
|
+
post :create, {:mailing_list => valid_attributes}, valid_session
|
|
85
|
+
expect(assigns(:mailing_list)).to be_a(MailManager::MailingList)
|
|
86
|
+
expect(assigns(:mailing_list)).to be_persisted
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
it "redirects to the created mailing_list" do
|
|
90
|
+
post :create, {:mailing_list => valid_attributes}, valid_session
|
|
91
|
+
expect(response).to redirect_to(mailing_lists_path)
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
context "with invalid params" do
|
|
96
|
+
it "assigns a newly created but unsaved mailing_list as @mailing_list" do
|
|
97
|
+
post :create, {:mailing_list => invalid_attributes}, valid_session
|
|
98
|
+
expect(assigns(:mailing_list)).to be_a_new(MailManager::MailingList)
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
it "re-renders the 'new' template" do
|
|
102
|
+
post :create, {:mailing_list => invalid_attributes}, valid_session
|
|
103
|
+
expect(response).to render_template("new")
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
describe "PUT #update" do
|
|
109
|
+
context "with valid params" do
|
|
110
|
+
let(:new_attributes) {
|
|
111
|
+
FactoryGirl.attributes_for(:mailing_list)
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
it "updates the requested mailing_list" do
|
|
115
|
+
mailing_list = MailManager::MailingList.create! valid_attributes
|
|
116
|
+
put :update, {:id => mailing_list.to_param, :mailing_list => new_attributes}, valid_session
|
|
117
|
+
mailing_list = MailManager::MailingList.find(mailing_list.id)
|
|
118
|
+
expect(mailing_list).to match_attributes(new_attributes)
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
it "assigns the requested mailing_list as @mailing_list" do
|
|
122
|
+
mailing_list = MailManager::MailingList.create! valid_attributes
|
|
123
|
+
put :update, {:id => mailing_list.to_param, :mailing_list => valid_attributes}, valid_session
|
|
124
|
+
expect(assigns(:mailing_list)).to eq(mailing_list)
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
it "redirects to the mailing_list" do
|
|
128
|
+
mailing_list = MailManager::MailingList.create! valid_attributes
|
|
129
|
+
put :update, {:id => mailing_list.to_param, :mailing_list => valid_attributes}, valid_session
|
|
130
|
+
expect(response).to redirect_to(mailing_lists_path)
|
|
131
|
+
end
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
context "with invalid params" do
|
|
135
|
+
it "assigns the mailing_list as @mailing_list" do
|
|
136
|
+
mailing_list = MailManager::MailingList.create! valid_attributes
|
|
137
|
+
put :update, {:id => mailing_list.to_param, :mailing_list => invalid_attributes}, valid_session
|
|
138
|
+
expect(assigns(:mailing_list)).to eq(mailing_list)
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
it "re-renders the 'edit' template" do
|
|
142
|
+
mailing_list = MailManager::MailingList.create! valid_attributes
|
|
143
|
+
put :update, {:id => mailing_list.to_param, :mailing_list => invalid_attributes}, valid_session
|
|
144
|
+
expect(response).to render_template("edit")
|
|
145
|
+
end
|
|
146
|
+
end
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
describe "DELETE #destroy" do
|
|
150
|
+
it "destroys the requested mailing_list" do
|
|
151
|
+
mailing_list = MailManager::MailingList.create! valid_attributes
|
|
152
|
+
expect {
|
|
153
|
+
delete :destroy, {:id => mailing_list.to_param}, valid_session
|
|
154
|
+
}.to change(MailManager::MailingList, :count).by(-1)
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
it "redirects to the mailing_lists list" do
|
|
158
|
+
mailing_list = MailManager::MailingList.create! valid_attributes
|
|
159
|
+
delete :destroy, {:id => mailing_list.to_param}, valid_session
|
|
160
|
+
expect(response).to redirect_to(mailing_lists_url)
|
|
161
|
+
end
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
end
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
require 'rails_helper'
|
|
2
|
+
|
|
3
|
+
# This spec was generated by rspec-rails when you ran the scaffold generator.
|
|
4
|
+
# It demonstrates how one might use RSpec to specify the controller code that
|
|
5
|
+
# was generated by Rails when you ran the scaffold generator.
|
|
6
|
+
#
|
|
7
|
+
# It assumes that the implementation code is generated by the rails scaffold
|
|
8
|
+
# generator. If you are using any extension libraries to generate different
|
|
9
|
+
# controller code, this generated spec may or may not pass.
|
|
10
|
+
#
|
|
11
|
+
# It only uses APIs available in rails and/or rspec-rails. There are a number
|
|
12
|
+
# of tools you can use to make these specs even more expressive, but we're
|
|
13
|
+
# sticking to rails and rspec-rails APIs to keep things simple and stable.
|
|
14
|
+
#
|
|
15
|
+
# Compared to earlier versions of this generator, there is very limited use of
|
|
16
|
+
# stubs and message expectations in this spec. Stubs are only used when there
|
|
17
|
+
# is no simpler way to get a handle on the object needed for the example.
|
|
18
|
+
# Message expectations are only used when there is no simpler way to specify
|
|
19
|
+
# that an instance is receiving a specific message.
|
|
20
|
+
|
|
21
|
+
RSpec.describe MailManager::MailingsController, :type => :controller do
|
|
22
|
+
render_views
|
|
23
|
+
routes {MailManager::Engine.routes}
|
|
24
|
+
|
|
25
|
+
# This should return the minimal set of attributes required to create a valid
|
|
26
|
+
# MailManager::Mailing. As you add validations to MailManager::Mailing, be sure to
|
|
27
|
+
# adjust the attributes here as well.
|
|
28
|
+
let(:valid_attributes) {
|
|
29
|
+
FactoryGirl.attributes_for(:mailing)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
let(:invalid_attributes) {
|
|
33
|
+
FactoryGirl.attributes_for(:mailing, subject: nil)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
# This should return the minimal set of values that should be in the session
|
|
37
|
+
# in order to pass any filters (e.g. authentication) defined in
|
|
38
|
+
# MailManager::MailingsController. Be sure to keep this updated too.
|
|
39
|
+
let(:valid_session) { {} }
|
|
40
|
+
|
|
41
|
+
describe "PUT #schedule" do
|
|
42
|
+
pending "FIXME:? its it's not recognizing non-crud routing!"
|
|
43
|
+
#FIXME: it's not recognizing non-crud routing!
|
|
44
|
+
#it "sets the mailing's scheduled_at and creates its job" do
|
|
45
|
+
# Delayed::Job.delete_all
|
|
46
|
+
# Delayed::Worker.delay_jobs = true
|
|
47
|
+
# mailing = MailManager::Mailing.create! valid_attributes
|
|
48
|
+
# put :schedule, {}, valid_session
|
|
49
|
+
# expect(assigns(:mailing)).to eq(mailing)
|
|
50
|
+
# mailing = MailManager::Mailing.find(mailing.id)
|
|
51
|
+
# expect(mailing.scheduled_at).not_to be nil
|
|
52
|
+
# expect(Delayed::Job.count).to eq(1)
|
|
53
|
+
# expect(Delayed::Job.first.handler).to match /MailMgr::Mailing/
|
|
54
|
+
# expect(response).to redirect_to(mailings_path)
|
|
55
|
+
# Delayed::Job.delete_all
|
|
56
|
+
# Delayed::Worker.delay_jobs = false
|
|
57
|
+
#end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
describe "GET #index" do
|
|
61
|
+
it "assigns all mailings as @mailings" do
|
|
62
|
+
mailing = MailManager::Mailing.create! valid_attributes
|
|
63
|
+
get :index, {}, valid_session
|
|
64
|
+
expect(assigns(:mailings)).to eq([mailing])
|
|
65
|
+
expect(response.body).to have_content("Listing Mailings")
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
describe "GET #show" do
|
|
70
|
+
it "assigns the requested mailing as @mailing" do
|
|
71
|
+
mailing = MailManager::Mailing.create! valid_attributes
|
|
72
|
+
get :show, {:id => mailing.to_param}, valid_session
|
|
73
|
+
expect(assigns(:mailing)).to eq(mailing)
|
|
74
|
+
expect(response.body).to have_content(mailing.subject)
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
describe "GET #new" do
|
|
79
|
+
it "assigns a new mailing as @mailing" do
|
|
80
|
+
get :new, {}, valid_session
|
|
81
|
+
expect(assigns(:mailing)).to be_a_new(MailManager::Mailing)
|
|
82
|
+
expect(response.body).to have_content("New Mailing")
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
describe "GET #edit" do
|
|
87
|
+
it "assigns the requested mailing as @mailing" do
|
|
88
|
+
mailing = MailManager::Mailing.create! valid_attributes
|
|
89
|
+
get :edit, {:id => mailing.to_param}, valid_session
|
|
90
|
+
expect(assigns(:mailing)).to eq(mailing)
|
|
91
|
+
expect(response.body).to have_content("Edit #{mailing.subject}")
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
describe "POST #create" do
|
|
96
|
+
context "with valid params" do
|
|
97
|
+
it "creates a new MailManager::Mailing" do
|
|
98
|
+
expect {
|
|
99
|
+
post :create, {:mailing => valid_attributes}, valid_session
|
|
100
|
+
}.to change(MailManager::Mailing, :count).by(1)
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
it "assigns a newly created mailing as @mailing" do
|
|
104
|
+
post :create, {:mailing => valid_attributes}, valid_session
|
|
105
|
+
expect(assigns(:mailing)).to be_a(MailManager::Mailing)
|
|
106
|
+
expect(assigns(:mailing)).to be_persisted
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
it "redirects to the mailings list" do
|
|
110
|
+
post :create, {:mailing => valid_attributes}, valid_session
|
|
111
|
+
expect(response).to redirect_to(mailings_path)
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
context "with invalid params" do
|
|
116
|
+
it "assigns a newly created but unsaved mailing as @mailing" do
|
|
117
|
+
post :create, {:mailing => invalid_attributes}, valid_session
|
|
118
|
+
expect(assigns(:mailing)).to be_a_new(MailManager::Mailing)
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
it "re-renders the 'new' template" do
|
|
122
|
+
post :create, {:mailing => invalid_attributes}, valid_session
|
|
123
|
+
expect(response).to render_template("new")
|
|
124
|
+
end
|
|
125
|
+
end
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
describe "PUT #update" do
|
|
129
|
+
context "with valid params" do
|
|
130
|
+
let(:new_attributes) {
|
|
131
|
+
FactoryGirl.attributes_for(:mailing)
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
it "updates the requested mailing" do
|
|
135
|
+
mailing = MailManager::Mailing.create! valid_attributes
|
|
136
|
+
put :update, {:id => mailing.to_param, :mailing => new_attributes}, valid_session
|
|
137
|
+
mailing = MailManager::Mailing.find(mailing.id)
|
|
138
|
+
expect(mailing).to match_attributes(new_attributes)
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
it "assigns the requested mailing as @mailing" do
|
|
142
|
+
mailing = MailManager::Mailing.create! valid_attributes
|
|
143
|
+
put :update, {:id => mailing.to_param, :mailing => valid_attributes}, valid_session
|
|
144
|
+
expect(assigns(:mailing)).to eq(mailing)
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
it "redirects to the mailing" do
|
|
148
|
+
mailing = MailManager::Mailing.create! valid_attributes
|
|
149
|
+
put :update, {:id => mailing.to_param, :mailing => valid_attributes}, valid_session
|
|
150
|
+
expect(response).to redirect_to(mailings_path)
|
|
151
|
+
end
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
context "with invalid params" do
|
|
155
|
+
it "assigns the mailing as @mailing" do
|
|
156
|
+
mailing = MailManager::Mailing.create! valid_attributes
|
|
157
|
+
put :update, {:id => mailing.to_param, :mailing => invalid_attributes}, valid_session
|
|
158
|
+
expect(assigns(:mailing)).to eq(mailing)
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
it "re-renders the 'edit' template" do
|
|
162
|
+
mailing = MailManager::Mailing.create! valid_attributes
|
|
163
|
+
put :update, {:id => mailing.to_param, :mailing => invalid_attributes}, valid_session
|
|
164
|
+
expect(response).to render_template("edit")
|
|
165
|
+
end
|
|
166
|
+
end
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
describe "DELETE #destroy" do
|
|
170
|
+
it "destroys the requested mailing" do
|
|
171
|
+
mailing = MailManager::Mailing.create! valid_attributes
|
|
172
|
+
expect {
|
|
173
|
+
delete :destroy, {:id => mailing.to_param}, valid_session
|
|
174
|
+
}.to change(MailManager::Mailing, :count).by(-1)
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
it "redirects to the mailings list" do
|
|
178
|
+
mailing = MailManager::Mailing.create! valid_attributes
|
|
179
|
+
delete :destroy, {:id => mailing.to_param}, valid_session
|
|
180
|
+
expect(response).to redirect_to(mailings_url)
|
|
181
|
+
end
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
end
|