fat_free_crm 0.15.0.beta.2 → 0.15.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 (225) hide show
  1. checksums.yaml +4 -4
  2. data/.docker/nginx/sites-enabled/ffcrm.conf +8 -0
  3. data/.gitignore +2 -0
  4. data/.rubocop.yml +4 -1
  5. data/.rubocop_todo.yml +190 -89
  6. data/.travis.yml +10 -3
  7. data/CHANGELOG.md +27 -0
  8. data/{CONTRIBUTORS → CONTRIBUTORS.md} +2 -1
  9. data/Dockerfile +15 -13
  10. data/Gemfile +7 -4
  11. data/Gemfile.lock +200 -167
  12. data/README.md +4 -2
  13. data/app/assets/javascripts/crm_sortable.js.coffee +5 -0
  14. data/app/assets/javascripts/timeago.js.coffee +5 -0
  15. data/app/assets/stylesheets/about.css.scss +5 -0
  16. data/app/assets/stylesheets/common.scss +2 -1
  17. data/app/controllers/admin/fields_controller.rb +1 -1
  18. data/app/controllers/admin/groups_controller.rb +5 -1
  19. data/app/controllers/admin/tags_controller.rb +1 -1
  20. data/app/controllers/admin/users_controller.rb +10 -6
  21. data/app/controllers/application_controller.rb +13 -13
  22. data/app/controllers/authentications_controller.rb +2 -2
  23. data/app/controllers/comments_controller.rb +3 -2
  24. data/app/controllers/entities/contacts_controller.rb +9 -7
  25. data/app/controllers/entities/opportunities_controller.rb +1 -1
  26. data/app/controllers/entities_controller.rb +4 -4
  27. data/app/controllers/home_controller.rb +9 -9
  28. data/app/controllers/passwords_controller.rb +1 -1
  29. data/app/controllers/tasks_controller.rb +2 -1
  30. data/app/controllers/users_controller.rb +4 -2
  31. data/app/helpers/application_helper.rb +9 -9
  32. data/app/helpers/javascript_helper.rb +5 -0
  33. data/app/helpers/opportunities_helper.rb +1 -1
  34. data/app/helpers/remote_link_pagination_helper.rb +5 -0
  35. data/app/inputs/date_pair_input.rb +1 -1
  36. data/app/models/entities/account.rb +2 -2
  37. data/app/models/entities/account_contact.rb +1 -1
  38. data/app/models/entities/campaign.rb +3 -3
  39. data/app/models/entities/contact.rb +3 -3
  40. data/app/models/entities/lead.rb +2 -2
  41. data/app/models/entities/opportunity.rb +3 -3
  42. data/app/models/fields/custom_field.rb +1 -1
  43. data/app/models/fields/custom_field_pair.rb +2 -2
  44. data/app/models/fields/field.rb +1 -1
  45. data/app/models/polymorphic/address.rb +2 -2
  46. data/app/models/polymorphic/avatar.rb +4 -2
  47. data/app/models/polymorphic/email.rb +8 -6
  48. data/app/models/polymorphic/task.rb +3 -1
  49. data/app/models/polymorphic/version.rb +3 -3
  50. data/app/models/users/ability.rb +1 -1
  51. data/app/models/users/permission.rb +2 -0
  52. data/app/models/users/user.rb +2 -2
  53. data/app/views/accounts/index.js.haml +1 -1
  54. data/app/views/admin/fields/_sort_by.html.haml +1 -1
  55. data/app/views/admin/users/_user.html.haml +1 -1
  56. data/app/views/campaigns/index.js.haml +1 -1
  57. data/app/views/contacts/index.js.haml +1 -1
  58. data/app/views/entities/_basic_search.html.haml +1 -1
  59. data/app/views/home/_duration_menu.html.haml +1 -1
  60. data/app/views/home/_events_menu.html.haml +1 -1
  61. data/app/views/home/_users_menu.html.haml +1 -1
  62. data/app/views/layouts/application.html.haml +1 -1
  63. data/app/views/leads/index.js.haml +1 -1
  64. data/app/views/opportunities/index.js.haml +1 -1
  65. data/app/views/shared/_naming.html.haml +1 -1
  66. data/app/views/users/_languages.html.haml +1 -1
  67. data/config/application.rb +2 -3
  68. data/config/boot.rb +2 -0
  69. data/config/deploy.example.rb +1 -1
  70. data/config/environments/development.rb +2 -0
  71. data/config/environments/production.rb +1 -1
  72. data/config/environments/test.rb +2 -2
  73. data/config/initializers/assets.rb +6 -1
  74. data/config/initializers/backtrace_silencers.rb +5 -0
  75. data/config/initializers/constants.rb +1 -1
  76. data/config/initializers/cookies_serializer.rb +5 -0
  77. data/config/initializers/custom_field_ransack_translations.rb +5 -0
  78. data/config/initializers/filter_parameter_logging.rb +5 -0
  79. data/config/initializers/inflections.rb +5 -0
  80. data/config/initializers/paper_trail.rb +5 -0
  81. data/config/initializers/ransack.rb +3 -3
  82. data/config/initializers/session_store.rb +5 -0
  83. data/config/initializers/wrap_parameters.rb +5 -0
  84. data/config/locales/et.yml +207 -0
  85. data/config/locales/et_fat_free_crm.yml +928 -0
  86. data/config/locales/pt-BR_ransack.yml +81 -0
  87. data/config/locales/th.rb +1 -1
  88. data/config/routes.rb +18 -18
  89. data/db/migrate/20100928030598_create_sessions.rb +1 -1
  90. data/db/migrate/20100928030599_create_users.rb +2 -2
  91. data/db/migrate/20100928030600_create_openid_tables.rb +1 -1
  92. data/db/migrate/20100928030601_create_accounts.rb +2 -2
  93. data/db/migrate/20100928030602_create_permissions.rb +1 -1
  94. data/db/migrate/20100928030603_create_settings.rb +1 -1
  95. data/db/migrate/20100928030604_create_preferences.rb +2 -2
  96. data/db/migrate/20100928030605_create_campaigns.rb +2 -2
  97. data/db/migrate/20100928030606_create_leads.rb +2 -2
  98. data/db/migrate/20100928030607_create_contacts.rb +2 -2
  99. data/db/migrate/20100928030608_create_opportunities.rb +2 -2
  100. data/db/migrate/20100928030609_create_account_contacts.rb +1 -1
  101. data/db/migrate/20100928030610_create_account_opportunities.rb +1 -1
  102. data/db/migrate/20100928030611_create_contact_opportunities.rb +1 -1
  103. data/db/migrate/20100928030612_create_tasks.rb +2 -2
  104. data/db/migrate/20100928030613_create_comments.rb +1 -1
  105. data/db/migrate/20100928030614_create_activities.rb +1 -1
  106. data/db/migrate/20100928030615_create_avatars.rb +1 -1
  107. data/db/migrate/20100928030616_rename_remember_token.rb +1 -1
  108. data/db/migrate/20100928030617_drop_openid_tables.rb +1 -1
  109. data/db/migrate/20100928030618_add_admin_to_users.rb +1 -1
  110. data/db/migrate/20100928030619_add_suspended_to_users.rb +1 -1
  111. data/db/migrate/20100928030620_remove_uuid.rb +2 -2
  112. data/db/migrate/20100928030621_add_email_to_accounts.rb +1 -1
  113. data/db/migrate/20100928030622_add_background_info_to_models.rb +1 -1
  114. data/db/migrate/20100928030623_create_addresses.rb +2 -2
  115. data/db/migrate/20100928030624_add_index_on_permissions.rb +3 -3
  116. data/db/migrate/20100928030625_create_emails.rb +2 -2
  117. data/db/migrate/20100928030626_add_state_to_timeline_objects.rb +1 -1
  118. data/db/migrate/20100928030627_acts_as_taggable_on_migration.rb +2 -2
  119. data/db/migrate/20101221123456_add_single_access_token_to_users.rb +1 -1
  120. data/db/migrate/20101221345678_add_rating_and_category_to_accounts.rb +1 -1
  121. data/db/migrate/20110719082054_add_skype_to_contacts_and_leads.rb +1 -1
  122. data/db/migrate/20111101083437_create_fields.rb +1 -1
  123. data/db/migrate/20111101090312_create_field_groups.rb +1 -1
  124. data/db/migrate/20111116091952_add_field_groups_tag_id.rb +1 -1
  125. data/db/migrate/20111117041311_change_fields_collection_to_text.rb +1 -1
  126. data/db/migrate/20111201030535_add_field_groups_klass_name.rb +2 -2
  127. data/db/migrate/20120121054235_create_lists.rb +1 -1
  128. data/db/migrate/20120216031616_create_versions.rb +3 -3
  129. data/db/migrate/20120216042541_is_paranoid_to_paper_trail.rb +1 -1
  130. data/db/migrate/20120220233724_add_versions_object_changes.rb +1 -1
  131. data/db/migrate/20120224073107_remove_default_value_and_clear_settings.rb +1 -1
  132. data/db/migrate/20120309070209_add_versions_related.rb +1 -1
  133. data/db/migrate/20120314080441_add_subscribed_users_to_entities.rb +2 -2
  134. data/db/migrate/20120316045804_activities_to_versions.rb +1 -1
  135. data/db/migrate/20120405080727_change_subscribed_users_to_set.rb +1 -1
  136. data/db/migrate/20120405080742_change_further_subscribed_users_to_set.rb +2 -2
  137. data/db/migrate/20120406082136_create_groups.rb +2 -2
  138. data/db/migrate/20120413034923_add_index_on_versions_item_type.rb +1 -1
  139. data/db/migrate/20120510025219_add_not_null_constraints_for_timestamp_columns.rb +3 -3
  140. data/db/migrate/20120528102124_increase_length_of_version_events.rb +1 -1
  141. data/db/migrate/20120801032706_add_pair_id_to_fields.rb +1 -1
  142. data/db/migrate/20121003063155_add_settings_to_custom_fields.rb +1 -1
  143. data/db/migrate/20121221033947_fix_country_mapping.rb +1 -1
  144. data/db/migrate/20131207033244_add_user_id_to_lists.rb +1 -1
  145. data/db/migrate/20140916011927_add_created_at_index_on_versions.rb +1 -1
  146. data/db/migrate/20140916012922_add_indexes_to_model_associations.rb +3 -3
  147. data/db/migrate/20141126031837_increase_email_to254_chars.rb +1 -1
  148. data/db/migrate/20141230021159_add_transaction_id_column_to_versions.rb +1 -1
  149. data/db/migrate/20141230205453_add_missing_unique_indices.acts_as_taggable_on_engine.rb +4 -4
  150. data/db/migrate/20141230205454_add_taggings_counter_cache_to_tags.acts_as_taggable_on_engine.rb +1 -1
  151. data/db/migrate/20141230205455_add_missing_taggable_index.acts_as_taggable_on_engine.rb +3 -3
  152. data/db/migrate/20150123060900_convert_radio_to_radio_buttons.rb +1 -1
  153. data/db/migrate/20150227123054_remove_last_request_at_from_users.rb +1 -1
  154. data/db/migrate/20150427131956_create_index_related_type.rb +3 -3
  155. data/db/migrate/20160511053730_add_account_contacts_index.rb +2 -2
  156. data/docker-compose.yml +17 -13
  157. data/fat_free_crm.gemspec +4 -6
  158. data/lib/development_tasks/license.rake +12 -9
  159. data/lib/fat_free_crm/callback.rb +4 -4
  160. data/lib/fat_free_crm/engine.rb +2 -2
  161. data/lib/fat_free_crm/exportable.rb +2 -2
  162. data/lib/fat_free_crm/fields.rb +2 -4
  163. data/lib/fat_free_crm/gem_ext.rb +0 -1
  164. data/lib/fat_free_crm/gem_ext/rake/task.rb +2 -0
  165. data/lib/fat_free_crm/mail_processor/base.rb +4 -4
  166. data/lib/fat_free_crm/mail_processor/dropbox.rb +1 -1
  167. data/lib/fat_free_crm/permissions.rb +5 -5
  168. data/lib/fat_free_crm/sortable.rb +1 -1
  169. data/lib/fat_free_crm/version.rb +1 -1
  170. data/lib/gravatar_image_tag.rb +1 -0
  171. data/lib/tasks/ffcrm/demo.rake +2 -2
  172. data/spec/controllers/admin/users_controller_spec.rb +25 -25
  173. data/spec/controllers/authentications_controller_spec.rb +9 -9
  174. data/spec/controllers/comments_controller_spec.rb +15 -15
  175. data/spec/controllers/emails_controller_spec.rb +2 -2
  176. data/spec/controllers/entities/accounts_controller_spec.rb +46 -46
  177. data/spec/controllers/entities/campaigns_controller_spec.rb +46 -46
  178. data/spec/controllers/entities/contacts_controller_spec.rb +55 -55
  179. data/spec/controllers/entities/leads_controller_spec.rb +85 -85
  180. data/spec/controllers/entities/opportunities_controller_spec.rb +74 -74
  181. data/spec/controllers/home_controller_spec.rb +11 -11
  182. data/spec/controllers/passwords_controller_spec.rb +2 -2
  183. data/spec/controllers/tasks_controller_spec.rb +37 -37
  184. data/spec/controllers/users_controller_spec.rb +31 -31
  185. data/spec/factories/campaign_factories.rb +1 -1
  186. data/spec/factories/contact_factories.rb +1 -1
  187. data/spec/factories/field_factories.rb +1 -1
  188. data/spec/factories/lead_factories.rb +2 -2
  189. data/spec/factories/opportunity_factories.rb +3 -3
  190. data/spec/factories/shared_factories.rb +1 -1
  191. data/spec/factories/task_factories.rb +1 -1
  192. data/spec/features/support/browser.rb +9 -1
  193. data/spec/lib/fields_spec.rb +2 -2
  194. data/spec/lib/permissions_spec.rb +38 -6
  195. data/spec/lib/view_factory_spec.rb +2 -2
  196. data/spec/models/fields/custom_field_spec.rb +3 -3
  197. data/spec/models/observers/entity_observer_spec.rb +1 -1
  198. data/spec/models/polymorphic/version_spec.rb +11 -11
  199. data/spec/models/users/abilities/user_ability_spec.rb +8 -3
  200. data/spec/models/users/permission_spec.rb +8 -0
  201. data/spec/models/users/user_spec.rb +1 -1
  202. data/spec/shared/controllers.rb +10 -10
  203. data/spec/spec_helper.rb +1 -1
  204. data/spec/views/accounts/index.haml_spec.rb +1 -1
  205. data/spec/views/accounts/update.js.haml_spec.rb +2 -2
  206. data/spec/views/admin/users/update.js.haml_spec.rb +2 -2
  207. data/spec/views/application/auto_complete.haml_spec.rb +1 -1
  208. data/spec/views/campaigns/index.haml_spec.rb +1 -1
  209. data/spec/views/campaigns/update.js.haml_spec.rb +2 -2
  210. data/spec/views/contacts/index.haml_spec.rb +1 -1
  211. data/spec/views/contacts/update.js.haml_spec.rb +2 -2
  212. data/spec/views/home/options.js.haml_spec.rb +1 -1
  213. data/spec/views/leads/index.haml_spec.rb +1 -1
  214. data/spec/views/leads/promote.js.haml_spec.rb +2 -2
  215. data/spec/views/leads/update.js.haml_spec.rb +2 -2
  216. data/spec/views/opportunities/index.haml_spec.rb +1 -1
  217. data/spec/views/opportunities/update.js.haml_spec.rb +1 -1
  218. data/spec/views/tasks/_edit.haml_spec.rb +2 -2
  219. data/spec/views/tasks/create.js.haml_spec.rb +2 -2
  220. data/spec/views/tasks/edit.js.haml_spec.rb +1 -1
  221. data/spec/views/users/change_password.js.haml_spec.rb +2 -2
  222. data/spec/views/users/update.js.haml_spec.rb +2 -2
  223. data/spec/views/users/upload_avatar.js.haml_spec.rb +2 -2
  224. metadata +17 -20
  225. data/lib/fat_free_crm/gem_ext/active_record/schema_dumper.rb +0 -27
@@ -47,7 +47,7 @@ describe AuthenticationsController do
47
47
 
48
48
  describe "POST authentication" do
49
49
  it "displays 'must be logged out message' and redirects to profile page" do
50
- post :create, authentication: @login
50
+ post :create, params: { authentication: @login }
51
51
  expect(flash[:notice]).not_to eq(nil)
52
52
  expect(flash[:notice]).to match(/^You must be logged out/)
53
53
  expect(response).to redirect_to(profile_path)
@@ -75,7 +75,7 @@ describe AuthenticationsController do
75
75
  @user = FactoryGirl.create(:user, username: "user", password: "pass", password_confirmation: "pass", login_count: 0)
76
76
  allow(@authentication).to receive(:user).and_return(@user)
77
77
 
78
- post :create, authentication: @login
78
+ post :create, params: { authentication: @login }
79
79
  expect(flash[:notice]).not_to eq(nil)
80
80
  expect(flash[:notice]).not_to match(/last login/)
81
81
  expect(response).to redirect_to(root_path)
@@ -85,7 +85,7 @@ describe AuthenticationsController do
85
85
  @user = FactoryGirl.create(:user, username: "user", password: "pass", password_confirmation: "pass", login_count: 42)
86
86
  allow(@authentication).to receive(:user).and_return(@user)
87
87
 
88
- post :create, authentication: @login
88
+ post :create, params: { authentication: @login }
89
89
  expect(flash[:notice]).to match(/last login/)
90
90
  expect(response).to redirect_to(root_path)
91
91
  end
@@ -99,7 +99,7 @@ describe AuthenticationsController do
99
99
  allow(@authentication).to receive(:save).and_return(false) # <--- Authentication failure.
100
100
  allow(Authentication).to receive(:new).and_return(@authentication)
101
101
 
102
- post :create, authentication: @login
102
+ post :create, params: { authentication: @login }
103
103
  expect(flash[:warning]).not_to eq(nil)
104
104
  expect(response).to redirect_to(action: :new)
105
105
  end
@@ -116,7 +116,7 @@ describe AuthenticationsController do
116
116
  @user = FactoryGirl.create(:user, username: "user", password: "pass", password_confirmation: "pass", suspended_at: Date.yesterday, login_count: 0, last_login_at: nil, last_login_ip: nil)
117
117
  allow(@authentication).to receive(:user).and_return(@user)
118
118
 
119
- post :create, authentication: @login
119
+ post :create, params: { authentication: @login }
120
120
  expect(@authentication.user.login_count).to eq(0)
121
121
  expect(@authentication.user.last_login_at).to be_nil
122
122
  expect(@authentication.user.last_login_ip).to be_nil
@@ -126,7 +126,7 @@ describe AuthenticationsController do
126
126
  @user = FactoryGirl.create(:user, username: "user", password: "pass", password_confirmation: "pass", suspended_at: Date.yesterday)
127
127
  allow(@authentication).to receive(:user).and_return(@user)
128
128
 
129
- post :create, authentication: @login
129
+ post :create, params: { authentication: @login }
130
130
  expect(flash[:warning]).not_to eq(nil) # Invalid username/password.
131
131
  expect(flash[:notice]).to eq(nil) # Not approved yet.
132
132
  expect(response).to redirect_to(action: :new)
@@ -137,12 +137,12 @@ describe AuthenticationsController do
137
137
  @user = FactoryGirl.create(:user, username: "user", password: "pass", password_confirmation: "pass", suspended_at: Date.yesterday, login_count: 0)
138
138
  allow(@authentication).to receive(:user).and_return(@user)
139
139
 
140
- post :create, authentication: @login
140
+ post :create, params: { authentication: @login }
141
141
  expect(flash[:warning]).to eq(nil) # Invalid username/password.
142
142
  expect(flash[:notice]).not_to eq(nil) # Not approved yet.
143
143
  expect(response).to redirect_to(action: :new)
144
144
  end
145
145
  end
146
- end # authentication failure
147
- end # POST authenticate
146
+ end
147
+ end
148
148
  end
@@ -6,7 +6,7 @@
6
6
  require 'spec_helper'
7
7
 
8
8
  describe CommentsController do
9
- COMMENTABLE = [:account, :campaign, :contact, :lead, :opportunity].freeze
9
+ COMMENTABLE = %i[account campaign contact lead opportunity].freeze
10
10
 
11
11
  before(:each) do
12
12
  require_user
@@ -23,16 +23,16 @@ describe CommentsController do
23
23
  end
24
24
 
25
25
  it "should redirect to the asset landing page if the asset is found" do
26
- get :index, :"#{asset}_id" => @asset.id
26
+ get :index, params: { :"#{asset}_id" => @asset.id }
27
27
  expect(response).to redirect_to(controller: asset.to_s.pluralize, action: :show, id: @asset.id)
28
28
  end
29
29
 
30
30
  it "should redirect to root url with warning if the asset is not found" do
31
- get :index, :"#{asset}_id" => @asset.id + 42
31
+ get :index, params: { :"#{asset}_id" => @asset.id + 42 }
32
32
  expect(flash[:warning]).not_to eq(nil)
33
33
  expect(response).to redirect_to(root_path)
34
34
  end
35
- end # HTML
35
+ end
36
36
 
37
37
  describe "(JSON)" do
38
38
  before(:each) do
@@ -42,16 +42,16 @@ describe CommentsController do
42
42
  end
43
43
 
44
44
  it "should render all comments as JSON if the asset is found found" do
45
- get :index, :"#{asset}_id" => @asset.id
45
+ get :index, params: { :"#{asset}_id" => @asset.id }
46
46
  expect(response.body).to eq(assigns[:comments].to_json)
47
47
  end
48
48
 
49
49
  it "JSON: should return 404 (Not Found) JSON error if the asset is not found" do
50
- get :index, :"#{asset}_id" => @asset.id + 42
50
+ get :index, params: { :"#{asset}_id" => @asset.id + 42 }
51
51
  expect(flash[:warning]).not_to eq(nil)
52
52
  expect(response.code).to eq("404")
53
53
  end
54
- end # JSON
54
+ end
55
55
 
56
56
  describe "(XML)" do
57
57
  before(:each) do
@@ -61,17 +61,17 @@ describe CommentsController do
61
61
  end
62
62
 
63
63
  it "should render all comments as XML if the asset is found found" do
64
- get :index, :"#{asset}_id" => @asset.id
64
+ get :index, params: { :"#{asset}_id" => @asset.id }
65
65
  expect(response.body).to eq(assigns[:comments].to_xml)
66
66
  end
67
67
 
68
68
  it "XML: should return 404 (Not Found) XML error if the asset is not found" do
69
- get :index, :"#{asset}_id" => @asset.id + 42
69
+ get :index, params: { :"#{asset}_id" => @asset.id + 42 }
70
70
  expect(flash[:warning]).not_to eq(nil)
71
71
  expect(response.code).to eq("404")
72
72
  end
73
- end # XML
74
- end # COMMENTABLE.each
73
+ end
74
+ end
75
75
  end
76
76
 
77
77
  # GET /comments/1/edit AJAX
@@ -83,7 +83,7 @@ describe CommentsController do
83
83
  @comment = FactoryGirl.create(:comment, id: 42, commentable: @asset, user: current_user)
84
84
  allow(Comment).to receive(:new).and_return(@comment)
85
85
 
86
- xhr :get, :edit, id: 42
86
+ get :edit, params: { id: 42 }, xhr: true
87
87
  expect(assigns[:comment]).to eq(@comment)
88
88
  expect(response).to render_template("comments/edit")
89
89
  end
@@ -101,7 +101,7 @@ describe CommentsController do
101
101
  @comment = FactoryGirl.build(:comment, commentable: @asset, user: current_user)
102
102
  allow(Comment).to receive(:new).and_return(@comment)
103
103
 
104
- xhr :post, :create, comment: { commentable_type: asset.to_s.classify, commentable_id: @asset.id, user_id: current_user.id, comment: "Hello" }
104
+ post :create, params: { comment: { commentable_type: asset.to_s.classify, commentable_id: @asset.id, user_id: current_user.id, comment: "Hello" } }, xhr: true
105
105
  expect(assigns[:comment]).to eq(@comment)
106
106
  expect(response).to render_template("comments/create")
107
107
  end
@@ -115,7 +115,7 @@ describe CommentsController do
115
115
  @comment = FactoryGirl.build(:comment, commentable: @asset, user: current_user)
116
116
  allow(Comment).to receive(:new).and_return(@comment)
117
117
 
118
- xhr :post, :create, comment: {}
118
+ post :create, params: { comment: {} }, xhr: true
119
119
  expect(assigns[:comment]).to eq(@comment)
120
120
  expect(response).to render_template("comments/create")
121
121
  end
@@ -182,7 +182,7 @@ describe CommentsController do
182
182
  @comment = FactoryGirl.create(:comment, commentable: @asset, user: current_user)
183
183
  allow(Comment).to receive(:new).and_return(@comment)
184
184
 
185
- xhr :delete, :destroy, id: @comment.id
185
+ delete :destroy, params: { id: @comment.id }, xhr: true
186
186
  expect { Comment.find(@comment.id) }.to raise_error(ActiveRecord::RecordNotFound)
187
187
  expect(response).to render_template("comments/destroy")
188
188
  end
@@ -6,7 +6,7 @@
6
6
  require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
7
7
 
8
8
  describe EmailsController, "handling GET /emails" do
9
- MEDIATOR = [:account, :campaign, :contact, :lead, :opportunity].freeze
9
+ MEDIATOR = %i[account campaign contact lead opportunity].freeze
10
10
 
11
11
  before(:each) do
12
12
  require_user
@@ -24,7 +24,7 @@ describe EmailsController, "handling GET /emails" do
24
24
  @email = FactoryGirl.create(:email, mediator: @asset, user: current_user)
25
25
  allow(Email).to receive(:new).and_return(@email)
26
26
 
27
- xhr :delete, :destroy, id: @email.id
27
+ delete :destroy, params: { id: @email.id }, xhr: true
28
28
  expect { Email.find(@email.id) }.to raise_error(ActiveRecord::RecordNotFound)
29
29
  expect(response).to render_template("emails/destroy")
30
30
  end
@@ -38,7 +38,7 @@ describe AccountsController do
38
38
  end
39
39
 
40
40
  it "should filter out accounts by category" do
41
- categories = %w(customer vendor)
41
+ categories = %w[customer vendor]
42
42
  controller.session[:accounts_filter] = categories.join(',')
43
43
  @accounts = [
44
44
  FactoryGirl.create(:account, user: current_user, category: categories.first),
@@ -55,7 +55,7 @@ describe AccountsController do
55
55
  @first = FactoryGirl.create(:account, user: current_user, name: "The first one")
56
56
  @second = FactoryGirl.create(:account, user: current_user, name: "The second one")
57
57
 
58
- get :index, query: "second"
58
+ get :index, params: { query: "second" }
59
59
  expect(assigns[:accounts]).to eq([@second])
60
60
  expect(assigns[:current_query]).to eq("second")
61
61
  expect(session[:accounts_current_query]).to eq("second")
@@ -64,7 +64,7 @@ describe AccountsController do
64
64
  describe "AJAX pagination" do
65
65
  it "should pick up page number from params" do
66
66
  @accounts = [FactoryGirl.create(:account, user: current_user)]
67
- xhr :get, :index, page: 42
67
+ get :index, params: { page: 42 }, xhr: true
68
68
 
69
69
  expect(assigns[:current_page].to_i).to eq(42)
70
70
  expect(assigns[:accounts]).to eq([]) # page #42 should be empty if there's only one account ;-)
@@ -75,7 +75,7 @@ describe AccountsController do
75
75
  it "should pick up saved page number from session" do
76
76
  session[:accounts_current_page] = 42
77
77
  @accounts = [FactoryGirl.create(:account, user: current_user)]
78
- xhr :get, :index
78
+ get :index, xhr: true
79
79
 
80
80
  expect(assigns[:current_page]).to eq(42)
81
81
  expect(assigns[:accounts]).to eq([])
@@ -86,7 +86,7 @@ describe AccountsController do
86
86
  session[:accounts_current_page] = 42
87
87
  session[:accounts_current_query] = "bill"
88
88
  @accounts = [FactoryGirl.create(:account, user: current_user)]
89
- xhr :get, :index
89
+ get :index, xhr: true
90
90
 
91
91
  expect(assigns[:current_page]).to eq(1)
92
92
  expect(assigns[:accounts]).to eq(@accounts)
@@ -129,7 +129,7 @@ describe AccountsController do
129
129
  end
130
130
 
131
131
  it "should expose the requested account as @account and render [show] template" do
132
- get :show, id: @account.id
132
+ get :show, params: { id: @account.id }
133
133
  expect(assigns[:account]).to eq(@account)
134
134
  expect(assigns[:stage]).to eq(@stage)
135
135
  expect(assigns[:comment].attributes).to eq(@comment.attributes)
@@ -137,7 +137,7 @@ describe AccountsController do
137
137
  end
138
138
 
139
139
  it "should update an activity when viewing the account" do
140
- get :show, id: @account.id
140
+ get :show, params: { id: @account.id }
141
141
  expect(@account.versions.last.event).to eq('view')
142
142
  end
143
143
  end
@@ -149,7 +149,7 @@ describe AccountsController do
149
149
  expect(@account).to receive(:to_json).and_return("generated JSON")
150
150
 
151
151
  request.env["HTTP_ACCEPT"] = "application/json"
152
- get :show, id: 42
152
+ get :show, params: { id: 42 }
153
153
  expect(response.body).to eq("generated JSON")
154
154
  end
155
155
  end
@@ -161,7 +161,7 @@ describe AccountsController do
161
161
  expect(@account).to receive(:to_xml).and_return("generated XML")
162
162
 
163
163
  request.env["HTTP_ACCEPT"] = "application/xml"
164
- get :show, id: 42
164
+ get :show, params: { id: 42 }
165
165
  expect(response.body).to eq("generated XML")
166
166
  end
167
167
  end
@@ -171,7 +171,7 @@ describe AccountsController do
171
171
  @account = FactoryGirl.create(:account, user: current_user)
172
172
  @account.destroy
173
173
 
174
- get :show, id: @account.id
174
+ get :show, params: { id: @account.id }
175
175
  expect(flash[:warning]).not_to eq(nil)
176
176
  expect(response).to redirect_to(accounts_path)
177
177
  end
@@ -179,7 +179,7 @@ describe AccountsController do
179
179
  it "should redirect to account index if the account is protected" do
180
180
  @private = FactoryGirl.create(:account, user: FactoryGirl.create(:user), access: "Private")
181
181
 
182
- get :show, id: @private.id
182
+ get :show, params: { id: @private.id }
183
183
  expect(flash[:warning]).not_to eq(nil)
184
184
  expect(response).to redirect_to(accounts_path)
185
185
  end
@@ -189,7 +189,7 @@ describe AccountsController do
189
189
  @account.destroy
190
190
  request.env["HTTP_ACCEPT"] = "application/json"
191
191
 
192
- get :show, id: @account.id
192
+ get :show, params: { id: @account.id }
193
193
  expect(response.code).to eq("404") # :not_found
194
194
  end
195
195
 
@@ -198,7 +198,7 @@ describe AccountsController do
198
198
  @account.destroy
199
199
  request.env["HTTP_ACCEPT"] = "application/xml"
200
200
 
201
- get :show, id: @account.id
201
+ get :show, params: { id: @account.id }
202
202
  expect(response.code).to eq("404") # :not_found
203
203
  end
204
204
  end
@@ -211,7 +211,7 @@ describe AccountsController do
211
211
  it "should expose a new account as @account and render [new] template" do
212
212
  @account = Account.new(user: current_user,
213
213
  access: Setting.default_access)
214
- xhr :get, :new
214
+ get :new, xhr: true
215
215
  expect(assigns[:account].attributes).to eq(@account.attributes)
216
216
  expect(assigns[:contact]).to eq(nil)
217
217
  expect(response).to render_template("accounts/new")
@@ -220,7 +220,7 @@ describe AccountsController do
220
220
  it "should created an instance of related object when necessary" do
221
221
  @contact = FactoryGirl.create(:contact, id: 42)
222
222
 
223
- xhr :get, :new, related: "contact_42"
223
+ get :new, params: { related: "contact_42" }, xhr: true
224
224
  expect(assigns[:contact]).to eq(@contact)
225
225
  end
226
226
  end
@@ -231,7 +231,7 @@ describe AccountsController do
231
231
  it "should expose the requested account as @account and render [edit] template" do
232
232
  @account = FactoryGirl.create(:account, id: 42, user: current_user)
233
233
 
234
- xhr :get, :edit, id: 42
234
+ get :edit, params: { id: 42 }, xhr: true
235
235
  expect(assigns[:account]).to eq(@account)
236
236
  expect(assigns[:previous]).to eq(nil)
237
237
  expect(response).to render_template("accounts/edit")
@@ -241,7 +241,7 @@ describe AccountsController do
241
241
  @account = FactoryGirl.create(:account, id: 42)
242
242
  @previous = FactoryGirl.create(:account, id: 41)
243
243
 
244
- xhr :get, :edit, id: 42, previous: 41
244
+ get :edit, params: { id: 42, previous: 41 }, xhr: true
245
245
  expect(assigns[:previous]).to eq(@previous)
246
246
  end
247
247
 
@@ -250,7 +250,7 @@ describe AccountsController do
250
250
  @account = FactoryGirl.create(:account, user: current_user)
251
251
  @account.destroy
252
252
 
253
- xhr :get, :edit, id: @account.id
253
+ get :edit, params: { id: @account.id }, xhr: true
254
254
  expect(flash[:warning]).not_to eq(nil)
255
255
  expect(response.body).to eq("window.location.reload();")
256
256
  end
@@ -258,7 +258,7 @@ describe AccountsController do
258
258
  it "should reload current page with the flash message if the account is protected" do
259
259
  @private = FactoryGirl.create(:account, user: FactoryGirl.create(:user), access: "Private")
260
260
 
261
- xhr :get, :edit, id: @private.id
261
+ get :edit, params: { id: @private.id }, xhr: true
262
262
  expect(flash[:warning]).not_to eq(nil)
263
263
  expect(response.body).to eq("window.location.reload();")
264
264
  end
@@ -273,7 +273,7 @@ describe AccountsController do
273
273
  it "should notify the view if previous account got deleted" do
274
274
  @previous.destroy
275
275
 
276
- xhr :get, :edit, id: @account.id, previous: @previous.id
276
+ get :edit, params: { id: @account.id, previous: @previous.id }, xhr: true
277
277
  expect(flash[:warning]).to eq(nil) # no warning, just silently remove the div
278
278
  expect(assigns[:previous]).to eq(@previous.id)
279
279
  expect(response).to render_template("accounts/edit")
@@ -282,7 +282,7 @@ describe AccountsController do
282
282
  it "should notify the view if previous account got protected" do
283
283
  @previous.update_attribute(:access, "Private")
284
284
 
285
- xhr :get, :edit, id: @account.id, previous: @previous.id
285
+ get :edit, params: { id: @account.id, previous: @previous.id }, xhr: true
286
286
  expect(flash[:warning]).to eq(nil)
287
287
  expect(assigns[:previous]).to eq(@previous.id)
288
288
  expect(response).to render_template("accounts/edit")
@@ -299,7 +299,7 @@ describe AccountsController do
299
299
  @account = FactoryGirl.build(:account, name: "Hello world", user: current_user)
300
300
  allow(Account).to receive(:new).and_return(@account)
301
301
 
302
- xhr :post, :create, account: { name: "Hello world" }
302
+ post :create, params: { account: { name: "Hello world" } }, xhr: true
303
303
  expect(assigns(:account)).to eq(@account)
304
304
  expect(response).to render_template("accounts/create")
305
305
  end
@@ -309,7 +309,7 @@ describe AccountsController do
309
309
  @account = FactoryGirl.build(:account, user: current_user)
310
310
  allow(Account).to receive(:new).and_return(@account)
311
311
 
312
- xhr :post, :create, account: { name: "Hello" }
312
+ post :create, params: { account: { name: "Hello" } }, xhr: true
313
313
  expect(assigns[:accounts]).to eq([@account])
314
314
  end
315
315
 
@@ -317,7 +317,7 @@ describe AccountsController do
317
317
  @account = FactoryGirl.build(:account, name: "Hello", user: current_user)
318
318
  allow(Campaign).to receive(:new).and_return(@account)
319
319
 
320
- xhr :post, :create, account: { name: "Hello" }
320
+ post :create, params: { account: { name: "Hello" } }, xhr: true
321
321
  expect(assigns[:account_category_total]).to be_instance_of(HashWithIndifferentAccess)
322
322
  end
323
323
 
@@ -325,7 +325,7 @@ describe AccountsController do
325
325
  @account = FactoryGirl.build(:account, name: "Hello world", user: current_user)
326
326
  allow(Account).to receive(:new).and_return(@account)
327
327
 
328
- xhr :post, :create, account: { name: "Hello world" }, comment_body: "Awesome comment is awesome"
328
+ post :create, params: { account: { name: "Hello world" }, comment_body: "Awesome comment is awesome" }, xhr: true
329
329
  expect(assigns[:account].comments.map(&:comment)).to include("Awesome comment is awesome")
330
330
  end
331
331
  end
@@ -335,7 +335,7 @@ describe AccountsController do
335
335
  @account = FactoryGirl.build(:account, name: nil, user: nil)
336
336
  allow(Account).to receive(:new).and_return(@account)
337
337
 
338
- xhr :post, :create, account: {}
338
+ post :create, params: { account: {} }, xhr: true
339
339
  expect(assigns(:account)).to eq(@account)
340
340
  expect(response).to render_template("accounts/create")
341
341
  end
@@ -350,7 +350,7 @@ describe AccountsController do
350
350
  it "should update the requested account, expose the requested account as @account, and render [update] template" do
351
351
  @account = FactoryGirl.create(:account, id: 42, name: "Hello people")
352
352
 
353
- xhr :put, :update, id: 42, account: { name: "Hello world" }
353
+ put :update, params: { id: 42, account: { name: "Hello world" } }, xhr: true
354
354
  expect(@account.reload.name).to eq("Hello world")
355
355
  expect(assigns(:account)).to eq(@account)
356
356
  expect(response).to render_template("accounts/update")
@@ -360,7 +360,7 @@ describe AccountsController do
360
360
  @account = FactoryGirl.create(:account, id: 42)
361
361
  request.env["HTTP_REFERER"] = "http://localhost/accounts"
362
362
 
363
- xhr :put, :update, id: 42, account: { name: "Hello" }
363
+ put :update, params: { id: 42, account: { name: "Hello" } }, xhr: true
364
364
  expect(assigns(:account)).to eq(@account)
365
365
  expect(assigns[:account_category_total]).to be_instance_of(HashWithIndifferentAccess)
366
366
  end
@@ -368,7 +368,7 @@ describe AccountsController do
368
368
  it "should update account permissions when sharing with specific users" do
369
369
  @account = FactoryGirl.create(:account, id: 42, access: "Public")
370
370
 
371
- xhr :put, :update, id: 42, account: { name: "Hello", access: "Shared", user_ids: [7, 8] }
371
+ put :update, params: { id: 42, account: { name: "Hello", access: "Shared", user_ids: [7, 8] } }, xhr: true
372
372
  expect(assigns[:account].access).to eq("Shared")
373
373
  expect(assigns[:account].user_ids.sort).to eq([7, 8])
374
374
  end
@@ -378,7 +378,7 @@ describe AccountsController do
378
378
  @account = FactoryGirl.create(:account, user: current_user)
379
379
  @account.destroy
380
380
 
381
- xhr :put, :update, id: @account.id
381
+ put :update, params: { id: @account.id }, xhr: true
382
382
  expect(flash[:warning]).not_to eq(nil)
383
383
  expect(response.body).to eq("window.location.reload();")
384
384
  end
@@ -386,7 +386,7 @@ describe AccountsController do
386
386
  it "should reload current page with the flash message if the account is protected" do
387
387
  @private = FactoryGirl.create(:account, user: FactoryGirl.create(:user), access: "Private")
388
388
 
389
- xhr :put, :update, id: @private.id
389
+ put :update, params: { id: @private.id }, xhr: true
390
390
  expect(flash[:warning]).not_to eq(nil)
391
391
  expect(response.body).to eq("window.location.reload();")
392
392
  end
@@ -397,7 +397,7 @@ describe AccountsController do
397
397
  it "should not update the requested account but still expose the requested account as @account, and render [update] template" do
398
398
  @account = FactoryGirl.create(:account, id: 42, name: "Hello people")
399
399
 
400
- xhr :put, :update, id: 42, account: { name: nil }
400
+ put :update, params: { id: 42, account: { name: nil } }, xhr: true
401
401
  expect(assigns(:account).reload.name).to eq("Hello people")
402
402
  expect(assigns(:account)).to eq(@account)
403
403
  expect(response).to render_template("accounts/update")
@@ -416,7 +416,7 @@ describe AccountsController do
416
416
  describe "AJAX request" do
417
417
  it "should destroy the requested account and render [destroy] template" do
418
418
  @another_account = FactoryGirl.create(:account, user: current_user)
419
- xhr :delete, :destroy, id: @account.id
419
+ delete :destroy, params: { id: @account.id }, xhr: true
420
420
 
421
421
  expect { Account.find(@account.id) }.to raise_error(ActiveRecord::RecordNotFound)
422
422
  expect(assigns[:accounts]).to eq([@another_account]) # @account got deleted
@@ -424,7 +424,7 @@ describe AccountsController do
424
424
  end
425
425
 
426
426
  it "should get data for accounts sidebar" do
427
- xhr :delete, :destroy, id: @account.id
427
+ delete :destroy, params: { id: @account.id }, xhr: true
428
428
 
429
429
  expect(assigns[:account_category_total]).to be_instance_of(HashWithIndifferentAccess)
430
430
  end
@@ -432,7 +432,7 @@ describe AccountsController do
432
432
  it "should try previous page and render index action if current page has no accounts" do
433
433
  session[:accounts_current_page] = 42
434
434
 
435
- xhr :delete, :destroy, id: @account.id
435
+ delete :destroy, params: { id: @account.id }, xhr: true
436
436
  expect(session[:accounts_current_page]).to eq(41)
437
437
  expect(response).to render_template("accounts/index")
438
438
  end
@@ -440,7 +440,7 @@ describe AccountsController do
440
440
  it "should render index action when deleting last account" do
441
441
  session[:accounts_current_page] = 1
442
442
 
443
- xhr :delete, :destroy, id: @account.id
443
+ delete :destroy, params: { id: @account.id }, xhr: true
444
444
  expect(session[:accounts_current_page]).to eq(1)
445
445
  expect(response).to render_template("accounts/index")
446
446
  end
@@ -450,7 +450,7 @@ describe AccountsController do
450
450
  @account = FactoryGirl.create(:account, user: current_user)
451
451
  @account.destroy
452
452
 
453
- xhr :delete, :destroy, id: @account.id
453
+ delete :destroy, params: { id: @account.id }, xhr: true
454
454
  expect(flash[:warning]).not_to eq(nil)
455
455
  expect(response.body).to eq("window.location.reload();")
456
456
  end
@@ -458,7 +458,7 @@ describe AccountsController do
458
458
  it "should reload current page with the flash message if the account is protected" do
459
459
  @private = FactoryGirl.create(:account, user: FactoryGirl.create(:user), access: "Private")
460
460
 
461
- xhr :delete, :destroy, id: @private.id
461
+ delete :destroy, params: { id: @private.id }, xhr: true
462
462
  expect(flash[:warning]).not_to eq(nil)
463
463
  expect(response.body).to eq("window.location.reload();")
464
464
  end
@@ -467,7 +467,7 @@ describe AccountsController do
467
467
 
468
468
  describe "HTML request" do
469
469
  it "should redirect to Accounts index when an account gets deleted from its landing page" do
470
- delete :destroy, id: @account.id
470
+ delete :destroy, params: { id: @account.id }
471
471
 
472
472
  expect(flash[:notice]).not_to eq(nil)
473
473
  expect(response).to redirect_to(accounts_path)
@@ -477,7 +477,7 @@ describe AccountsController do
477
477
  @account = FactoryGirl.create(:account, user: current_user)
478
478
  @account.destroy
479
479
 
480
- delete :destroy, id: @account.id
480
+ delete :destroy, params: { id: @account.id }
481
481
  expect(flash[:warning]).not_to eq(nil)
482
482
  expect(response).to redirect_to(accounts_path)
483
483
  end
@@ -485,7 +485,7 @@ describe AccountsController do
485
485
  it "should redirect to account index with the flash message if the account is protected" do
486
486
  @private = FactoryGirl.create(:account, user: FactoryGirl.create(:user), access: "Private")
487
487
 
488
- delete :destroy, id: @private.id
488
+ delete :destroy, params: { id: @private.id }
489
489
  expect(flash[:warning]).not_to eq(nil)
490
490
  expect(response).to redirect_to(accounts_path)
491
491
  end
@@ -560,14 +560,14 @@ describe AccountsController do
560
560
  #----------------------------------------------------------------------------
561
561
  describe "responding to GET redraw" do
562
562
  it "should save user selected account preference" do
563
- xhr :get, :redraw, per_page: 42, view: "brief", sort_by: "name"
563
+ get :redraw, params: { per_page: 42, view: "brief", sort_by: "name" }, xhr: true
564
564
  expect(current_user.preference[:accounts_per_page]).to eq("42")
565
565
  expect(current_user.preference[:accounts_index_view]).to eq("brief")
566
566
  expect(current_user.preference[:accounts_sort_by]).to eq("accounts.name ASC")
567
567
  end
568
568
 
569
569
  it "should reset current page to 1" do
570
- xhr :get, :redraw, per_page: 42, view: "brief", sort_by: "name"
570
+ get :redraw, params: { per_page: 42, view: "brief", sort_by: "name" }, xhr: true
571
571
  expect(session[:accounts_current_page]).to eq(1)
572
572
  end
573
573
 
@@ -577,7 +577,7 @@ describe AccountsController do
577
577
  FactoryGirl.create(:account, name: "B", user: current_user)
578
578
  ]
579
579
 
580
- xhr :get, :redraw, per_page: 1, sort_by: "name"
580
+ get :redraw, params: { per_page: 1, sort_by: "name" }, xhr: true
581
581
  expect(assigns(:accounts)).to eq([@accounts.first])
582
582
  expect(response).to render_template("accounts/index")
583
583
  end
@@ -590,14 +590,14 @@ describe AccountsController do
590
590
  session[:accounts_filter] = "customer,vendor"
591
591
  @accounts = [FactoryGirl.create(:account, category: "partner", user: current_user)]
592
592
 
593
- xhr :post, :filter, category: "partner"
593
+ post :filter, params: { category: "partner" }, xhr: true
594
594
  expect(assigns(:accounts)).to eq(@accounts)
595
595
  expect(response).to render_template("accounts/index")
596
596
  end
597
597
 
598
598
  it "should reset current page to 1" do
599
599
  @accounts = []
600
- xhr :post, :filter, category: "partner"
600
+ post :filter, params: { category: "partner" }, xhr: true
601
601
 
602
602
  expect(session[:accounts_current_page]).to eq(1)
603
603
  end