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.

Files changed (195) hide show
  1. checksums.yaml +4 -4
  2. data/.dockerignore +11 -0
  3. data/.rubocop.yml +1 -1
  4. data/.rubocop_todo.yml +30 -8
  5. data/.travis.yml +14 -9
  6. data/CHANGELOG.md +43 -7
  7. data/CONTRIBUTORS.md +95 -53
  8. data/Gemfile +11 -7
  9. data/Gemfile.lock +83 -83
  10. data/README.md +7 -4
  11. data/app/assets/javascripts/crm.js.coffee +3 -3
  12. data/app/assets/javascripts/crm_select2.js.coffee +15 -14
  13. data/app/controllers/admin/field_groups_controller.rb +8 -1
  14. data/app/controllers/admin/fields_controller.rb +4 -4
  15. data/app/controllers/admin/groups_controller.rb +1 -1
  16. data/app/controllers/admin/tags_controller.rb +1 -1
  17. data/app/controllers/application_controller.rb +11 -0
  18. data/app/controllers/authentications_controller.rb +1 -1
  19. data/app/controllers/comments_controller.rb +15 -7
  20. data/app/controllers/entities/campaigns_controller.rb +7 -2
  21. data/app/controllers/entities/leads_controller.rb +9 -2
  22. data/app/controllers/entities/opportunities_controller.rb +13 -2
  23. data/app/controllers/entities_controller.rb +10 -5
  24. data/app/controllers/lists_controller.rb +5 -1
  25. data/app/controllers/tasks_controller.rb +15 -1
  26. data/app/helpers/accounts_helper.rb +1 -1
  27. data/app/helpers/application_helper.rb +2 -2
  28. data/app/helpers/leads_helper.rb +1 -1
  29. data/app/helpers/opportunities_helper.rb +56 -3
  30. data/app/helpers/tags_helper.rb +1 -1
  31. data/app/models/entities/lead.rb +0 -7
  32. data/app/models/entities/opportunity.rb +3 -2
  33. data/app/models/observers/opportunity_observer.rb +4 -4
  34. data/app/models/users/ability.rb +3 -4
  35. data/app/views/campaigns/_metrics.html.haml +3 -3
  36. data/app/views/home/_opportunity.html.haml +4 -19
  37. data/app/views/opportunities/_index_long.html.haml +1 -24
  38. data/app/views/opportunities/_sidebar_show.html.haml +3 -3
  39. data/app/views/opportunities/_top_section.html.haml +1 -1
  40. data/db/schema.rb +0 -3
  41. data/fat_free_crm.gemspec +1 -1
  42. data/lib/fat_free_crm/core_ext/string.rb +1 -1
  43. data/lib/fat_free_crm/engine.rb +2 -2
  44. data/lib/fat_free_crm/fields.rb +1 -1
  45. data/lib/fat_free_crm/permissions.rb +0 -14
  46. data/lib/fat_free_crm/version.rb +2 -2
  47. data/lib/tasks/ffcrm/setup.rake +4 -4
  48. data/spec/controllers/admin/users_controller_spec.rb +27 -27
  49. data/spec/controllers/authentications_controller_spec.rb +7 -7
  50. data/spec/controllers/comments_controller_spec.rb +13 -13
  51. data/spec/controllers/emails_controller_spec.rb +2 -2
  52. data/spec/controllers/entities/accounts_controller_spec.rb +56 -56
  53. data/spec/controllers/entities/campaigns_controller_spec.rb +66 -66
  54. data/spec/controllers/entities/contacts_controller_spec.rb +67 -67
  55. data/spec/controllers/entities/leads_controller_spec.rb +125 -125
  56. data/spec/controllers/entities/opportunities_controller_spec.rb +100 -100
  57. data/spec/controllers/home_controller_spec.rb +26 -26
  58. data/spec/controllers/passwords_controller_spec.rb +1 -1
  59. data/spec/controllers/tasks_controller_spec.rb +37 -37
  60. data/spec/controllers/users_controller_spec.rb +18 -18
  61. data/spec/factories/account_factories.rb +8 -8
  62. data/spec/factories/campaign_factories.rb +5 -5
  63. data/spec/factories/contact_factories.rb +10 -10
  64. data/spec/factories/field_factories.rb +7 -7
  65. data/spec/factories/lead_factories.rb +8 -8
  66. data/spec/factories/list_factories.rb +1 -1
  67. data/spec/factories/opportunity_factories.rb +6 -6
  68. data/spec/factories/sequences.rb +1 -1
  69. data/spec/factories/setting_factories.rb +3 -3
  70. data/spec/factories/shared_factories.rb +14 -14
  71. data/spec/factories/subscription_factories.rb +1 -1
  72. data/spec/factories/tag_factories.rb +1 -1
  73. data/spec/factories/task_factories.rb +4 -4
  74. data/spec/factories/user_factories.rb +13 -13
  75. data/spec/features/accounts_spec.rb +17 -4
  76. data/spec/features/admin/groups_spec.rb +1 -1
  77. data/spec/features/admin/users_spec.rb +1 -1
  78. data/spec/features/campaigns_spec.rb +4 -4
  79. data/spec/features/contacts_spec.rb +10 -4
  80. data/spec/features/dashboard_spec.rb +7 -7
  81. data/spec/features/leads_spec.rb +4 -4
  82. data/spec/features/opportunities_overview_spec.rb +15 -15
  83. data/spec/features/opportunities_spec.rb +34 -8
  84. data/spec/features/support/autocomlete_helper.rb +17 -0
  85. data/spec/features/support/browser.rb +3 -8
  86. data/spec/features/support/helpers.rb +1 -1
  87. data/spec/features/tasks_spec.rb +4 -4
  88. data/spec/helpers/admin/field_groups_helper_spec.rb +1 -1
  89. data/spec/helpers/application_helper_spec.rb +1 -1
  90. data/spec/helpers/tasks_helper_spec.rb +1 -1
  91. data/spec/helpers/users_helper_spec.rb +3 -3
  92. data/spec/lib/comment_extensions_spec.rb +1 -1
  93. data/spec/lib/mail_processor/base_spec.rb +3 -3
  94. data/spec/lib/mail_processor/comment_replies_spec.rb +3 -3
  95. data/spec/lib/mail_processor/dropbox_spec.rb +16 -16
  96. data/spec/lib/permissions_spec.rb +7 -25
  97. data/spec/mailers/user_mailer_spec.rb +7 -7
  98. data/spec/models/entities/account_spec.rb +31 -32
  99. data/spec/models/entities/campaign_spec.rb +18 -25
  100. data/spec/models/entities/contact_spec.rb +18 -21
  101. data/spec/models/entities/lead_spec.rb +9 -11
  102. data/spec/models/entities/opportunity_spec.rb +45 -45
  103. data/spec/models/fields/custom_field_spec.rb +17 -17
  104. data/spec/models/list_spec.rb +2 -2
  105. data/spec/models/observers/entity_observer_spec.rb +6 -6
  106. data/spec/models/polymorphic/address_spec.rb +1 -1
  107. data/spec/models/polymorphic/avatar_spec.rb +5 -5
  108. data/spec/models/polymorphic/comment_spec.rb +5 -5
  109. data/spec/models/polymorphic/task_spec.rb +65 -58
  110. data/spec/models/polymorphic/version_spec.rb +26 -26
  111. data/spec/models/setting_spec.rb +2 -2
  112. data/spec/models/users/preference_spec.rb +6 -6
  113. data/spec/models/users/user_spec.rb +26 -26
  114. data/spec/shared/models.rb +22 -22
  115. data/spec/spec_helper.rb +2 -2
  116. data/spec/support/auth_macros.rb +1 -1
  117. data/spec/support/macros.rb +3 -3
  118. data/spec/views/accounts/_edit.haml_spec.rb +1 -1
  119. data/spec/views/accounts/create.js.haml_spec.rb +2 -2
  120. data/spec/views/accounts/destroy.js.haml_spec.rb +1 -1
  121. data/spec/views/accounts/edit.js.haml_spec.rb +2 -2
  122. data/spec/views/accounts/index.haml_spec.rb +2 -2
  123. data/spec/views/accounts/index.js.haml_spec.rb +1 -1
  124. data/spec/views/accounts/show.haml_spec.rb +4 -4
  125. data/spec/views/accounts/update.js.haml_spec.rb +1 -1
  126. data/spec/views/admin/field_groups/create.js.haml_spec.rb +1 -1
  127. data/spec/views/admin/field_groups/destroy.js.haml_spec.rb +1 -1
  128. data/spec/views/admin/field_groups/edit.js.haml_spec.rb +1 -1
  129. data/spec/views/admin/field_groups/new.js.haml_spec.rb +1 -1
  130. data/spec/views/admin/field_groups/update.js.haml_spec.rb +1 -1
  131. data/spec/views/admin/users/create.js.haml_spec.rb +2 -2
  132. data/spec/views/admin/users/destroy.js.haml_spec.rb +2 -2
  133. data/spec/views/admin/users/edit.js.haml_spec.rb +2 -2
  134. data/spec/views/admin/users/index.haml_spec.rb +1 -1
  135. data/spec/views/admin/users/index.js.haml_spec.rb +2 -2
  136. data/spec/views/admin/users/reactivate.js.haml_spec.rb +1 -1
  137. data/spec/views/admin/users/suspend.js.haml_spec.rb +1 -1
  138. data/spec/views/admin/users/update.js.haml_spec.rb +1 -1
  139. data/spec/views/application/auto_complete.haml_spec.rb +3 -3
  140. data/spec/views/campaigns/_edit.haml_spec.rb +1 -1
  141. data/spec/views/campaigns/create.js.haml_spec.rb +3 -3
  142. data/spec/views/campaigns/destroy.js.haml_spec.rb +1 -1
  143. data/spec/views/campaigns/edit.js.haml_spec.rb +2 -2
  144. data/spec/views/campaigns/index.haml_spec.rb +1 -1
  145. data/spec/views/campaigns/index.js.haml_spec.rb +1 -1
  146. data/spec/views/campaigns/show.haml_spec.rb +4 -4
  147. data/spec/views/campaigns/update.js.haml_spec.rb +1 -1
  148. data/spec/views/contacts/_edit.haml_spec.rb +7 -7
  149. data/spec/views/contacts/_new.haml_spec.rb +1 -1
  150. data/spec/views/contacts/create.js.haml_spec.rb +4 -4
  151. data/spec/views/contacts/destroy.js.haml_spec.rb +1 -1
  152. data/spec/views/contacts/edit.js.haml_spec.rb +3 -3
  153. data/spec/views/contacts/index.haml_spec.rb +1 -1
  154. data/spec/views/contacts/index.js.html_spec.rb +1 -1
  155. data/spec/views/contacts/new.js.haml_spec.rb +1 -1
  156. data/spec/views/contacts/show.haml_spec.rb +3 -3
  157. data/spec/views/contacts/update.js.haml_spec.rb +2 -2
  158. data/spec/views/home/index.haml_spec.rb +1 -1
  159. data/spec/views/home/index.js.haml_spec.rb +1 -1
  160. data/spec/views/home/options.js.haml_spec.rb +2 -2
  161. data/spec/views/leads/_convert.haml_spec.rb +3 -3
  162. data/spec/views/leads/_edit.haml_spec.rb +2 -2
  163. data/spec/views/leads/_new.haml_spec.rb +2 -2
  164. data/spec/views/leads/_sidebar_show.haml_spec.rb +5 -5
  165. data/spec/views/leads/convert.js.haml_spec.rb +4 -4
  166. data/spec/views/leads/create.js.haml_spec.rb +5 -5
  167. data/spec/views/leads/destroy.js.haml_spec.rb +2 -2
  168. data/spec/views/leads/edit.js.haml_spec.rb +4 -4
  169. data/spec/views/leads/index.haml_spec.rb +1 -1
  170. data/spec/views/leads/index.js.haml_spec.rb +1 -1
  171. data/spec/views/leads/new.js.haml_spec.rb +1 -1
  172. data/spec/views/leads/promote.js.haml_spec.rb +7 -7
  173. data/spec/views/leads/reject.js.haml_spec.rb +2 -2
  174. data/spec/views/leads/show.haml_spec.rb +2 -2
  175. data/spec/views/leads/update.js.haml_spec.rb +4 -4
  176. data/spec/views/opportunities/_edit.haml_spec.rb +7 -7
  177. data/spec/views/opportunities/_new.haml_spec.rb +2 -2
  178. data/spec/views/opportunities/create.js.haml_spec.rb +6 -6
  179. data/spec/views/opportunities/destroy.js.haml_spec.rb +3 -3
  180. data/spec/views/opportunities/edit.js.haml_spec.rb +3 -3
  181. data/spec/views/opportunities/index.haml_spec.rb +1 -1
  182. data/spec/views/opportunities/index.js.haml_spec.rb +1 -1
  183. data/spec/views/opportunities/new.js.haml_spec.rb +1 -1
  184. data/spec/views/opportunities/show.haml_spec.rb +3 -3
  185. data/spec/views/opportunities/update.js.haml_spec.rb +4 -4
  186. data/spec/views/tasks/_edit.haml_spec.rb +1 -1
  187. data/spec/views/tasks/complete.js.haml_spec.rb +4 -4
  188. data/spec/views/tasks/create.js.haml_spec.rb +6 -6
  189. data/spec/views/tasks/destroy.js.haml_spec.rb +2 -2
  190. data/spec/views/tasks/index.haml_spec.rb +4 -4
  191. data/spec/views/tasks/new.js.haml_spec.rb +1 -1
  192. data/spec/views/tasks/uncomplete.js.haml_spec.rb +2 -2
  193. data/spec/views/tasks/update.js.haml_spec.rb +18 -18
  194. data/spec/views/users/upload_avatar.js.haml_spec.rb +2 -2
  195. 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 = [FactoryGirl.create(:lead, user: current_user)]
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 = [FactoryGirl.create(:lead, user: current_user)]
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
- FactoryGirl.create(:lead, status: "new", user: current_user),
40
- FactoryGirl.create(:lead, status: "contacted", user: current_user)
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
- FactoryGirl.create(:lead, status: "rejected", user: current_user)
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 = FactoryGirl.create(:lead, user: current_user, first_name: "Billy", last_name: "Bones")
54
- @captain_flint = FactoryGirl.create(:lead, user: current_user, first_name: "Captain", last_name: "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 = [FactoryGirl.create(:lead, user: current_user)]
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 = [FactoryGirl.create(:lead, user: current_user)]
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 = [FactoryGirl.create(:lead, user: current_user)]
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 = FactoryGirl.create(:lead, id: 42, user: current_user)
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 = FactoryGirl.create(:lead, id: 42, user: current_user)
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 = FactoryGirl.create(:lead, id: 42, user: current_user)
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 = FactoryGirl.create(:lead, user: current_user)
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 = FactoryGirl.create(:lead, user: FactoryGirl.create(:user), access: "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 = FactoryGirl.create(:lead, user: current_user)
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 = FactoryGirl.create(:lead, user: current_user)
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 = FactoryGirl.build(:lead, user: current_user, campaign: nil)
209
+ @lead = build(:lead, user: current_user, campaign: nil)
210
210
  allow(Lead).to receive(:new).and_return(@lead)
211
- @campaigns = [FactoryGirl.create(:campaign, user: current_user)]
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 = FactoryGirl.create(:campaign, id: 123)
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 = FactoryGirl.create(: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 = FactoryGirl.create(:campaign, access: "Private")
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 = FactoryGirl.create(:lead, id: 42, user: current_user, campaign: nil)
251
- @campaigns = [FactoryGirl.create(:campaign, user: current_user)]
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 = FactoryGirl.create(:lead, id: 42)
261
- @previous = FactoryGirl.create(:lead, id: 321)
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 = FactoryGirl.create(:lead, user: current_user)
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 = FactoryGirl.create(:lead, user: FactoryGirl.create(:user), access: "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 = FactoryGirl.create(:lead, user: current_user)
289
- @previous = FactoryGirl.create(:lead, user: FactoryGirl.create(:user))
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 = FactoryGirl.build(:lead, user: current_user, campaign: nil)
318
+ @lead = build(:lead, user: current_user, campaign: nil)
319
319
  allow(Lead).to receive(:new).and_return(@lead)
320
- @campaigns = [FactoryGirl.create(:campaign, user: current_user)]
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 = FactoryGirl.create(:user, id: 7)
331
- she = FactoryGirl.create(:user, id: 8)
332
- @campaign = FactoryGirl.build(:campaign, access: "Shared")
333
- @campaign.permissions << FactoryGirl.build(:permission, user: he, asset: @campaign)
334
- @campaign.permissions << FactoryGirl.build(:permission, user: she, asset: @campaign)
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 = FactoryGirl.build(:lead, campaign: @campaign, user: current_user, access: "Shared")
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 = FactoryGirl.build(:lead, user: current_user, campaign: nil)
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 = FactoryGirl.build(:lead, user: current_user, campaign: nil)
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 = FactoryGirl.create(:campaign)
368
- @lead = FactoryGirl.build(:lead, user: current_user, campaign: @campaign)
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 = FactoryGirl.create(: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 = FactoryGirl.build(:lead, user: current_user, first_name: nil, campaign: nil)
385
+ @lead = build(:lead, user: current_user, first_name: nil, campaign: nil)
386
386
  allow(Lead).to receive(:new).and_return(@lead)
387
- @campaigns = [FactoryGirl.create(:campaign, user: current_user)]
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 = FactoryGirl.create(:lead, first_name: "Billy", user: current_user)
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 = FactoryGirl.create(:lead, status: "new", user: current_user)
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 = FactoryGirl.create(:lead, source: "campaign", user: current_user)
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: FactoryGirl.create(:campaign), new: FactoryGirl.create(:campaign) }
429
- @lead = FactoryGirl.create(:lead, campaign: @campaigns[:old])
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 = FactoryGirl.create(:campaign)
437
- @lead = FactoryGirl.create(:lead, campaign: @campaign)
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 = FactoryGirl.create(:campaign)
447
- @lead = FactoryGirl.create(:lead, campaign: nil)
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: FactoryGirl.create(:campaign), new: FactoryGirl.create(:campaign) }
457
- @lead = FactoryGirl.create(:lead, campaign: @campaigns[:old])
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 = FactoryGirl.create(:lead, user: current_user)
468
- he = FactoryGirl.create(:user, id: 7)
469
- she = FactoryGirl.create(:user, id: 8)
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 = FactoryGirl.create(: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 = FactoryGirl.create(:campaign)
486
- @lead = FactoryGirl.create(:lead, campaign: @campaign)
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 = FactoryGirl.create(:lead, user: current_user)
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 = FactoryGirl.create(:lead, user: FactoryGirl.create(:user), access: "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 = FactoryGirl.create(:lead, id: 42, user: current_user, campaign: nil)
516
- @campaigns = [FactoryGirl.create(:campaign, user: current_user)]
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 = FactoryGirl.create(:lead, user: current_user)
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 = FactoryGirl.create(:lead, user: current_user)
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 = FactoryGirl.create(:campaign)
578
- @lead = FactoryGirl.create(:lead, user: current_user, campaign: @campaign)
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 = FactoryGirl.create(:lead, user: current_user)
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 = FactoryGirl.create(:lead, user: FactoryGirl.create(:user), access: "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 = FactoryGirl.create(:lead, user: current_user)
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 = FactoryGirl.create(:lead, user: FactoryGirl.create(:user), access: "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 = FactoryGirl.create(:campaign, user: current_user)
648
- @lead = FactoryGirl.create(:lead, user: current_user, campaign: @campaign, source: "cold_call")
649
- @accounts = [FactoryGirl.create(:account, user: current_user)]
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 = FactoryGirl.create(:lead, user: current_user)
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 = FactoryGirl.create(:lead, user: FactoryGirl.create(:user), access: "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 = FactoryGirl.create(:lead, user: current_user)
684
- @previous = FactoryGirl.create(:lead, user: FactoryGirl.create(:user))
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 = FactoryGirl.create(:lead, id: 42, user: current_user, campaign: nil)
713
- @account = FactoryGirl.create(:account, id: 123, user: current_user)
714
- @opportunity = FactoryGirl.build(:opportunity, user: current_user, campaign: @lead.campaign,
715
- account: @account)
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 = FactoryGirl.build(:contact, user: current_user, lead: @lead)
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 = FactoryGirl.create(:user, id: 7)
733
- she = FactoryGirl.create(:user, id: 8)
734
- @lead = FactoryGirl.build(:lead, access: "Shared")
735
- @lead.permissions << FactoryGirl.build(:permission, user: he, asset: @lead)
736
- @lead.permissions << FactoryGirl.build(:permission, user: she, asset: @lead)
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 = FactoryGirl.build(:account, user: current_user, access: "Shared")
739
- @account.permissions << FactoryGirl.create(:permission, user: he, asset: @account)
740
- @account.permissions << FactoryGirl.create(:permission, user: she, asset: @account)
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 = FactoryGirl.build(:opportunity, user: current_user, access: "Shared")
743
- @opportunity.permissions << FactoryGirl.create(:permission, user: he, asset: @opportunity)
744
- @opportunity.permissions << FactoryGirl.create(:permission, user: she, asset: @opportunity)
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 = FactoryGirl.create(:campaign)
760
- @lead = FactoryGirl.create(:lead, user: current_user, campaign: @campaign)
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 = FactoryGirl.create(:lead, user: current_user, source: "cold_call")
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 = FactoryGirl.create(: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 = FactoryGirl.create(:campaign)
784
- @lead = FactoryGirl.create(:lead, campaign: @campaign)
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 = FactoryGirl.create(:lead, id: 42, user: current_user, status: "new")
793
- @account = FactoryGirl.create(:account, id: 123, user: current_user)
794
- @contact = FactoryGirl.build(:contact, first_name: nil) # make it fail
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 = FactoryGirl.create(:lead, user: current_user)
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 = FactoryGirl.create(:lead, user: FactoryGirl.create(:user), access: "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 = FactoryGirl.create(:lead, user: current_user, status: "new")
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 = FactoryGirl.create(:campaign)
848
- @lead = FactoryGirl.create(:lead, campaign: @campaign)
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 = FactoryGirl.create(:lead, user: current_user)
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 = FactoryGirl.create(:lead, user: FactoryGirl.create(:user), access: "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 = FactoryGirl.create(:lead, user: current_user)
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 = FactoryGirl.create(:lead, user: FactoryGirl.create(:user), access: "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 = FactoryGirl.create(:lead)
913
- @attachment = FactoryGirl.create(:task, asset: nil)
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 = FactoryGirl.create(:lead)
926
- @attachment = FactoryGirl.create(:task, asset: nil)
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 = FactoryGirl.create(:task, assigned_to: current_user)
938
- @model = FactoryGirl.create(:lead)
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 = [FactoryGirl.create(:lead, first_name: "Hello", last_name: "World", user: current_user)]
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
- FactoryGirl.create(:lead, first_name: "Alice", user: current_user),
980
- FactoryGirl.create(:lead, first_name: "Bobby", user: current_user)
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 = [FactoryGirl.create(:lead, user: current_user, status: "new")]
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