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
@@ -26,7 +26,7 @@ describe OpportunitiesController do
26
26
  end
27
27
 
28
28
  it "should expose all opportunities as @opportunities and render [index] template" do
29
- @opportunities = [FactoryGirl.create(:opportunity, user: current_user)]
29
+ @opportunities = [create(:opportunity, user: current_user)]
30
30
 
31
31
  get :index
32
32
  expect(assigns[:opportunities]).to eq(@opportunities)
@@ -42,11 +42,11 @@ describe OpportunitiesController do
42
42
  it "should filter out opportunities by stage" do
43
43
  controller.session[:opportunities_filter] = "prospecting,negotiation"
44
44
  @opportunities = [
45
- FactoryGirl.create(:opportunity, user: current_user, stage: "negotiation"),
46
- FactoryGirl.create(:opportunity, user: current_user, stage: "prospecting")
45
+ create(:opportunity, user: current_user, stage: "negotiation"),
46
+ create(:opportunity, user: current_user, stage: "prospecting")
47
47
  ]
48
48
  # This one should be filtered out.
49
- FactoryGirl.create(:opportunity, user: current_user, stage: "analysis")
49
+ create(:opportunity, user: current_user, stage: "analysis")
50
50
 
51
51
  get :index
52
52
  # Note: can't compare opportunities directly because of BigDecimal objects.
@@ -55,8 +55,8 @@ describe OpportunitiesController do
55
55
  end
56
56
 
57
57
  it "should perform lookup using query string" do
58
- @first = FactoryGirl.create(:opportunity, user: current_user, name: "The first one")
59
- @second = FactoryGirl.create(:opportunity, user: current_user, name: "The second one")
58
+ @first = create(:opportunity, user: current_user, name: "The first one")
59
+ @second = create(:opportunity, user: current_user, name: "The second one")
60
60
 
61
61
  get :index, params: { query: "second" }
62
62
  expect(assigns[:opportunities]).to eq([@second])
@@ -66,7 +66,7 @@ describe OpportunitiesController do
66
66
 
67
67
  describe "AJAX pagination" do
68
68
  it "should pick up page number from params" do
69
- @opportunities = [FactoryGirl.create(:opportunity, user: current_user)]
69
+ @opportunities = [create(:opportunity, user: current_user)]
70
70
  get :index, params: { page: 42 }, xhr: true
71
71
 
72
72
  expect(assigns[:current_page].to_i).to eq(42)
@@ -77,7 +77,7 @@ describe OpportunitiesController do
77
77
 
78
78
  it "should pick up saved page number from session" do
79
79
  session[:opportunities_current_page] = 42
80
- @opportunities = [FactoryGirl.create(:opportunity, user: current_user)]
80
+ @opportunities = [create(:opportunity, user: current_user)]
81
81
  get :index, xhr: true
82
82
 
83
83
  expect(assigns[:current_page]).to eq(42)
@@ -88,7 +88,7 @@ describe OpportunitiesController do
88
88
  it "should reset current_page when query is altered" do
89
89
  session[:opportunities_current_page] = 42
90
90
  session[:opportunities_current_query] = "bill"
91
- @opportunities = [FactoryGirl.create(:opportunity, user: current_user)]
91
+ @opportunities = [create(:opportunity, user: current_user)]
92
92
  get :index, xhr: true
93
93
 
94
94
  expect(assigns[:current_page]).to eq(1)
@@ -137,7 +137,7 @@ describe OpportunitiesController do
137
137
  describe "responding to GET show" do
138
138
  describe "with mime type of HTML" do
139
139
  before do
140
- @opportunity = FactoryGirl.create(:opportunity, id: 42)
140
+ @opportunity = create(:opportunity, id: 42)
141
141
  @stage = Setting.unroll(:opportunity_stage)
142
142
  @comment = Comment.new
143
143
  end
@@ -158,7 +158,7 @@ describe OpportunitiesController do
158
158
 
159
159
  describe "with mime type of JSON" do
160
160
  it "should render the requested opportunity as JSON" do
161
- @opportunity = FactoryGirl.create(:opportunity, id: 42)
161
+ @opportunity = create(:opportunity, id: 42)
162
162
  expect(Opportunity).to receive(:find).and_return(@opportunity)
163
163
  expect(@opportunity).to receive(:to_json).and_return("generated JSON")
164
164
 
@@ -170,7 +170,7 @@ describe OpportunitiesController do
170
170
 
171
171
  describe "with mime type of XML" do
172
172
  it "should render the requested opportunity as xml" do
173
- @opportunity = FactoryGirl.create(:opportunity, id: 42)
173
+ @opportunity = create(:opportunity, id: 42)
174
174
  expect(Opportunity).to receive(:find).and_return(@opportunity)
175
175
  expect(@opportunity).to receive(:to_xml).and_return("generated XML")
176
176
 
@@ -182,7 +182,7 @@ describe OpportunitiesController do
182
182
 
183
183
  describe "opportunity got deleted or otherwise unavailable" do
184
184
  it "should redirect to opportunity index if the opportunity got deleted" do
185
- @opportunity = FactoryGirl.create(:opportunity, user: current_user)
185
+ @opportunity = create(:opportunity, user: current_user)
186
186
  @opportunity.destroy
187
187
 
188
188
  get :show, params: { id: @opportunity.id }
@@ -191,7 +191,7 @@ describe OpportunitiesController do
191
191
  end
192
192
 
193
193
  it "should redirect to opportunity index if the opportunity is protected" do
194
- @private = FactoryGirl.create(:opportunity, user: FactoryGirl.create(:user), access: "Private")
194
+ @private = create(:opportunity, user: create(:user), access: "Private")
195
195
 
196
196
  get :show, params: { id: @private.id }
197
197
  expect(flash[:warning]).not_to eq(nil)
@@ -199,7 +199,7 @@ describe OpportunitiesController do
199
199
  end
200
200
 
201
201
  it "should return 404 (Not Found) JSON error" do
202
- @opportunity = FactoryGirl.create(:opportunity, user: current_user)
202
+ @opportunity = create(:opportunity, user: current_user)
203
203
  @opportunity.destroy
204
204
  request.env["HTTP_ACCEPT"] = "application/json"
205
205
 
@@ -208,7 +208,7 @@ describe OpportunitiesController do
208
208
  end
209
209
 
210
210
  it "should return 404 (Not Found) XML error" do
211
- @opportunity = FactoryGirl.create(:opportunity, user: current_user)
211
+ @opportunity = create(:opportunity, user: current_user)
212
212
  @opportunity.destroy
213
213
  request.env["HTTP_ACCEPT"] = "application/xml"
214
214
 
@@ -225,7 +225,7 @@ describe OpportunitiesController do
225
225
  it "should expose a new opportunity as @opportunity and render [new] template" do
226
226
  @opportunity = Opportunity.new(user: current_user, access: Setting.default_access, stage: "prospecting")
227
227
  @account = Account.new(user: current_user, access: Setting.default_access)
228
- @accounts = [FactoryGirl.create(:account, user: current_user)]
228
+ @accounts = [create(:account, user: current_user)]
229
229
 
230
230
  get :new, xhr: true
231
231
  expect(assigns[:opportunity].attributes).to eq(@opportunity.attributes)
@@ -235,7 +235,7 @@ describe OpportunitiesController do
235
235
  end
236
236
 
237
237
  it "should created an instance of related object when necessary" do
238
- @contact = FactoryGirl.create(:contact, id: 42)
238
+ @contact = create(:contact, id: 42)
239
239
 
240
240
  get :new, params: { related: "contact_42" }, xhr: true
241
241
  expect(assigns[:contact]).to eq(@contact)
@@ -243,7 +243,7 @@ describe OpportunitiesController do
243
243
 
244
244
  describe "(when creating related opportunity)" do
245
245
  it "should redirect to parent asset's index page with the message if parent asset got deleted" do
246
- @account = FactoryGirl.create(:account)
246
+ @account = create(:account)
247
247
  @account.destroy
248
248
 
249
249
  get :new, params: { related: "account_#{@account.id}" }, xhr: true
@@ -252,7 +252,7 @@ describe OpportunitiesController do
252
252
  end
253
253
 
254
254
  it "should redirect to parent asset's index page with the message if parent asset got protected" do
255
- @account = FactoryGirl.create(:account, access: "Private")
255
+ @account = create(:account, access: "Private")
256
256
 
257
257
  get :new, params: { related: "account_#{@account.id}" }, xhr: true
258
258
  expect(flash[:warning]).not_to eq(nil)
@@ -267,9 +267,9 @@ describe OpportunitiesController do
267
267
  it "should expose the requested opportunity as @opportunity and render [edit] template" do
268
268
  # Note: campaign => nil makes sure campaign factory is not invoked which has a side
269
269
  # effect of creating an extra (campaign) user.
270
- @account = FactoryGirl.create(:account, user: current_user)
271
- @opportunity = FactoryGirl.create(:opportunity, id: 42, user: current_user, campaign: nil,
272
- account: @account)
270
+ @account = create(:account, user: current_user)
271
+ @opportunity = create(:opportunity, id: 42, user: current_user, campaign: nil,
272
+ account: @account)
273
273
  @stage = Setting.unroll(:opportunity_stage)
274
274
  @accounts = [@account]
275
275
 
@@ -284,8 +284,8 @@ describe OpportunitiesController do
284
284
  end
285
285
 
286
286
  it "should expose previous opportunity as @previous when necessary" do
287
- @opportunity = FactoryGirl.create(:opportunity, id: 42)
288
- @previous = FactoryGirl.create(:opportunity, id: 41)
287
+ @opportunity = create(:opportunity, id: 42)
288
+ @previous = create(:opportunity, id: 41)
289
289
 
290
290
  get :edit, params: { id: 42, previous: 41 }, xhr: true
291
291
  expect(assigns[:previous]).to eq(@previous)
@@ -293,7 +293,7 @@ describe OpportunitiesController do
293
293
 
294
294
  describe "opportunity got deleted or is otherwise unavailable" do
295
295
  it "should reload current page with the flash message if the opportunity got deleted" do
296
- @opportunity = FactoryGirl.create(:opportunity, user: current_user)
296
+ @opportunity = create(:opportunity, user: current_user)
297
297
  @opportunity.destroy
298
298
 
299
299
  get :edit, params: { id: @opportunity.id }, xhr: true
@@ -302,7 +302,7 @@ describe OpportunitiesController do
302
302
  end
303
303
 
304
304
  it "should reload current page with the flash message if the opportunity is protected" do
305
- @private = FactoryGirl.create(:opportunity, user: FactoryGirl.create(:user), access: "Private")
305
+ @private = create(:opportunity, user: create(:user), access: "Private")
306
306
 
307
307
  get :edit, params: { id: @private.id }, xhr: true
308
308
  expect(flash[:warning]).not_to eq(nil)
@@ -312,8 +312,8 @@ describe OpportunitiesController do
312
312
 
313
313
  describe "(previous opportunity got deleted or is otherwise unavailable)" do
314
314
  before do
315
- @opportunity = FactoryGirl.create(:opportunity, user: current_user)
316
- @previous = FactoryGirl.create(:opportunity, user: FactoryGirl.create(:user))
315
+ @opportunity = create(:opportunity, user: current_user)
316
+ @previous = create(:opportunity, user: create(:user))
317
317
  end
318
318
 
319
319
  it "should notify the view if previous opportunity got deleted" do
@@ -342,7 +342,7 @@ describe OpportunitiesController do
342
342
  describe "responding to POST create" do
343
343
  describe "with valid params" do
344
344
  before do
345
- @opportunity = FactoryGirl.build(:opportunity, user: current_user)
345
+ @opportunity = build(:opportunity, user: current_user)
346
346
  allow(Opportunity).to receive(:new).and_return(@opportunity)
347
347
  @stage = Setting.unroll(:opportunity_stage)
348
348
  end
@@ -362,7 +362,7 @@ describe OpportunitiesController do
362
362
  end
363
363
 
364
364
  it "should find related account if called from account landing page" do
365
- @account = FactoryGirl.create(:account, user: current_user)
365
+ @account = create(:account, user: current_user)
366
366
  request.env["HTTP_REFERER"] = "http://localhost/accounts/#{@account.id}"
367
367
 
368
368
  post :create, params: { opportunity: { name: "Hello" }, account: { id: @account.id } }, xhr: true
@@ -370,7 +370,7 @@ describe OpportunitiesController do
370
370
  end
371
371
 
372
372
  it "should find related campaign if called from campaign landing page" do
373
- @campaign = FactoryGirl.create(:campaign, user: current_user)
373
+ @campaign = create(:campaign, user: current_user)
374
374
  request.env["HTTP_REFERER"] = "http://localhost/campaigns/#{@campaign.id}"
375
375
 
376
376
  post :create, params: { opportunity: { name: "Hello" }, campaign: @campaign.id, account: { name: "Hello again" } }, xhr: true
@@ -384,7 +384,7 @@ describe OpportunitiesController do
384
384
  end
385
385
 
386
386
  it "should associate opportunity with the campaign when called from campaign landing page" do
387
- @campaign = FactoryGirl.create(:campaign)
387
+ @campaign = create(:campaign)
388
388
 
389
389
  request.env["HTTP_REFERER"] = "http://localhost/campaigns/#{@campaign.id}"
390
390
  post :create, params: { opportunity: { name: "Hello" }, campaign: @campaign.id, account: { name: "Test Account" } }, xhr: true
@@ -394,7 +394,7 @@ describe OpportunitiesController do
394
394
  end
395
395
 
396
396
  it "should associate opportunity with the contact when called from contact landing page" do
397
- @contact = FactoryGirl.create(:contact, id: 42)
397
+ @contact = create(:contact, id: 42)
398
398
 
399
399
  request.env["HTTP_REFERER"] = "http://localhost/contacts/42"
400
400
  post :create, params: { opportunity: { name: "Hello" }, contact: 42, account: { name: "Hello again" } }, xhr: true
@@ -410,7 +410,7 @@ describe OpportunitiesController do
410
410
  end
411
411
 
412
412
  it "should associate opportunity with the existing account" do
413
- @account = FactoryGirl.create(:account, id: 42)
413
+ @account = create(:account, id: 42)
414
414
 
415
415
  post :create, params: { opportunity: { name: "Hello world" }, account: { id: 42 } }, xhr: true
416
416
  expect(assigns(:opportunity)).to eq(@opportunity)
@@ -419,8 +419,8 @@ describe OpportunitiesController do
419
419
  end
420
420
 
421
421
  it "should update related campaign revenue if won" do
422
- @campaign = FactoryGirl.create(:campaign, revenue: 0)
423
- @opportunity = FactoryGirl.build(:opportunity, user: current_user, stage: "won", amount: 1100, discount: 100)
422
+ @campaign = create(:campaign, revenue: 0)
423
+ @opportunity = build(:opportunity, user: current_user, stage: "won", amount: 1100, discount: 100)
424
424
  allow(Opportunity).to receive(:new).and_return(@opportunity)
425
425
 
426
426
  post :create, params: { opportunity: { name: "Hello world" }, campaign: @campaign.id, account: { name: "Test Account" } }, xhr: true
@@ -430,7 +430,7 @@ describe OpportunitiesController do
430
430
  end
431
431
 
432
432
  it "should add a new comment to the newly created opportunity when specified" do
433
- @opportunity = FactoryGirl.build(:opportunity, user: current_user)
433
+ @opportunity = build(:opportunity, user: current_user)
434
434
  allow(Opportunity).to receive(:new).and_return(@opportunity)
435
435
 
436
436
  post :create, params: { opportunity: { name: "Opportunity Knocks" }, account: { name: "My Account" }, comment_body: "Awesome comment is awesome" }, xhr: true
@@ -441,11 +441,11 @@ describe OpportunitiesController do
441
441
  describe "with invalid params" do
442
442
  it "should expose a newly created but unsaved opportunity as @opportunity with blank @account and render [create] template" do
443
443
  @account = Account.new(user: current_user)
444
- @opportunity = FactoryGirl.build(:opportunity, name: nil, campaign: nil, user: current_user,
445
- account: @account)
444
+ @opportunity = build(:opportunity, name: nil, campaign: nil, user: current_user,
445
+ account: @account)
446
446
  allow(Opportunity).to receive(:new).and_return(@opportunity)
447
447
  @stage = Setting.unroll(:opportunity_stage)
448
- @accounts = [FactoryGirl.create(:account, user: current_user)]
448
+ @accounts = [create(:account, user: current_user)]
449
449
 
450
450
  # Expect to redraw [create] form with blank account.
451
451
  post :create, params: { opportunity: {}, account: { user_id: current_user.id } }, xhr: true
@@ -456,9 +456,9 @@ describe OpportunitiesController do
456
456
  end
457
457
 
458
458
  it "should expose a newly created but unsaved opportunity as @opportunity with existing @account and render [create] template" do
459
- @account = FactoryGirl.create(:account, id: 42, user: current_user)
460
- @opportunity = FactoryGirl.build(:opportunity, name: nil, campaign: nil, user: current_user,
461
- account: @account)
459
+ @account = create(:account, id: 42, user: current_user)
460
+ @opportunity = build(:opportunity, name: nil, campaign: nil, user: current_user,
461
+ account: @account)
462
462
  allow(Opportunity).to receive(:new).and_return(@opportunity)
463
463
  @stage = Setting.unroll(:opportunity_stage)
464
464
 
@@ -471,7 +471,7 @@ describe OpportunitiesController do
471
471
  end
472
472
 
473
473
  it "should preserve the campaign when called from campaign landing page" do
474
- @campaign = FactoryGirl.create(:campaign, id: 42)
474
+ @campaign = create(:campaign, id: 42)
475
475
 
476
476
  request.env["HTTP_REFERER"] = "http://localhost/campaigns/42"
477
477
  post :create, params: { opportunity: { name: nil }, campaign: 42, account: { name: "Test Account" } }, xhr: true
@@ -480,7 +480,7 @@ describe OpportunitiesController do
480
480
  end
481
481
 
482
482
  it "should preserve the contact when called from contact landing page" do
483
- @contact = FactoryGirl.create(:contact, id: 42)
483
+ @contact = create(:contact, id: 42)
484
484
 
485
485
  request.env["HTTP_REFERER"] = "http://localhost/contacts/42"
486
486
  post :create, params: { opportunity: { name: nil }, contact: 42, account: { name: "Test Account" } }, xhr: true
@@ -496,7 +496,7 @@ describe OpportunitiesController do
496
496
  describe "responding to PUT update" do
497
497
  describe "with valid params" do
498
498
  it "should update the requested opportunity, expose it as @opportunity, and render [update] template" do
499
- @opportunity = FactoryGirl.create(:opportunity, id: 42)
499
+ @opportunity = create(:opportunity, id: 42)
500
500
  @stage = Setting.unroll(:opportunity_stage)
501
501
 
502
502
  put :update, params: { id: 42, opportunity: { name: "Hello world" }, account: { name: "Test Account" } }, xhr: true
@@ -508,7 +508,7 @@ describe OpportunitiesController do
508
508
  end
509
509
 
510
510
  it "should get sidebar data if called from opportunities index" do
511
- @opportunity = FactoryGirl.create(:opportunity, id: 42)
511
+ @opportunity = create(:opportunity, id: 42)
512
512
 
513
513
  request.env["HTTP_REFERER"] = "http://localhost/opportunities"
514
514
  put :update, params: { id: 42, opportunity: { name: "Hello world" }, account: { name: "Test Account" } }, xhr: true
@@ -516,8 +516,8 @@ describe OpportunitiesController do
516
516
  end
517
517
 
518
518
  it "should find related account if called from account landing page" do
519
- @account = FactoryGirl.create(:account, user: current_user)
520
- @opportunity = FactoryGirl.create(:opportunity, id: 42, account: @account)
519
+ @account = create(:account, user: current_user)
520
+ @opportunity = create(:opportunity, id: 42, account: @account)
521
521
  request.env["HTTP_REFERER"] = "http://localhost/accounts/#{@account.id}"
522
522
 
523
523
  put :update, params: { id: 42, opportunity: { name: "Hello world" } }, xhr: true
@@ -525,8 +525,8 @@ describe OpportunitiesController do
525
525
  end
526
526
 
527
527
  it "should remove related account if blank :account param is given" do
528
- @account = FactoryGirl.create(:account, user: current_user)
529
- @opportunity = FactoryGirl.create(:opportunity, id: 42, account: @account)
528
+ @account = create(:account, user: current_user)
529
+ @opportunity = create(:opportunity, id: 42, account: @account)
530
530
  request.env["HTTP_REFERER"] = "http://localhost/accounts/#{@account.id}"
531
531
 
532
532
  put :update, params: { id: 42, opportunity: { name: "Hello world" }, account: { id: "" } }, xhr: true
@@ -534,8 +534,8 @@ describe OpportunitiesController do
534
534
  end
535
535
 
536
536
  it "should find related campaign if called from campaign landing page" do
537
- @campaign = FactoryGirl.create(:campaign, user: current_user)
538
- @opportunity = FactoryGirl.create(:opportunity, id: 42, user: current_user)
537
+ @campaign = create(:campaign, user: current_user)
538
+ @opportunity = create(:opportunity, id: 42, user: current_user)
539
539
  @campaign.opportunities << @opportunity
540
540
  request.env["HTTP_REFERER"] = "http://localhost/campaigns/#{@campaign.id}"
541
541
 
@@ -544,7 +544,7 @@ describe OpportunitiesController do
544
544
  end
545
545
 
546
546
  it "should be able to create an account and associate it with updated opportunity" do
547
- @opportunity = FactoryGirl.create(:opportunity, id: 42)
547
+ @opportunity = create(:opportunity, id: 42)
548
548
 
549
549
  put :update, params: { id: 42, opportunity: { name: "Hello" }, account: { name: "new account" } }, xhr: true
550
550
  expect(assigns[:opportunity]).to eq(@opportunity)
@@ -553,9 +553,9 @@ describe OpportunitiesController do
553
553
  end
554
554
 
555
555
  it "should be able to create an account and associate it with updated opportunity" do
556
- @old_account = FactoryGirl.create(:account, id: 111)
557
- @new_account = FactoryGirl.create(:account, id: 999)
558
- @opportunity = FactoryGirl.create(:opportunity, id: 42, account: @old_account)
556
+ @old_account = create(:account, id: 111)
557
+ @new_account = create(:account, id: 999)
558
+ @opportunity = create(:opportunity, id: 42, account: @old_account)
559
559
 
560
560
  put :update, params: { id: 42, opportunity: { name: "Hello" }, account: { id: 999 } }, xhr: true
561
561
  expect(assigns[:opportunity]).to eq(@opportunity)
@@ -563,7 +563,7 @@ describe OpportunitiesController do
563
563
  end
564
564
 
565
565
  it "should update opportunity permissions when sharing with specific users" do
566
- @opportunity = FactoryGirl.create(:opportunity, id: 42, access: "Public")
566
+ @opportunity = create(:opportunity, id: 42, access: "Public")
567
567
 
568
568
  put :update, params: { id: 42, opportunity: { name: "Hello", access: "Shared", user_ids: [7, 8] }, account: { name: "Test Account" } }, xhr: true
569
569
  expect(assigns[:opportunity].access).to eq("Shared")
@@ -571,8 +571,8 @@ describe OpportunitiesController do
571
571
  end
572
572
 
573
573
  it "should reload opportunity campaign if called from campaign landing page" do
574
- @campaign = FactoryGirl.create(:campaign)
575
- @opportunity = FactoryGirl.create(:opportunity, campaign: @campaign)
574
+ @campaign = create(:campaign)
575
+ @opportunity = create(:opportunity, campaign: @campaign)
576
576
 
577
577
  request.env["HTTP_REFERER"] = "http://localhost/campaigns/#{@campaign.id}"
578
578
  put :update, params: { id: @opportunity.id, opportunity: { name: "Hello" }, account: { name: "Test Account" } }, xhr: true
@@ -581,16 +581,16 @@ describe OpportunitiesController do
581
581
 
582
582
  describe "updating campaign revenue (same campaign)" do
583
583
  it "should add to actual revenue when opportunity is closed/won" do
584
- @campaign = FactoryGirl.create(:campaign, revenue: 1000)
585
- @opportunity = FactoryGirl.create(:opportunity, campaign: @campaign, stage: 'prospecting', amount: 1100, discount: 100)
584
+ @campaign = create(:campaign, revenue: 1000)
585
+ @opportunity = create(:opportunity, campaign: @campaign, stage: 'prospecting', amount: 1100, discount: 100)
586
586
 
587
587
  put :update, params: { id: @opportunity, opportunity: { stage: "won" }, account: { name: "Test Account" } }, xhr: true
588
588
  expect(@campaign.reload.revenue.to_i).to eq(2000) # 1000 -> 2000
589
589
  end
590
590
 
591
591
  it "should substract from actual revenue when opportunity is no longer closed/won" do
592
- @campaign = FactoryGirl.create(:campaign, revenue: 1000)
593
- @opportunity = FactoryGirl.create(:opportunity, campaign: @campaign, stage: "won", amount: 1100, discount: 100)
592
+ @campaign = create(:campaign, revenue: 1000)
593
+ @opportunity = create(:opportunity, campaign: @campaign, stage: "won", amount: 1100, discount: 100)
594
594
  # @campaign.revenue is now $2000 since we created winning opportunity.
595
595
 
596
596
  put :update, params: { id: @opportunity, opportunity: { stage: 'prospecting' }, account: { name: "Test Account" } }, xhr: true
@@ -598,8 +598,8 @@ describe OpportunitiesController do
598
598
  end
599
599
 
600
600
  it "should not update actual revenue when opportunity is not closed/won" do
601
- @campaign = FactoryGirl.create(:campaign, revenue: 1000)
602
- @opportunity = FactoryGirl.create(:opportunity, campaign: @campaign, stage: 'prospecting', amount: 1100, discount: 100)
601
+ @campaign = create(:campaign, revenue: 1000)
602
+ @opportunity = create(:opportunity, campaign: @campaign, stage: 'prospecting', amount: 1100, discount: 100)
603
603
 
604
604
  put :update, params: { id: @opportunity, opportunity: { stage: "lost" }, account: { name: "Test Account" } }, xhr: true
605
605
  expect(@campaign.reload.revenue.to_i).to eq(1000) # Stays the same.
@@ -608,8 +608,8 @@ describe OpportunitiesController do
608
608
 
609
609
  describe "updating campaign revenue (diferent campaigns)" do
610
610
  it "should update newly assigned campaign when opportunity is closed/won" do
611
- @campaigns = { old: FactoryGirl.create(:campaign, revenue: 1000), new: FactoryGirl.create(:campaign, revenue: 1000) }
612
- @opportunity = FactoryGirl.create(:opportunity, campaign: @campaigns[:old], stage: 'prospecting', amount: 1100, discount: 100)
611
+ @campaigns = { old: create(:campaign, revenue: 1000), new: create(:campaign, revenue: 1000) }
612
+ @opportunity = create(:opportunity, campaign: @campaigns[:old], stage: 'prospecting', amount: 1100, discount: 100)
613
613
 
614
614
  put :update, params: { id: @opportunity, opportunity: { stage: "won", campaign_id: @campaigns[:new].id }, account: { name: "Test Account" } }, xhr: true
615
615
 
@@ -618,8 +618,8 @@ describe OpportunitiesController do
618
618
  end
619
619
 
620
620
  it "should update old campaign when opportunity is no longer closed/won" do
621
- @campaigns = { old: FactoryGirl.create(:campaign, revenue: 1000), new: FactoryGirl.create(:campaign, revenue: 1000) }
622
- @opportunity = FactoryGirl.create(:opportunity, campaign: @campaigns[:old], stage: "won", amount: 1100, discount: 100)
621
+ @campaigns = { old: create(:campaign, revenue: 1000), new: create(:campaign, revenue: 1000) }
622
+ @opportunity = create(:opportunity, campaign: @campaigns[:old], stage: "won", amount: 1100, discount: 100)
623
623
  # @campaign.revenue is now $2000 since we created winning opportunity.
624
624
 
625
625
  put :update, params: { id: @opportunity, opportunity: { stage: 'prospecting', campaign_id: @campaigns[:new].id }, account: { name: "Test Account" } }, xhr: true
@@ -628,8 +628,8 @@ describe OpportunitiesController do
628
628
  end
629
629
 
630
630
  it "should not update campaigns when opportunity is not closed/won" do
631
- @campaigns = { old: FactoryGirl.create(:campaign, revenue: 1000), new: FactoryGirl.create(:campaign, revenue: 1000) }
632
- @opportunity = FactoryGirl.create(:opportunity, campaign: @campaigns[:old], stage: 'prospecting', amount: 1100, discount: 100)
631
+ @campaigns = { old: create(:campaign, revenue: 1000), new: create(:campaign, revenue: 1000) }
632
+ @opportunity = create(:opportunity, campaign: @campaigns[:old], stage: 'prospecting', amount: 1100, discount: 100)
633
633
 
634
634
  put :update, params: { id: @opportunity, opportunity: { stage: "lost", campaign_id: @campaigns[:new].id }, account: { name: "Test Account" } }, xhr: true
635
635
  expect(@campaigns[:old].reload.revenue.to_i).to eq(1000) # Stays the same.
@@ -639,7 +639,7 @@ describe OpportunitiesController do
639
639
 
640
640
  describe "opportunity got deleted or otherwise unavailable" do
641
641
  it "should reload current page with the flash message if the opportunity got deleted" do
642
- @opportunity = FactoryGirl.create(:opportunity, user: current_user)
642
+ @opportunity = create(:opportunity, user: current_user)
643
643
  @opportunity.destroy
644
644
 
645
645
  put :update, params: { id: @opportunity.id }, xhr: true
@@ -648,7 +648,7 @@ describe OpportunitiesController do
648
648
  end
649
649
 
650
650
  it "should reload current page with the flash message if the opportunity is protected" do
651
- @private = FactoryGirl.create(:opportunity, user: FactoryGirl.create(:user), access: "Private")
651
+ @private = create(:opportunity, user: create(:user), access: "Private")
652
652
 
653
653
  put :update, params: { id: @private.id }, xhr: true
654
654
  expect(flash[:warning]).not_to eq(nil)
@@ -659,7 +659,7 @@ describe OpportunitiesController do
659
659
 
660
660
  describe "with invalid params" do
661
661
  it "should not update the requested opportunity but still expose it as @opportunity, and render [update] template" do
662
- @opportunity = FactoryGirl.create(:opportunity, id: 42, name: "Hello people")
662
+ @opportunity = create(:opportunity, id: 42, name: "Hello people")
663
663
 
664
664
  put :update, params: { id: 42, opportunity: { name: nil }, account: { name: "Test Account" } }, xhr: true
665
665
  expect(@opportunity.reload.name).to eq("Hello people")
@@ -669,9 +669,9 @@ describe OpportunitiesController do
669
669
  end
670
670
 
671
671
  it "should expose existing account as @account if selected" do
672
- @account = FactoryGirl.create(:account, id: 99)
673
- @opportunity = FactoryGirl.create(:opportunity, id: 42)
674
- FactoryGirl.create(:account_opportunity, account: @account, opportunity: @opportunity)
672
+ @account = create(:account, id: 99)
673
+ @opportunity = create(:opportunity, id: 42)
674
+ create(:account_opportunity, account: @account, opportunity: @opportunity)
675
675
 
676
676
  put :update, params: { id: 42, opportunity: { name: nil }, account: { id: 99 } }, xhr: true
677
677
  expect(assigns(:account)).to eq(@account)
@@ -684,7 +684,7 @@ describe OpportunitiesController do
684
684
  #----------------------------------------------------------------------------
685
685
  describe "responding to DELETE destroy" do
686
686
  before do
687
- @opportunity = FactoryGirl.create(:opportunity, user: current_user)
687
+ @opportunity = create(:opportunity, user: current_user)
688
688
  end
689
689
 
690
690
  describe "AJAX request" do
@@ -733,8 +733,8 @@ describe OpportunitiesController do
733
733
  end
734
734
 
735
735
  it "should reload campaiign to be able to refresh its summary" do
736
- @account = FactoryGirl.create(:account)
737
- @opportunity = FactoryGirl.create(:opportunity, user: current_user, account: @account)
736
+ @account = create(:account)
737
+ @opportunity = create(:opportunity, user: current_user, account: @account)
738
738
  request.env["HTTP_REFERER"] = "http://localhost/accounts/#{@account.id}"
739
739
 
740
740
  delete :destroy, params: { id: @opportunity.id }, xhr: true
@@ -743,8 +743,8 @@ describe OpportunitiesController do
743
743
  end
744
744
 
745
745
  it "should reload campaiign to be able to refresh its summary" do
746
- @campaign = FactoryGirl.create(:campaign)
747
- @opportunity = FactoryGirl.create(:opportunity, user: current_user, campaign: @campaign)
746
+ @campaign = create(:campaign)
747
+ @opportunity = create(:opportunity, user: current_user, campaign: @campaign)
748
748
  request.env["HTTP_REFERER"] = "http://localhost/campaigns/#{@campaign.id}"
749
749
 
750
750
  delete :destroy, params: { id: @opportunity.id }, xhr: true
@@ -755,7 +755,7 @@ describe OpportunitiesController do
755
755
 
756
756
  describe "opportunity got deleted or otherwise unavailable" do
757
757
  it "should reload current page is the opportunity got deleted" do
758
- @opportunity = FactoryGirl.create(:opportunity, user: current_user)
758
+ @opportunity = create(:opportunity, user: current_user)
759
759
  @opportunity.destroy
760
760
 
761
761
  delete :destroy, params: { id: @opportunity.id }, xhr: true
@@ -764,7 +764,7 @@ describe OpportunitiesController do
764
764
  end
765
765
 
766
766
  it "should reload current page with the flash message if the opportunity is protected" do
767
- @private = FactoryGirl.create(:opportunity, user: FactoryGirl.create(:user), access: "Private")
767
+ @private = create(:opportunity, user: create(:user), access: "Private")
768
768
 
769
769
  delete :destroy, params: { id: @private.id }, xhr: true
770
770
  expect(flash[:warning]).not_to eq(nil)
@@ -781,7 +781,7 @@ describe OpportunitiesController do
781
781
  end
782
782
 
783
783
  it "should redirect to opportunity index with the flash message is the opportunity got deleted" do
784
- @opportunity = FactoryGirl.create(:opportunity, user: current_user)
784
+ @opportunity = create(:opportunity, user: current_user)
785
785
  @opportunity.destroy
786
786
 
787
787
  delete :destroy, params: { id: @opportunity.id }
@@ -790,7 +790,7 @@ describe OpportunitiesController do
790
790
  end
791
791
 
792
792
  it "should redirect to opportunity index with the flash message if the opportunity is protected" do
793
- @private = FactoryGirl.create(:opportunity, user: FactoryGirl.create(:user), access: "Private")
793
+ @private = create(:opportunity, user: create(:user), access: "Private")
794
794
 
795
795
  delete :destroy, params: { id: @private.id }
796
796
  expect(flash[:warning]).not_to eq(nil)
@@ -805,16 +805,16 @@ describe OpportunitiesController do
805
805
  describe "responding to PUT attach" do
806
806
  describe "tasks" do
807
807
  before do
808
- @model = FactoryGirl.create(:opportunity)
809
- @attachment = FactoryGirl.create(:task, asset: nil)
808
+ @model = create(:opportunity)
809
+ @attachment = create(:task, asset: nil)
810
810
  end
811
811
  it_should_behave_like("attach")
812
812
  end
813
813
 
814
814
  describe "contacts" do
815
815
  before do
816
- @model = FactoryGirl.create(:opportunity)
817
- @attachment = FactoryGirl.create(:contact)
816
+ @model = create(:opportunity)
817
+ @attachment = create(:contact)
818
818
  end
819
819
  it_should_behave_like("attach")
820
820
  end
@@ -826,16 +826,16 @@ describe OpportunitiesController do
826
826
  describe "responding to POST discard" do
827
827
  describe "tasks" do
828
828
  before do
829
- @model = FactoryGirl.create(:opportunity)
830
- @attachment = FactoryGirl.create(:task, asset: @model)
829
+ @model = create(:opportunity)
830
+ @attachment = create(:task, asset: @model)
831
831
  end
832
832
  it_should_behave_like("discard")
833
833
  end
834
834
 
835
835
  describe "contacts" do
836
836
  before do
837
- @attachment = FactoryGirl.create(:contact)
838
- @model = FactoryGirl.create(:opportunity)
837
+ @attachment = create(:contact)
838
+ @model = create(:opportunity)
839
839
  @model.contacts << @attachment
840
840
  end
841
841
  it_should_behave_like("discard")
@@ -846,7 +846,7 @@ describe OpportunitiesController do
846
846
  #----------------------------------------------------------------------------
847
847
  describe "responding to POST auto_complete" do
848
848
  before do
849
- @auto_complete_matches = [FactoryGirl.create(:opportunity, name: "Hello World", user: current_user)]
849
+ @auto_complete_matches = [create(:opportunity, name: "Hello World", user: current_user)]
850
850
  end
851
851
 
852
852
  it_should_behave_like("auto complete")
@@ -869,8 +869,8 @@ describe OpportunitiesController do
869
869
 
870
870
  it "should select @opportunities and render [index] template" do
871
871
  @opportunities = [
872
- FactoryGirl.create(:opportunity, name: "A", user: current_user),
873
- FactoryGirl.create(:opportunity, name: "B", user: current_user)
872
+ create(:opportunity, name: "A", user: current_user),
873
+ create(:opportunity, name: "B", user: current_user)
874
874
  ]
875
875
 
876
876
  get :redraw, params: { per_page: 1, sort_by: "name" }, xhr: true
@@ -884,7 +884,7 @@ describe OpportunitiesController do
884
884
  describe "responding to GET filter" do
885
885
  it "should expose filtered opportunities as @opportunity and render [filter] template" do
886
886
  session[:opportunities_filter] = "negotiation,analysis"
887
- @opportunities = [FactoryGirl.create(:opportunity, stage: "prospecting", user: current_user)]
887
+ @opportunities = [create(:opportunity, stage: "prospecting", user: current_user)]
888
888
  @stage = Setting.unroll(:opportunity_stage)
889
889
 
890
890
  get :filter, params: { stage: "prospecting" }, xhr: true