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 CampaignsController do
26
26
  end
27
27
 
28
28
  it "should expose all campaigns as @campaigns and render [index] template" do
29
- @campaigns = [FactoryGirl.create(:campaign, user: current_user)]
29
+ @campaigns = [create(:campaign, user: current_user)]
30
30
 
31
31
  get :index
32
32
  expect(assigns[:campaigns]).to eq(@campaigns)
@@ -34,7 +34,7 @@ describe CampaignsController do
34
34
  end
35
35
 
36
36
  it "should collect the data for the opportunities sidebar" do
37
- @campaigns = [FactoryGirl.create(:campaign, user: current_user)]
37
+ @campaigns = [create(:campaign, user: current_user)]
38
38
 
39
39
  get :index
40
40
  expect(assigns[:campaign_status_total].keys.map(&:to_sym) - (@status << :all << :other)).to eq([])
@@ -43,12 +43,12 @@ describe CampaignsController do
43
43
  it "should filter out campaigns by status" do
44
44
  controller.session[:campaigns_filter] = "planned,started"
45
45
  @campaigns = [
46
- FactoryGirl.create(:campaign, user: current_user, status: "started"),
47
- FactoryGirl.create(:campaign, user: current_user, status: "planned")
46
+ create(:campaign, user: current_user, status: "started"),
47
+ create(:campaign, user: current_user, status: "planned")
48
48
  ]
49
49
 
50
50
  # This one should be filtered out.
51
- FactoryGirl.create(:campaign, user: current_user, status: "completed")
51
+ create(:campaign, user: current_user, status: "completed")
52
52
 
53
53
  get :index
54
54
  # Note: can't compare campaigns directly because of BigDecimal objects.
@@ -57,8 +57,8 @@ describe CampaignsController do
57
57
  end
58
58
 
59
59
  it "should perform lookup using query string" do
60
- @first = FactoryGirl.create(:campaign, user: current_user, name: "Hello, world!")
61
- @second = FactoryGirl.create(:campaign, user: current_user, name: "Hello again")
60
+ @first = create(:campaign, user: current_user, name: "Hello, world!")
61
+ @second = create(:campaign, user: current_user, name: "Hello again")
62
62
 
63
63
  get :index, params: { query: "again" }
64
64
  expect(assigns[:campaigns]).to eq([@second])
@@ -68,7 +68,7 @@ describe CampaignsController do
68
68
 
69
69
  describe "AJAX pagination" do
70
70
  it "should pick up page number from params" do
71
- @campaigns = [FactoryGirl.create(:campaign, user: current_user)]
71
+ @campaigns = [create(:campaign, user: current_user)]
72
72
  get :index, params: { page: 42 }, xhr: true
73
73
 
74
74
  expect(assigns[:current_page].to_i).to eq(42)
@@ -79,7 +79,7 @@ describe CampaignsController do
79
79
 
80
80
  it "should pick up saved page number from session" do
81
81
  session[:campaigns_current_page] = 42
82
- @campaigns = [FactoryGirl.create(:campaign, user: current_user)]
82
+ @campaigns = [create(:campaign, user: current_user)]
83
83
  get :index, xhr: true
84
84
 
85
85
  expect(assigns[:current_page]).to eq(42)
@@ -90,7 +90,7 @@ describe CampaignsController do
90
90
  it "should reset current_page when query is altered" do
91
91
  session[:campaigns_current_page] = 42
92
92
  session[:campaigns_current_query] = "bill"
93
- @campaigns = [FactoryGirl.create(:campaign, user: current_user)]
93
+ @campaigns = [create(:campaign, user: current_user)]
94
94
  get :index, xhr: true
95
95
 
96
96
  expect(assigns[:current_page]).to eq(1)
@@ -128,7 +128,7 @@ describe CampaignsController do
128
128
  describe "responding to GET show" do
129
129
  describe "with mime type of HTML" do
130
130
  before(:each) do
131
- @campaign = FactoryGirl.create(:campaign, id: 42, user: current_user)
131
+ @campaign = create(:campaign, id: 42, user: current_user)
132
132
  @stage = Setting.unroll(:opportunity_stage)
133
133
  @comment = Comment.new
134
134
  end
@@ -149,7 +149,7 @@ describe CampaignsController do
149
149
 
150
150
  describe "with mime type of JSON" do
151
151
  it "should render the requested campaign as JSON" do
152
- @campaign = FactoryGirl.create(:campaign, id: 42, user: current_user)
152
+ @campaign = create(:campaign, id: 42, user: current_user)
153
153
  expect(Campaign).to receive(:find).and_return(@campaign)
154
154
  expect(@campaign).to receive(:to_json).and_return("generated JSON")
155
155
 
@@ -161,7 +161,7 @@ describe CampaignsController do
161
161
 
162
162
  describe "with mime type of XML" do
163
163
  it "should render the requested campaign as XML" do
164
- @campaign = FactoryGirl.create(:campaign, id: 42, user: current_user)
164
+ @campaign = create(:campaign, id: 42, user: current_user)
165
165
  expect(Campaign).to receive(:find).and_return(@campaign)
166
166
  expect(@campaign).to receive(:to_xml).and_return("generated XML")
167
167
 
@@ -173,7 +173,7 @@ describe CampaignsController do
173
173
 
174
174
  describe "campaign got deleted or otherwise unavailable" do
175
175
  it "should redirect to campaign index if the campaign got deleted" do
176
- @campaign = FactoryGirl.create(:campaign, user: current_user)
176
+ @campaign = create(:campaign, user: current_user)
177
177
  @campaign.destroy
178
178
 
179
179
  get :show, params: { id: @campaign.id }
@@ -182,7 +182,7 @@ describe CampaignsController do
182
182
  end
183
183
 
184
184
  it "should redirect to campaign index if the campaign is protected" do
185
- @campaign = FactoryGirl.create(:campaign, user: FactoryGirl.create(:user), access: "Private")
185
+ @campaign = create(:campaign, user: create(:user), access: "Private")
186
186
 
187
187
  get :show, params: { id: @campaign.id }
188
188
  expect(flash[:warning]).not_to eq(nil)
@@ -190,7 +190,7 @@ describe CampaignsController do
190
190
  end
191
191
 
192
192
  it "should return 404 (Not Found) JSON error" do
193
- @campaign = FactoryGirl.create(:campaign, user: current_user)
193
+ @campaign = create(:campaign, user: current_user)
194
194
  @campaign.destroy
195
195
  request.env["HTTP_ACCEPT"] = "application/json"
196
196
 
@@ -199,7 +199,7 @@ describe CampaignsController do
199
199
  end
200
200
 
201
201
  it "should return 404 (Not Found) XML error" do
202
- @campaign = FactoryGirl.create(:campaign, user: current_user)
202
+ @campaign = create(:campaign, user: current_user)
203
203
  @campaign.destroy
204
204
  request.env["HTTP_ACCEPT"] = "application/xml"
205
205
 
@@ -222,7 +222,7 @@ describe CampaignsController do
222
222
  end
223
223
 
224
224
  it "should create related object when necessary" do
225
- @lead = FactoryGirl.create(:lead, id: 42)
225
+ @lead = create(:lead, id: 42)
226
226
 
227
227
  get :new, params: { related: "lead_42" }, xhr: true
228
228
  expect(assigns[:lead]).to eq(@lead)
@@ -233,7 +233,7 @@ describe CampaignsController do
233
233
  #----------------------------------------------------------------------------
234
234
  describe "responding to GET edit" do
235
235
  it "should expose the requested campaign as @campaign and render [edit] template" do
236
- @campaign = FactoryGirl.create(:campaign, id: 42, user: current_user)
236
+ @campaign = create(:campaign, id: 42, user: current_user)
237
237
 
238
238
  get :edit, params: { id: 42 }, xhr: true
239
239
  expect(assigns[:campaign]).to eq(@campaign)
@@ -241,8 +241,8 @@ describe CampaignsController do
241
241
  end
242
242
 
243
243
  it "should find previous campaign as necessary" do
244
- @campaign = FactoryGirl.create(:campaign, id: 42)
245
- @previous = FactoryGirl.create(:campaign, id: 99)
244
+ @campaign = create(:campaign, id: 42)
245
+ @previous = create(:campaign, id: 99)
246
246
 
247
247
  get :edit, params: { id: 42, previous: 99 }, xhr: true
248
248
  expect(assigns[:campaign]).to eq(@campaign)
@@ -251,7 +251,7 @@ describe CampaignsController do
251
251
 
252
252
  describe "(campaign got deleted or is otherwise unavailable)" do
253
253
  it "should reload current page with the flash message if the campaign got deleted" do
254
- @campaign = FactoryGirl.create(:campaign, user: current_user)
254
+ @campaign = create(:campaign, user: current_user)
255
255
  @campaign.destroy
256
256
 
257
257
  get :edit, params: { id: @campaign.id }, xhr: true
@@ -260,7 +260,7 @@ describe CampaignsController do
260
260
  end
261
261
 
262
262
  it "should reload current page with the flash message if the campaign is protected" do
263
- @private = FactoryGirl.create(:campaign, user: FactoryGirl.create(:user), access: "Private")
263
+ @private = create(:campaign, user: create(:user), access: "Private")
264
264
 
265
265
  get :edit, params: { id: @private.id }, xhr: true
266
266
  expect(flash[:warning]).not_to eq(nil)
@@ -270,8 +270,8 @@ describe CampaignsController do
270
270
 
271
271
  describe "(previous campaign got deleted or is otherwise unavailable)" do
272
272
  before(:each) do
273
- @campaign = FactoryGirl.create(:campaign, user: current_user)
274
- @previous = FactoryGirl.create(:campaign, user: FactoryGirl.create(:user))
273
+ @campaign = create(:campaign, user: current_user)
274
+ @previous = create(:campaign, user: create(:user))
275
275
  end
276
276
 
277
277
  it "should notify the view if previous campaign got deleted" do
@@ -300,7 +300,7 @@ describe CampaignsController do
300
300
  describe "responding to POST create" do
301
301
  describe "with valid params" do
302
302
  it "should expose a newly created campaign as @campaign and render [create] template" do
303
- @campaign = FactoryGirl.build(:campaign, name: "Hello", user: current_user)
303
+ @campaign = build(:campaign, name: "Hello", user: current_user)
304
304
  allow(Campaign).to receive(:new).and_return(@campaign)
305
305
 
306
306
  post :create, params: { campaign: { name: "Hello" } }, xhr: true
@@ -309,7 +309,7 @@ describe CampaignsController do
309
309
  end
310
310
 
311
311
  it "should get data to update campaign sidebar" do
312
- @campaign = FactoryGirl.build(:campaign, name: "Hello", user: current_user)
312
+ @campaign = build(:campaign, name: "Hello", user: current_user)
313
313
  allow(Campaign).to receive(:new).and_return(@campaign)
314
314
 
315
315
  post :create, params: { campaign: { name: "Hello" } }, xhr: true
@@ -317,7 +317,7 @@ describe CampaignsController do
317
317
  end
318
318
 
319
319
  it "should reload campaigns to update pagination" do
320
- @campaign = FactoryGirl.build(:campaign, user: current_user)
320
+ @campaign = build(:campaign, user: current_user)
321
321
  allow(Campaign).to receive(:new).and_return(@campaign)
322
322
 
323
323
  post :create, params: { campaign: { name: "Hello" } }, xhr: true
@@ -325,7 +325,7 @@ describe CampaignsController do
325
325
  end
326
326
 
327
327
  it "should add a new comment to the newly created campaign when specified" do
328
- @campaign = FactoryGirl.build(:campaign, name: "Hello world", user: current_user)
328
+ @campaign = build(:campaign, name: "Hello world", user: current_user)
329
329
  allow(Campaign).to receive(:new).and_return(@campaign)
330
330
 
331
331
  post :create, params: { campaign: { name: "Hello world" }, comment_body: "Awesome comment is awesome" }, xhr: true
@@ -335,7 +335,7 @@ describe CampaignsController do
335
335
 
336
336
  describe "with invalid params" do
337
337
  it "should expose a newly created but unsaved campaign as @campaign and still render [create] template" do
338
- @campaign = FactoryGirl.build(:campaign, id: nil, name: nil, user: current_user)
338
+ @campaign = build(:campaign, id: nil, name: nil, user: current_user)
339
339
  allow(Campaign).to receive(:new).and_return(@campaign)
340
340
 
341
341
  post :create, params: { campaign: {} }, xhr: true
@@ -351,7 +351,7 @@ describe CampaignsController do
351
351
  describe "responding to PUT update" do
352
352
  describe "with valid params" do
353
353
  it "should update the requested campaign and render [update] template" do
354
- @campaign = FactoryGirl.create(:campaign, id: 42, name: "Bye")
354
+ @campaign = create(:campaign, id: 42, name: "Bye")
355
355
 
356
356
  put :update, params: { id: 42, campaign: { name: "Hello" } }, xhr: true
357
357
  expect(@campaign.reload.name).to eq("Hello")
@@ -360,7 +360,7 @@ describe CampaignsController do
360
360
  end
361
361
 
362
362
  it "should get data for campaigns sidebar when called from Campaigns index" do
363
- @campaign = FactoryGirl.create(:campaign, id: 42)
363
+ @campaign = create(:campaign, id: 42)
364
364
  request.env["HTTP_REFERER"] = "http://localhost/campaigns"
365
365
 
366
366
  put :update, params: { id: 42, campaign: { name: "Hello" } }, xhr: true
@@ -369,9 +369,9 @@ describe CampaignsController do
369
369
  end
370
370
 
371
371
  it "should update campaign permissions when sharing with specific users" do
372
- @campaign = FactoryGirl.create(:campaign, id: 42, access: "Public")
373
- he = FactoryGirl.create(:user, id: 7)
374
- she = FactoryGirl.create(:user, id: 8)
372
+ @campaign = create(:campaign, id: 42, access: "Public")
373
+ he = create(:user, id: 7)
374
+ she = create(:user, id: 8)
375
375
 
376
376
  put :update, params: { id: 42, campaign: { name: "Hello", access: "Shared", user_ids: %w[7 8] } }, xhr: true
377
377
  expect(assigns[:campaign].access).to eq("Shared")
@@ -380,7 +380,7 @@ describe CampaignsController do
380
380
 
381
381
  describe "campaign got deleted or otherwise unavailable" do
382
382
  it "should reload current page with the flash message if the campaign got deleted" do
383
- @campaign = FactoryGirl.create(:campaign, user: current_user)
383
+ @campaign = create(:campaign, user: current_user)
384
384
  @campaign.destroy
385
385
 
386
386
  put :update, params: { id: @campaign.id }, xhr: true
@@ -389,7 +389,7 @@ describe CampaignsController do
389
389
  end
390
390
 
391
391
  it "should reload current page with the flash message if the campaign is protected" do
392
- @private = FactoryGirl.create(:campaign, user: FactoryGirl.create(:user), access: "Private")
392
+ @private = create(:campaign, user: create(:user), access: "Private")
393
393
 
394
394
  put :update, params: { id: @private.id }, xhr: true
395
395
  expect(flash[:warning]).not_to eq(nil)
@@ -400,7 +400,7 @@ describe CampaignsController do
400
400
 
401
401
  describe "with invalid params" do
402
402
  it "should not update the requested campaign, but still expose it as @campaign and still render [update] template" do
403
- @campaign = FactoryGirl.create(:campaign, id: 42, name: "Hello", user: current_user)
403
+ @campaign = create(:campaign, id: 42, name: "Hello", user: current_user)
404
404
 
405
405
  put :update, params: { id: 42, campaign: { name: nil } }, xhr: true
406
406
  expect(@campaign.reload.name).to eq("Hello")
@@ -415,12 +415,12 @@ describe CampaignsController do
415
415
  #----------------------------------------------------------------------------
416
416
  describe "responding to DELETE destroy" do
417
417
  before(:each) do
418
- @campaign = FactoryGirl.create(:campaign, user: current_user)
418
+ @campaign = create(:campaign, user: current_user)
419
419
  end
420
420
 
421
421
  describe "AJAX request" do
422
422
  it "should destroy the requested campaign and render [destroy] template" do
423
- @another_campaign = FactoryGirl.create(:campaign, user: current_user)
423
+ @another_campaign = create(:campaign, user: current_user)
424
424
  delete :destroy, params: { id: @campaign.id }, xhr: true
425
425
 
426
426
  expect(assigns[:campaigns]).to eq([@another_campaign])
@@ -452,7 +452,7 @@ describe CampaignsController do
452
452
 
453
453
  describe "campaign got deleted or otherwise unavailable" do
454
454
  it "should reload current page with the flash message if the campaign got deleted" do
455
- @campaign = FactoryGirl.create(:campaign, user: current_user)
455
+ @campaign = create(:campaign, user: current_user)
456
456
  @campaign.destroy
457
457
 
458
458
  delete :destroy, params: { id: @campaign.id }, xhr: true
@@ -461,7 +461,7 @@ describe CampaignsController do
461
461
  end
462
462
 
463
463
  it "should reload current page with the flash message if the campaign is protected" do
464
- @private = FactoryGirl.create(:campaign, user: FactoryGirl.create(:user), access: "Private")
464
+ @private = create(:campaign, user: create(:user), access: "Private")
465
465
 
466
466
  delete :destroy, params: { id: @private.id }, xhr: true
467
467
  expect(flash[:warning]).not_to eq(nil)
@@ -479,7 +479,7 @@ describe CampaignsController do
479
479
  end
480
480
 
481
481
  it "should redirect to campaign index with the flash message is the campaign got deleted" do
482
- @campaign = FactoryGirl.create(:campaign, user: current_user)
482
+ @campaign = create(:campaign, user: current_user)
483
483
  @campaign.destroy
484
484
 
485
485
  delete :destroy, params: { id: @campaign.id }
@@ -488,7 +488,7 @@ describe CampaignsController do
488
488
  end
489
489
 
490
490
  it "should redirect to campaign index with the flash message if the campaign is protected" do
491
- @private = FactoryGirl.create(:campaign, user: FactoryGirl.create(:user), access: "Private")
491
+ @private = create(:campaign, user: create(:user), access: "Private")
492
492
 
493
493
  delete :destroy, params: { id: @private.id }
494
494
  expect(flash[:warning]).not_to eq(nil)
@@ -503,24 +503,24 @@ describe CampaignsController do
503
503
  describe "responding to PUT attach" do
504
504
  describe "tasks" do
505
505
  before do
506
- @model = FactoryGirl.create(:campaign)
507
- @attachment = FactoryGirl.create(:task, asset: nil)
506
+ @model = create(:campaign)
507
+ @attachment = create(:task, asset: nil)
508
508
  end
509
509
  it_should_behave_like("attach")
510
510
  end
511
511
 
512
512
  describe "leads" do
513
513
  before do
514
- @model = FactoryGirl.create(:campaign)
515
- @attachment = FactoryGirl.create(:lead, campaign: nil)
514
+ @model = create(:campaign)
515
+ @attachment = create(:lead, campaign: nil)
516
516
  end
517
517
  it_should_behave_like("attach")
518
518
  end
519
519
 
520
520
  describe "opportunities" do
521
521
  before do
522
- @model = FactoryGirl.create(:campaign)
523
- @attachment = FactoryGirl.create(:opportunity, campaign: nil)
522
+ @model = create(:campaign)
523
+ @attachment = create(:opportunity, campaign: nil)
524
524
  end
525
525
  it_should_behave_like("attach")
526
526
  end
@@ -532,24 +532,24 @@ describe CampaignsController do
532
532
  describe "responding to PUT attach" do
533
533
  describe "tasks" do
534
534
  before do
535
- @model = FactoryGirl.create(:campaign)
536
- @attachment = FactoryGirl.create(:task, asset: nil)
535
+ @model = create(:campaign)
536
+ @attachment = create(:task, asset: nil)
537
537
  end
538
538
  it_should_behave_like("attach")
539
539
  end
540
540
 
541
541
  describe "leads" do
542
542
  before do
543
- @model = FactoryGirl.create(:campaign)
544
- @attachment = FactoryGirl.create(:lead, campaign: nil)
543
+ @model = create(:campaign)
544
+ @attachment = create(:lead, campaign: nil)
545
545
  end
546
546
  it_should_behave_like("attach")
547
547
  end
548
548
 
549
549
  describe "opportunities" do
550
550
  before do
551
- @model = FactoryGirl.create(:campaign)
552
- @attachment = FactoryGirl.create(:opportunity, campaign: nil)
551
+ @model = create(:campaign)
552
+ @attachment = create(:opportunity, campaign: nil)
553
553
  end
554
554
  it_should_behave_like("attach")
555
555
  end
@@ -561,16 +561,16 @@ describe CampaignsController do
561
561
  describe "responding to POST discard" do
562
562
  describe "tasks" do
563
563
  before do
564
- @model = FactoryGirl.create(:campaign)
565
- @attachment = FactoryGirl.create(:task, asset: @model)
564
+ @model = create(:campaign)
565
+ @attachment = create(:task, asset: @model)
566
566
  end
567
567
  it_should_behave_like("discard")
568
568
  end
569
569
 
570
570
  describe "leads" do
571
571
  before do
572
- @attachment = FactoryGirl.create(:lead)
573
- @model = FactoryGirl.create(:campaign)
572
+ @attachment = create(:lead)
573
+ @model = create(:campaign)
574
574
  @model.leads << @attachment
575
575
  end
576
576
  it_should_behave_like("discard")
@@ -578,8 +578,8 @@ describe CampaignsController do
578
578
 
579
579
  describe "opportunities" do
580
580
  before do
581
- @attachment = FactoryGirl.create(:opportunity)
582
- @model = FactoryGirl.create(:campaign)
581
+ @attachment = create(:opportunity)
582
+ @model = create(:campaign)
583
583
  @model.opportunities << @attachment
584
584
  end
585
585
  it_should_behave_like("discard")
@@ -590,7 +590,7 @@ describe CampaignsController do
590
590
  #----------------------------------------------------------------------------
591
591
  describe "responding to POST auto_complete" do
592
592
  before(:each) do
593
- @auto_complete_matches = [FactoryGirl.create(:campaign, name: "Hello World", user: current_user)]
593
+ @auto_complete_matches = [create(:campaign, name: "Hello World", user: current_user)]
594
594
  end
595
595
 
596
596
  it_should_behave_like("auto complete")
@@ -613,8 +613,8 @@ describe CampaignsController do
613
613
 
614
614
  it "should select @campaigns and render [index] template" do
615
615
  @campaigns = [
616
- FactoryGirl.create(:campaign, name: "A", user: current_user),
617
- FactoryGirl.create(:campaign, name: "B", user: current_user)
616
+ create(:campaign, name: "A", user: current_user),
617
+ create(:campaign, name: "B", user: current_user)
618
618
  ]
619
619
 
620
620
  get :redraw, params: { per_page: 1, sort_by: "name" }, xhr: true
@@ -628,7 +628,7 @@ describe CampaignsController do
628
628
  describe "responding to POST filter" do
629
629
  it "should expose filtered campaigns as @campaigns and render [index] template" do
630
630
  session[:campaigns_filter] = "planned,started"
631
- @campaigns = [FactoryGirl.create(:campaign, status: "completed", user: current_user)]
631
+ @campaigns = [create(:campaign, status: "completed", user: current_user)]
632
632
 
633
633
  post :filter, params: { status: "completed" }, xhr: true
634
634
  expect(assigns(:campaigns)).to eq(@campaigns)
@@ -18,7 +18,7 @@ describe ContactsController do
18
18
  #----------------------------------------------------------------------------
19
19
  describe "responding to GET index" do
20
20
  it "should expose all contacts as @contacts and render [index] template" do
21
- @contacts = [FactoryGirl.create(:contact, user: current_user)]
21
+ @contacts = [create(:contact, user: current_user)]
22
22
  get :index
23
23
  expect(assigns[:contacts].count).to eq(@contacts.count)
24
24
  expect(assigns[:contacts]).to eq(@contacts)
@@ -26,8 +26,8 @@ describe ContactsController do
26
26
  end
27
27
 
28
28
  it "should perform lookup using query string" do
29
- @billy_bones = FactoryGirl.create(:contact, user: current_user, first_name: "Billy", last_name: "Bones")
30
- @captain_flint = FactoryGirl.create(:contact, user: current_user, first_name: "Captain", last_name: "Flint")
29
+ @billy_bones = create(:contact, user: current_user, first_name: "Billy", last_name: "Bones")
30
+ @captain_flint = create(:contact, user: current_user, first_name: "Captain", last_name: "Flint")
31
31
 
32
32
  get :index, params: { query: @billy_bones.email }
33
33
  expect(assigns[:contacts]).to eq([@billy_bones])
@@ -37,7 +37,7 @@ describe ContactsController do
37
37
 
38
38
  describe "AJAX pagination" do
39
39
  it "should pick up page number from params" do
40
- @contacts = [FactoryGirl.create(:contact, user: current_user)]
40
+ @contacts = [create(:contact, user: current_user)]
41
41
  get :index, params: { page: 42 }, xhr: true
42
42
 
43
43
  expect(assigns[:current_page].to_i).to eq(42)
@@ -48,7 +48,7 @@ describe ContactsController do
48
48
 
49
49
  it "should pick up saved page number from session" do
50
50
  session[:contacts_current_page] = 42
51
- @contacts = [FactoryGirl.create(:contact, user: current_user)]
51
+ @contacts = [create(:contact, user: current_user)]
52
52
  get :index, xhr: true
53
53
 
54
54
  expect(assigns[:current_page]).to eq(42)
@@ -59,7 +59,7 @@ describe ContactsController do
59
59
  it "should reset current_page when query is altered" do
60
60
  session[:contacts_current_page] = 42
61
61
  session[:contacts_current_query] = "bill"
62
- @contacts = [FactoryGirl.create(:contact, user: current_user)]
62
+ @contacts = [create(:contact, user: current_user)]
63
63
  get :index, xhr: true
64
64
 
65
65
  expect(assigns[:current_page]).to eq(1)
@@ -97,7 +97,7 @@ describe ContactsController do
97
97
  describe "responding to GET show" do
98
98
  describe "with mime type of HTML" do
99
99
  before(:each) do
100
- @contact = FactoryGirl.create(:contact, id: 42)
100
+ @contact = create(:contact, id: 42)
101
101
  @stage = Setting.unroll(:opportunity_stage)
102
102
  @comment = Comment.new
103
103
  end
@@ -118,7 +118,7 @@ describe ContactsController do
118
118
 
119
119
  describe "with mime type of JSON" do
120
120
  it "should render the requested contact as JSON" do
121
- @contact = FactoryGirl.create(:contact, id: 42)
121
+ @contact = create(:contact, id: 42)
122
122
  expect(Contact).to receive(:find).and_return(@contact)
123
123
  expect(@contact).to receive(:to_json).and_return("generated JSON")
124
124
 
@@ -130,7 +130,7 @@ describe ContactsController do
130
130
 
131
131
  describe "with mime type of XML" do
132
132
  it "should render the requested contact as xml" do
133
- @contact = FactoryGirl.create(:contact, id: 42)
133
+ @contact = create(:contact, id: 42)
134
134
  expect(Contact).to receive(:find).and_return(@contact)
135
135
  expect(@contact).to receive(:to_xml).and_return("generated XML")
136
136
 
@@ -142,7 +142,7 @@ describe ContactsController do
142
142
 
143
143
  describe "contact got deleted or otherwise unavailable" do
144
144
  it "should redirect to contact index if the contact got deleted" do
145
- @contact = FactoryGirl.create(:contact, user: current_user)
145
+ @contact = create(:contact, user: current_user)
146
146
  @contact.destroy
147
147
 
148
148
  get :show, params: { id: @contact.id }
@@ -151,7 +151,7 @@ describe ContactsController do
151
151
  end
152
152
 
153
153
  it "should redirect to contact index if the contact is protected" do
154
- @private = FactoryGirl.create(:contact, user: FactoryGirl.create(:user), access: "Private")
154
+ @private = create(:contact, user: create(:user), access: "Private")
155
155
 
156
156
  get :show, params: { id: @private.id }
157
157
  expect(flash[:warning]).not_to eq(nil)
@@ -159,7 +159,7 @@ describe ContactsController do
159
159
  end
160
160
 
161
161
  it "should return 404 (Not Found) XML error" do
162
- @contact = FactoryGirl.create(:contact, user: current_user)
162
+ @contact = create(:contact, user: current_user)
163
163
  @contact.destroy
164
164
  request.env["HTTP_ACCEPT"] = "application/xml"
165
165
 
@@ -177,7 +177,7 @@ describe ContactsController do
177
177
  @contact = Contact.new(user: current_user,
178
178
  access: Setting.default_access)
179
179
  @account = Account.new(user: current_user)
180
- @accounts = [FactoryGirl.create(:account, user: current_user)]
180
+ @accounts = [create(:account, user: current_user)]
181
181
 
182
182
  get :new, xhr: true
183
183
  expect(assigns[:contact].attributes).to eq(@contact.attributes)
@@ -188,7 +188,7 @@ describe ContactsController do
188
188
  end
189
189
 
190
190
  it "should created an instance of related object when necessary" do
191
- @opportunity = FactoryGirl.create(:opportunity)
191
+ @opportunity = create(:opportunity)
192
192
 
193
193
  get :new, params: { related: "opportunity_#{@opportunity.id}" }, xhr: true
194
194
  expect(assigns[:opportunity]).to eq(@opportunity)
@@ -196,7 +196,7 @@ describe ContactsController do
196
196
 
197
197
  describe "(when creating related contact)" do
198
198
  it "should redirect to parent asset's index page with the message if parent asset got deleted" do
199
- @account = FactoryGirl.create(:account)
199
+ @account = create(:account)
200
200
  @account.destroy
201
201
 
202
202
  get :new, params: { related: "account_#{@account.id}" }, xhr: true
@@ -205,7 +205,7 @@ describe ContactsController do
205
205
  end
206
206
 
207
207
  it "should redirect to parent asset's index page with the message if parent asset got protected" do
208
- @account = FactoryGirl.create(:account, access: "Private")
208
+ @account = create(:account, access: "Private")
209
209
 
210
210
  get :new, params: { related: "account_#{@account.id}" }, xhr: true
211
211
  expect(flash[:warning]).not_to eq(nil)
@@ -219,7 +219,7 @@ describe ContactsController do
219
219
  describe "responding to GET field_group" do
220
220
  context "with an existing tag" do
221
221
  before :each do
222
- @tag = FactoryGirl.create(:tag)
222
+ @tag = create(:tag)
223
223
  end
224
224
 
225
225
  it "should return with an existing tag name" do
@@ -252,7 +252,7 @@ describe ContactsController do
252
252
  #----------------------------------------------------------------------------
253
253
  describe "responding to GET edit" do
254
254
  it "should expose the requested contact as @contact and render [edit] template" do
255
- @contact = FactoryGirl.create(:contact, id: 42, user: current_user, lead: nil)
255
+ @contact = create(:contact, id: 42, user: current_user, lead: nil)
256
256
  @account = Account.new(user: current_user)
257
257
 
258
258
  get :edit, params: { id: 42 }, xhr: true
@@ -263,9 +263,9 @@ describe ContactsController do
263
263
  end
264
264
 
265
265
  it "should expose the requested contact as @contact and linked account as @account" do
266
- @account = FactoryGirl.create(:account, id: 99)
267
- @contact = FactoryGirl.create(:contact, id: 42, user: current_user, lead: nil)
268
- FactoryGirl.create(:account_contact, account: @account, contact: @contact)
266
+ @account = create(:account, id: 99)
267
+ @contact = create(:contact, id: 42, user: current_user, lead: nil)
268
+ create(:account_contact, account: @account, contact: @contact)
269
269
 
270
270
  get :edit, params: { id: 42 }, xhr: true
271
271
  expect(assigns[:contact]).to eq(@contact)
@@ -273,8 +273,8 @@ describe ContactsController do
273
273
  end
274
274
 
275
275
  it "should expose previous contact as @previous when necessary" do
276
- @contact = FactoryGirl.create(:contact, id: 42)
277
- @previous = FactoryGirl.create(:contact, id: 1992)
276
+ @contact = create(:contact, id: 42)
277
+ @previous = create(:contact, id: 1992)
278
278
 
279
279
  get :edit, params: { id: 42, previous: 1992 }, xhr: true
280
280
  expect(assigns[:previous]).to eq(@previous)
@@ -282,7 +282,7 @@ describe ContactsController do
282
282
 
283
283
  describe "(contact got deleted or is otherwise unavailable)" do
284
284
  it "should reload current page with the flash message if the contact got deleted" do
285
- @contact = FactoryGirl.create(:contact, user: current_user)
285
+ @contact = create(:contact, user: current_user)
286
286
  @contact.destroy
287
287
 
288
288
  get :edit, params: { id: @contact.id }, xhr: true
@@ -291,7 +291,7 @@ describe ContactsController do
291
291
  end
292
292
 
293
293
  it "should reload current page with the flash message if the contact is protected" do
294
- @private = FactoryGirl.create(:contact, user: FactoryGirl.create(:user), access: "Private")
294
+ @private = create(:contact, user: create(:user), access: "Private")
295
295
 
296
296
  get :edit, params: { id: @private.id }, xhr: true
297
297
  expect(flash[:warning]).not_to eq(nil)
@@ -301,8 +301,8 @@ describe ContactsController do
301
301
 
302
302
  describe "(previous contact got deleted or is otherwise unavailable)" do
303
303
  before(:each) do
304
- @contact = FactoryGirl.create(:contact, user: current_user)
305
- @previous = FactoryGirl.create(:contact, user: FactoryGirl.create(:user))
304
+ @contact = create(:contact, user: current_user)
305
+ @previous = create(:contact, user: create(:user))
306
306
  end
307
307
 
308
308
  it "should notify the view if previous contact got deleted" do
@@ -331,7 +331,7 @@ describe ContactsController do
331
331
  describe "responding to POST create" do
332
332
  describe "with valid params" do
333
333
  it "should expose a newly created contact as @contact and render [create] template" do
334
- @contact = FactoryGirl.build(:contact, first_name: "Billy", last_name: "Bones")
334
+ @contact = build(:contact, first_name: "Billy", last_name: "Bones")
335
335
  allow(Contact).to receive(:new).and_return(@contact)
336
336
 
337
337
  post :create, params: { contact: { first_name: "Billy", last_name: "Bones" }, account: { name: "Hello world" } }, xhr: true
@@ -341,8 +341,8 @@ describe ContactsController do
341
341
  end
342
342
 
343
343
  it "should be able to associate newly created contact with the opportunity" do
344
- @opportunity = FactoryGirl.create(:opportunity, id: 987)
345
- @contact = FactoryGirl.build(:contact)
344
+ @opportunity = create(:opportunity, id: 987)
345
+ @contact = build(:contact)
346
346
  allow(Contact).to receive(:new).and_return(@contact)
347
347
 
348
348
  post :create, params: { contact: { first_name: "Billy" }, account: {}, opportunity: 987 }, xhr: true
@@ -351,7 +351,7 @@ describe ContactsController do
351
351
  end
352
352
 
353
353
  it "should reload contacts to update pagination if called from contacts index" do
354
- @contact = FactoryGirl.build(:contact, user: current_user)
354
+ @contact = build(:contact, user: current_user)
355
355
  allow(Contact).to receive(:new).and_return(@contact)
356
356
 
357
357
  request.env["HTTP_REFERER"] = "http://localhost/contacts"
@@ -360,7 +360,7 @@ describe ContactsController do
360
360
  end
361
361
 
362
362
  it "should add a new comment to the newly created contact when specified" do
363
- @contact = FactoryGirl.build(:contact, user: current_user)
363
+ @contact = build(:contact, user: current_user)
364
364
  allow(Contact).to receive(:new).and_return(@contact)
365
365
 
366
366
  post :create, params: { contact: { first_name: "Testy", last_name: "McTest" }, account: { name: "Hello world" }, comment_body: "Awesome comment is awesome" }, xhr: true
@@ -370,13 +370,13 @@ describe ContactsController do
370
370
 
371
371
  describe "with invalid params" do
372
372
  before(:each) do
373
- @contact = FactoryGirl.build(:contact, first_name: nil, user: current_user, lead: nil)
373
+ @contact = build(:contact, first_name: nil, user: current_user, lead: nil)
374
374
  allow(Contact).to receive(:new).and_return(@contact)
375
375
  end
376
376
 
377
377
  # Redraw [create] form with selected account.
378
378
  it "should redraw [Create Contact] form with selected account" do
379
- @account = FactoryGirl.create(:account, id: 42, user: current_user)
379
+ @account = create(:account, id: 42, user: current_user)
380
380
 
381
381
  # This redraws [create] form with blank account.
382
382
  post :create, params: { contact: {}, account: { id: 42, user_id: current_user.id } }, xhr: true
@@ -388,7 +388,7 @@ describe ContactsController do
388
388
 
389
389
  # Redraw [create] form with related account.
390
390
  it "should redraw [Create Contact] form with related account" do
391
- @account = FactoryGirl.create(:account, id: 123, user: current_user)
391
+ @account = create(:account, id: 123, user: current_user)
392
392
 
393
393
  request.env["HTTP_REFERER"] = "http://localhost/accounts/123"
394
394
  post :create, params: { contact: { first_name: nil }, account: { name: nil, user_id: current_user.id } }, xhr: true
@@ -399,7 +399,7 @@ describe ContactsController do
399
399
  end
400
400
 
401
401
  it "should redraw [Create Contact] form with blank account" do
402
- @accounts = [FactoryGirl.create(:account, user: current_user)]
402
+ @accounts = [create(:account, user: current_user)]
403
403
  @account = Account.new(user: current_user)
404
404
 
405
405
  post :create, params: { contact: { first_name: nil }, account: { name: nil, user_id: current_user.id } }, xhr: true
@@ -410,7 +410,7 @@ describe ContactsController do
410
410
  end
411
411
 
412
412
  it "should preserve Opportunity when called from Oppotuunity page" do
413
- @opportunity = FactoryGirl.create(:opportunity, id: 987)
413
+ @opportunity = create(:opportunity, id: 987)
414
414
 
415
415
  post :create, params: { contact: {}, account: {}, opportunity: 987 }, xhr: true
416
416
  expect(assigns(:opportunity)).to eq(@opportunity)
@@ -425,7 +425,7 @@ describe ContactsController do
425
425
  describe "responding to PUT update" do
426
426
  describe "with valid params" do
427
427
  it "should update the requested contact and render [update] template" do
428
- @contact = FactoryGirl.create(:contact, id: 42, first_name: "Billy")
428
+ @contact = create(:contact, id: 42, first_name: "Billy")
429
429
 
430
430
  put :update, params: { id: 42, contact: { first_name: "Bones" }, account: {} }, xhr: true
431
431
  expect(assigns[:contact].first_name).to eq("Bones")
@@ -434,7 +434,7 @@ describe ContactsController do
434
434
  end
435
435
 
436
436
  it "should be able to create a new account and link it to the contact" do
437
- @contact = FactoryGirl.create(:contact, id: 42, first_name: "Billy")
437
+ @contact = create(:contact, id: 42, first_name: "Billy")
438
438
 
439
439
  put :update, params: { id: 42, contact: { first_name: "Bones" }, account: { name: "new account" } }, xhr: true
440
440
  expect(assigns[:contact].first_name).to eq("Bones")
@@ -442,8 +442,8 @@ describe ContactsController do
442
442
  end
443
443
 
444
444
  it "should be able to link existing account with the contact" do
445
- @account = FactoryGirl.create(:account, id: 99, name: "Hello world")
446
- @contact = FactoryGirl.create(:contact, id: 42, first_name: "Billy")
445
+ @account = create(:account, id: 99, name: "Hello world")
446
+ @contact = create(:contact, id: 42, first_name: "Billy")
447
447
 
448
448
  put :update, params: { id: 42, contact: { first_name: "Bones" }, account: { id: 99 } }, xhr: true
449
449
  expect(assigns[:contact].first_name).to eq("Bones")
@@ -451,7 +451,7 @@ describe ContactsController do
451
451
  end
452
452
 
453
453
  it "should update contact permissions when sharing with specific users" do
454
- @contact = FactoryGirl.create(:contact, id: 42, access: "Public")
454
+ @contact = create(:contact, id: 42, access: "Public")
455
455
 
456
456
  put :update, params: { id: 42, contact: { first_name: "Hello", access: "Shared", user_ids: [7, 8] }, account: {} }, xhr: true
457
457
  expect(assigns[:contact].access).to eq("Shared")
@@ -461,7 +461,7 @@ describe ContactsController do
461
461
 
462
462
  describe "contact got deleted or otherwise unavailable" do
463
463
  it "should reload current page is the contact got deleted" do
464
- @contact = FactoryGirl.create(:contact, user: current_user)
464
+ @contact = create(:contact, user: current_user)
465
465
  @contact.destroy
466
466
 
467
467
  put :update, params: { id: @contact.id }, xhr: true
@@ -470,7 +470,7 @@ describe ContactsController do
470
470
  end
471
471
 
472
472
  it "should reload current page with the flash message if the contact is protected" do
473
- @private = FactoryGirl.create(:contact, user: FactoryGirl.create(:user), access: "Private")
473
+ @private = create(:contact, user: create(:user), access: "Private")
474
474
 
475
475
  put :update, params: { id: @private.id }, xhr: true
476
476
  expect(flash[:warning]).not_to eq(nil)
@@ -481,7 +481,7 @@ describe ContactsController do
481
481
 
482
482
  describe "with invalid params" do
483
483
  it "should not update the contact, but still expose it as @contact and render [update] template" do
484
- @contact = FactoryGirl.create(:contact, id: 42, user: current_user, first_name: "Billy", lead: nil)
484
+ @contact = create(:contact, id: 42, user: current_user, first_name: "Billy", lead: nil)
485
485
 
486
486
  put :update, params: { id: 42, contact: { first_name: nil }, account: {} }, xhr: true
487
487
  expect(assigns[:contact].reload.first_name).to eq("Billy")
@@ -490,8 +490,8 @@ describe ContactsController do
490
490
  end
491
491
 
492
492
  it "should expose existing account as @account if selected" do
493
- @account = FactoryGirl.create(:account, id: 99)
494
- @contact = FactoryGirl.create(:contact, id: 42, account: @account)
493
+ @account = create(:account, id: 99)
494
+ @contact = create(:contact, id: 42, account: @account)
495
495
 
496
496
  put :update, params: { id: 42, contact: { first_name: nil }, account: { id: 99 } }, xhr: true
497
497
  expect(assigns[:account]).to eq(@account)
@@ -504,7 +504,7 @@ describe ContactsController do
504
504
  #----------------------------------------------------------------------------
505
505
  describe "responding to DELETE destroy" do
506
506
  before(:each) do
507
- @contact = FactoryGirl.create(:contact, user: current_user)
507
+ @contact = create(:contact, user: current_user)
508
508
  end
509
509
 
510
510
  describe "AJAX request" do
@@ -549,7 +549,7 @@ describe ContactsController do
549
549
 
550
550
  describe "contact got deleted or otherwise unavailable" do
551
551
  it "should reload current page is the contact got deleted" do
552
- @contact = FactoryGirl.create(:contact, user: current_user)
552
+ @contact = create(:contact, user: current_user)
553
553
  @contact.destroy
554
554
 
555
555
  delete :destroy, params: { id: @contact.id }, xhr: true
@@ -558,7 +558,7 @@ describe ContactsController do
558
558
  end
559
559
 
560
560
  it "should reload current page with the flash message if the contact is protected" do
561
- @private = FactoryGirl.create(:contact, user: FactoryGirl.create(:user), access: "Private")
561
+ @private = create(:contact, user: create(:user), access: "Private")
562
562
 
563
563
  delete :destroy, params: { id: @private.id }, xhr: true
564
564
  expect(flash[:warning]).not_to eq(nil)
@@ -576,7 +576,7 @@ describe ContactsController do
576
576
  end
577
577
 
578
578
  it "should redirect to contact index with the flash message is the contact got deleted" do
579
- @contact = FactoryGirl.create(:contact, user: current_user)
579
+ @contact = create(:contact, user: current_user)
580
580
  @contact.destroy
581
581
 
582
582
  delete :destroy, params: { id: @contact.id }
@@ -585,7 +585,7 @@ describe ContactsController do
585
585
  end
586
586
 
587
587
  it "should redirect to contact index with the flash message if the contact is protected" do
588
- @private = FactoryGirl.create(:contact, user: FactoryGirl.create(:user), access: "Private")
588
+ @private = create(:contact, user: create(:user), access: "Private")
589
589
 
590
590
  delete :destroy, params: { id: @private.id }
591
591
  expect(flash[:warning]).not_to eq(nil)
@@ -600,16 +600,16 @@ describe ContactsController do
600
600
  describe "responding to PUT attach" do
601
601
  describe "tasks" do
602
602
  before do
603
- @model = FactoryGirl.create(:contact)
604
- @attachment = FactoryGirl.create(:task, asset: nil)
603
+ @model = create(:contact)
604
+ @attachment = create(:task, asset: nil)
605
605
  end
606
606
  it_should_behave_like("attach")
607
607
  end
608
608
 
609
609
  describe "opportunities" do
610
610
  before do
611
- @model = FactoryGirl.create(:contact)
612
- @attachment = FactoryGirl.create(:opportunity)
611
+ @model = create(:contact)
612
+ @attachment = create(:opportunity)
613
613
  end
614
614
  it_should_behave_like("attach")
615
615
  end
@@ -621,16 +621,16 @@ describe ContactsController do
621
621
  describe "responding to PUT attach" do
622
622
  describe "tasks" do
623
623
  before do
624
- @model = FactoryGirl.create(:contact)
625
- @attachment = FactoryGirl.create(:task, asset: nil)
624
+ @model = create(:contact)
625
+ @attachment = create(:task, asset: nil)
626
626
  end
627
627
  it_should_behave_like("attach")
628
628
  end
629
629
 
630
630
  describe "opportunities" do
631
631
  before do
632
- @model = FactoryGirl.create(:contact)
633
- @attachment = FactoryGirl.create(:opportunity)
632
+ @model = create(:contact)
633
+ @attachment = create(:opportunity)
634
634
  end
635
635
  it_should_behave_like("attach")
636
636
  end
@@ -642,16 +642,16 @@ describe ContactsController do
642
642
  describe "responding to POST discard" do
643
643
  describe "tasks" do
644
644
  before do
645
- @model = FactoryGirl.create(:contact)
646
- @attachment = FactoryGirl.create(:task, asset: @model)
645
+ @model = create(:contact)
646
+ @attachment = create(:task, asset: @model)
647
647
  end
648
648
  it_should_behave_like("discard")
649
649
  end
650
650
 
651
651
  describe "opportunities" do
652
652
  before do
653
- @attachment = FactoryGirl.create(:opportunity)
654
- @model = FactoryGirl.create(:contact)
653
+ @attachment = create(:opportunity)
654
+ @model = create(:contact)
655
655
  @model.opportunities << @attachment
656
656
  end
657
657
  it_should_behave_like("discard")
@@ -662,7 +662,7 @@ describe ContactsController do
662
662
  #----------------------------------------------------------------------------
663
663
  describe "responding to POST auto_complete" do
664
664
  before(:each) do
665
- @auto_complete_matches = [FactoryGirl.create(:contact, first_name: "Hello", last_name: "World", user: current_user)]
665
+ @auto_complete_matches = [create(:contact, first_name: "Hello", last_name: "World", user: current_user)]
666
666
  end
667
667
 
668
668
  it_should_behave_like("auto complete")
@@ -692,8 +692,8 @@ describe ContactsController do
692
692
 
693
693
  it "should select @contacts and render [index] template" do
694
694
  @contacts = [
695
- FactoryGirl.create(:contact, first_name: "Alice", user: current_user),
696
- FactoryGirl.create(:contact, first_name: "Bobby", user: current_user)
695
+ create(:contact, first_name: "Alice", user: current_user),
696
+ create(:contact, first_name: "Bobby", user: current_user)
697
697
  ]
698
698
 
699
699
  get :redraw, params: { per_page: 1, sort_by: "first_name" }, xhr: true