fat_free_crm 0.17.3 → 0.18.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of fat_free_crm might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/.dockerignore +11 -0
- data/.rubocop.yml +1 -1
- data/.rubocop_todo.yml +30 -8
- data/.travis.yml +14 -9
- data/CHANGELOG.md +43 -7
- data/CONTRIBUTORS.md +95 -53
- data/Gemfile +11 -7
- data/Gemfile.lock +83 -83
- data/README.md +7 -4
- data/app/assets/javascripts/crm.js.coffee +3 -3
- data/app/assets/javascripts/crm_select2.js.coffee +15 -14
- data/app/controllers/admin/field_groups_controller.rb +8 -1
- data/app/controllers/admin/fields_controller.rb +4 -4
- data/app/controllers/admin/groups_controller.rb +1 -1
- data/app/controllers/admin/tags_controller.rb +1 -1
- data/app/controllers/application_controller.rb +11 -0
- data/app/controllers/authentications_controller.rb +1 -1
- data/app/controllers/comments_controller.rb +15 -7
- data/app/controllers/entities/campaigns_controller.rb +7 -2
- data/app/controllers/entities/leads_controller.rb +9 -2
- data/app/controllers/entities/opportunities_controller.rb +13 -2
- data/app/controllers/entities_controller.rb +10 -5
- data/app/controllers/lists_controller.rb +5 -1
- data/app/controllers/tasks_controller.rb +15 -1
- data/app/helpers/accounts_helper.rb +1 -1
- data/app/helpers/application_helper.rb +2 -2
- data/app/helpers/leads_helper.rb +1 -1
- data/app/helpers/opportunities_helper.rb +56 -3
- data/app/helpers/tags_helper.rb +1 -1
- data/app/models/entities/lead.rb +0 -7
- data/app/models/entities/opportunity.rb +3 -2
- data/app/models/observers/opportunity_observer.rb +4 -4
- data/app/models/users/ability.rb +3 -4
- data/app/views/campaigns/_metrics.html.haml +3 -3
- data/app/views/home/_opportunity.html.haml +4 -19
- data/app/views/opportunities/_index_long.html.haml +1 -24
- data/app/views/opportunities/_sidebar_show.html.haml +3 -3
- data/app/views/opportunities/_top_section.html.haml +1 -1
- data/db/schema.rb +0 -3
- data/fat_free_crm.gemspec +1 -1
- data/lib/fat_free_crm/core_ext/string.rb +1 -1
- data/lib/fat_free_crm/engine.rb +2 -2
- data/lib/fat_free_crm/fields.rb +1 -1
- data/lib/fat_free_crm/permissions.rb +0 -14
- data/lib/fat_free_crm/version.rb +2 -2
- data/lib/tasks/ffcrm/setup.rake +4 -4
- data/spec/controllers/admin/users_controller_spec.rb +27 -27
- data/spec/controllers/authentications_controller_spec.rb +7 -7
- data/spec/controllers/comments_controller_spec.rb +13 -13
- data/spec/controllers/emails_controller_spec.rb +2 -2
- data/spec/controllers/entities/accounts_controller_spec.rb +56 -56
- data/spec/controllers/entities/campaigns_controller_spec.rb +66 -66
- data/spec/controllers/entities/contacts_controller_spec.rb +67 -67
- data/spec/controllers/entities/leads_controller_spec.rb +125 -125
- data/spec/controllers/entities/opportunities_controller_spec.rb +100 -100
- data/spec/controllers/home_controller_spec.rb +26 -26
- data/spec/controllers/passwords_controller_spec.rb +1 -1
- data/spec/controllers/tasks_controller_spec.rb +37 -37
- data/spec/controllers/users_controller_spec.rb +18 -18
- data/spec/factories/account_factories.rb +8 -8
- data/spec/factories/campaign_factories.rb +5 -5
- data/spec/factories/contact_factories.rb +10 -10
- data/spec/factories/field_factories.rb +7 -7
- data/spec/factories/lead_factories.rb +8 -8
- data/spec/factories/list_factories.rb +1 -1
- data/spec/factories/opportunity_factories.rb +6 -6
- data/spec/factories/sequences.rb +1 -1
- data/spec/factories/setting_factories.rb +3 -3
- data/spec/factories/shared_factories.rb +14 -14
- data/spec/factories/subscription_factories.rb +1 -1
- data/spec/factories/tag_factories.rb +1 -1
- data/spec/factories/task_factories.rb +4 -4
- data/spec/factories/user_factories.rb +13 -13
- data/spec/features/accounts_spec.rb +17 -4
- data/spec/features/admin/groups_spec.rb +1 -1
- data/spec/features/admin/users_spec.rb +1 -1
- data/spec/features/campaigns_spec.rb +4 -4
- data/spec/features/contacts_spec.rb +10 -4
- data/spec/features/dashboard_spec.rb +7 -7
- data/spec/features/leads_spec.rb +4 -4
- data/spec/features/opportunities_overview_spec.rb +15 -15
- data/spec/features/opportunities_spec.rb +34 -8
- data/spec/features/support/autocomlete_helper.rb +17 -0
- data/spec/features/support/browser.rb +3 -8
- data/spec/features/support/helpers.rb +1 -1
- data/spec/features/tasks_spec.rb +4 -4
- data/spec/helpers/admin/field_groups_helper_spec.rb +1 -1
- data/spec/helpers/application_helper_spec.rb +1 -1
- data/spec/helpers/tasks_helper_spec.rb +1 -1
- data/spec/helpers/users_helper_spec.rb +3 -3
- data/spec/lib/comment_extensions_spec.rb +1 -1
- data/spec/lib/mail_processor/base_spec.rb +3 -3
- data/spec/lib/mail_processor/comment_replies_spec.rb +3 -3
- data/spec/lib/mail_processor/dropbox_spec.rb +16 -16
- data/spec/lib/permissions_spec.rb +7 -25
- data/spec/mailers/user_mailer_spec.rb +7 -7
- data/spec/models/entities/account_spec.rb +31 -32
- data/spec/models/entities/campaign_spec.rb +18 -25
- data/spec/models/entities/contact_spec.rb +18 -21
- data/spec/models/entities/lead_spec.rb +9 -11
- data/spec/models/entities/opportunity_spec.rb +45 -45
- data/spec/models/fields/custom_field_spec.rb +17 -17
- data/spec/models/list_spec.rb +2 -2
- data/spec/models/observers/entity_observer_spec.rb +6 -6
- data/spec/models/polymorphic/address_spec.rb +1 -1
- data/spec/models/polymorphic/avatar_spec.rb +5 -5
- data/spec/models/polymorphic/comment_spec.rb +5 -5
- data/spec/models/polymorphic/task_spec.rb +65 -58
- data/spec/models/polymorphic/version_spec.rb +26 -26
- data/spec/models/setting_spec.rb +2 -2
- data/spec/models/users/preference_spec.rb +6 -6
- data/spec/models/users/user_spec.rb +26 -26
- data/spec/shared/models.rb +22 -22
- data/spec/spec_helper.rb +2 -2
- data/spec/support/auth_macros.rb +1 -1
- data/spec/support/macros.rb +3 -3
- data/spec/views/accounts/_edit.haml_spec.rb +1 -1
- data/spec/views/accounts/create.js.haml_spec.rb +2 -2
- data/spec/views/accounts/destroy.js.haml_spec.rb +1 -1
- data/spec/views/accounts/edit.js.haml_spec.rb +2 -2
- data/spec/views/accounts/index.haml_spec.rb +2 -2
- data/spec/views/accounts/index.js.haml_spec.rb +1 -1
- data/spec/views/accounts/show.haml_spec.rb +4 -4
- data/spec/views/accounts/update.js.haml_spec.rb +1 -1
- data/spec/views/admin/field_groups/create.js.haml_spec.rb +1 -1
- data/spec/views/admin/field_groups/destroy.js.haml_spec.rb +1 -1
- data/spec/views/admin/field_groups/edit.js.haml_spec.rb +1 -1
- data/spec/views/admin/field_groups/new.js.haml_spec.rb +1 -1
- data/spec/views/admin/field_groups/update.js.haml_spec.rb +1 -1
- data/spec/views/admin/users/create.js.haml_spec.rb +2 -2
- data/spec/views/admin/users/destroy.js.haml_spec.rb +2 -2
- data/spec/views/admin/users/edit.js.haml_spec.rb +2 -2
- data/spec/views/admin/users/index.haml_spec.rb +1 -1
- data/spec/views/admin/users/index.js.haml_spec.rb +2 -2
- data/spec/views/admin/users/reactivate.js.haml_spec.rb +1 -1
- data/spec/views/admin/users/suspend.js.haml_spec.rb +1 -1
- data/spec/views/admin/users/update.js.haml_spec.rb +1 -1
- data/spec/views/application/auto_complete.haml_spec.rb +3 -3
- data/spec/views/campaigns/_edit.haml_spec.rb +1 -1
- data/spec/views/campaigns/create.js.haml_spec.rb +3 -3
- data/spec/views/campaigns/destroy.js.haml_spec.rb +1 -1
- data/spec/views/campaigns/edit.js.haml_spec.rb +2 -2
- data/spec/views/campaigns/index.haml_spec.rb +1 -1
- data/spec/views/campaigns/index.js.haml_spec.rb +1 -1
- data/spec/views/campaigns/show.haml_spec.rb +4 -4
- data/spec/views/campaigns/update.js.haml_spec.rb +1 -1
- data/spec/views/contacts/_edit.haml_spec.rb +7 -7
- data/spec/views/contacts/_new.haml_spec.rb +1 -1
- data/spec/views/contacts/create.js.haml_spec.rb +4 -4
- data/spec/views/contacts/destroy.js.haml_spec.rb +1 -1
- data/spec/views/contacts/edit.js.haml_spec.rb +3 -3
- data/spec/views/contacts/index.haml_spec.rb +1 -1
- data/spec/views/contacts/index.js.html_spec.rb +1 -1
- data/spec/views/contacts/new.js.haml_spec.rb +1 -1
- data/spec/views/contacts/show.haml_spec.rb +3 -3
- data/spec/views/contacts/update.js.haml_spec.rb +2 -2
- data/spec/views/home/index.haml_spec.rb +1 -1
- data/spec/views/home/index.js.haml_spec.rb +1 -1
- data/spec/views/home/options.js.haml_spec.rb +2 -2
- data/spec/views/leads/_convert.haml_spec.rb +3 -3
- data/spec/views/leads/_edit.haml_spec.rb +2 -2
- data/spec/views/leads/_new.haml_spec.rb +2 -2
- data/spec/views/leads/_sidebar_show.haml_spec.rb +5 -5
- data/spec/views/leads/convert.js.haml_spec.rb +4 -4
- data/spec/views/leads/create.js.haml_spec.rb +5 -5
- data/spec/views/leads/destroy.js.haml_spec.rb +2 -2
- data/spec/views/leads/edit.js.haml_spec.rb +4 -4
- data/spec/views/leads/index.haml_spec.rb +1 -1
- data/spec/views/leads/index.js.haml_spec.rb +1 -1
- data/spec/views/leads/new.js.haml_spec.rb +1 -1
- data/spec/views/leads/promote.js.haml_spec.rb +7 -7
- data/spec/views/leads/reject.js.haml_spec.rb +2 -2
- data/spec/views/leads/show.haml_spec.rb +2 -2
- data/spec/views/leads/update.js.haml_spec.rb +4 -4
- data/spec/views/opportunities/_edit.haml_spec.rb +7 -7
- data/spec/views/opportunities/_new.haml_spec.rb +2 -2
- data/spec/views/opportunities/create.js.haml_spec.rb +6 -6
- data/spec/views/opportunities/destroy.js.haml_spec.rb +3 -3
- data/spec/views/opportunities/edit.js.haml_spec.rb +3 -3
- data/spec/views/opportunities/index.haml_spec.rb +1 -1
- data/spec/views/opportunities/index.js.haml_spec.rb +1 -1
- data/spec/views/opportunities/new.js.haml_spec.rb +1 -1
- data/spec/views/opportunities/show.haml_spec.rb +3 -3
- data/spec/views/opportunities/update.js.haml_spec.rb +4 -4
- data/spec/views/tasks/_edit.haml_spec.rb +1 -1
- data/spec/views/tasks/complete.js.haml_spec.rb +4 -4
- data/spec/views/tasks/create.js.haml_spec.rb +6 -6
- data/spec/views/tasks/destroy.js.haml_spec.rb +2 -2
- data/spec/views/tasks/index.haml_spec.rb +4 -4
- data/spec/views/tasks/new.js.haml_spec.rb +1 -1
- data/spec/views/tasks/uncomplete.js.haml_spec.rb +2 -2
- data/spec/views/tasks/update.js.haml_spec.rb +18 -18
- data/spec/views/users/upload_avatar.js.haml_spec.rb +2 -2
- metadata +5 -3
@@ -18,7 +18,7 @@ describe LeadsController do
|
|
18
18
|
#----------------------------------------------------------------------------
|
19
19
|
describe "responding to GET index" do
|
20
20
|
it "should expose all leads as @leads and render [index] template" do
|
21
|
-
@leads = [
|
21
|
+
@leads = [create(:lead, user: current_user)]
|
22
22
|
|
23
23
|
get :index
|
24
24
|
expect(assigns[:leads]).to eq(@leads)
|
@@ -26,7 +26,7 @@ describe LeadsController do
|
|
26
26
|
end
|
27
27
|
|
28
28
|
it "should collect the data for the leads sidebar" do
|
29
|
-
@leads = [
|
29
|
+
@leads = [create(:lead, user: current_user)]
|
30
30
|
@status = Setting.lead_status.dup
|
31
31
|
|
32
32
|
get :index
|
@@ -36,12 +36,12 @@ describe LeadsController do
|
|
36
36
|
it "should filter out leads by status" do
|
37
37
|
controller.session[:leads_filter] = "new,contacted"
|
38
38
|
@leads = [
|
39
|
-
|
40
|
-
|
39
|
+
create(:lead, status: "new", user: current_user),
|
40
|
+
create(:lead, status: "contacted", user: current_user)
|
41
41
|
]
|
42
42
|
|
43
43
|
# This one should be filtered out.
|
44
|
-
|
44
|
+
create(:lead, status: "rejected", user: current_user)
|
45
45
|
|
46
46
|
get :index
|
47
47
|
# Note: can't compare campaigns directly because of BigDecimals.
|
@@ -50,8 +50,8 @@ describe LeadsController do
|
|
50
50
|
end
|
51
51
|
|
52
52
|
it "should perform lookup using query string" do
|
53
|
-
@billy_bones =
|
54
|
-
@captain_flint =
|
53
|
+
@billy_bones = create(:lead, user: current_user, first_name: "Billy", last_name: "Bones")
|
54
|
+
@captain_flint = create(:lead, user: current_user, first_name: "Captain", last_name: "Flint")
|
55
55
|
|
56
56
|
get :index, params: { query: "bill" }
|
57
57
|
expect(assigns[:leads]).to eq([@billy_bones])
|
@@ -61,7 +61,7 @@ describe LeadsController do
|
|
61
61
|
|
62
62
|
describe "AJAX pagination" do
|
63
63
|
it "should pick up page number from params" do
|
64
|
-
@leads = [
|
64
|
+
@leads = [create(:lead, user: current_user)]
|
65
65
|
get :index, params: { page: 42 }, xhr: true
|
66
66
|
|
67
67
|
expect(assigns[:current_page].to_i).to eq(42)
|
@@ -73,7 +73,7 @@ describe LeadsController do
|
|
73
73
|
it "should pick up saved page number from session" do
|
74
74
|
session[:leads_current_page] = 42
|
75
75
|
session[:leads_current_query] = "bill"
|
76
|
-
@leads = [
|
76
|
+
@leads = [create(:lead, user: current_user)]
|
77
77
|
get :index, params: { query: "bill" }, xhr: true
|
78
78
|
|
79
79
|
expect(assigns[:current_page]).to eq(42)
|
@@ -84,7 +84,7 @@ describe LeadsController do
|
|
84
84
|
it "should reset current_page when query is altered" do
|
85
85
|
session[:leads_current_page] = 42
|
86
86
|
session[:leads_current_query] = "bill"
|
87
|
-
@leads = [
|
87
|
+
@leads = [create(:lead, user: current_user)]
|
88
88
|
get :index, xhr: true
|
89
89
|
|
90
90
|
expect(assigns[:current_page]).to eq(1)
|
@@ -122,7 +122,7 @@ describe LeadsController do
|
|
122
122
|
describe "responding to GET show" do
|
123
123
|
describe "with mime type of HTML" do
|
124
124
|
before(:each) do
|
125
|
-
@lead =
|
125
|
+
@lead = create(:lead, id: 42, user: current_user)
|
126
126
|
@comment = Comment.new
|
127
127
|
end
|
128
128
|
|
@@ -141,7 +141,7 @@ describe LeadsController do
|
|
141
141
|
|
142
142
|
describe "with mime type of JSON" do
|
143
143
|
it "should render the requested lead as JSON" do
|
144
|
-
@lead =
|
144
|
+
@lead = create(:lead, id: 42, user: current_user)
|
145
145
|
expect(Lead).to receive(:find).and_return(@lead)
|
146
146
|
expect(@lead).to receive(:to_json).and_return("generated JSON")
|
147
147
|
|
@@ -153,7 +153,7 @@ describe LeadsController do
|
|
153
153
|
|
154
154
|
describe "with mime type of XML" do
|
155
155
|
it "should render the requested lead as xml" do
|
156
|
-
@lead =
|
156
|
+
@lead = create(:lead, id: 42, user: current_user)
|
157
157
|
expect(Lead).to receive(:find).and_return(@lead)
|
158
158
|
expect(@lead).to receive(:to_xml).and_return("generated XML")
|
159
159
|
|
@@ -165,7 +165,7 @@ describe LeadsController do
|
|
165
165
|
|
166
166
|
describe "lead got deleted or otherwise unavailable" do
|
167
167
|
it "should redirect to lead index if the lead got deleted" do
|
168
|
-
@lead =
|
168
|
+
@lead = create(:lead, user: current_user)
|
169
169
|
@lead.destroy
|
170
170
|
|
171
171
|
get :show, params: { id: @lead.id }
|
@@ -174,7 +174,7 @@ describe LeadsController do
|
|
174
174
|
end
|
175
175
|
|
176
176
|
it "should redirect to lead index if the lead is protected" do
|
177
|
-
@private =
|
177
|
+
@private = create(:lead, user: create(:user), access: "Private")
|
178
178
|
|
179
179
|
get :show, params: { id: @private.id }
|
180
180
|
expect(flash[:warning]).not_to eq(nil)
|
@@ -182,7 +182,7 @@ describe LeadsController do
|
|
182
182
|
end
|
183
183
|
|
184
184
|
it "should return 404 (Not Found) JSON error" do
|
185
|
-
@lead =
|
185
|
+
@lead = create(:lead, user: current_user)
|
186
186
|
@lead.destroy
|
187
187
|
request.env["HTTP_ACCEPT"] = "application/json"
|
188
188
|
|
@@ -191,7 +191,7 @@ describe LeadsController do
|
|
191
191
|
end
|
192
192
|
|
193
193
|
it "should return 404 (Not Found) XML error" do
|
194
|
-
@lead =
|
194
|
+
@lead = create(:lead, user: current_user)
|
195
195
|
@lead.destroy
|
196
196
|
request.env["HTTP_ACCEPT"] = "application/xml"
|
197
197
|
|
@@ -206,9 +206,9 @@ describe LeadsController do
|
|
206
206
|
#----------------------------------------------------------------------------
|
207
207
|
describe "responding to GET new" do
|
208
208
|
it "should expose a new lead as @lead and render [new] template" do
|
209
|
-
@lead =
|
209
|
+
@lead = build(:lead, user: current_user, campaign: nil)
|
210
210
|
allow(Lead).to receive(:new).and_return(@lead)
|
211
|
-
@campaigns = [
|
211
|
+
@campaigns = [create(:campaign, user: current_user)]
|
212
212
|
|
213
213
|
get :new, xhr: true
|
214
214
|
expect(assigns[:lead].attributes).to eq(@lead.attributes)
|
@@ -217,7 +217,7 @@ describe LeadsController do
|
|
217
217
|
end
|
218
218
|
|
219
219
|
it "should create related object when necessary" do
|
220
|
-
@campaign =
|
220
|
+
@campaign = create(:campaign, id: 123)
|
221
221
|
|
222
222
|
get :new, params: { related: "campaign_123" }, xhr: true
|
223
223
|
expect(assigns[:campaign]).to eq(@campaign)
|
@@ -225,7 +225,7 @@ describe LeadsController do
|
|
225
225
|
|
226
226
|
describe "(when creating related lead)" do
|
227
227
|
it "should redirect to parent asset's index page with the message if parent asset got deleted" do
|
228
|
-
@campaign =
|
228
|
+
@campaign = create(:campaign)
|
229
229
|
@campaign.destroy
|
230
230
|
|
231
231
|
get :new, params: { related: "campaign_#{@campaign.id}" }, xhr: true
|
@@ -234,7 +234,7 @@ describe LeadsController do
|
|
234
234
|
end
|
235
235
|
|
236
236
|
it "should redirect to parent asset's index page with the message if parent asset got protected" do
|
237
|
-
@campaign =
|
237
|
+
@campaign = create(:campaign, access: "Private")
|
238
238
|
|
239
239
|
get :new, params: { related: "campaign_#{@campaign.id}" }, xhr: true
|
240
240
|
expect(flash[:warning]).not_to eq(nil)
|
@@ -247,8 +247,8 @@ describe LeadsController do
|
|
247
247
|
#----------------------------------------------------------------------------
|
248
248
|
describe "responding to GET edit" do
|
249
249
|
it "should expose the requested lead as @lead and render [edit] template" do
|
250
|
-
@lead =
|
251
|
-
@campaigns = [
|
250
|
+
@lead = create(:lead, id: 42, user: current_user, campaign: nil)
|
251
|
+
@campaigns = [create(:campaign, user: current_user)]
|
252
252
|
|
253
253
|
get :edit, params: { id: 42 }, xhr: true
|
254
254
|
expect(assigns[:lead]).to eq(@lead)
|
@@ -257,8 +257,8 @@ describe LeadsController do
|
|
257
257
|
end
|
258
258
|
|
259
259
|
it "should find previous lead when necessary" do
|
260
|
-
@lead =
|
261
|
-
@previous =
|
260
|
+
@lead = create(:lead, id: 42)
|
261
|
+
@previous = create(:lead, id: 321)
|
262
262
|
|
263
263
|
get :edit, params: { id: 42, previous: 321 }, xhr: true
|
264
264
|
expect(assigns[:previous]).to eq(@previous)
|
@@ -266,7 +266,7 @@ describe LeadsController do
|
|
266
266
|
|
267
267
|
describe "lead got deleted or is otherwise unavailable" do
|
268
268
|
it "should reload current page with the flash message if the lead got deleted" do
|
269
|
-
@lead =
|
269
|
+
@lead = create(:lead, user: current_user)
|
270
270
|
@lead.destroy
|
271
271
|
|
272
272
|
get :edit, params: { id: @lead.id }, xhr: true
|
@@ -275,7 +275,7 @@ describe LeadsController do
|
|
275
275
|
end
|
276
276
|
|
277
277
|
it "should reload current page with the flash message if the lead is protected" do
|
278
|
-
@private =
|
278
|
+
@private = create(:lead, user: create(:user), access: "Private")
|
279
279
|
|
280
280
|
get :edit, params: { id: @private.id }, xhr: true
|
281
281
|
expect(flash[:warning]).not_to eq(nil)
|
@@ -285,8 +285,8 @@ describe LeadsController do
|
|
285
285
|
|
286
286
|
describe "(previous lead got deleted or is otherwise unavailable)" do
|
287
287
|
before(:each) do
|
288
|
-
@lead =
|
289
|
-
@previous =
|
288
|
+
@lead = create(:lead, user: current_user)
|
289
|
+
@previous = create(:lead, user: create(:user))
|
290
290
|
end
|
291
291
|
|
292
292
|
it "should notify the view if previous lead got deleted" do
|
@@ -315,9 +315,9 @@ describe LeadsController do
|
|
315
315
|
describe "responding to POST create" do
|
316
316
|
describe "with valid params" do
|
317
317
|
it "should expose a newly created lead as @lead and render [create] template" do
|
318
|
-
@lead =
|
318
|
+
@lead = build(:lead, user: current_user, campaign: nil)
|
319
319
|
allow(Lead).to receive(:new).and_return(@lead)
|
320
|
-
@campaigns = [
|
320
|
+
@campaigns = [create(:campaign, user: current_user)]
|
321
321
|
|
322
322
|
post :create, params: { lead: { first_name: "Billy", last_name: "Bones" } }, xhr: true
|
323
323
|
expect(assigns(:lead)).to eq(@lead)
|
@@ -327,14 +327,14 @@ describe LeadsController do
|
|
327
327
|
end
|
328
328
|
|
329
329
|
it "should copy selected campaign permissions unless asked otherwise" do
|
330
|
-
he =
|
331
|
-
she =
|
332
|
-
@campaign =
|
333
|
-
@campaign.permissions <<
|
334
|
-
@campaign.permissions <<
|
330
|
+
he = create(:user, id: 7)
|
331
|
+
she = create(:user, id: 8)
|
332
|
+
@campaign = build(:campaign, access: "Shared")
|
333
|
+
@campaign.permissions << build(:permission, user: he, asset: @campaign)
|
334
|
+
@campaign.permissions << build(:permission, user: she, asset: @campaign)
|
335
335
|
@campaign.save
|
336
336
|
|
337
|
-
@lead =
|
337
|
+
@lead = build(:lead, campaign: @campaign, user: current_user, access: "Shared")
|
338
338
|
allow(Lead).to receive(:new).and_return(@lead)
|
339
339
|
|
340
340
|
post :create, params: { lead: { first_name: "Billy", last_name: "Bones", access: "Campaign", user_ids: %w[7 8] }, campaign: @campaign.id }, xhr: true
|
@@ -346,7 +346,7 @@ describe LeadsController do
|
|
346
346
|
end
|
347
347
|
|
348
348
|
it "should get the data to update leads sidebar if called from leads index" do
|
349
|
-
@lead =
|
349
|
+
@lead = build(:lead, user: current_user, campaign: nil)
|
350
350
|
allow(Lead).to receive(:new).and_return(@lead)
|
351
351
|
|
352
352
|
request.env["HTTP_REFERER"] = "http://localhost/leads"
|
@@ -355,7 +355,7 @@ describe LeadsController do
|
|
355
355
|
end
|
356
356
|
|
357
357
|
it "should reload leads to update pagination if called from leads index" do
|
358
|
-
@lead =
|
358
|
+
@lead = build(:lead, user: current_user, campaign: nil)
|
359
359
|
allow(Lead).to receive(:new).and_return(@lead)
|
360
360
|
|
361
361
|
request.env["HTTP_REFERER"] = "http://localhost/leads"
|
@@ -364,8 +364,8 @@ describe LeadsController do
|
|
364
364
|
end
|
365
365
|
|
366
366
|
it "should reload lead campaign if called from campaign landing page" do
|
367
|
-
@campaign =
|
368
|
-
@lead =
|
367
|
+
@campaign = create(:campaign)
|
368
|
+
@lead = build(:lead, user: current_user, campaign: @campaign)
|
369
369
|
|
370
370
|
request.env["HTTP_REFERER"] = "http://localhost/campaigns/#{@campaign.id}"
|
371
371
|
put :create, params: { lead: { first_name: "Billy", last_name: "Bones" }, campaign: @campaign.id }, xhr: true
|
@@ -373,7 +373,7 @@ describe LeadsController do
|
|
373
373
|
end
|
374
374
|
|
375
375
|
it "should add a new comment to the newly created lead when specified" do
|
376
|
-
@lead =
|
376
|
+
@lead = create(:lead)
|
377
377
|
allow(Lead).to receive(:new).and_return(@lead)
|
378
378
|
post :create, params: { lead: { first_name: "Test", last_name: "Lead" }, comment_body: "This is an important lead." }, xhr: true
|
379
379
|
expect(@lead.reload.comments.map(&:comment)).to include("This is an important lead.")
|
@@ -382,9 +382,9 @@ describe LeadsController do
|
|
382
382
|
|
383
383
|
describe "with invalid params" do
|
384
384
|
it "should expose a newly created but unsaved lead as @lead and still render [create] template" do
|
385
|
-
@lead =
|
385
|
+
@lead = build(:lead, user: current_user, first_name: nil, campaign: nil)
|
386
386
|
allow(Lead).to receive(:new).and_return(@lead)
|
387
|
-
@campaigns = [
|
387
|
+
@campaigns = [create(:campaign, user: current_user)]
|
388
388
|
|
389
389
|
post :create, params: { lead: { first_name: nil } }, xhr: true
|
390
390
|
expect(assigns(:lead)).to eq(@lead)
|
@@ -401,7 +401,7 @@ describe LeadsController do
|
|
401
401
|
describe "responding to PUT update" do
|
402
402
|
describe "with valid params" do
|
403
403
|
it "should update the requested lead, expose it as @lead, and render [update] template" do
|
404
|
-
@lead =
|
404
|
+
@lead = create(:lead, first_name: "Billy", user: current_user)
|
405
405
|
|
406
406
|
put :update, params: { id: @lead.id, lead: { first_name: "Bones" } }, xhr: true
|
407
407
|
expect(@lead.reload.first_name).to eq("Bones")
|
@@ -411,30 +411,30 @@ describe LeadsController do
|
|
411
411
|
end
|
412
412
|
|
413
413
|
it "should update lead status" do
|
414
|
-
@lead =
|
414
|
+
@lead = create(:lead, status: "new", user: current_user)
|
415
415
|
|
416
416
|
put :update, params: { id: @lead.id, lead: { status: "rejected" } }, xhr: true
|
417
417
|
expect(@lead.reload.status).to eq("rejected")
|
418
418
|
end
|
419
419
|
|
420
420
|
it "should update lead source" do
|
421
|
-
@lead =
|
421
|
+
@lead = create(:lead, source: "campaign", user: current_user)
|
422
422
|
|
423
423
|
put :update, params: { id: @lead.id, lead: { source: "cald_call" } }, xhr: true
|
424
424
|
expect(@lead.reload.source).to eq("cald_call")
|
425
425
|
end
|
426
426
|
|
427
427
|
it "should update lead campaign" do
|
428
|
-
@campaigns = { old:
|
429
|
-
@lead =
|
428
|
+
@campaigns = { old: create(:campaign), new: create(:campaign) }
|
429
|
+
@lead = create(:lead, campaign: @campaigns[:old])
|
430
430
|
|
431
431
|
put :update, params: { id: @lead.id, lead: { campaign_id: @campaigns[:new].id } }, xhr: true
|
432
432
|
expect(@lead.reload.campaign).to eq(@campaigns[:new])
|
433
433
|
end
|
434
434
|
|
435
435
|
it "should decrement campaign leads count if campaign has been removed" do
|
436
|
-
@campaign =
|
437
|
-
@lead =
|
436
|
+
@campaign = create(:campaign)
|
437
|
+
@lead = create(:lead, campaign: @campaign)
|
438
438
|
@count = @campaign.reload.leads_count
|
439
439
|
|
440
440
|
put :update, params: { id: @lead, lead: { campaign_id: nil } }, xhr: true
|
@@ -443,8 +443,8 @@ describe LeadsController do
|
|
443
443
|
end
|
444
444
|
|
445
445
|
it "should increment campaign leads count if campaign has been assigned" do
|
446
|
-
@campaign =
|
447
|
-
@lead =
|
446
|
+
@campaign = create(:campaign)
|
447
|
+
@lead = create(:lead, campaign: nil)
|
448
448
|
@count = @campaign.leads_count
|
449
449
|
|
450
450
|
put :update, params: { id: @lead, lead: { campaign_id: @campaign.id } }, xhr: true
|
@@ -453,8 +453,8 @@ describe LeadsController do
|
|
453
453
|
end
|
454
454
|
|
455
455
|
it "should update both campaign leads counts if reassigned to a new campaign" do
|
456
|
-
@campaigns = { old:
|
457
|
-
@lead =
|
456
|
+
@campaigns = { old: create(:campaign), new: create(:campaign) }
|
457
|
+
@lead = create(:lead, campaign: @campaigns[:old])
|
458
458
|
@counts = { old: @campaigns[:old].reload.leads_count, new: @campaigns[:new].leads_count }
|
459
459
|
|
460
460
|
put :update, params: { id: @lead, lead: { campaign_id: @campaigns[:new].id } }, xhr: true
|
@@ -464,16 +464,16 @@ describe LeadsController do
|
|
464
464
|
end
|
465
465
|
|
466
466
|
it "should update shared permissions for the lead" do
|
467
|
-
@lead =
|
468
|
-
he =
|
469
|
-
she =
|
467
|
+
@lead = create(:lead, user: current_user)
|
468
|
+
he = create(:user, id: 7)
|
469
|
+
she = create(:user, id: 8)
|
470
470
|
|
471
471
|
put :update, params: { id: @lead.id, lead: { access: "Shared", user_ids: %w[7 8] } }, xhr: true
|
472
472
|
expect(@lead.user_ids.sort).to eq([he.id, she.id])
|
473
473
|
end
|
474
474
|
|
475
475
|
it "should get the data for leads sidebar when called from leads index" do
|
476
|
-
@lead =
|
476
|
+
@lead = create(:lead)
|
477
477
|
|
478
478
|
request.env["HTTP_REFERER"] = "http://localhost/leads"
|
479
479
|
put :update, params: { id: @lead.id, lead: { first_name: "Billy" } }, xhr: true
|
@@ -482,8 +482,8 @@ describe LeadsController do
|
|
482
482
|
end
|
483
483
|
|
484
484
|
it "should reload lead campaign if called from campaign landing page" do
|
485
|
-
@campaign =
|
486
|
-
@lead =
|
485
|
+
@campaign = create(:campaign)
|
486
|
+
@lead = create(:lead, campaign: @campaign)
|
487
487
|
|
488
488
|
request.env["HTTP_REFERER"] = "http://localhost/campaigns/#{@campaign.id}"
|
489
489
|
put :update, params: { id: @lead.id, lead: { first_name: "Hello" } }, xhr: true
|
@@ -492,7 +492,7 @@ describe LeadsController do
|
|
492
492
|
|
493
493
|
describe "lead got deleted or otherwise unavailable" do
|
494
494
|
it "should reload current page with the flash message if the lead got deleted" do
|
495
|
-
@lead =
|
495
|
+
@lead = create(:lead, user: current_user)
|
496
496
|
@lead.destroy
|
497
497
|
|
498
498
|
put :update, params: { id: @lead.id }, xhr: true
|
@@ -501,7 +501,7 @@ describe LeadsController do
|
|
501
501
|
end
|
502
502
|
|
503
503
|
it "should reload current page with the flash message if the lead is protected" do
|
504
|
-
@private =
|
504
|
+
@private = create(:lead, user: create(:user), access: "Private")
|
505
505
|
|
506
506
|
put :update, params: { id: @private.id }, xhr: true
|
507
507
|
expect(flash[:warning]).not_to eq(nil)
|
@@ -512,8 +512,8 @@ describe LeadsController do
|
|
512
512
|
|
513
513
|
describe "with invalid params" do
|
514
514
|
it "should not update the lead, but still expose it as @lead and render [update] template" do
|
515
|
-
@lead =
|
516
|
-
@campaigns = [
|
515
|
+
@lead = create(:lead, id: 42, user: current_user, campaign: nil)
|
516
|
+
@campaigns = [create(:campaign, user: current_user)]
|
517
517
|
|
518
518
|
put :update, params: { id: 42, lead: { first_name: nil } }, xhr: true
|
519
519
|
expect(assigns[:lead]).to eq(@lead)
|
@@ -528,7 +528,7 @@ describe LeadsController do
|
|
528
528
|
#----------------------------------------------------------------------------
|
529
529
|
describe "responding to DELETE destroy" do
|
530
530
|
before(:each) do
|
531
|
-
@lead =
|
531
|
+
@lead = create(:lead, user: current_user)
|
532
532
|
end
|
533
533
|
|
534
534
|
describe "AJAX request" do
|
@@ -546,7 +546,7 @@ describe LeadsController do
|
|
546
546
|
end
|
547
547
|
|
548
548
|
it "should get data for the sidebar" do
|
549
|
-
@another_lead =
|
549
|
+
@another_lead = create(:lead, user: current_user)
|
550
550
|
|
551
551
|
delete :destroy, params: { id: @lead.id }, xhr: true
|
552
552
|
expect(assigns[:leads]).to eq([@another_lead]) # @lead got deleted
|
@@ -574,8 +574,8 @@ describe LeadsController do
|
|
574
574
|
|
575
575
|
describe "when called from campaign landing page" do
|
576
576
|
before(:each) do
|
577
|
-
@campaign =
|
578
|
-
@lead =
|
577
|
+
@campaign = create(:campaign)
|
578
|
+
@lead = create(:lead, user: current_user, campaign: @campaign)
|
579
579
|
request.env["HTTP_REFERER"] = "http://localhost/campaigns/#{@campaign.id}"
|
580
580
|
end
|
581
581
|
|
@@ -594,7 +594,7 @@ describe LeadsController do
|
|
594
594
|
|
595
595
|
describe "lead got deleted or otherwise unavailable" do
|
596
596
|
it "should reload current page with the flash message if the lead got deleted" do
|
597
|
-
@lead =
|
597
|
+
@lead = create(:lead, user: current_user)
|
598
598
|
@lead.destroy
|
599
599
|
|
600
600
|
delete :destroy, params: { id: @lead.id }, xhr: true
|
@@ -603,7 +603,7 @@ describe LeadsController do
|
|
603
603
|
end
|
604
604
|
|
605
605
|
it "should reload current page with the flash message if the lead is protected" do
|
606
|
-
@private =
|
606
|
+
@private = create(:lead, user: create(:user), access: "Private")
|
607
607
|
|
608
608
|
delete :destroy, params: { id: @private.id }, xhr: true
|
609
609
|
expect(flash[:warning]).not_to eq(nil)
|
@@ -621,7 +621,7 @@ describe LeadsController do
|
|
621
621
|
end
|
622
622
|
|
623
623
|
it "should redirect to lead index with the flash message is the lead got deleted" do
|
624
|
-
@lead =
|
624
|
+
@lead = create(:lead, user: current_user)
|
625
625
|
@lead.destroy
|
626
626
|
|
627
627
|
delete :destroy, params: { id: @lead.id }
|
@@ -630,7 +630,7 @@ describe LeadsController do
|
|
630
630
|
end
|
631
631
|
|
632
632
|
it "should redirect to lead index with the flash message if the lead is protected" do
|
633
|
-
@private =
|
633
|
+
@private = create(:lead, user: create(:user), access: "Private")
|
634
634
|
|
635
635
|
delete :destroy, params: { id: @private.id }
|
636
636
|
expect(flash[:warning]).not_to eq(nil)
|
@@ -644,9 +644,9 @@ describe LeadsController do
|
|
644
644
|
#----------------------------------------------------------------------------
|
645
645
|
describe "responding to GET convert" do
|
646
646
|
it "should should collect necessary data and render [convert] template" do
|
647
|
-
@campaign =
|
648
|
-
@lead =
|
649
|
-
@accounts = [
|
647
|
+
@campaign = create(:campaign, user: current_user)
|
648
|
+
@lead = create(:lead, user: current_user, campaign: @campaign, source: "cold_call")
|
649
|
+
@accounts = [create(:account, user: current_user)]
|
650
650
|
@account = Account.new(user: current_user, name: @lead.company, access: "Lead")
|
651
651
|
@opportunity = Opportunity.new(user: current_user, access: "Lead", stage: "prospecting", campaign: @lead.campaign, source: @lead.source)
|
652
652
|
|
@@ -661,7 +661,7 @@ describe LeadsController do
|
|
661
661
|
|
662
662
|
describe "(lead got deleted or is otherwise unavailable)" do
|
663
663
|
it "should reload current page with the flash message if the lead got deleted" do
|
664
|
-
@lead =
|
664
|
+
@lead = create(:lead, user: current_user)
|
665
665
|
@lead.destroy
|
666
666
|
|
667
667
|
get :convert, params: { id: @lead.id }, xhr: true
|
@@ -670,7 +670,7 @@ describe LeadsController do
|
|
670
670
|
end
|
671
671
|
|
672
672
|
it "should reload current page with the flash message if the lead is protected" do
|
673
|
-
@private =
|
673
|
+
@private = create(:lead, user: create(:user), access: "Private")
|
674
674
|
|
675
675
|
get :convert, params: { id: @private.id }, xhr: true
|
676
676
|
expect(flash[:warning]).not_to eq(nil)
|
@@ -680,8 +680,8 @@ describe LeadsController do
|
|
680
680
|
|
681
681
|
describe "(previous lead got deleted or is otherwise unavailable)" do
|
682
682
|
before(:each) do
|
683
|
-
@lead =
|
684
|
-
@previous =
|
683
|
+
@lead = create(:lead, user: current_user)
|
684
|
+
@previous = create(:lead, user: create(:user))
|
685
685
|
end
|
686
686
|
|
687
687
|
it "should notify the view if previous lead got deleted" do
|
@@ -709,12 +709,12 @@ describe LeadsController do
|
|
709
709
|
#----------------------------------------------------------------------------
|
710
710
|
describe "responding to PUT promote" do
|
711
711
|
it "on success: should change lead's status to [converted] and render [promote] template" do
|
712
|
-
@lead =
|
713
|
-
@account =
|
714
|
-
@opportunity =
|
715
|
-
|
712
|
+
@lead = create(:lead, id: 42, user: current_user, campaign: nil)
|
713
|
+
@account = create(:account, id: 123, user: current_user)
|
714
|
+
@opportunity = build(:opportunity, user: current_user, campaign: @lead.campaign,
|
715
|
+
account: @account)
|
716
716
|
allow(Opportunity).to receive(:new).and_return(@opportunity)
|
717
|
-
@contact =
|
717
|
+
@contact = build(:contact, user: current_user, lead: @lead)
|
718
718
|
allow(Contact).to receive(:new).and_return(@contact)
|
719
719
|
|
720
720
|
put :promote, params: { id: 42, account: { id: 123 }, opportunity: { name: "Hello" } }, xhr: true
|
@@ -729,19 +729,19 @@ describe LeadsController do
|
|
729
729
|
end
|
730
730
|
|
731
731
|
it "should copy lead permissions to newly created account and opportunity when asked so" do
|
732
|
-
he =
|
733
|
-
she =
|
734
|
-
@lead =
|
735
|
-
@lead.permissions <<
|
736
|
-
@lead.permissions <<
|
732
|
+
he = create(:user, id: 7)
|
733
|
+
she = create(:user, id: 8)
|
734
|
+
@lead = build(:lead, access: "Shared")
|
735
|
+
@lead.permissions << build(:permission, user: he, asset: @lead)
|
736
|
+
@lead.permissions << build(:permission, user: she, asset: @lead)
|
737
737
|
@lead.save
|
738
|
-
@account =
|
739
|
-
@account.permissions <<
|
740
|
-
@account.permissions <<
|
738
|
+
@account = build(:account, user: current_user, access: "Shared")
|
739
|
+
@account.permissions << create(:permission, user: he, asset: @account)
|
740
|
+
@account.permissions << create(:permission, user: she, asset: @account)
|
741
741
|
allow(@account).to receive(:new).and_return(@account)
|
742
|
-
@opportunity =
|
743
|
-
@opportunity.permissions <<
|
744
|
-
@opportunity.permissions <<
|
742
|
+
@opportunity = build(:opportunity, user: current_user, access: "Shared")
|
743
|
+
@opportunity.permissions << create(:permission, user: he, asset: @opportunity)
|
744
|
+
@opportunity.permissions << create(:permission, user: she, asset: @opportunity)
|
745
745
|
allow(@opportunity).to receive(:new).and_return(@opportunity)
|
746
746
|
|
747
747
|
put :promote, params: { id: @lead.id, access: "Lead", account: { name: "Hello", access: "Lead", user_id: current_user.id }, opportunity: { name: "World", access: "Lead", user_id: current_user.id } }, xhr: true
|
@@ -756,22 +756,22 @@ describe LeadsController do
|
|
756
756
|
end
|
757
757
|
|
758
758
|
it "should assign lead's campaign to the newly created opportunity" do
|
759
|
-
@campaign =
|
760
|
-
@lead =
|
759
|
+
@campaign = create(:campaign)
|
760
|
+
@lead = create(:lead, user: current_user, campaign: @campaign)
|
761
761
|
|
762
762
|
put :promote, params: { id: @lead.id, account: { name: "Hello" }, opportunity: { name: "Hello", campaign_id: @campaign.id } }, xhr: true
|
763
763
|
expect(assigns[:opportunity].campaign).to eq(@campaign)
|
764
764
|
end
|
765
765
|
|
766
766
|
it "should assign lead's source to the newly created opportunity" do
|
767
|
-
@lead =
|
767
|
+
@lead = create(:lead, user: current_user, source: "cold_call")
|
768
768
|
|
769
769
|
put :promote, params: { id: @lead.id, account: { name: "Hello" }, opportunity: { name: "Hello", source: @lead.source } }, xhr: true
|
770
770
|
expect(assigns[:opportunity].source).to eq(@lead.source)
|
771
771
|
end
|
772
772
|
|
773
773
|
it "should get the data for leads sidebar when called from leads index" do
|
774
|
-
@lead =
|
774
|
+
@lead = create(:lead)
|
775
775
|
request.env["HTTP_REFERER"] = "http://localhost/leads"
|
776
776
|
|
777
777
|
put :promote, params: { id: @lead.id, account: { name: "Hello" }, opportunity: {} }, xhr: true
|
@@ -780,8 +780,8 @@ describe LeadsController do
|
|
780
780
|
end
|
781
781
|
|
782
782
|
it "should reload lead campaign if called from campaign landing page" do
|
783
|
-
@campaign =
|
784
|
-
@lead =
|
783
|
+
@campaign = create(:campaign)
|
784
|
+
@lead = create(:lead, campaign: @campaign)
|
785
785
|
request.env["HTTP_REFERER"] = "http://localhost/campaigns/#{@campaign.id}"
|
786
786
|
|
787
787
|
put :promote, params: { id: @lead.id, account: { name: "Hello" }, opportunity: {} }, xhr: true
|
@@ -789,9 +789,9 @@ describe LeadsController do
|
|
789
789
|
end
|
790
790
|
|
791
791
|
it "on failure: should not change lead's status and still render [promote] template" do
|
792
|
-
@lead =
|
793
|
-
@account =
|
794
|
-
@contact =
|
792
|
+
@lead = create(:lead, id: 42, user: current_user, status: "new")
|
793
|
+
@account = create(:account, id: 123, user: current_user)
|
794
|
+
@contact = build(:contact, first_name: nil) # make it fail
|
795
795
|
allow(Contact).to receive(:new).and_return(@contact)
|
796
796
|
|
797
797
|
put :promote, params: { id: 42, account: { id: 123 } }, xhr: true
|
@@ -801,7 +801,7 @@ describe LeadsController do
|
|
801
801
|
|
802
802
|
describe "lead got deleted or otherwise unavailable" do
|
803
803
|
it "should reload current page with the flash message if the lead got deleted" do
|
804
|
-
@lead =
|
804
|
+
@lead = create(:lead, user: current_user)
|
805
805
|
@lead.destroy
|
806
806
|
|
807
807
|
put :promote, params: { id: @lead.id }, xhr: true
|
@@ -810,7 +810,7 @@ describe LeadsController do
|
|
810
810
|
end
|
811
811
|
|
812
812
|
it "should reload current page with the flash message if the lead is protected" do
|
813
|
-
@private =
|
813
|
+
@private = create(:lead, user: create(:user), access: "Private")
|
814
814
|
|
815
815
|
put :promote, params: { id: @private.id }, xhr: true
|
816
816
|
expect(flash[:warning]).not_to eq(nil)
|
@@ -824,7 +824,7 @@ describe LeadsController do
|
|
824
824
|
#----------------------------------------------------------------------------
|
825
825
|
describe "responding to PUT reject" do
|
826
826
|
before(:each) do
|
827
|
-
@lead =
|
827
|
+
@lead = create(:lead, user: current_user, status: "new")
|
828
828
|
end
|
829
829
|
|
830
830
|
describe "AJAX request" do
|
@@ -844,8 +844,8 @@ describe LeadsController do
|
|
844
844
|
end
|
845
845
|
|
846
846
|
it "should reload lead campaign if called from campaign landing page" do
|
847
|
-
@campaign =
|
848
|
-
@lead =
|
847
|
+
@campaign = create(:campaign)
|
848
|
+
@lead = create(:lead, campaign: @campaign)
|
849
849
|
|
850
850
|
request.env["HTTP_REFERER"] = "http://localhost/campaigns/#{@campaign.id}"
|
851
851
|
put :reject, params: { id: @lead.id }, xhr: true
|
@@ -854,7 +854,7 @@ describe LeadsController do
|
|
854
854
|
|
855
855
|
describe "lead got deleted or otherwise unavailable" do
|
856
856
|
it "should reload current page with the flash message if the lead got deleted" do
|
857
|
-
@lead =
|
857
|
+
@lead = create(:lead, user: current_user)
|
858
858
|
@lead.destroy
|
859
859
|
|
860
860
|
put :reject, params: { id: @lead.id }, xhr: true
|
@@ -863,7 +863,7 @@ describe LeadsController do
|
|
863
863
|
end
|
864
864
|
|
865
865
|
it "should reload current page with the flash message if the lead is protected" do
|
866
|
-
@private =
|
866
|
+
@private = create(:lead, user: create(:user), access: "Private")
|
867
867
|
|
868
868
|
put :reject, params: { id: @private.id }, xhr: true
|
869
869
|
expect(flash[:warning]).not_to eq(nil)
|
@@ -884,7 +884,7 @@ describe LeadsController do
|
|
884
884
|
|
885
885
|
describe "lead got deleted or otherwise unavailable" do
|
886
886
|
it "should redirect to lead index if the lead got deleted" do
|
887
|
-
@lead =
|
887
|
+
@lead = create(:lead, user: current_user)
|
888
888
|
@lead.destroy
|
889
889
|
|
890
890
|
put :reject, params: { id: @lead.id }
|
@@ -893,7 +893,7 @@ describe LeadsController do
|
|
893
893
|
end
|
894
894
|
|
895
895
|
it "should redirect to lead index if the lead is protected" do
|
896
|
-
@private =
|
896
|
+
@private = create(:lead, user: create(:user), access: "Private")
|
897
897
|
|
898
898
|
put :reject, params: { id: @private.id }
|
899
899
|
expect(flash[:warning]).not_to eq(nil)
|
@@ -909,8 +909,8 @@ describe LeadsController do
|
|
909
909
|
describe "responding to PUT attach" do
|
910
910
|
describe "tasks" do
|
911
911
|
before do
|
912
|
-
@model =
|
913
|
-
@attachment =
|
912
|
+
@model = create(:lead)
|
913
|
+
@attachment = create(:task, asset: nil)
|
914
914
|
end
|
915
915
|
it_should_behave_like("attach")
|
916
916
|
end
|
@@ -922,8 +922,8 @@ describe LeadsController do
|
|
922
922
|
describe "responding to PUT attach" do
|
923
923
|
describe "tasks" do
|
924
924
|
before do
|
925
|
-
@model =
|
926
|
-
@attachment =
|
925
|
+
@model = create(:lead)
|
926
|
+
@attachment = create(:task, asset: nil)
|
927
927
|
end
|
928
928
|
it_should_behave_like("attach")
|
929
929
|
end
|
@@ -934,8 +934,8 @@ describe LeadsController do
|
|
934
934
|
#----------------------------------------------------------------------------
|
935
935
|
describe "responding to POST discard" do
|
936
936
|
before(:each) do
|
937
|
-
@attachment =
|
938
|
-
@model =
|
937
|
+
@attachment = create(:task, assigned_to: current_user)
|
938
|
+
@model = create(:lead)
|
939
939
|
@model.tasks << @attachment
|
940
940
|
end
|
941
941
|
|
@@ -946,7 +946,7 @@ describe LeadsController do
|
|
946
946
|
#----------------------------------------------------------------------------
|
947
947
|
describe "responding to POST auto_complete" do
|
948
948
|
before(:each) do
|
949
|
-
@auto_complete_matches = [
|
949
|
+
@auto_complete_matches = [create(:lead, first_name: "Hello", last_name: "World", user: current_user)]
|
950
950
|
end
|
951
951
|
|
952
952
|
it_should_behave_like("auto complete")
|
@@ -976,8 +976,8 @@ describe LeadsController do
|
|
976
976
|
|
977
977
|
it "should select @leads and render [index] template" do
|
978
978
|
@leads = [
|
979
|
-
|
980
|
-
|
979
|
+
create(:lead, first_name: "Alice", user: current_user),
|
980
|
+
create(:lead, first_name: "Bobby", user: current_user)
|
981
981
|
]
|
982
982
|
|
983
983
|
get :redraw, params: { per_page: 1, sort_by: "first_name" }, xhr: true
|
@@ -992,7 +992,7 @@ describe LeadsController do
|
|
992
992
|
it "should filter out leads as @leads and render :index action" do
|
993
993
|
session[:leads_filter] = "contacted,rejected"
|
994
994
|
|
995
|
-
@leads = [
|
995
|
+
@leads = [create(:lead, user: current_user, status: "new")]
|
996
996
|
post :filter, params: { status: "new" }, xhr: true
|
997
997
|
expect(assigns[:leads]).to eq(@leads)
|
998
998
|
expect(response).to be_a_success
|