fat_free_crm 0.18.2 → 0.19.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 (251) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop_todo.yml +61 -160
  3. data/.travis.yml +27 -11
  4. data/CHANGELOG.md +40 -24
  5. data/CONTRIBUTORS.md +1 -0
  6. data/Dockerfile +45 -14
  7. data/Gemfile +16 -10
  8. data/Gemfile.lock +230 -222
  9. data/Procfile +1 -1
  10. data/README.md +2 -2
  11. data/Rakefile +1 -1
  12. data/app/assets/stylesheets/common.scss +1 -1
  13. data/app/controllers/admin/application_controller.rb +1 -1
  14. data/app/controllers/admin/field_groups_controller.rb +1 -3
  15. data/app/controllers/admin/tags_controller.rb +1 -3
  16. data/app/controllers/admin/users_controller.rb +5 -8
  17. data/app/controllers/application_controller.rb +11 -45
  18. data/app/controllers/comments_controller.rb +2 -5
  19. data/{config/initializers/authlogic.rb → app/controllers/confirmations_controller.rb} +4 -2
  20. data/app/controllers/emails_controller.rb +0 -2
  21. data/app/controllers/entities/accounts_controller.rb +1 -3
  22. data/app/controllers/entities/campaigns_controller.rb +1 -3
  23. data/app/controllers/entities/contacts_controller.rb +4 -24
  24. data/app/controllers/entities/leads_controller.rb +7 -10
  25. data/app/controllers/entities/opportunities_controller.rb +4 -14
  26. data/app/controllers/entities_controller.rb +21 -7
  27. data/app/controllers/home_controller.rb +2 -4
  28. data/app/controllers/passwords_controller.rb +3 -59
  29. data/{spec/features/support/maintain_sessions.rb → app/controllers/registrations_controller.rb} +12 -5
  30. data/{lib/development_tasks/gem.rake → app/controllers/sessions_controller.rb} +6 -6
  31. data/app/controllers/tasks_controller.rb +8 -17
  32. data/app/controllers/users_controller.rb +8 -29
  33. data/app/helpers/admin/users_helper.rb +1 -1
  34. data/app/helpers/application_helper.rb +27 -32
  35. data/app/helpers/campaigns_helper.rb +1 -1
  36. data/app/helpers/contacts_helper.rb +1 -3
  37. data/app/helpers/opportunities_helper.rb +4 -12
  38. data/app/helpers/tasks_helper.rb +1 -1
  39. data/app/helpers/users_helper.rb +1 -3
  40. data/{config/initializers/paper_trail.rb → app/mailers/devise_mailer.rb} +5 -1
  41. data/app/mailers/user_mailer.rb +0 -9
  42. data/app/models/entities/account.rb +10 -10
  43. data/app/models/entities/campaign.rb +4 -6
  44. data/app/models/entities/contact.rb +24 -12
  45. data/app/models/entities/lead.rb +7 -7
  46. data/app/models/entities/opportunity.rb +7 -9
  47. data/app/models/fields/custom_field.rb +1 -0
  48. data/app/models/fields/custom_field_date_pair.rb +2 -0
  49. data/app/models/fields/field.rb +1 -3
  50. data/app/models/list.rb +1 -1
  51. data/app/models/observers/entity_observer.rb +3 -7
  52. data/app/models/observers/lead_observer.rb +2 -4
  53. data/app/models/observers/opportunity_observer.rb +2 -4
  54. data/app/models/observers/task_observer.rb +1 -1
  55. data/app/models/polymorphic/email.rb +2 -2
  56. data/app/models/polymorphic/task.rb +13 -9
  57. data/app/models/polymorphic/version.rb +3 -2
  58. data/app/models/setting.rb +2 -0
  59. data/app/models/users/permission.rb +3 -3
  60. data/app/models/users/preference.rb +2 -1
  61. data/app/models/users/user.rb +67 -42
  62. data/app/views/accounts/_top_section.html.haml +1 -1
  63. data/app/views/accounts/edit.js.haml +1 -1
  64. data/app/views/accounts/update.js.haml +2 -2
  65. data/app/views/admin/users/_user.html.haml +4 -4
  66. data/app/views/contacts/_index_brief.html.haml +1 -1
  67. data/app/views/contacts/_index_full.html.haml +1 -1
  68. data/app/views/contacts/_index_long.html.haml +1 -1
  69. data/app/views/devise/confirmations/new.html.haml +9 -0
  70. data/app/views/devise/mailer/confirmation_instructions.html.haml +4 -0
  71. data/app/views/devise/mailer/password_change.html.haml +3 -0
  72. data/app/views/devise/mailer/reset_password_instructions.html.haml +6 -0
  73. data/app/views/devise/passwords/edit.html.haml +18 -0
  74. data/app/views/devise/passwords/new.html.haml +10 -0
  75. data/app/views/devise/registrations/new.html.haml +21 -0
  76. data/app/views/devise/sessions/new.html.haml +32 -0
  77. data/app/views/layouts/_about.html.haml +5 -5
  78. data/app/views/layouts/_header.html.haml +3 -3
  79. data/app/views/layouts/admin/_header.html.haml +1 -1
  80. data/app/views/shared/_address.html.haml +5 -5
  81. data/app/views/shared/_paginate_with_per_page.html.haml +1 -0
  82. data/app/views/users/_avatar.html.haml +1 -1
  83. data/bin/bundle +1 -1
  84. data/bin/rails +1 -1
  85. data/bin/setup +38 -0
  86. data/bin/update +33 -0
  87. data/bin/yarn +13 -0
  88. data/config/application.rb +8 -6
  89. data/config/boot.rb +1 -1
  90. data/config/brakeman.ignore +2 -2
  91. data/config/database.postgres.docker.yml +5 -5
  92. data/config/environment.rb +1 -1
  93. data/config/environments/development.rb +1 -0
  94. data/config/environments/test.rb +7 -0
  95. data/config/initializers/action_mailer.rb +1 -3
  96. data/config/initializers/application_controller_renderer.rb +9 -0
  97. data/config/initializers/assets.rb +6 -11
  98. data/config/initializers/backtrace_silencers.rb +0 -6
  99. data/config/initializers/content_security_policy.rb +26 -0
  100. data/config/initializers/cookies_serializer.rb +3 -6
  101. data/config/initializers/devise.rb +289 -0
  102. data/config/initializers/filter_parameter_logging.rb +0 -5
  103. data/config/initializers/gravatar.rb +0 -1
  104. data/config/initializers/inflections.rb +0 -6
  105. data/config/initializers/mime_types.rb +1 -9
  106. data/config/initializers/new_framework_defaults_5_2.rb +40 -0
  107. data/config/initializers/relative_url_root.rb +1 -3
  108. data/config/initializers/session_store.rb +1 -3
  109. data/config/initializers/wrap_parameters.rb +4 -9
  110. data/config/locales/fat_free_crm.en-GB.yml +5 -5
  111. data/config/locales/fat_free_crm.en-US.yml +5 -5
  112. data/config/locales/fat_free_crm.fr.yml +1 -1
  113. data/config/locales/fat_free_crm.ru.yml +1 -0
  114. data/config/routes.rb +20 -9
  115. data/db/demo/users.yml +62 -81
  116. data/db/migrate/20100928030620_remove_uuid.rb +1 -2
  117. data/db/migrate/20120316045804_activities_to_versions.rb +1 -0
  118. data/db/migrate/20120510025219_add_not_null_constraints_for_timestamp_columns.rb +1 -0
  119. data/db/migrate/20180107082701_authlogic_to_devise.rb +58 -0
  120. data/db/schema.rb +48 -43
  121. data/docker-compose.yml +10 -0
  122. data/fat_free_crm.gemspec +11 -13
  123. data/lib/development_tasks/license.rake +2 -2
  124. data/lib/fat_free_crm/callback.rb +2 -2
  125. data/lib/fat_free_crm/comment_extensions.rb +2 -4
  126. data/lib/fat_free_crm/core_ext/string.rb +1 -1
  127. data/lib/fat_free_crm/engine.rb +1 -1
  128. data/lib/fat_free_crm/errors.rb +1 -1
  129. data/lib/fat_free_crm/export_csv.rb +1 -0
  130. data/lib/fat_free_crm/exportable.rb +1 -1
  131. data/lib/fat_free_crm/fields.rb +1 -1
  132. data/lib/fat_free_crm/gem_dependencies.rb +1 -1
  133. data/lib/fat_free_crm/gem_ext/simple_form/action_view_extensions/form_helper.rb +1 -3
  134. data/lib/fat_free_crm/i18n.rb +2 -2
  135. data/lib/fat_free_crm/mail_processor/base.rb +4 -10
  136. data/lib/fat_free_crm/mail_processor/dropbox.rb +5 -15
  137. data/lib/fat_free_crm/permissions.rb +7 -4
  138. data/lib/fat_free_crm/sortable.rb +1 -1
  139. data/lib/fat_free_crm/tabs.rb +2 -2
  140. data/lib/fat_free_crm/version.rb +2 -2
  141. data/lib/gravatar_image_tag.rb +7 -8
  142. data/lib/missing_translation_detector.rb +1 -0
  143. data/lib/tasks/ffcrm/missing_translations.rake +1 -0
  144. data/lib/tasks/ffcrm/setup.rake +10 -1
  145. data/lib/tasks/ffcrm/update_data.rake +2 -2
  146. data/script/rails +2 -2
  147. data/spec/controllers/admin/users_controller_spec.rb +0 -56
  148. data/spec/controllers/comments_controller_spec.rb +6 -6
  149. data/spec/controllers/entities/campaigns_controller_spec.rb +1 -1
  150. data/spec/controllers/entities/contacts_controller_spec.rb +2 -1
  151. data/spec/controllers/entities/leads_controller_spec.rb +2 -2
  152. data/spec/controllers/entities/opportunities_controller_spec.rb +1 -1
  153. data/spec/controllers/entities_controller_spec.rb +5 -0
  154. data/spec/controllers/home_controller_spec.rb +5 -5
  155. data/spec/controllers/tasks_controller_spec.rb +6 -4
  156. data/spec/controllers/users_controller_spec.rb +28 -98
  157. data/spec/factories/account_factories.rb +5 -5
  158. data/spec/factories/campaign_factories.rb +3 -3
  159. data/spec/factories/contact_factories.rb +8 -8
  160. data/spec/factories/field_factories.rb +4 -3
  161. data/spec/factories/lead_factories.rb +5 -5
  162. data/spec/factories/list_factories.rb +2 -2
  163. data/spec/factories/opportunity_factories.rb +3 -3
  164. data/spec/factories/setting_factories.rb +2 -2
  165. data/spec/factories/shared_factories.rb +11 -9
  166. data/spec/factories/task_factories.rb +7 -7
  167. data/spec/factories/user_factories.rb +16 -19
  168. data/spec/features/admin/groups_spec.rb +1 -1
  169. data/spec/features/admin/users_spec.rb +3 -1
  170. data/spec/features/campaigns_spec.rb +1 -1
  171. data/spec/features/contacts_spec.rb +1 -1
  172. data/spec/features/dashboard_spec.rb +1 -1
  173. data/spec/features/devise/sign_in_spec.rb +58 -0
  174. data/spec/features/devise/sign_up_spec.rb +36 -0
  175. data/spec/features/leads_spec.rb +1 -1
  176. data/spec/features/opportunities_overview_spec.rb +1 -1
  177. data/spec/features/opportunities_spec.rb +3 -3
  178. data/spec/features/support/browser.rb +2 -1
  179. data/spec/features/tasks_spec.rb +1 -1
  180. data/spec/helpers/admin/field_groups_helper_spec.rb +1 -1
  181. data/spec/helpers/users_helper_spec.rb +4 -4
  182. data/spec/lib/comment_extensions_spec.rb +10 -4
  183. data/spec/lib/errors_spec.rb +2 -2
  184. data/spec/lib/mail_processor/dropbox_spec.rb +1 -1
  185. data/spec/lib/mail_processor/sample_emails/dropbox.rb +8 -8
  186. data/spec/lib/permissions_spec.rb +8 -3
  187. data/spec/mailers/devise_mailer_spec.rb +35 -0
  188. data/spec/mailers/user_mailer_spec.rb +0 -26
  189. data/spec/models/entities/account_spec.rb +27 -0
  190. data/spec/models/entities/contact_spec.rb +96 -1
  191. data/spec/models/fields/custom_field_date_pair_spec.rb +4 -2
  192. data/spec/models/fields/custom_field_spec.rb +4 -2
  193. data/spec/models/observers/entity_observer_spec.rb +1 -1
  194. data/spec/models/polymorphic/version_spec.rb +7 -7
  195. data/spec/models/users/user_spec.rb +22 -26
  196. data/spec/routing/users_routing_spec.rb +30 -8
  197. data/spec/shared/controllers.rb +3 -9
  198. data/spec/spec_helper.rb +10 -2
  199. data/spec/support/assert_select.rb +1 -0
  200. data/spec/support/devise_helpers.rb +28 -0
  201. data/spec/{features/support/helpers.rb → support/feature_helpers.rb} +10 -10
  202. data/spec/support/macros.rb +4 -1
  203. data/spec/views/contacts/update.js.haml_spec.rb +1 -1
  204. data/spec/views/opportunities/update.js.haml_spec.rb +1 -1
  205. data/vendor/gems/ransack_ui-1.3.4/.gitignore +17 -0
  206. data/vendor/gems/ransack_ui-1.3.4/Gemfile +7 -0
  207. data/vendor/gems/ransack_ui-1.3.4/LICENSE.txt +22 -0
  208. data/vendor/gems/ransack_ui-1.3.4/README.md +57 -0
  209. data/vendor/gems/ransack_ui-1.3.4/Rakefile +1 -0
  210. data/vendor/gems/ransack_ui-1.3.4/app/assets/images/ransack_ui/calendar.png +0 -0
  211. data/vendor/gems/ransack_ui-1.3.4/app/assets/images/ransack_ui/delete.png +0 -0
  212. data/vendor/gems/ransack_ui-1.3.4/app/assets/javascripts/ransack/predicates.js.coffee +41 -0
  213. data/vendor/gems/ransack_ui-1.3.4/app/assets/javascripts/ransack_ui_bootstrap/button_group_select.js.coffee +26 -0
  214. data/vendor/gems/ransack_ui-1.3.4/app/assets/javascripts/ransack_ui_bootstrap/index.js.coffee +2 -0
  215. data/vendor/gems/ransack_ui-1.3.4/app/assets/javascripts/ransack_ui_jquery/index.js +2 -0
  216. data/vendor/gems/ransack_ui-1.3.4/app/assets/javascripts/ransack_ui_jquery/search_form.js.coffee.erb +499 -0
  217. data/vendor/gems/ransack_ui-1.3.4/app/assets/stylesheets/ransack_ui_bootstrap/index.css +3 -0
  218. data/vendor/gems/ransack_ui-1.3.4/app/assets/stylesheets/ransack_ui_bootstrap/search.css.scss +41 -0
  219. data/vendor/gems/ransack_ui-1.3.4/app/views/ransack_ui/_condition_fields.html.erb +15 -0
  220. data/vendor/gems/ransack_ui-1.3.4/app/views/ransack_ui/_grouping_fields.html.erb +16 -0
  221. data/vendor/gems/ransack_ui-1.3.4/app/views/ransack_ui/_search.html.erb +29 -0
  222. data/vendor/gems/ransack_ui-1.3.4/app/views/ransack_ui/_sort_fields.html.erb +4 -0
  223. data/vendor/gems/ransack_ui-1.3.4/config/locales/en.yml +24 -0
  224. data/vendor/gems/ransack_ui-1.3.4/lib/ransack_ui.rb +9 -0
  225. data/vendor/gems/ransack_ui-1.3.4/lib/ransack_ui/adapters/active_record.rb +6 -0
  226. data/vendor/gems/ransack_ui-1.3.4/lib/ransack_ui/adapters/active_record/base.rb +46 -0
  227. data/vendor/gems/ransack_ui-1.3.4/lib/ransack_ui/controller_helpers.rb +18 -0
  228. data/vendor/gems/ransack_ui-1.3.4/lib/ransack_ui/rails/engine.rb +21 -0
  229. data/vendor/gems/ransack_ui-1.3.4/lib/ransack_ui/ransack_overrides/adapters/active_record/base.rb +47 -0
  230. data/vendor/gems/ransack_ui-1.3.4/lib/ransack_ui/ransack_overrides/configuration.rb +15 -0
  231. data/vendor/gems/ransack_ui-1.3.4/lib/ransack_ui/ransack_overrides/context.rb +9 -0
  232. data/vendor/gems/ransack_ui-1.3.4/lib/ransack_ui/ransack_overrides/helpers/form_builder.rb +262 -0
  233. data/vendor/gems/ransack_ui-1.3.4/lib/ransack_ui/ransack_overrides/nodes/attribute.rb +13 -0
  234. data/vendor/gems/ransack_ui-1.3.4/lib/ransack_ui/ransack_overrides/nodes/condition.rb +13 -0
  235. data/vendor/gems/ransack_ui-1.3.4/lib/ransack_ui/ransack_overrides/nodes/grouping.rb +20 -0
  236. data/vendor/gems/ransack_ui-1.3.4/lib/ransack_ui/version.rb +3 -0
  237. data/vendor/gems/ransack_ui-1.3.4/lib/ransack_ui/view_helpers.rb +30 -0
  238. data/vendor/gems/ransack_ui-1.3.4/ransack_ui.gemspec +23 -0
  239. metadata +79 -67
  240. data/app/controllers/authentications_controller.rb +0 -53
  241. data/app/models/users/authentication.rb +0 -56
  242. data/app/views/authentications/new.html.haml +0 -19
  243. data/app/views/passwords/edit.html.haml +0 -15
  244. data/app/views/passwords/new.html.haml +0 -10
  245. data/app/views/user_mailer/password_reset_instructions.html.haml +0 -6
  246. data/app/views/users/new.html.haml +0 -19
  247. data/spec/controllers/authentications_controller_spec.rb +0 -150
  248. data/spec/controllers/passwords_controller_spec.rb +0 -32
  249. data/spec/models/users/authentication_spec.rb +0 -19
  250. data/spec/support/auth_macros.rb +0 -49
  251. data/spec/views/authentications/new.haml_spec.rb +0 -31
@@ -11,7 +11,7 @@
11
11
  #
12
12
  # id :integer not null, primary key
13
13
  # username :string(32) default(""), not null
14
- # email :string(64) default(""), not null
14
+ # email :string(254) default(""), not null
15
15
  # first_name :string(32)
16
16
  # last_name :string(32)
17
17
  # title :string(64)
@@ -23,21 +23,27 @@
23
23
  # yahoo :string(32)
24
24
  # google :string(32)
25
25
  # skype :string(32)
26
- # password_hash :string(255) default(""), not null
26
+ # encrypted_password :string(255) default(""), not null
27
27
  # password_salt :string(255) default(""), not null
28
- # persistence_token :string(255) default(""), not null
29
- # perishable_token :string(255) default(""), not null
30
- # last_login_at :datetime
31
- # current_login_at :datetime
32
- # last_login_ip :string(255)
33
- # current_login_ip :string(255)
34
- # login_count :integer default(0), not null
28
+ # last_sign_in_at :datetime
29
+ # current_sign_in_at :datetime
30
+ # last_sign_in_ip :string(255)
31
+ # current_sign_in_ip :string(255)
32
+ # sign_in_count :integer default(0), not null
35
33
  # deleted_at :datetime
36
34
  # created_at :datetime
37
35
  # updated_at :datetime
38
36
  # admin :boolean default(FALSE), not null
39
37
  # suspended_at :datetime
40
- # single_access_token :string(255)
38
+ # unconfirmed_email :string(254) default(""), not null
39
+ # reset_password_token :string(255)
40
+ # reset_password_sent_at :datetime
41
+ # remember_token :string(255)
42
+ # remember_created_at :datetime
43
+ # authentication_token :string(255)
44
+ # confirmation_token :string(255)
45
+ # confirmed_at :datetime
46
+ # confirmation_sent_at :datetime
41
47
  #
42
48
 
43
49
  require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
@@ -75,6 +81,12 @@ describe User do
75
81
  end
76
82
  end
77
83
 
84
+ it "should not destroy the user if she owns a comment" do
85
+ account = build(:account, user: @current_user)
86
+ FactoryBot.create(:comment, user: @user, commentable: account)
87
+ expect(@user.destroyable?(@current_user)).to eq(false)
88
+ end
89
+
78
90
  it "should not destroy the current user" do
79
91
  expect(@user.destroyable?(@user)).to eq(false)
80
92
  end
@@ -202,22 +214,6 @@ describe User do
202
214
  end
203
215
  end
204
216
 
205
- describe "Setting single access token" do
206
- it "should update single_access_token attribute if it is not set already" do
207
- @user = build(:user, single_access_token: nil)
208
-
209
- @user.set_single_access_token
210
- expect(@user.single_access_token).not_to eq(nil)
211
- end
212
-
213
- it "should not update single_access_token attribute if it is set already" do
214
- @user = build(:user, single_access_token: "token")
215
-
216
- @user.set_single_access_token
217
- expect(@user.single_access_token).to eq("token")
218
- end
219
- end
220
-
221
217
  describe "serialization" do
222
218
  let(:user) { build(:user) }
223
219
 
@@ -9,12 +9,38 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
9
9
 
10
10
  describe UsersController do
11
11
  describe "routing" do
12
- it "doesn't recognize #index" do
13
- expect(get: "/users").not_to be_routable
12
+ it "recognizes #index" do
13
+ expect(get: "/users").to route_to(controller: "users", action: "index")
14
14
  end
15
15
 
16
- it "recognizes and generates #new as /signup" do
17
- expect(get: "/signup").to route_to(controller: "users", action: "new")
16
+ it "recognizes and generates Devise registrations routes" do
17
+ expect(get: "/users/sign_up").to route_to(controller: "registrations", action: "new")
18
+ expect(get: "/users/edit").to route_to(controller: "registrations", action: "edit")
19
+ expect(get: "/users/cancel").to route_to(controller: "registrations", action: "cancel")
20
+ expect(post: "/users").to route_to(controller: "registrations", action: "create")
21
+ expect(put: "/users").to route_to(controller: "registrations", action: "update")
22
+ expect(patch: "/users").to route_to(controller: "registrations", action: "update")
23
+ expect(delete: "/users").to route_to(controller: "registrations", action: "destroy")
24
+ end
25
+
26
+ it "recognizes and generates Devise sessions routes" do
27
+ expect(get: "/users/sign_in").to route_to(controller: "sessions", action: "new")
28
+ expect(post: "/users/sign_in").to route_to(controller: "sessions", action: "create")
29
+ expect(delete: "/users/sign_out").to route_to(controller: "sessions", action: "destroy")
30
+ end
31
+
32
+ it "recognizes and generates Devise passwords routes" do
33
+ expect(get: "/users/password/new").to route_to(controller: "passwords", action: "new")
34
+ expect(get: "/users/password/edit").to route_to(controller: "passwords", action: "edit")
35
+ expect(post: "/users/password").to route_to(controller: "passwords", action: "create")
36
+ expect(put: "/users/password").to route_to(controller: "passwords", action: "update")
37
+ expect(patch: "/users/password").to route_to(controller: "passwords", action: "update")
38
+ end
39
+
40
+ it "recognizes and generates Devise confirmations routes" do
41
+ expect(get: "/users/confirmation/new").to route_to(controller: "confirmations", action: "new")
42
+ expect(get: "/users/confirmation").to route_to(controller: "confirmations", action: "show")
43
+ expect(post: "/users/confirmation").to route_to(controller: "confirmations", action: "create")
18
44
  end
19
45
 
20
46
  it "recognizes and generates #show as /profile" do
@@ -29,10 +55,6 @@ describe UsersController do
29
55
  expect(get: "/users/aaron/edit").not_to be_routable
30
56
  end
31
57
 
32
- it "recognizes and generates #create" do
33
- expect(post: "/users").to route_to(controller: "users", action: "create")
34
- end
35
-
36
58
  it "recognizes and generates #update" do
37
59
  expect(put: "/users/1").to route_to(controller: "users", action: "update", id: "1")
38
60
  end
@@ -22,9 +22,7 @@ shared_examples "auto complete" do
22
22
 
23
23
  # We don't save Admin/Users autocomplete controller in a session since Users are not
24
24
  # exposed through the Jumpbox.
25
- unless controller.class.to_s.starts_with?("Admin::")
26
- expect(session[:auto_complete]).to eq(@controller.controller_name.to_sym)
27
- end
25
+ expect(session[:auto_complete]).to eq(@controller.controller_name.to_sym) unless controller.class.to_s.starts_with?("Admin::")
28
26
  end
29
27
 
30
28
  it "should render application/_auto_complete template" do
@@ -39,12 +37,8 @@ shared_examples "attach" do
39
37
  expect(@model.send(@attachment.class.name.tableize)).to include(@attachment)
40
38
  expect(assigns[:attachment]).to eq(@attachment)
41
39
  expect(assigns[:attached]).to eq([@attachment])
42
- if @model.is_a?(Campaign) && (@attachment.is_a?(Lead) || @attachment.is_a?(Opportunity))
43
- expect(assigns[:campaign]).to eq(@attachment.reload.campaign)
44
- end
45
- if @model.is_a?(Account) && @attachment.respond_to?(:account) # Skip Tasks...
46
- expect(assigns[:account]).to eq(@attachment.reload.account)
47
- end
40
+ expect(assigns[:campaign]).to eq(@attachment.reload.campaign) if @model.is_a?(Campaign) && (@attachment.is_a?(Lead) || @attachment.is_a?(Opportunity))
41
+ expect(assigns[:account]).to eq(@attachment.reload.account) if @model.is_a?(Account) && @attachment.respond_to?(:account) # Skip Tasks...
48
42
  expect(response).to render_template("entities/attach")
49
43
  end
50
44
 
data/spec/spec_helper.rb CHANGED
@@ -8,15 +8,15 @@
8
8
  require 'rubygems'
9
9
 
10
10
  ENV["RAILS_ENV"] = 'test'
11
- require File.expand_path("../../config/environment", __FILE__)
11
+ require File.expand_path('../config/environment', __dir__)
12
12
  require 'rspec/rails'
13
13
  require 'capybara/rails'
14
14
  require 'paper_trail/frameworks/rspec'
15
15
 
16
- require 'acts_as_fu'
17
16
  require 'factory_bot_rails'
18
17
  require 'ffaker'
19
18
  require 'timecop'
19
+ require 'webdrivers'
20
20
 
21
21
  # Requires supporting ruby files with custom matchers and macros, etc,
22
22
  # in spec/support/ and its subdirectories.
@@ -41,6 +41,14 @@ RSpec.configure do |config|
41
41
  # RSpec configuration options for Fat Free CRM.
42
42
  config.include RSpec::Rails::Matchers
43
43
  config.include FactoryBot::Syntax::Methods
44
+ config.include Devise::Test::ControllerHelpers, type: :controller
45
+ config.include Devise::Test::ControllerHelpers, type: :view
46
+ config.include Devise::Test::IntegrationHelpers, type: :features
47
+ config.include Warden::Test::Helpers
48
+ config.include DeviseHelpers
49
+ config.include FeatureHelpers
50
+
51
+ Warden.test_mode!
44
52
 
45
53
  config.before(:each) do
46
54
  # Overwrite locale settings within "config/settings.yml" if necessary.
@@ -155,6 +155,7 @@ module RSpec # :nodoc:
155
155
 
156
156
  def prepare_args(args, current_scope = nil)
157
157
  return args if current_scope.nil?
158
+
158
159
  defaults = current_scope.options || { strict: false, xml: false }
159
160
  args << {} unless args.last.is_a?(::Hash)
160
161
  args.last[:strict] = defaults[:strict] if args.last[:strict].nil?
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright (c) 2008-2013 Michael Dvorkin and contributors.
4
+ #
5
+ # Fat Free CRM is freely distributable under the terms of MIT license.
6
+ # See MIT-LICENSE file or http://www.opensource.org/licenses/mit-license.php
7
+
8
+ module DeviseHelpers
9
+ def login
10
+ user = create :user
11
+ perform_login(user)
12
+ end
13
+
14
+ def login_admin
15
+ admin = FactoryBot.create(:user, admin: true)
16
+ perform_login(admin)
17
+ end
18
+
19
+ def perform_login(user)
20
+ user.confirm
21
+ user.update_attribute(:suspended_at, nil)
22
+ sign_in user
23
+ end
24
+
25
+ def current_user
26
+ User.find_by_id(session['warden.user.user.key'][0][0])
27
+ end
28
+ end
@@ -5,21 +5,23 @@
5
5
  # Fat Free CRM is freely distributable under the terms of MIT license.
6
6
  # See MIT-LICENSE file or http://www.opensource.org/licenses/mit-license.php
7
7
  #------------------------------------------------------------------------------
8
- module HelperMethods
8
+
9
+ module FeatureHelpers
9
10
  # Put helper methods you need to be available in all acceptance specs here.
10
11
 
11
12
  def do_login(options = {})
12
13
  @user = create(:user, options)
13
- visit '/login'
14
- fill_in "authentication_username", with: @user.username
15
- fill_in "authentication_password", with: @user.password
16
- click_button "Login"
14
+ @user.confirm
15
+ @user.update_attribute(:suspended_at, nil)
16
+ login_as(@user)
17
17
  end
18
18
 
19
19
  def login_as_user(user)
20
- visit '/login'
21
- fill_in "authentication_username", with: user.username
22
- fill_in "authentication_password", with: user.password
20
+ user.confirm
21
+ user.update_attribute(:suspended_at, nil)
22
+ visit '/users/sign_in'
23
+ fill_in "user[email]", with: user.username
24
+ fill_in "user[password]", with: user.password
23
25
  click_button "Login"
24
26
  end
25
27
 
@@ -28,5 +30,3 @@ module HelperMethods
28
30
  do_login(options) unless @user.present?
29
31
  end
30
32
  end
31
-
32
- RSpec.configuration.include HelperMethods, type: :feature
@@ -24,7 +24,10 @@ end
24
24
  #----------------------------------------------------------------------------
25
25
  def stub_task_total(view = "pending")
26
26
  settings = (view == "completed" ? Setting.task_completed : Setting.task_bucket)
27
- settings.each_with_object(all: 0) { |key, hash| hash[key] = 1; hash }
27
+ settings.each_with_object(all: 0) do |key, hash|
28
+ hash[key] = 1
29
+ hash
30
+ end
28
31
  end
29
32
 
30
33
  # Get current server timezone and set it (see rake time:zones:local for details).
@@ -118,7 +118,7 @@ describe "/contacts/update" do
118
118
 
119
119
  it "errors: should show disabled accounts dropdown" do
120
120
  render
121
- expect(rendered).to include("crm.create_or_select_account(#{@referer =~ /\/accounts\//})")
121
+ expect(rendered).to include("crm.create_or_select_account(#{@referer =~ %r{/accounts/}})")
122
122
  end
123
123
 
124
124
  it "should redraw the [edit_contact] form and shake it" do
@@ -137,7 +137,7 @@ describe "/opportunities/update" do
137
137
 
138
138
  it "should show disabled accounts dropdown when called from accounts landing page" do
139
139
  render
140
- expect(rendered).to include("crm.create_or_select_account(#{@referer =~ /\/accounts\//})")
140
+ expect(rendered).to include("crm.create_or_select_account(#{@referer =~ %r{/accounts/}})")
141
141
  end
142
142
 
143
143
  it "should redraw the [edit_opportunity] form and shake it" do
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Include rake in Gemfile so that `bundle exec rake` doesn't raise an error
4
+ gem 'rake', :group => :test
5
+
6
+ # Specify your gem's dependencies in ransack_ui.gemspec
7
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Nathan Broadbent
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,57 @@
1
+ # Ransack UI
2
+
3
+ Provides HTML templates and JavaScript to build a fully functional
4
+ advanced search form using Ransack.
5
+
6
+ Please note: this project is still in *alpha* and the following instructions are not yet complete/fully working.
7
+
8
+ ## Installation
9
+
10
+ Add this line to your application's Gemfile:
11
+
12
+ gem 'ransack_ui'
13
+
14
+ And then execute:
15
+
16
+ $ bundle
17
+
18
+ Or install it yourself as:
19
+
20
+ $ gem install ransack_ui
21
+
22
+ ## Usage
23
+
24
+ Make your model ransackable (if you name associations, it will enable you to search them aswell).
25
+
26
+ ```ruby
27
+ has_ransackable_associations %w(account tags)
28
+ ransack_can_autocomplete
29
+ ```
30
+
31
+ In your controller, where you'd like to add search functionality, add the following before_filter hook. You can change the 'index' action if needed.
32
+
33
+ ```ruby
34
+ before_filter :load_ransack_search, :only => :index
35
+ ```
36
+
37
+ Insert the following helper call into your rails view code where you'd like the search form to appear.
38
+
39
+ ```ruby
40
+ = ransack_ui_search
41
+ ```
42
+
43
+ Now you can start playing with the results.
44
+
45
+ ## Contributing
46
+
47
+ 1. Fork it
48
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
49
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
50
+ 4. Push to the branch (`git push origin my-new-feature`)
51
+ 5. Create new Pull Request
52
+
53
+ ## Credits / Acknowledgements
54
+
55
+ * Nathan Broadbent (ndbroadbent) - creator of ransack_ui code
56
+ * Ernie Miller (ernie) for creating ransack - https://github.com/ernie/ransack
57
+ * Steve Kenworthy (steveyken) - for tiny tweaks
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,41 @@
1
+ window.Ransack ?= {}
2
+
3
+ Ransack.predicates =
4
+ eq: 'not_eq'
5
+ cont: 'not_cont'
6
+ matches: 'does_not_match'
7
+ start: 'not_start'
8
+ end: 'not_end'
9
+ present: 'blank'
10
+ null: 'not_null'
11
+ lt: 'gteq'
12
+ gt: 'lteq'
13
+ in: 'not_in'
14
+ true: 'false'
15
+
16
+ # Setup supported predicates for each column type.
17
+ Ransack.type_predicates = {}
18
+ ((o, f) -> f.call o) Ransack.type_predicates, ->
19
+ @text = @string = ['eq', 'cont', 'matches', 'start', 'end', 'present', 'in']
20
+ @boolean = ['true', 'null']
21
+ @integer = @float = @decimal = ['eq', 'null', 'lt', 'gt', 'in']
22
+ @date = @datetime = @time = ['eq', 'null', 'lt', 'gt']
23
+
24
+ # Setup input field types for each predicate
25
+ Ransack.predicate_inputs = {}
26
+ ((o, f) -> f.call o) Ransack.predicate_inputs, ->
27
+ @cont = @matches = @start = @end = @in = 'string'
28
+ @present = @null = @true = false
29
+ @eq = @gt = @lt = (type) ->
30
+ switch type
31
+ when 'string','text' then 'string'
32
+ when 'integer','float','decimal' then 'numeric'
33
+ when 'date','datetime','time' then type
34
+ else false # Hide for unhandled types.
35
+
36
+ # Setup predicates for fixed select options. Includes relevant any/all permutations
37
+ Ransack.option_predicates = ['eq', 'eq_any', 'not_eq', 'not_eq_all', 'null', 'not_null']
38
+
39
+ # Use a tags input for 'in' if Select2 is available
40
+ if Select2?
41
+ Ransack.predicate_inputs.in = 'tags'