fat_free_crm 0.15.0.beta.2 → 0.15.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of fat_free_crm might be problematic. Click here for more details.

Files changed (225) hide show
  1. checksums.yaml +4 -4
  2. data/.docker/nginx/sites-enabled/ffcrm.conf +8 -0
  3. data/.gitignore +2 -0
  4. data/.rubocop.yml +4 -1
  5. data/.rubocop_todo.yml +190 -89
  6. data/.travis.yml +10 -3
  7. data/CHANGELOG.md +27 -0
  8. data/{CONTRIBUTORS → CONTRIBUTORS.md} +2 -1
  9. data/Dockerfile +15 -13
  10. data/Gemfile +7 -4
  11. data/Gemfile.lock +200 -167
  12. data/README.md +4 -2
  13. data/app/assets/javascripts/crm_sortable.js.coffee +5 -0
  14. data/app/assets/javascripts/timeago.js.coffee +5 -0
  15. data/app/assets/stylesheets/about.css.scss +5 -0
  16. data/app/assets/stylesheets/common.scss +2 -1
  17. data/app/controllers/admin/fields_controller.rb +1 -1
  18. data/app/controllers/admin/groups_controller.rb +5 -1
  19. data/app/controllers/admin/tags_controller.rb +1 -1
  20. data/app/controllers/admin/users_controller.rb +10 -6
  21. data/app/controllers/application_controller.rb +13 -13
  22. data/app/controllers/authentications_controller.rb +2 -2
  23. data/app/controllers/comments_controller.rb +3 -2
  24. data/app/controllers/entities/contacts_controller.rb +9 -7
  25. data/app/controllers/entities/opportunities_controller.rb +1 -1
  26. data/app/controllers/entities_controller.rb +4 -4
  27. data/app/controllers/home_controller.rb +9 -9
  28. data/app/controllers/passwords_controller.rb +1 -1
  29. data/app/controllers/tasks_controller.rb +2 -1
  30. data/app/controllers/users_controller.rb +4 -2
  31. data/app/helpers/application_helper.rb +9 -9
  32. data/app/helpers/javascript_helper.rb +5 -0
  33. data/app/helpers/opportunities_helper.rb +1 -1
  34. data/app/helpers/remote_link_pagination_helper.rb +5 -0
  35. data/app/inputs/date_pair_input.rb +1 -1
  36. data/app/models/entities/account.rb +2 -2
  37. data/app/models/entities/account_contact.rb +1 -1
  38. data/app/models/entities/campaign.rb +3 -3
  39. data/app/models/entities/contact.rb +3 -3
  40. data/app/models/entities/lead.rb +2 -2
  41. data/app/models/entities/opportunity.rb +3 -3
  42. data/app/models/fields/custom_field.rb +1 -1
  43. data/app/models/fields/custom_field_pair.rb +2 -2
  44. data/app/models/fields/field.rb +1 -1
  45. data/app/models/polymorphic/address.rb +2 -2
  46. data/app/models/polymorphic/avatar.rb +4 -2
  47. data/app/models/polymorphic/email.rb +8 -6
  48. data/app/models/polymorphic/task.rb +3 -1
  49. data/app/models/polymorphic/version.rb +3 -3
  50. data/app/models/users/ability.rb +1 -1
  51. data/app/models/users/permission.rb +2 -0
  52. data/app/models/users/user.rb +2 -2
  53. data/app/views/accounts/index.js.haml +1 -1
  54. data/app/views/admin/fields/_sort_by.html.haml +1 -1
  55. data/app/views/admin/users/_user.html.haml +1 -1
  56. data/app/views/campaigns/index.js.haml +1 -1
  57. data/app/views/contacts/index.js.haml +1 -1
  58. data/app/views/entities/_basic_search.html.haml +1 -1
  59. data/app/views/home/_duration_menu.html.haml +1 -1
  60. data/app/views/home/_events_menu.html.haml +1 -1
  61. data/app/views/home/_users_menu.html.haml +1 -1
  62. data/app/views/layouts/application.html.haml +1 -1
  63. data/app/views/leads/index.js.haml +1 -1
  64. data/app/views/opportunities/index.js.haml +1 -1
  65. data/app/views/shared/_naming.html.haml +1 -1
  66. data/app/views/users/_languages.html.haml +1 -1
  67. data/config/application.rb +2 -3
  68. data/config/boot.rb +2 -0
  69. data/config/deploy.example.rb +1 -1
  70. data/config/environments/development.rb +2 -0
  71. data/config/environments/production.rb +1 -1
  72. data/config/environments/test.rb +2 -2
  73. data/config/initializers/assets.rb +6 -1
  74. data/config/initializers/backtrace_silencers.rb +5 -0
  75. data/config/initializers/constants.rb +1 -1
  76. data/config/initializers/cookies_serializer.rb +5 -0
  77. data/config/initializers/custom_field_ransack_translations.rb +5 -0
  78. data/config/initializers/filter_parameter_logging.rb +5 -0
  79. data/config/initializers/inflections.rb +5 -0
  80. data/config/initializers/paper_trail.rb +5 -0
  81. data/config/initializers/ransack.rb +3 -3
  82. data/config/initializers/session_store.rb +5 -0
  83. data/config/initializers/wrap_parameters.rb +5 -0
  84. data/config/locales/et.yml +207 -0
  85. data/config/locales/et_fat_free_crm.yml +928 -0
  86. data/config/locales/pt-BR_ransack.yml +81 -0
  87. data/config/locales/th.rb +1 -1
  88. data/config/routes.rb +18 -18
  89. data/db/migrate/20100928030598_create_sessions.rb +1 -1
  90. data/db/migrate/20100928030599_create_users.rb +2 -2
  91. data/db/migrate/20100928030600_create_openid_tables.rb +1 -1
  92. data/db/migrate/20100928030601_create_accounts.rb +2 -2
  93. data/db/migrate/20100928030602_create_permissions.rb +1 -1
  94. data/db/migrate/20100928030603_create_settings.rb +1 -1
  95. data/db/migrate/20100928030604_create_preferences.rb +2 -2
  96. data/db/migrate/20100928030605_create_campaigns.rb +2 -2
  97. data/db/migrate/20100928030606_create_leads.rb +2 -2
  98. data/db/migrate/20100928030607_create_contacts.rb +2 -2
  99. data/db/migrate/20100928030608_create_opportunities.rb +2 -2
  100. data/db/migrate/20100928030609_create_account_contacts.rb +1 -1
  101. data/db/migrate/20100928030610_create_account_opportunities.rb +1 -1
  102. data/db/migrate/20100928030611_create_contact_opportunities.rb +1 -1
  103. data/db/migrate/20100928030612_create_tasks.rb +2 -2
  104. data/db/migrate/20100928030613_create_comments.rb +1 -1
  105. data/db/migrate/20100928030614_create_activities.rb +1 -1
  106. data/db/migrate/20100928030615_create_avatars.rb +1 -1
  107. data/db/migrate/20100928030616_rename_remember_token.rb +1 -1
  108. data/db/migrate/20100928030617_drop_openid_tables.rb +1 -1
  109. data/db/migrate/20100928030618_add_admin_to_users.rb +1 -1
  110. data/db/migrate/20100928030619_add_suspended_to_users.rb +1 -1
  111. data/db/migrate/20100928030620_remove_uuid.rb +2 -2
  112. data/db/migrate/20100928030621_add_email_to_accounts.rb +1 -1
  113. data/db/migrate/20100928030622_add_background_info_to_models.rb +1 -1
  114. data/db/migrate/20100928030623_create_addresses.rb +2 -2
  115. data/db/migrate/20100928030624_add_index_on_permissions.rb +3 -3
  116. data/db/migrate/20100928030625_create_emails.rb +2 -2
  117. data/db/migrate/20100928030626_add_state_to_timeline_objects.rb +1 -1
  118. data/db/migrate/20100928030627_acts_as_taggable_on_migration.rb +2 -2
  119. data/db/migrate/20101221123456_add_single_access_token_to_users.rb +1 -1
  120. data/db/migrate/20101221345678_add_rating_and_category_to_accounts.rb +1 -1
  121. data/db/migrate/20110719082054_add_skype_to_contacts_and_leads.rb +1 -1
  122. data/db/migrate/20111101083437_create_fields.rb +1 -1
  123. data/db/migrate/20111101090312_create_field_groups.rb +1 -1
  124. data/db/migrate/20111116091952_add_field_groups_tag_id.rb +1 -1
  125. data/db/migrate/20111117041311_change_fields_collection_to_text.rb +1 -1
  126. data/db/migrate/20111201030535_add_field_groups_klass_name.rb +2 -2
  127. data/db/migrate/20120121054235_create_lists.rb +1 -1
  128. data/db/migrate/20120216031616_create_versions.rb +3 -3
  129. data/db/migrate/20120216042541_is_paranoid_to_paper_trail.rb +1 -1
  130. data/db/migrate/20120220233724_add_versions_object_changes.rb +1 -1
  131. data/db/migrate/20120224073107_remove_default_value_and_clear_settings.rb +1 -1
  132. data/db/migrate/20120309070209_add_versions_related.rb +1 -1
  133. data/db/migrate/20120314080441_add_subscribed_users_to_entities.rb +2 -2
  134. data/db/migrate/20120316045804_activities_to_versions.rb +1 -1
  135. data/db/migrate/20120405080727_change_subscribed_users_to_set.rb +1 -1
  136. data/db/migrate/20120405080742_change_further_subscribed_users_to_set.rb +2 -2
  137. data/db/migrate/20120406082136_create_groups.rb +2 -2
  138. data/db/migrate/20120413034923_add_index_on_versions_item_type.rb +1 -1
  139. data/db/migrate/20120510025219_add_not_null_constraints_for_timestamp_columns.rb +3 -3
  140. data/db/migrate/20120528102124_increase_length_of_version_events.rb +1 -1
  141. data/db/migrate/20120801032706_add_pair_id_to_fields.rb +1 -1
  142. data/db/migrate/20121003063155_add_settings_to_custom_fields.rb +1 -1
  143. data/db/migrate/20121221033947_fix_country_mapping.rb +1 -1
  144. data/db/migrate/20131207033244_add_user_id_to_lists.rb +1 -1
  145. data/db/migrate/20140916011927_add_created_at_index_on_versions.rb +1 -1
  146. data/db/migrate/20140916012922_add_indexes_to_model_associations.rb +3 -3
  147. data/db/migrate/20141126031837_increase_email_to254_chars.rb +1 -1
  148. data/db/migrate/20141230021159_add_transaction_id_column_to_versions.rb +1 -1
  149. data/db/migrate/20141230205453_add_missing_unique_indices.acts_as_taggable_on_engine.rb +4 -4
  150. data/db/migrate/20141230205454_add_taggings_counter_cache_to_tags.acts_as_taggable_on_engine.rb +1 -1
  151. data/db/migrate/20141230205455_add_missing_taggable_index.acts_as_taggable_on_engine.rb +3 -3
  152. data/db/migrate/20150123060900_convert_radio_to_radio_buttons.rb +1 -1
  153. data/db/migrate/20150227123054_remove_last_request_at_from_users.rb +1 -1
  154. data/db/migrate/20150427131956_create_index_related_type.rb +3 -3
  155. data/db/migrate/20160511053730_add_account_contacts_index.rb +2 -2
  156. data/docker-compose.yml +17 -13
  157. data/fat_free_crm.gemspec +4 -6
  158. data/lib/development_tasks/license.rake +12 -9
  159. data/lib/fat_free_crm/callback.rb +4 -4
  160. data/lib/fat_free_crm/engine.rb +2 -2
  161. data/lib/fat_free_crm/exportable.rb +2 -2
  162. data/lib/fat_free_crm/fields.rb +2 -4
  163. data/lib/fat_free_crm/gem_ext.rb +0 -1
  164. data/lib/fat_free_crm/gem_ext/rake/task.rb +2 -0
  165. data/lib/fat_free_crm/mail_processor/base.rb +4 -4
  166. data/lib/fat_free_crm/mail_processor/dropbox.rb +1 -1
  167. data/lib/fat_free_crm/permissions.rb +5 -5
  168. data/lib/fat_free_crm/sortable.rb +1 -1
  169. data/lib/fat_free_crm/version.rb +1 -1
  170. data/lib/gravatar_image_tag.rb +1 -0
  171. data/lib/tasks/ffcrm/demo.rake +2 -2
  172. data/spec/controllers/admin/users_controller_spec.rb +25 -25
  173. data/spec/controllers/authentications_controller_spec.rb +9 -9
  174. data/spec/controllers/comments_controller_spec.rb +15 -15
  175. data/spec/controllers/emails_controller_spec.rb +2 -2
  176. data/spec/controllers/entities/accounts_controller_spec.rb +46 -46
  177. data/spec/controllers/entities/campaigns_controller_spec.rb +46 -46
  178. data/spec/controllers/entities/contacts_controller_spec.rb +55 -55
  179. data/spec/controllers/entities/leads_controller_spec.rb +85 -85
  180. data/spec/controllers/entities/opportunities_controller_spec.rb +74 -74
  181. data/spec/controllers/home_controller_spec.rb +11 -11
  182. data/spec/controllers/passwords_controller_spec.rb +2 -2
  183. data/spec/controllers/tasks_controller_spec.rb +37 -37
  184. data/spec/controllers/users_controller_spec.rb +31 -31
  185. data/spec/factories/campaign_factories.rb +1 -1
  186. data/spec/factories/contact_factories.rb +1 -1
  187. data/spec/factories/field_factories.rb +1 -1
  188. data/spec/factories/lead_factories.rb +2 -2
  189. data/spec/factories/opportunity_factories.rb +3 -3
  190. data/spec/factories/shared_factories.rb +1 -1
  191. data/spec/factories/task_factories.rb +1 -1
  192. data/spec/features/support/browser.rb +9 -1
  193. data/spec/lib/fields_spec.rb +2 -2
  194. data/spec/lib/permissions_spec.rb +38 -6
  195. data/spec/lib/view_factory_spec.rb +2 -2
  196. data/spec/models/fields/custom_field_spec.rb +3 -3
  197. data/spec/models/observers/entity_observer_spec.rb +1 -1
  198. data/spec/models/polymorphic/version_spec.rb +11 -11
  199. data/spec/models/users/abilities/user_ability_spec.rb +8 -3
  200. data/spec/models/users/permission_spec.rb +8 -0
  201. data/spec/models/users/user_spec.rb +1 -1
  202. data/spec/shared/controllers.rb +10 -10
  203. data/spec/spec_helper.rb +1 -1
  204. data/spec/views/accounts/index.haml_spec.rb +1 -1
  205. data/spec/views/accounts/update.js.haml_spec.rb +2 -2
  206. data/spec/views/admin/users/update.js.haml_spec.rb +2 -2
  207. data/spec/views/application/auto_complete.haml_spec.rb +1 -1
  208. data/spec/views/campaigns/index.haml_spec.rb +1 -1
  209. data/spec/views/campaigns/update.js.haml_spec.rb +2 -2
  210. data/spec/views/contacts/index.haml_spec.rb +1 -1
  211. data/spec/views/contacts/update.js.haml_spec.rb +2 -2
  212. data/spec/views/home/options.js.haml_spec.rb +1 -1
  213. data/spec/views/leads/index.haml_spec.rb +1 -1
  214. data/spec/views/leads/promote.js.haml_spec.rb +2 -2
  215. data/spec/views/leads/update.js.haml_spec.rb +2 -2
  216. data/spec/views/opportunities/index.haml_spec.rb +1 -1
  217. data/spec/views/opportunities/update.js.haml_spec.rb +1 -1
  218. data/spec/views/tasks/_edit.haml_spec.rb +2 -2
  219. data/spec/views/tasks/create.js.haml_spec.rb +2 -2
  220. data/spec/views/tasks/edit.js.haml_spec.rb +1 -1
  221. data/spec/views/users/change_password.js.haml_spec.rb +2 -2
  222. data/spec/views/users/update.js.haml_spec.rb +2 -2
  223. data/spec/views/users/upload_avatar.js.haml_spec.rb +2 -2
  224. metadata +17 -20
  225. data/lib/fat_free_crm/gem_ext/active_record/schema_dumper.rb +0 -27
data/fat_free_crm.gemspec CHANGED
@@ -20,10 +20,9 @@ Gem::Specification.new do |gem|
20
20
  gem.required_ruby_version = '>= 2.0.0'
21
21
  gem.license = 'MIT'
22
22
 
23
- gem.add_dependency 'rails', '~> 4.2'
23
+ gem.add_dependency 'rails', '~> 5.0.0'
24
24
  gem.add_dependency 'rails-observers'
25
- # Sprockets 2.2.3 appears to have a bug resolving assets from the engine update to '>= 3.0.0 once released'
26
- gem.add_dependency 'sprockets-rails', '2.2.2'
25
+ gem.add_dependency 'sprockets-rails', '>= 3.0.0'
27
26
  gem.add_dependency 'responders', '~> 2.0'
28
27
  gem.add_dependency 'jquery-rails'
29
28
  gem.add_dependency 'jquery-migrate-rails'
@@ -35,7 +34,7 @@ Gem::Specification.new do |gem|
35
34
  # Manually added paperclip gem dependency "cocaine" in order to fix load error: "no such file to load -- cocaine"
36
35
  gem.add_dependency 'cocaine'
37
36
  gem.add_dependency 'paper_trail', '~> 6.0.0'
38
- gem.add_dependency 'authlogic', '>= 3.4.4', '< 3.5.0' # View tests fail on authlogic 3.5.0+
37
+ gem.add_dependency 'authlogic', '>= 3.4.4'
39
38
  gem.add_dependency 'acts_as_commentable'
40
39
  gem.add_dependency 'acts-as-taggable-on', '>= 3.4.3'
41
40
  gem.add_dependency 'dynamic_form'
@@ -49,7 +48,6 @@ Gem::Specification.new do |gem|
49
48
  gem.add_dependency 'nokogiri'
50
49
  gem.add_dependency 'responds_to_parent'
51
50
  gem.add_dependency 'rails3-jquery-autocomplete'
52
- gem.add_dependency 'psych', '~> 1' if RUBY_VERSION.to_f < 2.0
53
51
  gem.add_dependency 'thor'
54
52
  gem.add_dependency 'rails_autolink'
55
53
  gem.add_dependency 'coffee-script-source', '~> 1.8', '>= 1.8.0' # pegged until https://github.com/jashkenas/coffeescript/issues/3829 is resolved
@@ -58,6 +56,6 @@ Gem::Specification.new do |gem|
58
56
  # FatFreeCRM has released it's own versions of the following gems:
59
57
  #-----------------------------------------------------------------
60
58
  gem.add_dependency 'ransack_ui', '~> 1.3', '>= 1.3.1'
61
- gem.add_dependency 'ransack', '~> 1.6', '>= 1.6.2'
59
+ gem.add_dependency 'ransack', '~> 1.7', '>= 1.6.2'
62
60
  gem.add_dependency 'email_reply_parser_ffcrm'
63
61
  end
@@ -22,11 +22,13 @@ namespace :license do
22
22
  ],
23
23
  js: [
24
24
  "app/assets/javascripts/**/*.js",
25
+ "app/assets/javascripts/**/*.js.erb",
25
26
  "app/assets/stylesheets/**/*.sass", # Sass also uses javascript style comments
26
27
  "app/assets/stylesheets/**/*.scss"
27
28
  ],
28
29
  css: [
29
- "app/assets/stylesheets/**/*.css"
30
+ "app/assets/stylesheets/**/*.css",
31
+ "app/assets/stylesheets/**/*.css.erb"
30
32
  ] }
31
33
 
32
34
  LICENSE_RB = %{# Copyright (c) 2008-2013 Michael Dvorkin and contributors.
@@ -37,12 +39,11 @@ namespace :license do
37
39
  }
38
40
  LICENSES = { ruby: LICENSE_RB,
39
41
  js: LICENSE_RB.gsub(/^#/, "//"),
40
- css: LICENSE_RB.gsub(/^# Fat Free/, "/*\n * Fat Free")
41
- .gsub(/^#/, " \*").sub(/---\n/, "---\n */") }
42
+ css: "/*\n" + LICENSE_RB.gsub(/^#/, ' *').sub(/---\n/, "---\n */\n") }
42
43
 
43
- REGEXPS = { ruby: /^# Fat Free CRM\n# Copyright \(C\).*?\n(#.*\n)*#-{10}-*\n*/,
44
- js: /^\/\/ Fat Free CRM\n\/\/ Copyright \(C\).*?\n(\/\/.*\n)*\/\/-{10}-*\n*/,
45
- css: /^\/\*\n \* Fat Free CRM\n \* Copyright \(C\).*?\n( \*.*\n)* \*-{10}-*\n \*\/\n*/ }
44
+ REGEXPS = { ruby: /^# Copyright \(c\).*?\n(?:#.*\n)*?#-{10}-*\n/,
45
+ js: /^\/\/ Copyright \(c\).*?\n(?:\/\/.*\n)*?\/\/-{10}-*\n/,
46
+ css: /^\/\*\n \* Copyright \(c\).*?\n(?: \*.*\n)*? \*-{10}-*\n \*\/\n/ }
46
47
 
47
48
  def expand_globs(globs)
48
49
  globs.map { |f| Dir.glob(f) }.flatten.uniq
@@ -52,11 +53,13 @@ namespace :license do
52
53
  task :add do
53
54
  FILES.each do |lang, globs|
54
55
  expand_globs(globs).each do |file|
55
- puts "== Adding license to '#{file}'..."
56
56
  old_content = File.read(file)
57
57
  new_content = LICENSES[lang] + old_content.sub(REGEXPS[lang], '')
58
58
 
59
- File.open(file, "wb") { |f| f.puts new_content }
59
+ if new_content != old_content
60
+ File.open(file, "wb") { |f| f.puts new_content }
61
+ puts "== Added license to #{file}"
62
+ end
60
63
  end
61
64
  end
62
65
  end
@@ -69,7 +72,7 @@ namespace :license do
69
72
  new_content = old_content.sub(REGEXPS[lang], '')
70
73
  if new_content != old_content
71
74
  File.open(file, "wb") { |f| f.puts new_content }
72
- puts "Removed license from '#{file}'."
75
+ puts "== Removed license from #{file}"
73
76
  end
74
77
  end
75
78
  end
@@ -98,7 +98,7 @@ module FatFreeCRM
98
98
  add_view_hook(hook, proc { "" }, :replace)
99
99
  end
100
100
  end
101
- end # class Base
101
+ end
102
102
 
103
103
  # This makes it possible to call hook() without FatFreeCRM::Callback prefix.
104
104
  # Returns stringified data when called from within templates, and the actual
@@ -137,9 +137,9 @@ module FatFreeCRM
137
137
  FatFreeCRM::Callback.hook(method, caller, context)
138
138
  end
139
139
  end
140
- end # module Helper
141
- end # module Callback
142
- end # module FatFreeCRM
140
+ end
141
+ end
142
+ end
143
143
 
144
144
  ActionView::Base.send(:include, FatFreeCRM::Callback::Helper)
145
145
  ActionController::Base.send(:include, FatFreeCRM::Callback::Helper)
@@ -8,8 +8,8 @@ module FatFreeCRM
8
8
  config.autoload_paths += Dir[root.join("app/models/**")] +
9
9
  Dir[root.join("app/controllers/entities")]
10
10
 
11
- config.active_record.observers = [:lead_observer, :opportunity_observer,
12
- :task_observer, :entity_observer]
11
+ config.active_record.observers = %i[lead_observer opportunity_observer
12
+ task_observer entity_observer]
13
13
 
14
14
  initializer "model_core.factories", after: "factory_girl.set_factory_paths" do
15
15
  FactoryGirl.definition_file_paths << File.expand_path('../../../spec/factories', __FILE__) if defined?(FactoryGirl)
@@ -43,7 +43,7 @@ module FatFreeCRM
43
43
 
44
44
  module SingletonMethods
45
45
  end
46
- end # Exportable
47
- end # FatFreeCRM
46
+ end
47
+ end
48
48
 
49
49
  ActiveRecord::Base.send(:include, FatFreeCRM::Exportable)
@@ -22,7 +22,7 @@ module FatFreeCRM
22
22
 
23
23
  module SingletonMethods
24
24
  def field_groups
25
- if ActiveRecord::Base.connection.table_exists? 'field_groups'
25
+ if ActiveRecord::Base.connection.data_source_exists? 'field_groups'
26
26
  FieldGroup.where(klass_name: name).order(:position)
27
27
  else
28
28
  []
@@ -35,9 +35,7 @@ module FatFreeCRM
35
35
 
36
36
  def serialize_custom_fields!
37
37
  fields.each do |field|
38
- if !serialized_attributes.keys.include?(field.name) && field.as == 'check_boxes'
39
- serialize(field.name.to_sym, Array)
40
- end
38
+ serialize(field.name.to_sym, Array) if field.as == 'check_boxes'
41
39
  end
42
40
  end
43
41
 
@@ -3,7 +3,6 @@
3
3
  # Fat Free CRM is freely distributable under the terms of MIT license.
4
4
  # See MIT-LICENSE file or http://www.opensource.org/licenses/mit-license.php
5
5
  #------------------------------------------------------------------------------
6
- require "fat_free_crm/gem_ext/active_record/schema_dumper"
7
6
  require "fat_free_crm/gem_ext/active_support/buffered_logger"
8
7
  require "fat_free_crm/gem_ext/action_controller/base"
9
8
  require "fat_free_crm/gem_ext/simple_form/action_view_extensions/form_helper"
@@ -3,6 +3,8 @@
3
3
  # Fat Free CRM is freely distributable under the terms of MIT license.
4
4
  # See MIT-LICENSE file or http://www.opensource.org/licenses/mit-license.php
5
5
  #------------------------------------------------------------------------------
6
+ require 'rake/task'
7
+
6
8
  module Rake
7
9
  Task.class_eval do
8
10
  # Removes a Rake task
@@ -12,7 +12,7 @@ require 'nokogiri'
12
12
  module FatFreeCRM
13
13
  module MailProcessor
14
14
  class Base
15
- KEYWORDS = %w(account campaign contact lead opportunity).freeze
15
+ KEYWORDS = %w[account campaign contact lead opportunity].freeze
16
16
 
17
17
  #--------------------------------------------------------------------------------------
18
18
  def initialize
@@ -94,7 +94,7 @@ module FatFreeCRM
94
94
 
95
95
  #--------------------------------------------------------------------------------------
96
96
  def with_new_emails
97
- @imap.uid_search(%w(NOT SEEN)).each do |uid|
97
+ @imap.uid_search(%w[NOT SEEN]).each do |uid|
98
98
  begin
99
99
  email = Mail.new(@imap.uid_fetch(uid, 'RFC822').first.attr['RFC822'])
100
100
  log "fetched new message...", email
@@ -104,7 +104,7 @@ module FatFreeCRM
104
104
  discard(uid)
105
105
  end
106
106
  rescue Exception => e
107
- if %w(test development).include?(Rails.env)
107
+ if %w[test development].include?(Rails.env)
108
108
  $stderr.puts e
109
109
  $stderr.puts e.backtrace
110
110
  end
@@ -184,7 +184,7 @@ module FatFreeCRM
184
184
  # Centralized logging.
185
185
  #--------------------------------------------------------------------------------------
186
186
  def log(message, email = nil)
187
- unless %w(test cucumber).include?(Rails.env)
187
+ unless %w[test cucumber].include?(Rails.env)
188
188
  klass = self.class.to_s.split("::").last
189
189
  klass << " [Dry Run]" if @dry_run
190
190
  puts "[#{Time.now.rfc822}] #{klass}: #{message}"
@@ -8,7 +8,7 @@ require 'fat_free_crm/mail_processor/base'
8
8
  module FatFreeCRM
9
9
  module MailProcessor
10
10
  class Dropbox < Base
11
- KEYWORDS = %w(account campaign contact lead opportunity).freeze
11
+ KEYWORDS = %w[account campaign contact lead opportunity].freeze
12
12
 
13
13
  #--------------------------------------------------------------------------------------
14
14
  def initialize
@@ -33,7 +33,7 @@ module FatFreeCRM
33
33
  module InstanceMethods
34
34
  # Save shared permissions to the model, if any.
35
35
  #--------------------------------------------------------------------------
36
- %w(group user).each do |model|
36
+ %w[group user].each do |model|
37
37
  class_eval %{
38
38
 
39
39
  def #{model}_ids=(value)
@@ -44,7 +44,7 @@ module FatFreeCRM
44
44
  permissions_to_remove = Permission.where(
45
45
  #{model}_id: self.#{model}_ids - value,
46
46
  asset_id: self.id,
47
- asset_type: self.class
47
+ asset_type: self.class.name
48
48
  )
49
49
  permissions_to_remove.each {|p| (permissions.delete(p); p.destroy)}
50
50
  (value - self.#{model}_ids).each {|id| permissions.build(:#{model}_id => id)}
@@ -69,7 +69,7 @@ module FatFreeCRM
69
69
  def remove_permissions
70
70
  # we don't use dependent => :destroy so must manually remove
71
71
  if id && self.class
72
- permissions_to_remove = Permission.where(asset_id: id, asset_type: self.class.to_s).to_a
72
+ permissions_to_remove = Permission.where(asset_id: id, asset_type: self.class.name).to_a
73
73
  else
74
74
  permissions_to_remove = []
75
75
  end
@@ -103,7 +103,7 @@ module FatFreeCRM
103
103
 
104
104
  module SingletonMethods
105
105
  end
106
- end # Permissions
107
- end # FatFreeCRM
106
+ end
107
+ end
108
108
 
109
109
  ActiveRecord::Base.send(:include, FatFreeCRM::Permissions)
@@ -36,7 +36,7 @@ module FatFreeCRM
36
36
  end
37
37
  ]
38
38
  end
39
- end # ClassMethods
39
+ end
40
40
  end
41
41
  end
42
42
 
@@ -8,7 +8,7 @@ module FatFreeCRM
8
8
  MAJOR = 0
9
9
  MINOR = 15
10
10
  TINY = 0
11
- PRE = 'beta.2'
11
+ PRE = nil
12
12
 
13
13
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
14
14
  end
@@ -22,6 +22,7 @@ module GravatarImageTag
22
22
 
23
23
  module InstanceMethods
24
24
  def gravatar_image_tag(email, options = {})
25
+ raise ArgumentError, "Options must be a hash, got #{options.inspect}" unless options.is_a? Hash
25
26
  options[:alt] ||= 'Gravatar'
26
27
  image_tag(GravatarImageTag.gravatar_url(email, options.delete(:gravatar)), options)
27
28
  end
@@ -10,7 +10,7 @@ namespace :ffcrm do
10
10
  # Load fixtures
11
11
  require 'active_record/fixtures'
12
12
  Dir.glob(FatFreeCRM.root.join('db', 'demo', '*.{yml,csv}')).each do |fixture_file|
13
- ActiveRecord::Fixtures.create_fixtures(FatFreeCRM.root.join('db/demo'), File.basename(fixture_file, '.*'))
13
+ ActiveRecord::FixtureSet.create_fixtures(FatFreeCRM.root.join('db/demo'), File.basename(fixture_file, '.*'))
14
14
  end
15
15
 
16
16
  def create_version(options)
@@ -22,7 +22,7 @@ namespace :ffcrm do
22
22
  # Simulate random user activities.
23
23
  $stdout.sync = true
24
24
  puts "Generating user activities..."
25
- %w(Account Address Campaign Comment Contact Email Lead Opportunity Task).map do |model|
25
+ %w[Account Address Campaign Comment Contact Email Lead Opportunity Task].map do |model|
26
26
  model.constantize.all
27
27
  end.flatten.each do |item|
28
28
  user = if item.respond_to?(:user)
@@ -28,7 +28,7 @@ describe Admin::UsersController do
28
28
  @amy = FactoryGirl.create(:user, username: "amy_anderson")
29
29
  @bob = FactoryGirl.create(:user, username: "bob_builder")
30
30
 
31
- get :index, query: "amy_anderson"
31
+ get :index, params: { query: "amy_anderson" }
32
32
  expect(assigns[:users]).to eq([@amy])
33
33
  expect(assigns[:current_query]).to eq("amy_anderson")
34
34
  expect(session[:users_current_query]).to eq("amy_anderson")
@@ -42,7 +42,7 @@ describe Admin::UsersController do
42
42
  it "assigns the requested user as @user and renders [show] template" do
43
43
  @user = FactoryGirl.create(:user)
44
44
 
45
- get :show, id: @user.id
45
+ get :show, params: { id: @user.id }
46
46
  expect(assigns[:user]).to eq(@user)
47
47
  expect(response).to render_template("admin/users/show")
48
48
  end
@@ -53,7 +53,7 @@ describe Admin::UsersController do
53
53
  #----------------------------------------------------------------------------
54
54
  describe "GET new" do
55
55
  it "assigns a new user as @user and renders [new] template" do
56
- xhr :get, :new
56
+ get :new, xhr: true
57
57
  expect(assigns[:user]).to be_new_record
58
58
  expect(response).to render_template("admin/users/new")
59
59
  end
@@ -65,7 +65,7 @@ describe Admin::UsersController do
65
65
  it "assigns the requested user as @user and renders [edit] template" do
66
66
  @user = FactoryGirl.create(:user)
67
67
 
68
- xhr :get, :edit, id: @user.id
68
+ get :edit, params: { id: @user.id }, xhr: true
69
69
  expect(assigns[:user]).to eq(@user)
70
70
  expect(assigns[:previous]).to eq(nil)
71
71
  expect(response).to render_template("admin/users/edit")
@@ -75,7 +75,7 @@ describe Admin::UsersController do
75
75
  @user = FactoryGirl.create(:user)
76
76
  @previous = FactoryGirl.create(:user)
77
77
 
78
- xhr :get, :edit, id: @user.id, previous: @previous.id
78
+ get :edit, params: { id: @user.id, previous: @previous.id }, xhr: true
79
79
  expect(assigns[:previous]).to eq(@previous)
80
80
  end
81
81
 
@@ -83,7 +83,7 @@ describe Admin::UsersController do
83
83
  @user = FactoryGirl.create(:user)
84
84
  @user.destroy
85
85
 
86
- xhr :get, :edit, id: @user.id
86
+ get :edit, params: { id: @user.id }, xhr: true
87
87
  expect(flash[:warning]).not_to eq(nil)
88
88
  expect(response.body).to eq("window.location.reload();")
89
89
  end
@@ -93,7 +93,7 @@ describe Admin::UsersController do
93
93
  @previous = FactoryGirl.create(:user)
94
94
  @previous.destroy
95
95
 
96
- xhr :get, :edit, id: @user.id, previous: @previous.id
96
+ get :edit, params: { id: @user.id, previous: @previous.id }, xhr: true
97
97
  expect(flash[:warning]).to eq(nil) # no warning, just silently remove the div
98
98
  expect(assigns[:previous]).to eq(@previous.id)
99
99
  expect(response).to render_template("admin/users/edit")
@@ -115,19 +115,19 @@ describe Admin::UsersController do
115
115
  @user = FactoryGirl.build(:user, username: @username, email: @email)
116
116
  allow(User).to receive(:new).and_return(@user)
117
117
 
118
- xhr :post, :create, user: { username: @username, email: @email, password: @password, password_confirmation: @password }
118
+ post :create, params: { user: { username: @username, email: @email, password: @password, password_confirmation: @password } }, xhr: true
119
119
  expect(assigns[:user]).to eq(@user)
120
120
  expect(response).to render_template("admin/users/create")
121
121
  end
122
122
 
123
123
  it "creates admin user when requested so" do
124
- xhr :post, :create, user: { username: @username, email: @email, admin: "1", password: @password, password_confirmation: @password }
124
+ post :create, params: { user: { username: @username, email: @email, admin: "1", password: @password, password_confirmation: @password } }, xhr: true
125
125
  expect(assigns[:user].admin).to eq(true)
126
126
  expect(response).to render_template("admin/users/create")
127
127
  end
128
128
 
129
129
  it "doesn't create admin user unless requested so" do
130
- xhr :post, :create, user: { username: @username, email: @email, admin: "0", password: @password, password_confirmation: @password }
130
+ post :create, params: { user: { username: @username, email: @email, admin: "0", password: @password, password_confirmation: @password } }, xhr: true
131
131
  expect(assigns[:user].admin).to eq(false)
132
132
  expect(response).to render_template("admin/users/create")
133
133
  end
@@ -138,7 +138,7 @@ describe Admin::UsersController do
138
138
  @user = FactoryGirl.build(:user, username: "", email: "")
139
139
  allow(User).to receive(:new).and_return(@user)
140
140
 
141
- xhr :post, :create, user: {}
141
+ post :create, params: { user: {} }, xhr: true
142
142
  expect(assigns[:user]).to eq(@user)
143
143
  expect(response).to render_template("admin/users/create")
144
144
  end
@@ -153,7 +153,7 @@ describe Admin::UsersController do
153
153
  it "updates the requested user, assigns it to @user, and renders [update] template" do
154
154
  @user = FactoryGirl.create(:user, username: "flip", email: "flip@example.com")
155
155
 
156
- xhr :put, :update, id: @user.id, user: { username: "flop", email: "flop@example.com" }
156
+ put :update, params: { id: @user.id, user: { username: "flop", email: "flop@example.com" } }, xhr: true
157
157
  expect(assigns[:user]).to eq(@user.reload)
158
158
  expect(assigns[:user].username).to eq("flop")
159
159
  expect(response).to render_template("admin/users/update")
@@ -163,14 +163,14 @@ describe Admin::UsersController do
163
163
  @user = FactoryGirl.create(:user)
164
164
  @user.destroy
165
165
 
166
- xhr :put, :update, id: @user.id, user: { username: "flop", email: "flop@example.com" }
166
+ put :update, params: { id: @user.id, user: { username: "flop", email: "flop@example.com" } }, xhr: true
167
167
  expect(flash[:warning]).not_to eq(nil)
168
168
  expect(response.body).to eq("window.location.reload();")
169
169
  end
170
170
 
171
171
  it "assigns admin rights when requested so" do
172
172
  @user = FactoryGirl.create(:user, admin: false)
173
- xhr :put, :update, id: @user.id, user: { admin: "1", username: @user.username, email: @user.email }
173
+ put :update, params: { id: @user.id, user: { admin: "1", username: @user.username, email: @user.email } }, xhr: true
174
174
  expect(assigns[:user]).to eq(@user.reload)
175
175
  expect(assigns[:user].admin).to eq(true)
176
176
  expect(response).to render_template("admin/users/update")
@@ -178,7 +178,7 @@ describe Admin::UsersController do
178
178
 
179
179
  it "revokes admin rights when requested so" do
180
180
  @user = FactoryGirl.create(:user, admin: true)
181
- xhr :put, :update, id: @user.id, user: { admin: "0", username: @user.username, email: @user.email }
181
+ put :update, params: { id: @user.id, user: { admin: "0", username: @user.username, email: @user.email } }, xhr: true
182
182
  expect(assigns[:user]).to eq(@user.reload)
183
183
  expect(assigns[:user].admin).to eq(false)
184
184
  expect(response).to render_template("admin/users/update")
@@ -189,7 +189,7 @@ describe Admin::UsersController do
189
189
  it "doesn't update the requested user, but assigns it to @user and renders [update] template" do
190
190
  @user = FactoryGirl.create(:user, username: "flip", email: "flip@example.com")
191
191
 
192
- xhr :put, :update, id: @user.id, user: {}
192
+ put :update, params: { id: @user.id, user: {} }, xhr: true
193
193
  expect(assigns[:user]).to eq(@user.reload)
194
194
  expect(assigns[:user].username).to eq("flip")
195
195
  expect(response).to render_template("admin/users/update")
@@ -203,7 +203,7 @@ describe Admin::UsersController do
203
203
  it "assigns the requested user as @user and renders [confirm] template" do
204
204
  @user = FactoryGirl.create(:user)
205
205
 
206
- xhr :get, :confirm, id: @user.id
206
+ get :confirm, params: { id: @user.id }, xhr: true
207
207
  expect(assigns[:user]).to eq(@user)
208
208
  expect(response).to render_template("admin/users/confirm")
209
209
  end
@@ -212,7 +212,7 @@ describe Admin::UsersController do
212
212
  @user = FactoryGirl.create(:user)
213
213
  @user.destroy
214
214
 
215
- xhr :get, :confirm, id: @user.id
215
+ get :confirm, params: { id: @user.id }, xhr: true
216
216
  expect(flash[:warning]).not_to eq(nil)
217
217
  expect(response.body).to eq("window.location.reload();")
218
218
  end
@@ -225,7 +225,7 @@ describe Admin::UsersController do
225
225
  it "destroys the requested user and renders [destroy] template" do
226
226
  @user = FactoryGirl.create(:user)
227
227
 
228
- xhr :delete, :destroy, id: @user.id
228
+ delete :destroy, params: { id: @user.id }, xhr: true
229
229
  expect { User.find(@user.id) }.to raise_error(ActiveRecord::RecordNotFound)
230
230
  expect(response).to render_template("admin/users/destroy")
231
231
  end
@@ -234,7 +234,7 @@ describe Admin::UsersController do
234
234
  @user = FactoryGirl.create(:user)
235
235
  @account = FactoryGirl.create(:account, user: @user) # Plant artifact to prevent the user from being deleted.
236
236
 
237
- xhr :delete, :destroy, id: @user.id
237
+ delete :destroy, params: { id: @user.id }, xhr: true
238
238
  expect(flash[:warning]).not_to eq(nil)
239
239
  expect { User.find(@user.id) }.not_to raise_error
240
240
  expect(response).to render_template("admin/users/destroy")
@@ -258,7 +258,7 @@ describe Admin::UsersController do
258
258
  it "suspends the requested user" do
259
259
  @user = FactoryGirl.create(:user)
260
260
 
261
- xhr :put, :suspend, id: @user.id
261
+ put :suspend, params: { id: @user.id }, xhr: true
262
262
  expect(assigns[:user].suspended?).to eq(true)
263
263
  expect(response).to render_template("admin/users/suspend")
264
264
  end
@@ -266,7 +266,7 @@ describe Admin::UsersController do
266
266
  it "doesn't suspend current user" do
267
267
  @user = current_user
268
268
 
269
- xhr :put, :suspend, id: @user.id
269
+ put :suspend, params: { id: @user.id }, xhr: true
270
270
  expect(assigns[:user].suspended?).to eq(false)
271
271
  expect(response).to render_template("admin/users/suspend")
272
272
  end
@@ -275,7 +275,7 @@ describe Admin::UsersController do
275
275
  @user = FactoryGirl.create(:user)
276
276
  @user.destroy
277
277
 
278
- xhr :put, :suspend, id: @user.id
278
+ put :suspend, params: { id: @user.id }, xhr: true
279
279
  expect(flash[:warning]).not_to eq(nil)
280
280
  expect(response.body).to eq("window.location.reload();")
281
281
  end
@@ -288,7 +288,7 @@ describe Admin::UsersController do
288
288
  it "re-activates the requested user" do
289
289
  @user = FactoryGirl.create(:user, suspended_at: Time.now.yesterday)
290
290
 
291
- xhr :put, :reactivate, id: @user.id
291
+ put :reactivate, params: { id: @user.id }, xhr: true
292
292
  expect(assigns[:user].suspended?).to eq(false)
293
293
  expect(response).to render_template("admin/users/reactivate")
294
294
  end
@@ -297,7 +297,7 @@ describe Admin::UsersController do
297
297
  @user = FactoryGirl.create(:user)
298
298
  @user.destroy
299
299
 
300
- xhr :put, :reactivate, id: @user.id
300
+ put :reactivate, params: { id: @user.id }, xhr: true
301
301
  expect(flash[:warning]).not_to eq(nil)
302
302
  expect(response.body).to eq("window.location.reload();")
303
303
  end