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
@@ -9,7 +9,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
9
9
 
10
10
  describe Admin::FieldGroupsHelper do
11
11
  it "should return the correct info text about tag restrictions and classes for groups" do
12
- field_group = build(:field_group, klass_name: "Contact", label: "Test Field Group")
12
+ field_group = create(:field_group, klass_name: "Contact", label: "Test Field Group")
13
13
  html = helper.field_group_subtitle(field_group)
14
14
  expect(html).to include("Test Field Group")
15
15
  expect(html).to include("This field group applies to contacts tagged with")
@@ -24,16 +24,16 @@ describe UsersHelper do
24
24
 
25
25
  describe "user_select" do
26
26
  it "includes blank option" do
27
- expect(user_select(:lead, [user1, user2], myself)).to match(/<option value="">Unassigned<\/option>/)
27
+ expect(user_select(:lead, [user1, user2], myself)).to match(%r{<option value="">Unassigned</option>})
28
28
  end
29
29
 
30
30
  it "includes myself" do
31
- expect(user_select(:lead, [user1, user2], myself)).to match(/<option value="54">Myself<\/option>/)
31
+ expect(user_select(:lead, [user1, user2], myself)).to match(%r{<option value="54">Myself</option>})
32
32
  end
33
33
 
34
34
  it "includes other users" do
35
- expect(user_select(:lead, [user1, user2], myself)).to match(/<option value="60">Bob Hope<\/option>/)
36
- expect(user_select(:lead, [user1, user2], myself)).to match(/<option value="75">Billy Joel<\/option>/)
35
+ expect(user_select(:lead, [user1, user2], myself)).to match(%r{<option value="60">Bob Hope</option>})
36
+ expect(user_select(:lead, [user1, user2], myself)).to match(%r{<option value="75">Billy Joel</option>})
37
37
  end
38
38
  end
39
39
  end
@@ -11,16 +11,22 @@ describe FatFreeCRM::CommentExtensions do
11
11
  describe "add_comment_by_user" do
12
12
  let(:user) { create(:user) }
13
13
 
14
- before :each do
15
- build_model(:commentable_entity) do
16
- string :subscribed_users
17
- serialize :subscribed_users, Set
14
+ before do
15
+ ActiveRecord::Base.connection.create_table(:commentable_entities) do |t|
16
+ t.string :subscribed_users
17
+ end
18
18
 
19
+ class CommentableEntity < ActiveRecord::Base
20
+ serialize :subscribed_users, Set
19
21
  acts_as_commentable
20
22
  uses_comment_extensions
21
23
  end
22
24
  end
23
25
 
26
+ after do
27
+ ActiveRecord::Base.connection.drop_table(:commentable_entities)
28
+ end
29
+
24
30
  it "should create a comment for user" do
25
31
  entity = CommentableEntity.create
26
32
  entity.add_comment_by_user("I will handle this one", user)
@@ -13,7 +13,7 @@ describe 'ActiveModel Validation Errors' do
13
13
  validates_presence_of :title, message: '^Missing title'
14
14
  end
15
15
 
16
- adam = Adam.create(username: 'adam', email: 'adam@example.com')
16
+ adam = Adam.create(username: 'adam', email: 'adam@example.com', password: 'ouchmyrib')
17
17
  expect(adam.valid?).to eq(false)
18
18
  expect(adam.errors[:title]).to eq(['^Missing title'])
19
19
  expect(adam.errors.full_messages[0]).to eq('Missing title')
@@ -24,7 +24,7 @@ describe 'ActiveModel Validation Errors' do
24
24
  validates_presence_of :title, message: 'missing'
25
25
  end
26
26
 
27
- eve = Eve.create(username: 'eve', email: 'eve@example.com')
27
+ eve = Eve.create(username: 'eve', email: 'eve@example.com', password: 'doyoulikeapples')
28
28
  expect(eve.valid?).to eq(false)
29
29
  expect(eve.errors[:title]).to eq(['missing'])
30
30
  expect(eve.errors.full_messages[0]).to eq('Title missing')
@@ -280,7 +280,7 @@ describe FatFreeCRM::MailProcessor::Dropbox do
280
280
  it "should extract text and strip tags from multipart text/html" do
281
281
  text = @dropbox.send(:plain_text_body, Mail.new(DROPBOX_EMAILS[:html]))
282
282
  expect(text).to be_present
283
- expect(text).not_to match(/<\/?[^>]*>/)
283
+ expect(text).not_to match(%r{</?[^>]*>})
284
284
  end
285
285
  end
286
286
 
@@ -17,7 +17,7 @@ DROPBOX_EMAILS = {
17
17
  #{FFaker::Lorem.paragraph}
18
18
 
19
19
  Aaron
20
- EMAIL
20
+ EMAIL
21
21
 
22
22
  html: <<~EMAIL,
23
23
  From: Aaron Assembler <aaron@example.com>
@@ -34,7 +34,7 @@ EMAIL
34
34
  <p>Aaron</p>
35
35
  </body>
36
36
  </html>
37
- EMAIL
37
+ EMAIL
38
38
 
39
39
  first_line: <<~EMAIL,
40
40
  From: Aaron Assembler <aaron@example.com>
@@ -48,7 +48,7 @@ EMAIL
48
48
  #{FFaker::Lorem.paragraph}
49
49
 
50
50
  Aaron
51
- EMAIL
51
+ EMAIL
52
52
 
53
53
  first_line_lead: <<~EMAIL,
54
54
  From: Aaron Assembler <aaron@example.com>
@@ -62,7 +62,7 @@ EMAIL
62
62
  #{FFaker::Lorem.paragraph}
63
63
 
64
64
  Aaron
65
- EMAIL
65
+ EMAIL
66
66
 
67
67
  first_line_contact: <<~EMAIL,
68
68
  From: Aaron Assembler <aaron@example.com>
@@ -76,7 +76,7 @@ EMAIL
76
76
  #{FFaker::Lorem.paragraph}
77
77
 
78
78
  Aaron
79
- EMAIL
79
+ EMAIL
80
80
 
81
81
  forwarded: <<~EMAIL,
82
82
  From: Aaron Assembler <aaron@example.com>
@@ -95,9 +95,9 @@ EMAIL
95
95
  #{FFaker::Lorem.paragraph}
96
96
 
97
97
  Ben
98
- EMAIL
98
+ EMAIL
99
99
 
100
- multipart: <<~EMAIL,
100
+ multipart: <<~EMAIL
101
101
  From: Aaron Assembler <aaron@example.com>
102
102
  To: Ben Bootloader <ben@example.com>
103
103
  Subject: Hi there
@@ -169,5 +169,5 @@ EMAIL
169
169
  ADpMhSwQ4p2Bz9o8V84oX868ufPn0KNLn64hAgA7
170
170
 
171
171
  --_006_200DA2FF7EAFC04BAD979DB9CF293BB365151E88CLEARWATERtesta_--
172
- EMAIL
172
+ EMAIL
173
173
  }
@@ -8,12 +8,17 @@
8
8
  require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
9
9
 
10
10
  describe FatFreeCRM::Permissions do
11
- before :each do
12
- build_model(:user_with_permission) do
11
+ before do
12
+ ActiveRecord::Base.connection.create_table(:user_with_permissions) do |t|
13
+ t.string :access
14
+ end
15
+ class UserWithPermission < ActiveRecord::Base
13
16
  uses_user_permissions
14
- string :access
15
17
  end
16
18
  end
19
+ after do
20
+ ActiveRecord::Base.connection.drop_table(:user_with_permissions)
21
+ end
17
22
 
18
23
  describe "initialization" do
19
24
  it "should add 'has_many permissions' to the model" do
@@ -0,0 +1,35 @@
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
+ require 'spec_helper'
9
+
10
+ describe DeviseMailer do
11
+ describe "reset_password_instructions" do
12
+ let(:user) { build(:user, email: "forgot_my_password@example.com") }
13
+ let(:mail) { DeviseMailer.reset_password_instructions(user, user.reset_password_token) }
14
+
15
+ before(:each) do
16
+ allow(user).to receive(:reset_password_token).and_return("62fe5299b45513f9d22a2e1454f35dd43d62ba50")
17
+ end
18
+
19
+ it "sets fatfree as the sender" do
20
+ expect(mail.from).to eql(["noreply@fatfreecrm.com"])
21
+ end
22
+
23
+ it "sets user 'forgot_my_password@example.com' as recipient" do
24
+ expect(mail.to).to eq(["forgot_my_password@example.com"])
25
+ end
26
+
27
+ it "sets the subject" do
28
+ expect(mail.subject).to eq("Reset password instructions")
29
+ end
30
+
31
+ it "includes password reset link in body" do
32
+ expect(mail.body.encoded).to have_link('Change my password', href: "http://www.example.com/users/password/edit?reset_password_token=#{user.reset_password_token}")
33
+ end
34
+ end
35
+ end
@@ -8,32 +8,6 @@
8
8
  require 'spec_helper'
9
9
 
10
10
  describe UserMailer do
11
- describe "password_reset_instructions" do
12
- let(:user) { build(:user, email: "forgot_my_password@example.com") }
13
- let(:mail) { UserMailer.password_reset_instructions(user) }
14
-
15
- before(:each) do
16
- allow(I18n).to receive(:t).with(:password_reset_instruction).and_return("Password Reset Instructions")
17
- allow(user).to receive(:perishable_token).and_return("62fe5299b45513f9d22a2e1454f35dd43d62ba50")
18
- end
19
-
20
- it "sets fatfree as the sender" do
21
- expect(mail.from).to eql(["noreply@fatfreecrm.com"])
22
- end
23
-
24
- it "sets user 'forgot_my_password@example.com' as recipient" do
25
- expect(mail.to).to eq(["forgot_my_password@example.com"])
26
- end
27
-
28
- it "sets the subject" do
29
- expect(mail.subject).to eq("Fat Free CRM: Password Reset Instructions")
30
- end
31
-
32
- it "includes password reset link in body" do
33
- expect(mail.body.encoded).to match("http://www.example.com/passwords/62fe5299b45513f9d22a2e1454f35dd43d62ba50/edit")
34
- end
35
- end
36
-
37
11
  describe "assigned_entity_notification" do
38
12
  let(:assigner) { build(:user, first_name: "Bob", last_name: "Hope") }
39
13
  let(:assignee) { build(:user, email: "assignee@example.com") }
@@ -34,6 +34,33 @@ describe Account do
34
34
  Account.create!(name: "Test Account")
35
35
  end
36
36
 
37
+ describe "Creating or selecting" do
38
+ it "must create a new account" do
39
+ @account = Account.create_or_select_for(nil, name: "Account T")
40
+
41
+ expect(Account.count).to eq(1)
42
+ expect(Account.first).to eq(@account)
43
+ end
44
+
45
+ it "must select an existing account based on id" do
46
+ @account = create(:account)
47
+
48
+ expect(Account.create_or_select_for(nil, id: @account.id)).to eq(@account)
49
+ end
50
+
51
+ it "must select an existing account based on name" do
52
+ @account = create(:account)
53
+
54
+ expect(Account.create_or_select_for(nil, name: @account.name)).to eq(@account)
55
+ end
56
+
57
+ it "must create a new account based on existing model" do
58
+ @contact = create(:contact)
59
+ @account = Account.create_or_select_for(@contact, name: "Account T")
60
+ expect(@account.user).to eq(@contact.user)
61
+ end
62
+ end
63
+
37
64
  describe "Attach" do
38
65
  before do
39
66
  @account = create(:account)
@@ -41,8 +41,18 @@
41
41
  require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
42
42
 
43
43
  describe Contact do
44
+ let(:user) { create(:user) }
45
+
44
46
  it "should create a new instance given valid attributes" do
45
- Contact.create!(first_name: "Billy", last_name: "Bones")
47
+ Contact.create!(first_name: "Billy", last_name: "Bones", user: user)
48
+ end
49
+
50
+ it "must create a new instance for a given model" do
51
+ lead = create(:lead)
52
+ account = create(:account)
53
+ opportunity = create(:opportunity)
54
+ @contact = Contact.create_for(lead, account, opportunity, account: {})
55
+ expect(@contact.valid?).to eq true
46
56
  end
47
57
 
48
58
  describe "Update existing contact" do
@@ -217,3 +227,88 @@ describe Contact do
217
227
  end
218
228
  end
219
229
  end
230
+
231
+ describe "field validations" do
232
+ let(:new_record) do
233
+ Contact.new(
234
+ first_name: "ChristopherChristopherChristopherChristopherChristopherChristopherChristopher",
235
+ last_name: "BonesBonesBonesBonesBonesBonesBonesBonesBonesBonesBonesBonesBonesBonesBonesBones",
236
+ title: 'This is a really long title for the contact and it should thow an error.',
237
+ department: 'This is a really long name for the department and it should thow an error.',
238
+ email: 'bob_dillionbob_dillionbob_dillionbob_dillionbob_dillionbob_dillionbob_dillionbob_dillionbob_dillionbob_dillionbob_dillionbob_dillionbob_dillionbob_dillionbob_dillionbob_dillionbob_dillionbob_dillionbob_dillionbob_dillionbob_dillionbob_dillionbob_dillionbob_dillionbob_dillionbob_dillionbob_dillionbob_dillionbob_dillionbob_dillionbob_dillionbob_dillionbob_dillionbob_dillionbob_dillionbob_dillionbob_dillionbob_dillionbob_dillionbob_dillion@example.com',
239
+ alt_email: 'bob_dillionbob_dillionbob_dillionbob_dillionbob_dillionbob_dillionbob_dillionbob_dillionbob_dillionbob_dillionbob_dillionbob_dillionbob_dillionbob_dillionbob_dillionbob_dillionbob_dillionbob_dillionbob_dillionbob_dillionbob_dillionbob_dillionbob_dillionbob_dillionbob_dillionbob_dillionbob_dillionbob_dillionbob_dillionbob_dillionbob_dillionbob_dillionbob_dillionbob_dillionbob_dillionbob_dillionbob_dillionbob_dillionbob_dillionbob_dillion@example.com',
240
+ phone: '+1 123 456 7891 123 456 7891 123 456 7891 123 456 7891 123 456 789',
241
+ mobile: '+1 123 456 7891 123 456 7891 123 456 7891 123 456 7891 123 456 789',
242
+ fax: '+1 123 456 7891 123 456 7891 123 456 789 123 456 7891 123 456 789',
243
+ blog: 'This is a test of how many characters before it throws an error message.This is a test of how many characters before it throws an error message.This is a test of how many characters before it throws an error message.',
244
+ linkedin: 'This is my linkedin name and it is way to long. This is my linkedin name and it is way to long. This is my linkedin name and it is way to long.',
245
+ twitter: 'This is my twitter name and it is way to long. This is my twitter name and it is way to long. This is my twitter name and it is way to long.',
246
+ skype: 'This is my skype name and it is way to long. This is my skype name and it is way to long. This is my skype name and it is way to long.'
247
+ )
248
+ end
249
+
250
+ it "validate first_name max_length 64" do
251
+ expect(new_record).to_not be_valid
252
+ expect(new_record.errors.messages[:first_name]).to include("is too long (maximum is 64 characters)")
253
+ end
254
+
255
+ it "validate last_name max_length 64" do
256
+ expect(new_record).to_not be_valid
257
+ expect(new_record.errors.messages[:last_name]).to include("is too long (maximum is 64 characters)")
258
+ end
259
+
260
+ it "validate title max_length 64" do
261
+ expect(new_record).to_not be_valid
262
+ expect(new_record.errors.messages[:title]).to include("is too long (maximum is 64 characters)")
263
+ end
264
+
265
+ it "validate department max_length 254" do
266
+ expect(new_record).to_not be_valid
267
+ expect(new_record.errors.messages[:department]).to include("is too long (maximum is 64 characters)")
268
+ end
269
+
270
+ it "validate email max_length 254" do
271
+ expect(new_record).to_not be_valid
272
+ expect(new_record.errors.messages[:email]).to include("is too long (maximum is 254 characters)")
273
+ end
274
+
275
+ it "validate alt_email max_length 254" do
276
+ expect(new_record).to_not be_valid
277
+ expect(new_record.errors.messages[:alt_email]).to include("is too long (maximum is 254 characters)")
278
+ end
279
+
280
+ it "validate phone max_length 32" do
281
+ expect(new_record).to_not be_valid
282
+ expect(new_record.errors.messages[:phone]).to include("is too long (maximum is 32 characters)")
283
+ end
284
+
285
+ it "validate mobile max_length 32" do
286
+ expect(new_record).to_not be_valid
287
+ expect(new_record.errors.messages[:mobile]).to include("is too long (maximum is 32 characters)")
288
+ end
289
+
290
+ it "validate fax max_length 32" do
291
+ expect(new_record).to_not be_valid
292
+ expect(new_record.errors.messages[:fax]).to include("is too long (maximum is 32 characters)")
293
+ end
294
+
295
+ it "validate blog max_length 128" do
296
+ expect(new_record).to_not be_valid
297
+ expect(new_record.errors.messages[:blog]).to include("is too long (maximum is 128 characters)")
298
+ end
299
+
300
+ it "validate linkedin max_length 128" do
301
+ expect(new_record).to_not be_valid
302
+ expect(new_record.errors.messages[:linkedin]).to include("is too long (maximum is 128 characters)")
303
+ end
304
+
305
+ it "validate twitter max_length 128" do
306
+ expect(new_record).to_not be_valid
307
+ expect(new_record.errors.messages[:twitter]).to include("is too long (maximum is 128 characters)")
308
+ end
309
+
310
+ it "validate skype max_length 128" do
311
+ expect(new_record).to_not be_valid
312
+ expect(new_record.errors.messages[:skype]).to include("is too long (maximum is 128 characters)")
313
+ end
314
+ end
@@ -67,7 +67,8 @@ describe CustomFieldDatePair do
67
67
 
68
68
  it "when from > to it should not be valid" do
69
69
  foo = double(cf_event_from: @today, cf_event_to: @today - 1.day)
70
- err = double(:errors); allow(err).to receive(:add)
70
+ err = double(:errors)
71
+ allow(err).to receive(:add)
71
72
  expect(foo).to receive(:errors).and_return(err)
72
73
  @to.custom_validator(foo)
73
74
  end
@@ -82,7 +83,8 @@ describe CustomFieldDatePair do
82
83
  it "should call custom field validation on super class" do
83
84
  from = CustomFieldDatePair.new(name: 'cf_event_from', required: true)
84
85
  foo = double(cf_event_from: nil)
85
- err = double(:errors); allow(err).to receive(:add)
86
+ err = double(:errors)
87
+ allow(err).to receive(:add)
86
88
  expect(foo).to receive(:errors).and_return(err)
87
89
  from.custom_validator(foo)
88
90
  end
@@ -111,7 +111,8 @@ describe CustomField do
111
111
  it "should have errors if custom field is required" do
112
112
  event = CustomField.new(name: 'cf_event', required: true)
113
113
  foo = double(cf_event: nil)
114
- err = double(:errors); allow(err).to receive(:add)
114
+ err = double(:errors)
115
+ allow(err).to receive(:add)
115
116
  expect(foo).to receive(:errors).and_return(err)
116
117
  event.custom_validator(foo)
117
118
  end
@@ -119,7 +120,8 @@ describe CustomField do
119
120
  it "should have errors if custom field is longer than maxlength" do
120
121
  event = CustomField.new(name: 'cf_event', maxlength: 5)
121
122
  foo = double(cf_event: "This is too long")
122
- err = double(:errors); allow(err).to receive(:add)
123
+ err = double(:errors)
124
+ allow(err).to receive(:add)
123
125
  expect(foo).to receive(:errors).and_return(err)
124
126
  event.custom_validator(foo)
125
127
  end
@@ -10,7 +10,7 @@ require 'spec_helper'
10
10
  describe EntityObserver do
11
11
  before do
12
12
  allow(Setting).to receive(:host).and_return('http://www.example.com')
13
- allow(PaperTrail).to receive(:whodunnit).and_return(assigner)
13
+ allow(PaperTrail.request).to receive(:whodunnit).and_return(assigner)
14
14
  end
15
15
 
16
16
  %i[account contact lead opportunity].each do |entity_type|
@@ -24,10 +24,10 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
24
24
 
25
25
  describe Version, versioning: true do
26
26
  let(:current_user) { create(:user) }
27
- before { PaperTrail.whodunnit = current_user.id.to_s }
27
+ before { PaperTrail.request.whodunnit = current_user.id.to_s }
28
28
 
29
29
  it "should create a new instance given valid attributes" do
30
- create(:version, whodunnit: PaperTrail.whodunnit, item: create(:lead))
30
+ create(:version, whodunnit: PaperTrail.request.whodunnit, item: create(:lead))
31
31
  end
32
32
 
33
33
  describe "with multiple version records" do
@@ -35,7 +35,7 @@ describe Version, versioning: true do
35
35
  @lead = create(:lead)
36
36
 
37
37
  %w[create destroy update view].each do |event|
38
- create(:version, event: event, item: @lead, whodunnit: PaperTrail.whodunnit)
38
+ create(:version, event: event, item: @lead, whodunnit: PaperTrail.request.whodunnit)
39
39
  create(:version, event: event, item: @lead, whodunnit: "1")
40
40
  end
41
41
  end
@@ -72,7 +72,7 @@ describe Version, versioning: true do
72
72
  describe "Create, update, and delete (#{item})" do
73
73
  before :each do
74
74
  @item = create(item.to_sym, user: current_user)
75
- @conditions = { item_id: @item.id, item_type: @item.class.name, whodunnit: PaperTrail.whodunnit }
75
+ @conditions = { item_id: @item.id, item_type: @item.class.name, whodunnit: PaperTrail.request.whodunnit }
76
76
  end
77
77
 
78
78
  it "should add a version when creating new #{item}" do
@@ -101,7 +101,7 @@ describe Version, versioning: true do
101
101
  it "should add a version when commenting on a #{item}" do
102
102
  @comment = create(:comment, commentable: @item, user: current_user)
103
103
 
104
- @version = Version.where(related_id: @item.id, related_type: @item.class.name, whodunnit: PaperTrail.whodunnit, event: 'create').first
104
+ @version = Version.where(related_id: @item.id, related_type: @item.class.name, whodunnit: PaperTrail.request.whodunnit, event: 'create').first
105
105
  expect(@version).not_to eq(nil)
106
106
  end
107
107
  end
@@ -129,7 +129,7 @@ describe Version, versioning: true do
129
129
  describe "Action refinements for task updates" do
130
130
  before do
131
131
  @task = create(:task, user: current_user)
132
- @conditions = { item_id: @task.id, item_type: @task.class.name, whodunnit: PaperTrail.whodunnit }
132
+ @conditions = { item_id: @task.id, item_type: @task.class.name, whodunnit: PaperTrail.request.whodunnit }
133
133
  end
134
134
 
135
135
  it "should create 'completed' task event" do
@@ -157,7 +157,7 @@ describe Version, versioning: true do
157
157
  describe "Rejecting a lead" do
158
158
  before do
159
159
  @lead = create(:lead, user: current_user, status: "new")
160
- @conditions = { item_id: @lead.id, item_type: @lead.class.name, whodunnit: PaperTrail.whodunnit }
160
+ @conditions = { item_id: @lead.id, item_type: @lead.class.name, whodunnit: PaperTrail.request.whodunnit }
161
161
  end
162
162
 
163
163
  it "should create 'rejected' lead event" do