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
@@ -44,8 +44,8 @@ namespace :license do
44
44
  css: "/*\n" + LICENSE_RB.gsub(/^#/, ' *').sub(/---\n/, "---\n */\n") }
45
45
 
46
46
  REGEXPS = { ruby: /^# Copyright \(c\).*?\n(?:#.*\n)*?#-{10}-*\n/,
47
- js: /^\/\/ Copyright \(c\).*?\n(?:\/\/.*\n)*?\/\/-{10}-*\n/,
48
- css: /^\/\*\n \* Copyright \(c\).*?\n(?: \*.*\n)*? \*-{10}-*\n \*\/\n/ }
47
+ js: %r{^// Copyright \(c\).*?\n(?://.*\n)*?//-{10}-*\n},
48
+ css: %r{^/\*\n \* Copyright \(c\).*?\n(?: \*.*\n)*? \*-{10}-*\n \*/\n} }
49
49
 
50
50
  def expand_globs(globs)
51
51
  globs.map { |f| Dir.glob(f) }.flatten.uniq
@@ -143,5 +143,5 @@ module FatFreeCRM
143
143
  end
144
144
  end
145
145
 
146
- ActionView::Base.send(:include, FatFreeCRM::Callback::Helper)
147
- ActionController::Base.send(:include, FatFreeCRM::Callback::Helper)
146
+ ActionView::Base.include FatFreeCRM::Callback::Helper
147
+ ActionController::Base.include FatFreeCRM::Callback::Helper
@@ -13,9 +13,7 @@ module FatFreeCRM
13
13
 
14
14
  module ClassMethods
15
15
  def uses_comment_extensions
16
- unless included_modules.include?(InstanceMethods)
17
- include FatFreeCRM::CommentExtensions::InstanceMethods
18
- end
16
+ include FatFreeCRM::CommentExtensions::InstanceMethods unless included_modules.include?(InstanceMethods)
19
17
  end
20
18
  end
21
19
 
@@ -27,4 +25,4 @@ module FatFreeCRM
27
25
  end
28
26
  end
29
27
 
30
- ActiveRecord::Base.send(:include, FatFreeCRM::CommentExtensions)
28
+ ActiveRecord::Base.include FatFreeCRM::CommentExtensions
@@ -21,7 +21,7 @@ class String
21
21
  end
22
22
 
23
23
  def to_url
24
- match?(/^https?:\/\//) ? self : "http://#{self}"
24
+ match?(%r{^https?://}) ? self : "http://#{self}"
25
25
  end
26
26
 
27
27
  def true?
@@ -14,7 +14,7 @@ module FatFreeCRM
14
14
  task_observer entity_observer]
15
15
 
16
16
  initializer "model_core.factories", after: "factory_bot.set_factory_paths" do
17
- FactoryBot.definition_file_paths << File.expand_path('../../../spec/factories', __FILE__) if defined?(FactoryBot)
17
+ FactoryBot.definition_file_paths << File.expand_path('../../spec/factories', __dir__) if defined?(FactoryBot)
18
18
  end
19
19
 
20
20
  initializer :append_migrations do |app|
@@ -36,4 +36,4 @@ module FatFreeCRM
36
36
  end
37
37
  end
38
38
 
39
- ActiveModel::Errors.send(:include, FatFreeCRM::ActiveModel::Errors)
39
+ ActiveModel::Errors.include FatFreeCRM::ActiveModel::Errors
@@ -14,6 +14,7 @@ module FatFreeCRM
14
14
  #----------------------------------------------------------------------------
15
15
  def self.from_array(items = [])
16
16
  return '' if items.empty?
17
+
17
18
  # Infer column types from the first item in the array
18
19
  klass = items.first.class
19
20
  columns = klass.columns.map(&:name).reject { |column| column =~ /password|token/ }
@@ -48,4 +48,4 @@ module FatFreeCRM
48
48
  end
49
49
  end
50
50
 
51
- ActiveRecord::Base.send(:include, FatFreeCRM::Exportable)
51
+ ActiveRecord::Base.include FatFreeCRM::Exportable
@@ -92,4 +92,4 @@ module FatFreeCRM
92
92
  end
93
93
  end
94
94
 
95
- ActiveRecord::Base.send(:include, FatFreeCRM::Fields)
95
+ ActiveRecord::Base.include FatFreeCRM::Fields
@@ -22,7 +22,7 @@ require 'dynamic_form'
22
22
  require 'paperclip'
23
23
  require 'simple_form'
24
24
  require 'will_paginate'
25
- require 'authlogic'
25
+ require 'devise'
26
26
  require 'ransack'
27
27
  require 'ransack_ui'
28
28
  require 'paper_trail'
@@ -13,9 +13,7 @@ module SimpleForm
13
13
  def simple_form_for(record, options = {}, &block)
14
14
  options[:builder] ||= SimpleForm::FormBuilder
15
15
  options[:html] ||= {}
16
- unless options[:html].key?(:novalidate)
17
- options[:html][:novalidate] = !SimpleForm.browser_validations
18
- end
16
+ options[:html][:novalidate] = !SimpleForm.browser_validations unless options[:html].key?(:novalidate)
19
17
 
20
18
  with_simple_form_field_error_proc do
21
19
  form_for(record, options, &block)
@@ -40,5 +40,5 @@ module FatFreeCRM
40
40
  end
41
41
  end
42
42
 
43
- ActionView::Base.send(:include, FatFreeCRM::I18n)
44
- ActionController::Base.send(:include, FatFreeCRM::I18n)
43
+ ActionView::Base.include FatFreeCRM::I18n
44
+ ActionController::Base.include FatFreeCRM::I18n
@@ -50,9 +50,7 @@ module FatFreeCRM
50
50
 
51
51
  #--------------------------------------------------------------------------------------
52
52
  def run(dry_run = false)
53
- if @dry_run = dry_run
54
- log "Not discarding or archiving any new messages..."
55
- end
53
+ log "Not discarding or archiving any new messages..." if @dry_run = dry_run
56
54
  connect! || (return nil)
57
55
  with_new_emails do |uid, email|
58
56
  # Subclasses must define a #process method that takes arguments: uid, email
@@ -127,9 +125,7 @@ module FatFreeCRM
127
125
  if @dry_run
128
126
  log "Not discarding message"
129
127
  else
130
- if @settings[:move_invalid_to_folder]
131
- @imap.uid_copy(uid, @settings[:move_invalid_to_folder])
132
- end
128
+ @imap.uid_copy(uid, @settings[:move_invalid_to_folder]) if @settings[:move_invalid_to_folder]
133
129
  @imap.uid_store(uid, "+FLAGS", [:Deleted])
134
130
  end
135
131
  @discarded += 1
@@ -141,9 +137,7 @@ module FatFreeCRM
141
137
  if @dry_run
142
138
  log "Not archiving message"
143
139
  else
144
- if @settings[:move_to_folder]
145
- @imap.uid_copy(uid, @settings[:move_to_folder])
146
- end
140
+ @imap.uid_copy(uid, @settings[:move_to_folder]) if @settings[:move_to_folder]
147
141
  @imap.uid_store(uid, "+FLAGS", [:Seen])
148
142
  end
149
143
  @archived += 1
@@ -171,7 +165,7 @@ module FatFreeCRM
171
165
  email: email_address.downcase
172
166
  )
173
167
  # Set the PaperTrail user for versions (if user is found)
174
- PaperTrail.whodunnit = @sender.id.to_s
168
+ PaperTrail.request.whodunnit = @sender.id.to_s
175
169
  end
176
170
  end
177
171
 
@@ -54,9 +54,7 @@ module FatFreeCRM
54
54
  #--------------------------------------------------------------------------------------
55
55
  def with_explicit_keyword(email)
56
56
  first_line = plain_text_body(email).split("\n").first
57
- if first_line =~ /(#{KEYWORDS.join('|')})[^a-zA-Z0-9]+(.+)$/i
58
- yield Regexp.last_match[1].capitalize, Regexp.last_match[2].strip
59
- end
57
+ yield Regexp.last_match[1].capitalize, Regexp.last_match[2].strip if first_line =~ /(#{KEYWORDS.join('|')})[^a-zA-Z0-9]+(.+)$/i
60
58
  end
61
59
 
62
60
  # Checks the email to detect assets on to/bcc addresses
@@ -68,9 +66,7 @@ module FatFreeCRM
68
66
 
69
67
  # Ignore the dropbox email address, and any address aliases
70
68
  ignored_addresses = [@settings[:address]]
71
- if @settings[:address_aliases].is_a?(Array)
72
- ignored_addresses += @settings[:address_aliases]
73
- end
69
+ ignored_addresses += @settings[:address_aliases] if @settings[:address_aliases].is_a?(Array)
74
70
  recipients -= ignored_addresses
75
71
 
76
72
  # Process each recipient until email has been attached
@@ -83,9 +79,7 @@ module FatFreeCRM
83
79
  # Checks the email to detect valid email address in body (first email), detect forwarded emails
84
80
  #----------------------------------------------------------------------------------------
85
81
  def with_forwarded_recipient(email, _options = {})
86
- if plain_text_body(email) =~ /\b([a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4})\b/
87
- yield Regexp.last_match[1]
88
- end
82
+ yield Regexp.last_match[1] if plain_text_body(email) =~ /\b([a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4})\b/
89
83
  end
90
84
 
91
85
  # Process pipe_separated_data or explicit keyword.
@@ -132,9 +126,7 @@ module FatFreeCRM
132
126
  asset = klass.where(["(lower(email) = ?)", recipient.downcase]).first
133
127
 
134
128
  # Leads and Contacts have an alt_email: try it if lookup by primary email has failed.
135
- if !asset && klass.column_names.include?("alt_email")
136
- asset = klass.where(["(lower(alt_email) = ?)", recipient.downcase]).first
137
- end
129
+ asset = klass.where(["(lower(alt_email) = ?)", recipient.downcase]).first if !asset && klass.column_names.include?("alt_email")
138
130
 
139
131
  if asset && sender_has_permissions_for?(asset)
140
132
  attach(email, asset)
@@ -176,9 +168,7 @@ module FatFreeCRM
176
168
  )
177
169
  asset.touch
178
170
 
179
- if asset.is_a?(Lead) && asset.status == "new"
180
- asset.update_attribute(:status, "contacted")
181
- end
171
+ asset.update_attribute(:status, "contacted") if asset.is_a?(Lead) && asset.status == "new"
182
172
 
183
173
  if @settings[:attach_to_account] && asset.respond_to?(:account) && asset.account
184
174
  Email.create(
@@ -34,7 +34,7 @@ module FatFreeCRM
34
34
  # Save shared permissions to the model, if any.
35
35
  #--------------------------------------------------------------------------
36
36
  %w[group user].each do |model|
37
- class_eval %{
37
+ class_eval(%{
38
38
  def #{model}_ids=(value)
39
39
  if access != 'Shared'
40
40
  remove_permissions
@@ -53,7 +53,7 @@ module FatFreeCRM
53
53
  def #{model}_ids
54
54
  permissions.map(&:#{model}_id).compact
55
55
  end
56
- }
56
+ }, __FILE__, __LINE__ - 19)
57
57
  end
58
58
 
59
59
  # Remove all shared permissions if no longer shared
@@ -73,7 +73,10 @@ module FatFreeCRM
73
73
  []
74
74
  end
75
75
 
76
- permissions_to_remove.each { |p| permissions.delete(p); p.destroy }
76
+ permissions_to_remove.each do |p|
77
+ permissions.delete(p)
78
+ p.destroy
79
+ end
77
80
  end
78
81
 
79
82
  # Save the model copying other model's permissions.
@@ -91,4 +94,4 @@ module FatFreeCRM
91
94
  end
92
95
  end
93
96
 
94
- ActiveRecord::Base.send(:include, FatFreeCRM::Permissions)
97
+ ActiveRecord::Base.include FatFreeCRM::Permissions
@@ -42,4 +42,4 @@ module FatFreeCRM
42
42
  end
43
43
  end
44
44
 
45
- ActiveRecord::Base.send(:include, FatFreeCRM::Sortable)
45
+ ActiveRecord::Base.include FatFreeCRM::Sortable
@@ -14,11 +14,11 @@ module FatFreeCRM
14
14
  #----------------------------------------------------------------------------
15
15
  class << self
16
16
  def main
17
- @@main ||= (Setting[:tabs] && Setting[:tabs].dup)
17
+ @@main ||= (Setting[:tabs]&.dup)
18
18
  end
19
19
 
20
20
  def admin
21
- @@admin ||= (Setting[:admin_tabs] && Setting[:admin_tabs].dup)
21
+ @@admin ||= (Setting[:admin_tabs]&.dup)
22
22
  end
23
23
  end
24
24
  end
@@ -8,8 +8,8 @@
8
8
  module FatFreeCRM
9
9
  module VERSION #:nodoc:
10
10
  MAJOR = 0
11
- MINOR = 18
12
- TINY = 2
11
+ MINOR = 19
12
+ TINY = 0
13
13
  PRE = nil
14
14
 
15
15
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
@@ -14,7 +14,7 @@ module GravatarImageTag
14
14
  end
15
15
 
16
16
  class Configuration
17
- attr_accessor :default_image, :filetype, :rating, :size, :secure
17
+ attr_accessor :default_image, :filetype, :rating, :size
18
18
  end
19
19
 
20
20
  def self.included(base)
@@ -25,6 +25,7 @@ module GravatarImageTag
25
25
  module InstanceMethods
26
26
  def gravatar_image_tag(email, options = {})
27
27
  raise ArgumentError, "Options must be a hash, got #{options.inspect}" unless options.is_a? Hash
28
+
28
29
  options[:alt] ||= 'Gravatar'
29
30
  image_tag(GravatarImageTag.gravatar_url(email, options.delete(:gravatar)), options)
30
31
  end
@@ -36,16 +37,13 @@ module GravatarImageTag
36
37
  default: GravatarImageTag.configuration.default_image,
37
38
  filetype: GravatarImageTag.configuration.filetype,
38
39
  rating: GravatarImageTag.configuration.rating,
39
- secure: GravatarImageTag.configuration.secure,
40
40
  size: GravatarImageTag.configuration.size
41
41
  }.merge(overrides).delete_if { |_key, value| value.nil? }
42
- "#{gravatar_url_base(gravatar_params.delete(:secure))}/#{gravatar_id(email, gravatar_params.delete(:filetype))}#{url_params(gravatar_params)}"
42
+ "#{gravatar_url_base}/#{gravatar_id(email, gravatar_params.delete(:filetype))}#{url_params(gravatar_params)}"
43
43
  end
44
44
 
45
- private
46
-
47
- def self.gravatar_url_base(secure = false)
48
- 'http' + (!!secure ? 's://secure.' : '://') + 'gravatar.com/avatar'
45
+ def self.gravatar_url_base
46
+ 'https://gravatar.com/avatar'
49
47
  end
50
48
 
51
49
  def self.gravatar_id(email, filetype = nil)
@@ -54,8 +52,9 @@ module GravatarImageTag
54
52
 
55
53
  def self.url_params(gravatar_params)
56
54
  return nil if gravatar_params.keys.empty?
55
+
57
56
  "?#{gravatar_params.map { |key, value| "#{key}=#{URI.escape(value.is_a?(String) ? value : value.to_s, Regexp.new("[^#{URI::PATTERN::UNRESERVED}]"))}" }.join('&amp;')}"
58
57
  end
59
58
  end
60
59
 
61
- ActionView::Base.send(:include, GravatarImageTag) if defined?(ActionView::Base)
60
+ ActionView::Base.include GravatarImageTag if defined?(ActionView::Base)
@@ -39,6 +39,7 @@ class MissingTranslationDetector
39
39
 
40
40
  keys.each do |key|
41
41
  return true if !h.is_a?(Hash) || !h.key?(key)
42
+
42
43
  h = h[key]
43
44
  end
44
45
 
@@ -22,6 +22,7 @@ namespace :ffcrm do
22
22
  detector.detect
23
23
 
24
24
  next unless detector.missing_translations?
25
+
25
26
  puts
26
27
  puts "Detected missing translations within \"config/locales/#{locale_file_names.last}.yml\":"
27
28
  puts
@@ -44,7 +44,12 @@ namespace :ffcrm do
44
44
 
45
45
  password ||= "manager"
46
46
  print "Password [#{password}]: "
47
- echo = ->(toggle) { return if RUBY_PLATFORM.match?(/mswin/); system(toggle ? "stty echo && echo" : "stty -echo") }
47
+ echo = lambda { |toggle|
48
+ return if RUBY_PLATFORM.match?(/mswin/)
49
+
50
+ system(toggle ? "stty echo && echo" : "stty -echo")
51
+ }
52
+
48
53
  begin
49
54
  echo.call(false)
50
55
  reply = STDIN.gets.strip
@@ -69,6 +74,7 @@ namespace :ffcrm do
69
74
  break unless reply.blank?
70
75
  end
71
76
  break if reply.match?(/y(?:es)*/i)
77
+
72
78
  redo if reply.match?(/no*/i)
73
79
  puts "No admin user was created."
74
80
  exit
@@ -76,7 +82,10 @@ namespace :ffcrm do
76
82
  end
77
83
  User.reset_column_information # Reload the class since we've added new fields in migrations.
78
84
  user = User.find_by_username(username) || User.new
85
+ user.skip_confirmation!
86
+ user.confirm
79
87
  user.update_attributes(username: username, password: password, email: email)
88
+ user.update_attribute(:confirmed_at, Time.now.utc) # Skip confirmation
80
89
  user.update_attribute(:admin, true) # Mass assignments don't work for :admin because of the attr_protected
81
90
  user.update_attribute(:suspended_at, nil) # Mass assignments don't work for :suspended_at because of the attr_protected
82
91
  puts "Admin user has been created."
@@ -114,7 +114,7 @@ in a console and continue. This is strongly discouraged. You have been warned!
114
114
  %w[Guam GQ GU],
115
115
  %w[Guernsey GK GG],
116
116
  %w[Guinea GV GN],
117
- ["Guinea-Bissau", "PU", "GW"],
117
+ %w[Guinea-Bissau PU GW],
118
118
  %w[Haiti HA HT],
119
119
  ["Holy See (Vatican City State)", "VT", "VA"],
120
120
  %w[Honduras HO HN],
@@ -184,7 +184,7 @@ in a console and continue. This is strongly discouraged. You have been warned!
184
184
  %w[Sweden SW SE],
185
185
  %w[Switzerland SZ CH],
186
186
  %w[Tajikistan TI TJ],
187
- ["Timor-Leste", "TT", "TL"],
187
+ %w[Timor-Leste TT TL],
188
188
  %w[Togo TO TG],
189
189
  %w[Tokelau TL TK],
190
190
  %w[Tonga TN TO],
data/script/rails CHANGED
@@ -3,6 +3,6 @@
3
3
 
4
4
  # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
5
5
 
6
- APP_PATH = File.expand_path('../../config/application', __FILE__)
7
- require File.expand_path('../../config/boot', __FILE__)
6
+ APP_PATH = File.expand_path('../config/application', __dir__)
7
+ require File.expand_path('../config/boot', __dir__)
8
8
  require 'rails/commands'
@@ -50,17 +50,6 @@ describe Admin::UsersController do
50
50
  end
51
51
  end
52
52
 
53
- # GET /admin/users/new
54
- # GET /admin/users/new.xml AJAX
55
- #----------------------------------------------------------------------------
56
- describe "GET new" do
57
- it "assigns a new user as @user and renders [new] template" do
58
- get :new, xhr: true
59
- expect(assigns[:user]).to be_new_record
60
- expect(response).to render_template("admin/users/new")
61
- end
62
- end
63
-
64
53
  # GET /admin/users/1/edit AJAX
65
54
  #----------------------------------------------------------------------------
66
55
  describe "GET edit" do
@@ -102,51 +91,6 @@ describe Admin::UsersController do
102
91
  end
103
92
  end
104
93
 
105
- # POST /admin/users
106
- # POST /admin/users.xml AJAX
107
- #----------------------------------------------------------------------------
108
- describe "POST create" do
109
- describe "with valid params" do
110
- before(:each) do
111
- @username = "none"
112
- @email = @username + "@example.com"
113
- @password = "secret"
114
- end
115
-
116
- it "assigns a newly created user as @user and renders [create] template" do
117
- @user = build(:user, username: @username, email: @email)
118
- allow(User).to receive(:new).and_return(@user)
119
-
120
- post :create, params: { user: { username: @username, email: @email, password: @password, password_confirmation: @password } }, xhr: true
121
- expect(assigns[:user]).to eq(@user)
122
- expect(response).to render_template("admin/users/create")
123
- end
124
-
125
- it "creates admin user when requested so" do
126
- post :create, params: { user: { username: @username, email: @email, admin: "1", password: @password, password_confirmation: @password } }, xhr: true
127
- expect(assigns[:user].admin).to eq(true)
128
- expect(response).to render_template("admin/users/create")
129
- end
130
-
131
- it "doesn't create admin user unless requested so" do
132
- post :create, params: { user: { username: @username, email: @email, admin: "0", password: @password, password_confirmation: @password } }, xhr: true
133
- expect(assigns[:user].admin).to eq(false)
134
- expect(response).to render_template("admin/users/create")
135
- end
136
- end
137
-
138
- describe "with invalid params" do
139
- it "assigns a newly created but unsaved user as @user and re-renders [create] template" do
140
- @user = build(:user, username: "", email: "")
141
- allow(User).to receive(:new).and_return(@user)
142
-
143
- post :create, params: { user: {} }, xhr: true
144
- expect(assigns[:user]).to eq(@user)
145
- expect(response).to render_template("admin/users/create")
146
- end
147
- end
148
- end
149
-
150
94
  # PUT /admin/users/1
151
95
  # PUT /admin/users/1.xml AJAX
152
96
  #----------------------------------------------------------------------------