fat_free_crm 0.13.6 → 0.14.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 (534) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +5 -0
  3. data/.travis.yml +8 -5
  4. data/CHANGELOG +26 -0
  5. data/Gemfile +26 -26
  6. data/Gemfile.lock +280 -250
  7. data/Guardfile +0 -1
  8. data/README.md +7 -9
  9. data/Rakefile +1 -1
  10. data/app/assets/javascripts/application.js.erb +1 -0
  11. data/app/assets/javascripts/crm.js.coffee +6 -7
  12. data/app/assets/javascripts/search.js.coffee +7 -1
  13. data/app/assets/stylesheets/about.css.scss +10 -0
  14. data/app/assets/stylesheets/application.css.erb +2 -0
  15. data/app/assets/stylesheets/common.scss +1 -1
  16. data/app/controllers/admin/application_controller.rb +3 -3
  17. data/app/controllers/admin/field_groups_controller.rb +12 -7
  18. data/app/controllers/admin/fields_controller.rb +21 -17
  19. data/app/controllers/admin/groups_controller.rb +10 -4
  20. data/app/controllers/admin/plugins_controller.rb +1 -2
  21. data/app/controllers/admin/settings_controller.rb +1 -2
  22. data/app/controllers/admin/tags_controller.rb +10 -4
  23. data/app/controllers/admin/users_controller.rb +32 -12
  24. data/app/controllers/application_controller.rb +58 -38
  25. data/app/controllers/authentications_controller.rb +5 -8
  26. data/app/controllers/comments_controller.rb +15 -11
  27. data/app/controllers/emails_controller.rb +1 -2
  28. data/app/controllers/entities/accounts_controller.rb +20 -20
  29. data/app/controllers/entities/campaigns_controller.rb +25 -22
  30. data/app/controllers/entities/contacts_controller.rb +25 -24
  31. data/app/controllers/entities/leads_controller.rb +33 -31
  32. data/app/controllers/entities/opportunities_controller.rb +31 -28
  33. data/app/controllers/entities_controller.rb +26 -22
  34. data/app/controllers/home_controller.rb +18 -18
  35. data/app/controllers/lists_controller.rb +11 -7
  36. data/app/controllers/passwords_controller.rb +5 -6
  37. data/app/controllers/tasks_controller.rb +23 -18
  38. data/app/controllers/users_controller.rb +31 -7
  39. data/app/helpers/accounts_helper.rb +40 -42
  40. data/app/helpers/addresses_helper.rb +1 -3
  41. data/app/helpers/admin/application_helper.rb +4 -4
  42. data/app/helpers/admin/field_groups_helper.rb +5 -7
  43. data/app/helpers/admin/fields_helper.rb +2 -3
  44. data/app/helpers/admin/plugins_helper.rb +0 -1
  45. data/app/helpers/admin/settings_helper.rb +0 -1
  46. data/app/helpers/admin/tags_helper.rb +1 -1
  47. data/app/helpers/admin/users_helper.rb +16 -18
  48. data/app/helpers/application_helper.rb +127 -119
  49. data/app/helpers/authentications_helper.rb +0 -1
  50. data/app/helpers/campaigns_helper.rb +5 -7
  51. data/app/helpers/comments_helper.rb +0 -1
  52. data/app/helpers/contacts_helper.rb +0 -1
  53. data/app/helpers/home_helper.rb +14 -14
  54. data/app/helpers/javascript_helper.rb +30 -0
  55. data/app/helpers/leads_helper.rb +7 -7
  56. data/app/helpers/opportunities_helper.rb +8 -10
  57. data/app/helpers/passwords_helper.rb +0 -1
  58. data/app/helpers/tags_helper.rb +1 -3
  59. data/app/helpers/tasks_helper.rb +24 -26
  60. data/app/helpers/users_helper.rb +6 -7
  61. data/app/helpers/versions_helper.rb +3 -5
  62. data/app/inputs/date_pair_input.rb +6 -7
  63. data/app/inputs/date_time_input.rb +3 -4
  64. data/app/inputs/datetime_pair_input.rb +0 -1
  65. data/app/inputs/text_input.rb +2 -2
  66. data/app/mailers/dropbox_mailer.rb +4 -7
  67. data/app/mailers/subscription_mailer.rb +4 -5
  68. data/app/mailers/user_mailer.rb +7 -9
  69. data/app/models/entities/account.rb +31 -28
  70. data/app/models/entities/account_contact.rb +2 -1
  71. data/app/models/entities/account_opportunity.rb +1 -1
  72. data/app/models/entities/campaign.rb +22 -19
  73. data/app/models/entities/contact.rb +55 -53
  74. data/app/models/entities/contact_opportunity.rb +1 -1
  75. data/app/models/entities/lead.rb +49 -41
  76. data/app/models/entities/opportunity.rb +38 -38
  77. data/app/models/fields/custom_field.rb +21 -27
  78. data/app/models/fields/custom_field_date_pair.rb +7 -8
  79. data/app/models/fields/custom_field_datetime_pair.rb +0 -2
  80. data/app/models/fields/custom_field_pair.rb +8 -10
  81. data/app/models/fields/field.rb +29 -30
  82. data/app/models/fields/field_group.rb +4 -4
  83. data/app/models/list.rb +1 -1
  84. data/app/models/observers/entity_observer.rb +1 -1
  85. data/app/models/observers/lead_observer.rb +1 -1
  86. data/app/models/observers/opportunity_observer.rb +1 -1
  87. data/app/models/observers/task_observer.rb +1 -1
  88. data/app/models/polymorphic/address.rb +7 -7
  89. data/app/models/polymorphic/avatar.rb +8 -9
  90. data/app/models/polymorphic/comment.rb +16 -10
  91. data/app/models/polymorphic/email.rb +13 -6
  92. data/app/models/polymorphic/tag.rb +2 -2
  93. data/app/models/polymorphic/task.rb +45 -45
  94. data/{config/initializers/paper_trail.rb → app/models/polymorphic/version.rb} +26 -31
  95. data/app/models/setting.rb +12 -17
  96. data/app/models/users/ability.rb +5 -6
  97. data/app/models/users/authentication.rb +6 -5
  98. data/app/models/users/group.rb +1 -3
  99. data/app/models/users/permission.rb +3 -3
  100. data/app/models/users/preference.rb +7 -7
  101. data/app/models/users/user.rb +36 -43
  102. data/app/views/accounts/_top_section.html.haml +2 -2
  103. data/app/views/accounts/edit.js.haml +0 -1
  104. data/app/views/admin/fields/_field.html.haml +1 -1
  105. data/app/views/admin/tags/_tag.html.haml +1 -1
  106. data/app/views/admin/users/_user.html.haml +4 -4
  107. data/app/views/campaigns/_top_section.html.haml +1 -1
  108. data/app/views/campaigns/edit.js.haml +0 -2
  109. data/app/views/contacts/_top_section.html.haml +1 -1
  110. data/app/views/contacts/edit.js.haml +0 -1
  111. data/app/views/entities/_basic_search.html.haml +1 -1
  112. data/app/views/home/_account.html.haml +2 -2
  113. data/app/views/home/_opportunity.html.haml +2 -2
  114. data/app/views/layouts/_about.html.haml +1 -1
  115. data/app/views/leads/_top_section.html.haml +1 -1
  116. data/app/views/leads/edit.js.haml +0 -2
  117. data/app/views/lists/_sidebar.html.haml +1 -1
  118. data/app/views/opportunities/_top_section.html.haml +2 -2
  119. data/app/views/opportunities/edit.js.haml +0 -1
  120. data/app/views/shared/_tags.html.haml +2 -1
  121. data/app/views/tasks/_edit.html.haml +2 -3
  122. data/app/views/tasks/_top_section.html.haml +1 -1
  123. data/app/views/users/_user.html.haml +2 -1
  124. data/app/views/users/opportunities_overview.html.haml +2 -2
  125. data/bin/bundle +3 -0
  126. data/bin/rails +4 -0
  127. data/bin/rake +4 -0
  128. data/config/application.rb +16 -33
  129. data/config/boot.rb +1 -1
  130. data/config/database.mysql.mac.yml +1 -0
  131. data/config/database.mysql.yml +1 -0
  132. data/config/database.postgres.docker.yml +1 -1
  133. data/config/database.postgres.yml +1 -0
  134. data/config/database.sqlite.yml +1 -0
  135. data/config/deploy.example.rb +3 -5
  136. data/config/environments/development.rb +13 -14
  137. data/config/environments/production.rb +8 -7
  138. data/config/environments/staging.rb +43 -41
  139. data/config/environments/test.rb +12 -14
  140. data/config/initializers/assets.rb +14 -0
  141. data/config/initializers/backtrace_silencers.rb +7 -0
  142. data/config/initializers/cookies_serializer.rb +3 -0
  143. data/config/initializers/custom_field_ransack_translations.rb +1 -1
  144. data/config/initializers/filter_parameter_logging.rb +4 -0
  145. data/config/initializers/inflections.rb +16 -0
  146. data/config/initializers/mime_types.rb +0 -1
  147. data/config/initializers/paginate_arrays.rb +0 -1
  148. data/config/initializers/ransack.rb +5 -5
  149. data/config/initializers/session_store.rb +5 -0
  150. data/config/initializers/simple_form.rb +1 -1
  151. data/config/initializers/views.rb +33 -33
  152. data/config/initializers/wrap_parameters.rb +14 -0
  153. data/config/locales/cz_fat_free_crm.yml +1 -1
  154. data/config/locales/de_fat_free_crm.yml +2 -2
  155. data/config/locales/en-GB_fat_free_crm.yml +2 -3
  156. data/config/locales/en-US_fat_free_crm.yml +2 -3
  157. data/config/locales/en.yml +23 -0
  158. data/config/locales/es-CL.yml +227 -0
  159. data/config/locales/es-CL_fat_free_crm.yml +929 -0
  160. data/config/locales/es-CL_ransack.yml +91 -0
  161. data/config/locales/es.yml +53 -59
  162. data/config/locales/es_fat_free_crm.yml +708 -370
  163. data/config/locales/es_ransack.yml +91 -0
  164. data/config/locales/fr-CA_fat_free_crm.yml +7 -7
  165. data/config/locales/fr_fat_free_crm.yml +285 -81
  166. data/config/locales/it_fat_free_crm.yml +1 -1
  167. data/config/locales/ja_fat_free_crm.yml +1 -1
  168. data/config/locales/nl.yml +210 -0
  169. data/config/locales/nl_fat_free_crm.yml +920 -0
  170. data/config/locales/nl_ransack.yml +91 -0
  171. data/config/locales/pl_fat_free_crm.yml +1 -1
  172. data/config/locales/pt-BR_fat_free_crm.yml +111 -38
  173. data/config/locales/ru_fat_free_crm.yml +3 -4
  174. data/config/locales/sv-SE_fat_free_crm.yml +1 -1
  175. data/config/locales/th.rb +157 -158
  176. data/config/locales/th_fat_free_crm.yml +1 -1
  177. data/config/locales/zh-CN_fat_free_crm.yml +3 -4
  178. data/config/routes.rb +93 -94
  179. data/config/unicorn.rb +25 -2
  180. data/custom_plan.rb +0 -2
  181. data/db/demo/accounts.yml +4 -5
  182. data/db/demo/addresses.yml +5 -5
  183. data/db/demo/campaigns.yml +2 -2
  184. data/db/demo/comments.yml +1 -1
  185. data/db/demo/contacts.yml +8 -8
  186. data/db/demo/emails.yml +5 -5
  187. data/db/demo/leads.yml +10 -10
  188. data/db/demo/opportunities.yml +2 -2
  189. data/db/demo/tasks.yml +2 -2
  190. data/db/demo/users.yml +12 -16
  191. data/db/migrate/20100928030598_create_sessions.rb +1 -2
  192. data/db/migrate/20100928030599_create_users.rb +24 -25
  193. data/db/migrate/20100928030600_create_openid_tables.rb +11 -12
  194. data/db/migrate/20100928030601_create_accounts.rb +14 -15
  195. data/db/migrate/20100928030602_create_permissions.rb +2 -3
  196. data/db/migrate/20100928030603_create_settings.rb +4 -5
  197. data/db/migrate/20100928030604_create_preferences.rb +3 -4
  198. data/db/migrate/20100928030605_create_campaigns.rb +19 -20
  199. data/db/migrate/20100928030606_create_leads.rb +26 -27
  200. data/db/migrate/20100928030607_create_contacts.rb +26 -27
  201. data/db/migrate/20100928030608_create_opportunities.rb +15 -16
  202. data/db/migrate/20100928030609_create_account_contacts.rb +2 -3
  203. data/db/migrate/20100928030610_create_account_opportunities.rb +2 -3
  204. data/db/migrate/20100928030611_create_contact_opportunities.rb +3 -4
  205. data/db/migrate/20100928030612_create_tasks.rb +14 -15
  206. data/db/migrate/20100928030613_create_comments.rb +6 -7
  207. data/db/migrate/20100928030614_create_activities.rb +6 -7
  208. data/db/migrate/20100928030615_create_avatars.rb +5 -6
  209. data/db/migrate/20100928030616_rename_remember_token.rb +0 -1
  210. data/db/migrate/20100928030617_drop_openid_tables.rb +11 -11
  211. data/db/migrate/20100928030618_add_admin_to_users.rb +1 -2
  212. data/db/migrate/20100928030619_add_suspended_to_users.rb +0 -1
  213. data/db/migrate/20100928030620_remove_uuid.rb +3 -3
  214. data/db/migrate/20100928030621_add_email_to_accounts.rb +1 -2
  215. data/db/migrate/20100928030622_add_background_info_to_models.rb +0 -1
  216. data/db/migrate/20100928030623_create_addresses.rb +14 -16
  217. data/db/migrate/20100928030624_add_index_on_permissions.rb +2 -3
  218. data/db/migrate/20100928030625_create_emails.rb +15 -16
  219. data/db/migrate/20100928030626_add_state_to_timeline_objects.rb +2 -3
  220. data/db/migrate/20100928030627_acts_as_taggable_on_migration.rb +2 -3
  221. data/db/migrate/20101221123456_add_single_access_token_to_users.rb +0 -1
  222. data/db/migrate/20101221345678_add_rating_and_category_to_accounts.rb +2 -3
  223. data/db/migrate/20110719082054_add_skype_to_contacts_and_leads.rb +2 -3
  224. data/db/migrate/20111101083437_create_fields.rb +14 -15
  225. data/db/migrate/20111101090312_create_field_groups.rb +4 -5
  226. data/db/migrate/20111116091952_add_field_groups_tag_id.rb +0 -1
  227. data/db/migrate/20111117041311_change_fields_collection_to_text.rb +0 -1
  228. data/db/migrate/20111201030535_add_field_groups_klass_name.rb +4 -4
  229. data/db/migrate/20120121054235_create_lists.rb +1 -1
  230. data/db/migrate/20120216031616_create_versions.rb +5 -5
  231. data/db/migrate/20120216042541_is_paranoid_to_paper_trail.rb +1 -3
  232. data/db/migrate/20120224073107_remove_default_value_and_clear_settings.rb +1 -1
  233. data/db/migrate/20120316045804_activities_to_versions.rb +6 -6
  234. data/db/migrate/20120405080727_change_subscribed_users_to_set.rb +5 -5
  235. data/db/migrate/20120405080742_change_further_subscribed_users_to_set.rb +5 -5
  236. data/db/migrate/20120406082136_create_groups.rb +1 -1
  237. data/db/migrate/20120510025219_add_not_null_constraints_for_timestamp_columns.rb +2 -1
  238. data/db/migrate/20120528102124_increase_length_of_version_events.rb +2 -2
  239. data/db/migrate/20121003063155_add_settings_to_custom_fields.rb +1 -1
  240. data/db/migrate/20121221033947_fix_country_mapping.rb +0 -1
  241. data/db/migrate/20131207033244_add_user_id_to_lists.rb +1 -1
  242. data/db/migrate/20141126031837_increase_email_to254_chars.rb +14 -14
  243. data/db/migrate/20141230021159_add_transaction_id_column_to_versions.rb +11 -0
  244. data/db/migrate/20141230205453_add_missing_unique_indices.acts_as_taggable_on_engine.rb +20 -0
  245. data/db/migrate/20141230205454_add_taggings_counter_cache_to_tags.acts_as_taggable_on_engine.rb +15 -0
  246. data/db/migrate/20141230205455_add_missing_taggable_index.acts_as_taggable_on_engine.rb +10 -0
  247. data/db/migrate/20150123060900_convert_radio_to_radio_buttons.rb +10 -0
  248. data/db/migrate/20150227123054_remove_last_request_at_from_users.rb +5 -0
  249. data/db/migrate/20150427131956_create_index_related_type.rb +9 -0
  250. data/db/migrate/20160511053730_add_account_contacts_index.rb +5 -0
  251. data/db/schema.rb +236 -228
  252. data/db/seeds.rb +1 -2
  253. data/db/seeds/fields.rb +36 -37
  254. data/{fig.yml → docker-compose.yml} +0 -0
  255. data/fat_free_crm.gemspec +31 -18
  256. data/lib/development_tasks/license.rake +29 -29
  257. data/lib/fat_free_crm.rb +1 -5
  258. data/lib/fat_free_crm/callback.rb +28 -20
  259. data/lib/fat_free_crm/comment_extensions.rb +1 -1
  260. data/lib/fat_free_crm/core_ext.rb +1 -1
  261. data/lib/fat_free_crm/core_ext/nil.rb +0 -3
  262. data/lib/fat_free_crm/core_ext/string.rb +7 -21
  263. data/lib/fat_free_crm/custom_fields.rb +2 -2
  264. data/lib/fat_free_crm/engine.rb +14 -0
  265. data/lib/fat_free_crm/errors.rb +0 -2
  266. data/lib/fat_free_crm/exceptions.rb +3 -4
  267. data/lib/fat_free_crm/export_csv.rb +0 -2
  268. data/lib/fat_free_crm/exportable.rb +5 -7
  269. data/lib/fat_free_crm/fields.rb +7 -8
  270. data/lib/fat_free_crm/gem_dependencies.rb +4 -1
  271. data/lib/fat_free_crm/gem_ext/active_record/schema_dumper.rb +2 -2
  272. data/lib/fat_free_crm/gem_ext/active_support/buffered_logger.rb +0 -3
  273. data/lib/fat_free_crm/gem_ext/rails/engine.rb +5 -12
  274. data/lib/fat_free_crm/gem_ext/rake/task.rb +1 -1
  275. data/lib/fat_free_crm/gem_ext/simple_form/action_view_extensions/form_helper.rb +1 -2
  276. data/lib/fat_free_crm/i18n.rb +2 -3
  277. data/lib/fat_free_crm/load_settings.rb +0 -2
  278. data/lib/fat_free_crm/mail_processor/base.rb +15 -16
  279. data/lib/fat_free_crm/mail_processor/comment_replies.rb +5 -10
  280. data/lib/fat_free_crm/mail_processor/dropbox.rb +56 -59
  281. data/lib/fat_free_crm/permissions.rb +18 -15
  282. data/lib/fat_free_crm/renderers.rb +2 -2
  283. data/lib/fat_free_crm/secret_token_generator.rb +3 -9
  284. data/lib/fat_free_crm/sortable.rb +4 -8
  285. data/lib/fat_free_crm/version.rb +2 -2
  286. data/lib/fat_free_crm/view_factory.rb +3 -8
  287. data/lib/gravatar_image_tag.rb +19 -24
  288. data/lib/missing_translation_detector.rb +10 -10
  289. data/lib/tasks/ffcrm/comment_replies.rake +3 -5
  290. data/lib/tasks/ffcrm/config.rake +3 -5
  291. data/lib/tasks/ffcrm/demo.rake +14 -16
  292. data/lib/tasks/ffcrm/dropbox.rake +3 -5
  293. data/lib/tasks/ffcrm/missing_translations.rake +1 -1
  294. data/lib/tasks/ffcrm/secret.rake +1 -3
  295. data/lib/tasks/ffcrm/settings.rake +2 -4
  296. data/lib/tasks/ffcrm/setup.rake +3 -6
  297. data/lib/tasks/ffcrm/update_data.rake +110 -116
  298. data/spec/controllers/admin/groups_controller_spec.rb +0 -1
  299. data/spec/controllers/admin/users_controller_spec.rb +98 -102
  300. data/spec/controllers/applications_controller_spec.rb +17 -21
  301. data/spec/controllers/authentications_controller_spec.rb +57 -61
  302. data/spec/controllers/comments_controller_spec.rb +32 -39
  303. data/spec/controllers/emails_controller_spec.rb +6 -7
  304. data/spec/controllers/entities/accounts_controller_spec.rb +204 -214
  305. data/spec/controllers/entities/campaigns_controller_spec.rb +210 -224
  306. data/spec/controllers/entities/contacts_controller_spec.rb +250 -270
  307. data/spec/controllers/entities/leads_controller_spec.rb +415 -438
  308. data/spec/controllers/entities/opportunities_controller_spec.rb +344 -359
  309. data/spec/controllers/entities_controller_spec.rb +10 -14
  310. data/spec/controllers/home_controller_spec.rb +85 -92
  311. data/spec/controllers/lists_controller_spec.rb +0 -1
  312. data/spec/controllers/passwords_controller_spec.rb +5 -9
  313. data/spec/controllers/tasks_controller_spec.rb +193 -210
  314. data/spec/controllers/users_controller_spec.rb +137 -146
  315. data/spec/factories/account_factories.rb +11 -13
  316. data/spec/factories/campaign_factories.rb +6 -6
  317. data/spec/factories/contact_factories.rb +21 -22
  318. data/spec/factories/field_factories.rb +8 -10
  319. data/spec/factories/lead_factories.rb +16 -16
  320. data/spec/factories/list_factories.rb +2 -2
  321. data/spec/factories/opportunity_factories.rb +8 -10
  322. data/spec/factories/sequences.rb +8 -9
  323. data/spec/factories/setting_factories.rb +2 -2
  324. data/spec/factories/shared_factories.rb +26 -30
  325. data/spec/factories/tag_factories.rb +1 -1
  326. data/spec/factories/task_factories.rb +11 -11
  327. data/spec/factories/user_factories.rb +22 -27
  328. data/spec/features/acceptance_helper.rb +1 -1
  329. data/spec/features/accounts_spec.rb +65 -61
  330. data/spec/features/admin/groups_spec.rb +11 -12
  331. data/spec/features/admin/users_spec.rb +17 -19
  332. data/spec/features/campaigns_spec.rb +61 -57
  333. data/spec/features/contacts_spec.rb +90 -59
  334. data/spec/features/dashboard_spec.rb +20 -21
  335. data/spec/features/leads_spec.rb +88 -67
  336. data/spec/features/opportunities_overview_spec.rb +31 -31
  337. data/spec/features/opportunities_spec.rb +64 -60
  338. data/spec/features/support/browser.rb +2 -2
  339. data/spec/features/support/headless.rb +1 -1
  340. data/spec/features/support/helpers.rb +5 -6
  341. data/spec/features/support/paths.rb +1 -2
  342. data/spec/features/support/selector_helpers.rb +2 -2
  343. data/spec/features/tasks_spec.rb +60 -54
  344. data/spec/helpers/accounts_helper_spec.rb +2 -5
  345. data/spec/helpers/admin/field_groups_helper_spec.rb +4 -4
  346. data/spec/helpers/admin/plugins_helper_spec.rb +0 -1
  347. data/spec/helpers/admin/settings_helper_spec.rb +0 -1
  348. data/spec/helpers/admin/users_helper_spec.rb +0 -1
  349. data/spec/helpers/application_helper_spec.rb +30 -33
  350. data/spec/helpers/authentications_helper_spec.rb +2 -5
  351. data/spec/helpers/campaigns_helper_spec.rb +2 -5
  352. data/spec/helpers/comments_helper_spec.rb +2 -5
  353. data/spec/helpers/contacts_helper_spec.rb +2 -5
  354. data/spec/helpers/emails_helper_spec.rb +0 -1
  355. data/spec/helpers/fields_helper_spec.rb +0 -1
  356. data/spec/helpers/groups_helper_spec.rb +0 -1
  357. data/spec/helpers/home_helper_spec.rb +2 -5
  358. data/spec/helpers/leads_helper_spec.rb +2 -5
  359. data/spec/helpers/lists_helper_spec.rb +0 -1
  360. data/spec/helpers/opportunities_helper_spec.rb +2 -5
  361. data/spec/helpers/passwords_helper_spec.rb +2 -5
  362. data/spec/helpers/tasks_helper_spec.rb +1 -5
  363. data/spec/helpers/users_helper_spec.rb +9 -11
  364. data/spec/lib/comment_extensions_spec.rb +3 -3
  365. data/spec/lib/core_ext/string_spec.rb +1 -1
  366. data/spec/lib/errors_spec.rb +10 -10
  367. data/spec/lib/fields_spec.rb +23 -33
  368. data/spec/lib/mail_processor/base_spec.rb +41 -43
  369. data/spec/lib/mail_processor/comment_replies_spec.rb +17 -17
  370. data/spec/lib/mail_processor/dropbox_spec.rb +91 -95
  371. data/spec/lib/mail_processor/sample_emails/dropbox.rb +13 -14
  372. data/spec/lib/permissions_spec.rb +44 -47
  373. data/spec/lib/secret_token_generator_spec.rb +16 -28
  374. data/spec/lib/view_factory_spec.rb +18 -24
  375. data/spec/mailers/subscription_mailer_spec.rb +14 -16
  376. data/spec/mailers/user_mailer_spec.rb +33 -34
  377. data/spec/models/entities/account_contact_spec.rb +2 -3
  378. data/spec/models/entities/account_opportunity_spec.rb +2 -3
  379. data/spec/models/entities/account_spec.rb +52 -59
  380. data/spec/models/entities/campaign_spec.rb +32 -39
  381. data/spec/models/entities/contact_opportunity_spec.rb +2 -3
  382. data/spec/models/entities/contact_spec.rb +71 -72
  383. data/spec/models/entities/lead_spec.rb +15 -22
  384. data/spec/models/entities/opportunity_spec.rb +104 -103
  385. data/spec/models/fields/custom_field_date_pair_spec.rb +38 -44
  386. data/spec/models/fields/custom_field_pair_spec.rb +28 -36
  387. data/spec/models/fields/custom_field_spec.rb +50 -56
  388. data/spec/models/fields/field_group_spec.rb +1 -2
  389. data/spec/models/fields/field_spec.rb +13 -15
  390. data/spec/models/list_spec.rb +4 -4
  391. data/spec/models/observers/entity_observer_spec.rb +18 -21
  392. data/spec/models/polymorphic/address_spec.rb +1 -3
  393. data/spec/models/polymorphic/avatar_spec.rb +6 -8
  394. data/spec/models/polymorphic/comment_spec.rb +7 -9
  395. data/spec/models/polymorphic/email_spec.rb +1 -2
  396. data/spec/models/polymorphic/task_spec.rb +130 -142
  397. data/spec/models/polymorphic/version_spec.rb +84 -91
  398. data/spec/models/setting_spec.rb +17 -19
  399. data/spec/models/users/abilities/user_ability_spec.rb +25 -20
  400. data/spec/models/users/authentication_spec.rb +0 -1
  401. data/spec/models/users/group_spec.rb +0 -1
  402. data/spec/models/users/permission_spec.rb +12 -13
  403. data/spec/models/users/preference_spec.rb +15 -15
  404. data/spec/models/users/user_spec.rb +53 -55
  405. data/spec/routing/accounts_routing_spec.rb +12 -14
  406. data/spec/routing/admin/users_routing_spec.rb +7 -9
  407. data/spec/routing/campaigns_routing_spec.rb +13 -14
  408. data/spec/routing/comments_routing_spec.rb +5 -6
  409. data/spec/routing/contacts_routing_spec.rb +12 -14
  410. data/spec/routing/emails_routing_spec.rb +7 -8
  411. data/spec/routing/leads_routing_spec.rb +19 -21
  412. data/spec/routing/opportunities_routing_spec.rb +13 -15
  413. data/spec/routing/tasks_routing_spec.rb +14 -15
  414. data/spec/routing/users_routing_spec.rb +18 -19
  415. data/spec/shared/controllers.rb +35 -35
  416. data/spec/shared/models.rb +52 -55
  417. data/spec/spec_helper.rb +21 -42
  418. data/spec/support/assert_select.rb +19 -18
  419. data/spec/support/auth_macros.rb +3 -3
  420. data/spec/support/macros.rb +5 -6
  421. data/spec/support/mail_processor_mocks.rb +11 -11
  422. data/spec/views/accounts/_edit.haml_spec.rb +9 -9
  423. data/spec/views/accounts/_new.haml_spec.rb +8 -9
  424. data/spec/views/accounts/create.js.haml_spec.rb +11 -12
  425. data/spec/views/accounts/destroy.js.haml_spec.rb +6 -7
  426. data/spec/views/accounts/edit.js.haml_spec.rb +12 -13
  427. data/spec/views/accounts/index.haml_spec.rb +8 -8
  428. data/spec/views/accounts/index.js.haml_spec.rb +7 -8
  429. data/spec/views/accounts/new.js.haml_spec.rb +7 -8
  430. data/spec/views/accounts/show.haml_spec.rb +11 -12
  431. data/spec/views/accounts/update.js.haml_spec.rb +18 -18
  432. data/spec/views/admin/field_groups/create.js.haml_spec.rb +8 -10
  433. data/spec/views/admin/field_groups/destroy.js.haml_spec.rb +7 -9
  434. data/spec/views/admin/field_groups/edit.js.haml_spec.rb +5 -7
  435. data/spec/views/admin/field_groups/new.js.haml_spec.rb +6 -8
  436. data/spec/views/admin/field_groups/update.js.haml_spec.rb +7 -9
  437. data/spec/views/admin/users/_create.haml_spec.rb +4 -4
  438. data/spec/views/admin/users/create.js.haml_spec.rb +8 -9
  439. data/spec/views/admin/users/destroy.js.haml_spec.rb +6 -6
  440. data/spec/views/admin/users/edit.js.haml_spec.rb +7 -9
  441. data/spec/views/admin/users/index.haml_spec.rb +4 -5
  442. data/spec/views/admin/users/index.js.haml_spec.rb +6 -8
  443. data/spec/views/admin/users/new.js.haml_spec.rb +4 -6
  444. data/spec/views/admin/users/reactivate.js.haml_spec.rb +4 -4
  445. data/spec/views/admin/users/show.haml_spec.rb +0 -1
  446. data/spec/views/admin/users/suspend.js.haml_spec.rb +4 -4
  447. data/spec/views/admin/users/update.js.haml_spec.rb +6 -7
  448. data/spec/views/application/auto_complete.haml_spec.rb +12 -14
  449. data/spec/views/authentications/new.haml_spec.rb +6 -7
  450. data/spec/views/campaigns/_edit.haml_spec.rb +9 -9
  451. data/spec/views/campaigns/_new.haml_spec.rb +8 -8
  452. data/spec/views/campaigns/create.js.haml_spec.rb +11 -12
  453. data/spec/views/campaigns/destroy.js.haml_spec.rb +7 -8
  454. data/spec/views/campaigns/edit.js.haml_spec.rb +12 -20
  455. data/spec/views/campaigns/index.haml_spec.rb +6 -7
  456. data/spec/views/campaigns/index.js.haml_spec.rb +9 -10
  457. data/spec/views/campaigns/new.js.haml_spec.rb +7 -8
  458. data/spec/views/campaigns/show.haml_spec.rb +12 -13
  459. data/spec/views/campaigns/update.js.haml_spec.rb +16 -16
  460. data/spec/views/comments/edit.js.haml_spec.rb +7 -7
  461. data/spec/views/contacts/_edit.haml_spec.rb +21 -21
  462. data/spec/views/contacts/_new.haml_spec.rb +12 -13
  463. data/spec/views/contacts/create.js.haml_spec.rb +12 -13
  464. data/spec/views/contacts/destroy.js.haml_spec.rb +6 -7
  465. data/spec/views/contacts/edit.js.haml_spec.rb +15 -17
  466. data/spec/views/contacts/index.haml_spec.rb +6 -7
  467. data/spec/views/contacts/index.js.html_spec.rb +7 -8
  468. data/spec/views/contacts/new.js.haml_spec.rb +8 -9
  469. data/spec/views/contacts/show.haml_spec.rb +9 -10
  470. data/spec/views/contacts/update.js.haml_spec.rb +26 -26
  471. data/spec/views/home/index.haml_spec.rb +4 -5
  472. data/spec/views/home/index.js.haml_spec.rb +6 -7
  473. data/spec/views/home/options.js.haml_spec.rb +10 -10
  474. data/spec/views/leads/_convert.haml_spec.rb +5 -6
  475. data/spec/views/leads/_edit.haml_spec.rb +13 -13
  476. data/spec/views/leads/_new.haml_spec.rb +11 -11
  477. data/spec/views/leads/_sidebar_show.haml_spec.rb +9 -9
  478. data/spec/views/leads/convert.js.haml_spec.rb +16 -17
  479. data/spec/views/leads/create.js.haml_spec.rb +16 -17
  480. data/spec/views/leads/destroy.js.haml_spec.rb +10 -11
  481. data/spec/views/leads/edit.js.haml_spec.rb +16 -17
  482. data/spec/views/leads/index.haml_spec.rb +7 -8
  483. data/spec/views/leads/index.js.haml_spec.rb +10 -11
  484. data/spec/views/leads/new.js.haml_spec.rb +8 -9
  485. data/spec/views/leads/promote.js.haml_spec.rb +30 -31
  486. data/spec/views/leads/reject.js.haml_spec.rb +10 -11
  487. data/spec/views/leads/show.haml_spec.rb +7 -8
  488. data/spec/views/leads/update.js.haml_spec.rb +28 -29
  489. data/spec/views/opportunities/_edit.haml_spec.rb +19 -19
  490. data/spec/views/opportunities/_new.haml_spec.rb +10 -10
  491. data/spec/views/opportunities/create.js.haml_spec.rb +19 -20
  492. data/spec/views/opportunities/destroy.js.haml_spec.rb +14 -15
  493. data/spec/views/opportunities/edit.js.haml_spec.rb +14 -16
  494. data/spec/views/opportunities/index.haml_spec.rb +6 -7
  495. data/spec/views/opportunities/index.js.haml_spec.rb +7 -8
  496. data/spec/views/opportunities/new.js.haml_spec.rb +8 -9
  497. data/spec/views/opportunities/show.haml_spec.rb +9 -10
  498. data/spec/views/opportunities/update.js.haml_spec.rb +35 -35
  499. data/spec/views/tasks/_edit.haml_spec.rb +9 -9
  500. data/spec/views/tasks/complete.js.haml_spec.rb +11 -12
  501. data/spec/views/tasks/create.js.haml_spec.rb +29 -31
  502. data/spec/views/tasks/destroy.js.haml_spec.rb +8 -8
  503. data/spec/views/tasks/edit.js.haml_spec.rb +12 -15
  504. data/spec/views/tasks/index.haml_spec.rb +7 -7
  505. data/spec/views/tasks/new.js.haml_spec.rb +7 -8
  506. data/spec/views/tasks/uncomplete.js.haml_spec.rb +6 -6
  507. data/spec/views/tasks/update.js.haml_spec.rb +41 -44
  508. data/spec/views/users/avatar.js.haml_spec.rb +7 -8
  509. data/spec/views/users/change_password.js.haml_spec.rb +9 -10
  510. data/spec/views/users/edit.js.haml_spec.rb +7 -8
  511. data/spec/views/users/password.js.haml_spec.rb +8 -9
  512. data/spec/views/users/update.js.haml_spec.rb +6 -7
  513. data/spec/views/users/upload_avatar.js.haml_spec.rb +9 -9
  514. data/vendor/assets/javascripts/jquery_timeago/index.js +2 -0
  515. data/vendor/assets/javascripts/jquery_timeago/jquery.timeago.es-CL.js +18 -0
  516. data/vendor/assets/javascripts/jquery_timeago/jquery.timeago.nl.js +20 -0
  517. data/vendor/assets/javascripts/jquery_ui_datepicker/jquery-ui-timepicker-es-CL.js +20 -0
  518. data/vendor/assets/javascripts/jquery_ui_datepicker/jquery.ui.datepicker-es-CL.js +23 -0
  519. data/vendor/assets/javascripts/jquery_ui_datepicker/jquery.ui.datepicker-nl.js +21 -0
  520. data/vendor/assets/stylesheets/{jquery-ui.custom.css → jquery-ui.custom.scss} +52 -51
  521. data/vendor/gems/globby-0.1.2/LICENSE.txt +20 -0
  522. data/vendor/gems/globby-0.1.2/README.md +65 -0
  523. data/vendor/gems/globby-0.1.2/Rakefile +9 -0
  524. data/vendor/gems/globby-0.1.2/lib/globby.rb +47 -0
  525. data/vendor/gems/globby-0.1.2/lib/globby/glob.rb +90 -0
  526. data/vendor/gems/globby-0.1.2/lib/globby/globject.rb +18 -0
  527. data/vendor/gems/globby-0.1.2/lib/globby/result.rb +20 -0
  528. data/vendor/gems/globby-0.1.2/spec/gitignore_spec.rb +109 -0
  529. data/vendor/gems/globby-0.1.2/spec/globby_spec.rb +93 -0
  530. metadata +177 -55
  531. data/Gemfile.ci +0 -13
  532. data/config/initializers/sass.rb +0 -18
  533. data/lib/country_select.rb +0 -570
  534. data/lib/fat_free_crm/plugin.rb +0 -94
@@ -21,8 +21,8 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
21
21
  describe ContactOpportunity do
22
22
  before(:each) do
23
23
  @valid_attributes = {
24
- :contact => mock_model(Contact),
25
- :opportunity => mock_model(Opportunity)
24
+ contact: mock_model(Contact),
25
+ opportunity: mock_model(Opportunity)
26
26
  }
27
27
  end
28
28
 
@@ -30,4 +30,3 @@ describe ContactOpportunity do
30
30
  ContactOpportunity.create!(@valid_attributes)
31
31
  end
32
32
  end
33
-
@@ -39,54 +39,61 @@
39
39
  require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
40
40
 
41
41
  describe Contact do
42
-
43
42
  before { login }
44
43
 
45
44
  it "should create a new instance given valid attributes" do
46
- Contact.create!(:first_name => "Billy", :last_name => "Bones")
45
+ Contact.create!(first_name: "Billy", last_name: "Bones")
47
46
  end
48
47
 
49
48
  describe "Update existing contact" do
50
49
  before(:each) do
51
50
  @account = FactoryGirl.create(:account)
52
- @contact = FactoryGirl.create(:contact, :account => @account)
51
+ @contact = FactoryGirl.create(:contact, account: @account)
53
52
  end
54
53
 
55
54
  it "should create new account if requested so" do
56
- lambda { @contact.update_with_account_and_permissions({
57
- :account => { :name => "New account" },
58
- :contact => { :first_name => "Billy" }
59
- })}.should change(Account, :count).by(1)
60
- Account.last.name.should == "New account"
61
- @contact.first_name.should == "Billy"
55
+ expect {
56
+ @contact.update_with_account_and_permissions(
57
+ account: { name: "New account" },
58
+ contact: { first_name: "Billy" }
59
+ )
60
+ }.to change(Account, :count).by(1)
61
+ expect(Account.last.name).to eq("New account")
62
+ expect(@contact.first_name).to eq("Billy")
62
63
  end
63
64
 
64
65
  it "should change account if another account was selected" do
65
66
  @another_account = FactoryGirl.create(:account)
66
- lambda { @contact.update_with_account_and_permissions({
67
- :account => { :id => @another_account.id },
68
- :contact => { :first_name => "Billy" }
69
- })}.should_not change(Account, :count)
70
- @contact.account.should == @another_account
71
- @contact.first_name.should == "Billy"
67
+ expect {
68
+ @contact.update_with_account_and_permissions(
69
+ account: { id: @another_account.id },
70
+ contact: { first_name: "Billy" }
71
+ )
72
+ }.not_to change(Account, :count)
73
+ expect(@contact.account).to eq(@another_account)
74
+ expect(@contact.first_name).to eq("Billy")
72
75
  end
73
76
 
74
77
  it "should drop existing Account if [create new account] is blank" do
75
- lambda { @contact.update_with_account_and_permissions({
76
- :account => { :name => "" },
77
- :contact => { :first_name => "Billy" }
78
- })}.should_not change(Account, :count)
79
- @contact.account.should == nil
80
- @contact.first_name.should == "Billy"
78
+ expect {
79
+ @contact.update_with_account_and_permissions(
80
+ account: { name: "" },
81
+ contact: { first_name: "Billy" }
82
+ )
83
+ }.not_to change(Account, :count)
84
+ expect(@contact.account).to eq(nil)
85
+ expect(@contact.first_name).to eq("Billy")
81
86
  end
82
87
 
83
88
  it "should drop existing Account if [-- None --] is selected from list of accounts" do
84
- lambda { @contact.update_with_account_and_permissions({
85
- :account => { :id => "" },
86
- :contact => { :first_name => "Billy" }
87
- })}.should_not change(Account, :count)
88
- @contact.account.should == nil
89
- @contact.first_name.should == "Billy"
89
+ expect {
90
+ @contact.update_with_account_and_permissions(
91
+ account: { id: "" },
92
+ contact: { first_name: "Billy" }
93
+ )
94
+ }.not_to change(Account, :count)
95
+ expect(@contact.account).to eq(nil)
96
+ expect(@contact.first_name).to eq("Billy")
90
97
  end
91
98
  end
92
99
 
@@ -96,20 +103,20 @@ describe Contact do
96
103
  end
97
104
 
98
105
  it "should return nil when attaching existing asset" do
99
- @task = FactoryGirl.create(:task, :asset => @contact, :user => current_user)
106
+ @task = FactoryGirl.create(:task, asset: @contact, user: current_user)
100
107
  @opportunity = FactoryGirl.create(:opportunity)
101
108
  @contact.opportunities << @opportunity
102
109
 
103
- @contact.attach!(@task).should == nil
104
- @contact.attach!(@opportunity).should == nil
110
+ expect(@contact.attach!(@task)).to eq(nil)
111
+ expect(@contact.attach!(@opportunity)).to eq(nil)
105
112
  end
106
113
 
107
114
  it "should return non-empty list of attachments when attaching new asset" do
108
- @task = FactoryGirl.create(:task, :user => current_user)
115
+ @task = FactoryGirl.create(:task, user: current_user)
109
116
  @opportunity = FactoryGirl.create(:opportunity)
110
117
 
111
- @contact.attach!(@task).should == [ @task ]
112
- @contact.attach!(@opportunity).should == [ @opportunity ]
118
+ expect(@contact.attach!(@task)).to eq([@task])
119
+ expect(@contact.attach!(@opportunity)).to eq([@opportunity])
113
120
  end
114
121
  end
115
122
 
@@ -119,91 +126,83 @@ describe Contact do
119
126
  end
120
127
 
121
128
  it "should discard a task" do
122
- @task = FactoryGirl.create(:task, :asset => @contact, :user => current_user)
123
- @contact.tasks.count.should == 1
129
+ @task = FactoryGirl.create(:task, asset: @contact, user: current_user)
130
+ expect(@contact.tasks.count).to eq(1)
124
131
 
125
132
  @contact.discard!(@task)
126
- @contact.reload.tasks.should == []
127
- @contact.tasks.count.should == 0
133
+ expect(@contact.reload.tasks).to eq([])
134
+ expect(@contact.tasks.count).to eq(0)
128
135
  end
129
136
 
130
137
  it "should discard an opportunity" do
131
138
  @opportunity = FactoryGirl.create(:opportunity)
132
139
  @contact.opportunities << @opportunity
133
- @contact.opportunities.count.should == 1
140
+ expect(@contact.opportunities.count).to eq(1)
134
141
 
135
142
  @contact.discard!(@opportunity)
136
- @contact.opportunities.should == []
137
- @contact.opportunities.count.should == 0
143
+ expect(@contact.opportunities).to eq([])
144
+ expect(@contact.opportunities.count).to eq(0)
138
145
  end
139
146
  end
140
147
 
141
148
  describe "Exportable" do
142
149
  describe "assigned contact" do
143
- before do
144
- Contact.delete_all
145
- FactoryGirl.create(:contact, :user => FactoryGirl.create(:user), :assignee => FactoryGirl.create(:user))
146
- FactoryGirl.create(:contact, :user => FactoryGirl.create(:user, :first_name => nil, :last_name => nil), :assignee => FactoryGirl.create(:user, :first_name => nil, :last_name => nil))
147
- end
150
+ let(:contact1) { FactoryGirl.build(:contact, user: FactoryGirl.create(:user), assignee: FactoryGirl.create(:user)) }
151
+ let(:contact2) { FactoryGirl.build(:contact, user: FactoryGirl.create(:user, first_name: nil, last_name: nil), assignee: FactoryGirl.create(:user, first_name: nil, last_name: nil)) }
148
152
  it_should_behave_like("exportable") do
149
- let(:exported) { Contact.all }
153
+ let(:exported) { [contact1, contact2] }
150
154
  end
151
155
  end
152
156
 
153
157
  describe "unassigned contact" do
154
- before do
155
- Contact.delete_all
156
- FactoryGirl.create(:contact, :user => FactoryGirl.create(:user), :assignee => nil)
157
- FactoryGirl.create(:contact, :user => FactoryGirl.create(:user, :first_name => nil, :last_name => nil), :assignee => nil)
158
- end
158
+ let(:contact1) { FactoryGirl.build(:contact, user: FactoryGirl.create(:user), assignee: nil) }
159
+ let(:contact2) { FactoryGirl.build(:contact, user: FactoryGirl.create(:user, first_name: nil, last_name: nil), assignee: nil) }
159
160
  it_should_behave_like("exportable") do
160
- let(:exported) { Contact.all }
161
+ let(:exported) { [contact1, contact2] }
161
162
  end
162
163
  end
163
164
  end
164
-
165
+
165
166
  describe "permissions" do
166
167
  it_should_behave_like Ability, Contact
167
168
  end
168
-
169
+
169
170
  describe "text_search" do
170
-
171
171
  before(:each) do
172
- @contact = FactoryGirl.create(:contact, :first_name => "Bob", :last_name => "Dillion", :email => 'bob_dillion@example.com', :phone => '+1 123 456 789')
172
+ @contact = FactoryGirl.create(:contact, first_name: "Bob", last_name: "Dillion", email: 'bob_dillion@example.com', phone: '+1 123 456 789')
173
173
  end
174
-
174
+
175
175
  it "should search first_name" do
176
- Contact.text_search('Bob').should == [@contact]
176
+ expect(Contact.text_search('Bob')).to eq([@contact])
177
177
  end
178
178
 
179
179
  it "should search last_name" do
180
- Contact.text_search('Dillion').should == [@contact]
180
+ expect(Contact.text_search('Dillion')).to eq([@contact])
181
181
  end
182
-
182
+
183
183
  it "should search whole name" do
184
- Contact.text_search('Bob Dillion').should == [@contact]
184
+ expect(Contact.text_search('Bob Dillion')).to eq([@contact])
185
185
  end
186
-
186
+
187
187
  it "should search whole name reversed" do
188
- Contact.text_search('Dillion Bob').should == [@contact]
188
+ expect(Contact.text_search('Dillion Bob')).to eq([@contact])
189
189
  end
190
190
 
191
191
  it "should search email" do
192
- Contact.text_search('example').should == [@contact]
192
+ expect(Contact.text_search('example')).to eq([@contact])
193
193
  end
194
-
194
+
195
195
  it "should search phone" do
196
- Contact.text_search('123').should == [@contact]
196
+ expect(Contact.text_search('123')).to eq([@contact])
197
197
  end
198
-
198
+
199
199
  it "should not break with a single quote" do
200
- contact2 = FactoryGirl.create(:contact, :first_name => "Shamus", :last_name => "O'Connell", :email => 'bob_dillion@example.com', :phone => '+1 123 456 789')
201
- Contact.text_search("O'Connell").should == [contact2]
200
+ contact2 = FactoryGirl.create(:contact, first_name: "Shamus", last_name: "O'Connell", email: 'bob_dillion@example.com', phone: '+1 123 456 789')
201
+ expect(Contact.text_search("O'Connell")).to eq([contact2])
202
202
  end
203
-
203
+
204
204
  it "should not break on special characters" do
205
- Contact.text_search('@$%#^@!').should == []
205
+ expect(Contact.text_search('@$%#^@!')).to eq([])
206
206
  end
207
-
208
207
  end
209
208
  end
@@ -39,11 +39,10 @@
39
39
  require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
40
40
 
41
41
  describe Lead do
42
-
43
42
  before { login }
44
43
 
45
44
  it "should create a new instance given valid attributes" do
46
- Lead.create!(:first_name => "Billy", :last_name => "Bones")
45
+ Lead.create!(first_name: "Billy", last_name: "Bones")
47
46
  end
48
47
 
49
48
  describe "Attach" do
@@ -52,15 +51,15 @@ describe Lead do
52
51
  end
53
52
 
54
53
  it "should return nil when attaching existing task" do
55
- @task = FactoryGirl.create(:task, :asset => @lead, :user => current_user)
54
+ @task = FactoryGirl.create(:task, asset: @lead, user: current_user)
56
55
 
57
- @lead.attach!(@task).should == nil
56
+ expect(@lead.attach!(@task)).to eq(nil)
58
57
  end
59
58
 
60
59
  it "should return non-empty list of tasks when attaching new task" do
61
- @task = FactoryGirl.create(:task, :user => current_user)
60
+ @task = FactoryGirl.create(:task, user: current_user)
62
61
 
63
- @lead.attach!(@task).should == [ @task ]
62
+ expect(@lead.attach!(@task)).to eq([@task])
64
63
  end
65
64
  end
66
65
 
@@ -70,35 +69,29 @@ describe Lead do
70
69
  end
71
70
 
72
71
  it "should discard a task" do
73
- @task = FactoryGirl.create(:task, :asset => @lead, :user => current_user)
74
- @lead.tasks.count.should == 1
72
+ @task = FactoryGirl.create(:task, asset: @lead, user: current_user)
73
+ expect(@lead.tasks.count).to eq(1)
75
74
 
76
75
  @lead.discard!(@task)
77
- @lead.reload.tasks.should == []
78
- @lead.tasks.count.should == 0
76
+ expect(@lead.reload.tasks).to eq([])
77
+ expect(@lead.tasks.count).to eq(0)
79
78
  end
80
79
  end
81
80
 
82
81
  describe "Exportable" do
83
82
  describe "assigned lead" do
84
- before do
85
- Lead.delete_all
86
- FactoryGirl.create(:lead, :user => FactoryGirl.create(:user), :assignee => FactoryGirl.create(:user))
87
- FactoryGirl.create(:lead, :user => FactoryGirl.create(:user, :first_name => nil, :last_name => nil), :assignee => FactoryGirl.create(:user, :first_name => nil, :last_name => nil))
88
- end
83
+ let(:lead1) { FactoryGirl.build(:lead, user: FactoryGirl.create(:user), assignee: FactoryGirl.create(:user)) }
84
+ let(:lead2) { FactoryGirl.build(:lead, user: FactoryGirl.create(:user, first_name: nil, last_name: nil), assignee: FactoryGirl.create(:user, first_name: nil, last_name: nil)) }
89
85
  it_should_behave_like("exportable") do
90
- let(:exported) { Lead.all }
86
+ let(:exported) { [lead1, lead2] }
91
87
  end
92
88
  end
93
89
 
94
90
  describe "unassigned lead" do
95
- before do
96
- Lead.delete_all
97
- FactoryGirl.create(:lead, :user => FactoryGirl.create(:user), :assignee => nil)
98
- FactoryGirl.create(:lead, :user => FactoryGirl.create(:user, :first_name => nil, :last_name => nil), :assignee => nil)
99
- end
91
+ let(:lead1) { FactoryGirl.build(:lead, user: FactoryGirl.create(:user), assignee: nil) }
92
+ let(:lead2) { FactoryGirl.build(:lead, user: FactoryGirl.create(:user, first_name: nil, last_name: nil), assignee: nil) }
100
93
  it_should_behave_like("exportable") do
101
- let(:exported) { Lead.all }
94
+ let(:exported) { [lead1, lead2] }
102
95
  end
103
96
  end
104
97
  end
@@ -28,82 +28,89 @@
28
28
  require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
29
29
 
30
30
  describe Opportunity do
31
-
32
31
  before { login }
33
32
 
34
33
  it "should create a new instance given valid attributes" do
35
- Opportunity.create!(:name => "Opportunity", :stage => 'analysis')
34
+ Opportunity.create!(name: "Opportunity", stage: 'analysis')
36
35
  end
37
36
 
38
37
  it "should be possible to create opportunity with the same name" do
39
- first = FactoryGirl.create(:opportunity, :name => "Hello", :user => current_user)
40
- expect { FactoryGirl.create(:opportunity, :name => "Hello", :user => current_user) }.to_not raise_error()
38
+ first = FactoryGirl.create(:opportunity, name: "Hello", user: current_user)
39
+ expect { FactoryGirl.create(:opportunity, name: "Hello", user: current_user) }.to_not raise_error
41
40
  end
42
41
 
43
42
  it "have a default stage" do
44
- Setting.should_receive(:[]).with(:opportunity_default_stage).and_return('default')
45
- Opportunity.default_stage.should eql('default')
43
+ expect(Setting).to receive(:[]).with(:opportunity_default_stage).and_return('default')
44
+ expect(Opportunity.default_stage).to eql('default')
46
45
  end
47
46
 
48
47
  it "have a fallback default stage" do
49
- Opportunity.default_stage.should eql('prospecting')
48
+ expect(Opportunity.default_stage).to eql('prospecting')
50
49
  end
51
50
 
52
51
  describe "Update existing opportunity" do
53
52
  before(:each) do
54
53
  @account = FactoryGirl.create(:account)
55
- @opportunity = FactoryGirl.create(:opportunity, :account => @account)
54
+ @opportunity = FactoryGirl.create(:opportunity, account: @account)
56
55
  end
57
56
 
58
57
  it "should create new account if requested so" do
59
- lambda { @opportunity.update_with_account_and_permissions({
60
- :account => { :name => "New account" },
61
- :opportunity => { :name => "Hello" }
62
- })}.should change(Account, :count).by(1)
63
- Account.last.name.should == "New account"
64
- @opportunity.name.gsub(/#\d+ /,'').should == "Hello"
58
+ expect {
59
+ @opportunity.update_with_account_and_permissions(
60
+ account: { name: "New account" },
61
+ opportunity: { name: "Hello" }
62
+ )
63
+ }.to change(Account, :count).by(1)
64
+ expect(Account.last.name).to eq("New account")
65
+ expect(@opportunity.name.gsub(/#\d+ /, '')).to eq("Hello")
65
66
  end
66
67
 
67
68
  it "should update the account another account was selected" do
68
69
  @another_account = FactoryGirl.create(:account)
69
- lambda { @opportunity.update_with_account_and_permissions({
70
- :account => { :id => @another_account.id },
71
- :opportunity => { :name => "Hello" }
72
- })}.should_not change(Account, :count)
73
- @opportunity.account.should == @another_account
74
- @opportunity.name.gsub(/#\d+ /,'').should == "Hello"
70
+ expect {
71
+ @opportunity.update_with_account_and_permissions(
72
+ account: { id: @another_account.id },
73
+ opportunity: { name: "Hello" }
74
+ )
75
+ }.not_to change(Account, :count)
76
+ expect(@opportunity.account).to eq(@another_account)
77
+ expect(@opportunity.name.gsub(/#\d+ /, '')).to eq("Hello")
75
78
  end
76
79
 
77
80
  it "should drop existing Account if [create new account] is blank" do
78
- lambda { @opportunity.update_with_account_and_permissions({
79
- :account => { :name => "" },
80
- :opportunity => { :name => "Hello" }
81
- })}.should_not change(Account, :count)
82
- @opportunity.account.should be_nil
83
- @opportunity.name.gsub(/#\d+ /,'').should == "Hello"
81
+ expect {
82
+ @opportunity.update_with_account_and_permissions(
83
+ account: { name: "" },
84
+ opportunity: { name: "Hello" }
85
+ )
86
+ }.not_to change(Account, :count)
87
+ expect(@opportunity.account).to be_nil
88
+ expect(@opportunity.name.gsub(/#\d+ /, '')).to eq("Hello")
84
89
  end
85
90
 
86
91
  it "should drop existing Account if [-- None --] is selected from list of accounts" do
87
- lambda { @opportunity.update_with_account_and_permissions({
88
- :account => { :id => "" },
89
- :opportunity => { :name => "Hello" }
90
- })}.should_not change(Account, :count)
91
- @opportunity.account.should be_nil
92
- @opportunity.name.gsub(/#\d+ /,'').should == "Hello"
92
+ expect {
93
+ @opportunity.update_with_account_and_permissions(
94
+ account: { id: "" },
95
+ opportunity: { name: "Hello" }
96
+ )
97
+ }.not_to change(Account, :count)
98
+ expect(@opportunity.account).to be_nil
99
+ expect(@opportunity.name.gsub(/#\d+ /, '')).to eq("Hello")
93
100
  end
94
101
 
95
102
  it "should set the probability to 0% if opportunity has been lost" do
96
- opportunity = FactoryGirl.create(:opportunity, :stage => "prospecting", :probability => 25)
97
- opportunity.update_attributes(:stage => 'lost')
103
+ opportunity = FactoryGirl.create(:opportunity, stage: "prospecting", probability: 25)
104
+ opportunity.update_attributes(stage: 'lost')
98
105
  opportunity.reload
99
- opportunity.probability.should == 0
106
+ expect(opportunity.probability).to eq(0)
100
107
  end
101
108
 
102
109
  it "should set the probablility to 100% if opportunity has been won" do
103
- opportunity = FactoryGirl.create(:opportunity, :stage => "prospecting", :probability => 65)
104
- opportunity.update_attributes(:stage => 'won')
110
+ opportunity = FactoryGirl.create(:opportunity, stage: "prospecting", probability: 65)
111
+ opportunity.update_attributes(stage: 'won')
105
112
  opportunity.reload
106
- opportunity.probability.should == 100
113
+ expect(opportunity.probability).to eq(100)
107
114
  end
108
115
  end
109
116
 
@@ -111,29 +118,29 @@ describe Opportunity do
111
118
  it "should find non-closed opportunities" do
112
119
  Opportunity.delete_all
113
120
  @opportunities = [
114
- FactoryGirl.create(:opportunity, :stage => "prospecting", :amount => 1),
115
- FactoryGirl.create(:opportunity, :stage => "analysis", :amount => 1),
116
- FactoryGirl.create(:opportunity, :stage => "won", :amount => 2),
117
- FactoryGirl.create(:opportunity, :stage => "won", :amount => 2),
118
- FactoryGirl.create(:opportunity, :stage => "lost", :amount => 3),
119
- FactoryGirl.create(:opportunity, :stage => "lost", :amount => 3)
121
+ FactoryGirl.create(:opportunity, stage: "prospecting", amount: 1),
122
+ FactoryGirl.create(:opportunity, stage: "analysis", amount: 1),
123
+ FactoryGirl.create(:opportunity, stage: "won", amount: 2),
124
+ FactoryGirl.create(:opportunity, stage: "won", amount: 2),
125
+ FactoryGirl.create(:opportunity, stage: "lost", amount: 3),
126
+ FactoryGirl.create(:opportunity, stage: "lost", amount: 3)
120
127
  ]
121
- Opportunity.pipeline.sum(:amount).should == 2
122
- Opportunity.won.sum(:amount).should == 4
123
- Opportunity.lost.sum(:amount).should == 6
124
- Opportunity.sum(:amount).should == 12
128
+ expect(Opportunity.pipeline.sum(:amount)).to eq(2)
129
+ expect(Opportunity.won.sum(:amount)).to eq(4)
130
+ expect(Opportunity.lost.sum(:amount)).to eq(6)
131
+ expect(Opportunity.sum(:amount)).to eq(12)
125
132
  end
126
133
 
127
134
  context "unassigned" do
128
- let(:unassigned_opportunity){ FactoryGirl.create(:opportunity, :assignee => nil)}
129
- let(:assigned_opportunity){ FactoryGirl.create(:opportunity, :assignee => FactoryGirl.create(:user))}
135
+ let(:unassigned_opportunity) { FactoryGirl.create(:opportunity, assignee: nil) }
136
+ let(:assigned_opportunity) { FactoryGirl.create(:opportunity, assignee: FactoryGirl.create(:user)) }
130
137
 
131
138
  it "includes unassigned opportunities" do
132
- Opportunity.unassigned.should include(unassigned_opportunity)
139
+ expect(Opportunity.unassigned).to include(unassigned_opportunity)
133
140
  end
134
141
 
135
142
  it "does not include opportunities assigned to a user" do
136
- Opportunity.unassigned.should_not include(assigned_opportunity)
143
+ expect(Opportunity.unassigned).not_to include(assigned_opportunity)
137
144
  end
138
145
  end
139
146
  end
@@ -144,20 +151,20 @@ describe Opportunity do
144
151
  end
145
152
 
146
153
  it "should return nil when attaching existing asset" do
147
- @task = FactoryGirl.create(:task, :asset => @opportunity, :user => current_user)
154
+ @task = FactoryGirl.create(:task, asset: @opportunity, user: current_user)
148
155
  @contact = FactoryGirl.create(:contact)
149
156
  @opportunity.contacts << @contact
150
157
 
151
- @opportunity.attach!(@task).should == nil
152
- @opportunity.attach!(@contact).should == nil
158
+ expect(@opportunity.attach!(@task)).to eq(nil)
159
+ expect(@opportunity.attach!(@contact)).to eq(nil)
153
160
  end
154
161
 
155
162
  it "should return non-empty list of attachments when attaching new asset" do
156
- @task = FactoryGirl.create(:task, :user => current_user)
163
+ @task = FactoryGirl.create(:task, user: current_user)
157
164
  @contact = FactoryGirl.create(:contact)
158
165
 
159
- @opportunity.attach!(@task).should == [ @task ]
160
- @opportunity.attach!(@contact).should == [ @contact ]
166
+ expect(@opportunity.attach!(@task)).to eq([@task])
167
+ expect(@opportunity.attach!(@contact)).to eq([@contact])
161
168
  end
162
169
  end
163
170
 
@@ -167,45 +174,39 @@ describe Opportunity do
167
174
  end
168
175
 
169
176
  it "should discard a task" do
170
- @task = FactoryGirl.create(:task, :asset => @opportunity, :user => current_user)
171
- @opportunity.tasks.count.should == 1
177
+ @task = FactoryGirl.create(:task, asset: @opportunity, user: current_user)
178
+ expect(@opportunity.tasks.count).to eq(1)
172
179
 
173
180
  @opportunity.discard!(@task)
174
- @opportunity.reload.tasks.should == []
175
- @opportunity.tasks.count.should == 0
181
+ expect(@opportunity.reload.tasks).to eq([])
182
+ expect(@opportunity.tasks.count).to eq(0)
176
183
  end
177
184
 
178
185
  it "should discard an contact" do
179
186
  @contact = FactoryGirl.create(:contact)
180
187
  @opportunity.contacts << @contact
181
- @opportunity.contacts.count.should == 1
188
+ expect(@opportunity.contacts.count).to eq(1)
182
189
 
183
190
  @opportunity.discard!(@contact)
184
- @opportunity.contacts.should == []
185
- @opportunity.contacts.count.should == 0
191
+ expect(@opportunity.contacts).to eq([])
192
+ expect(@opportunity.contacts.count).to eq(0)
186
193
  end
187
194
  end
188
195
 
189
196
  describe "Exportable" do
190
197
  describe "assigned opportunity" do
191
- before do
192
- Opportunity.delete_all
193
- FactoryGirl.create(:opportunity, :user => FactoryGirl.create(:user), :assignee => FactoryGirl.create(:user))
194
- FactoryGirl.create(:opportunity, :user => FactoryGirl.create(:user, :first_name => nil, :last_name => nil), :assignee => FactoryGirl.create(:user, :first_name => nil, :last_name => nil))
195
- end
198
+ let(:opportunity1) { FactoryGirl.build(:opportunity, user: FactoryGirl.create(:user), assignee: FactoryGirl.create(:user)) }
199
+ let(:opportunity2) { FactoryGirl.build(:opportunity, user: FactoryGirl.create(:user, first_name: nil, last_name: nil), assignee: FactoryGirl.create(:user, first_name: nil, last_name: nil)) }
196
200
  it_should_behave_like("exportable") do
197
- let(:exported) { Opportunity.all }
201
+ let(:exported) { [opportunity1, opportunity2] }
198
202
  end
199
203
  end
200
204
 
201
205
  describe "unassigned opportunity" do
202
- before do
203
- Opportunity.delete_all
204
- FactoryGirl.create(:opportunity, :user => FactoryGirl.create(:user), :assignee => nil)
205
- FactoryGirl.create(:opportunity, :user => FactoryGirl.create(:user, :first_name => nil, :last_name => nil), :assignee => nil)
206
- end
206
+ let(:opportunity1) { FactoryGirl.build(:opportunity, user: FactoryGirl.create(:user), assignee: nil) }
207
+ let(:opportunity2) { FactoryGirl.build(:opportunity, user: FactoryGirl.create(:user, first_name: nil, last_name: nil), assignee: nil) }
207
208
  it_should_behave_like("exportable") do
208
- let(:exported) { Opportunity.all }
209
+ let(:exported) { [opportunity1, opportunity2] }
209
210
  end
210
211
  end
211
212
  end
@@ -218,68 +219,68 @@ describe Opportunity do
218
219
  context "visible_on_dashboard" do
219
220
  before :each do
220
221
  @user = FactoryGirl.create(:user)
221
- @o1 = FactoryGirl.create(:opportunity_in_pipeline, :user => @user, :stage => 'prospecting')
222
- @o2 = FactoryGirl.create(:opportunity_in_pipeline, :user => @user, :assignee => FactoryGirl.create(:user), :stage => 'prospecting')
223
- @o3 = FactoryGirl.create(:opportunity_in_pipeline, :user => FactoryGirl.create(:user), :assignee => @user, :stage => 'prospecting')
224
- @o4 = FactoryGirl.create(:opportunity_in_pipeline, :user => FactoryGirl.create(:user), :assignee => FactoryGirl.create(:user), :stage => 'prospecting')
225
- @o5 = FactoryGirl.create(:opportunity_in_pipeline, :user => FactoryGirl.create(:user), :assignee => @user, :stage => 'prospecting')
226
- @o6 = FactoryGirl.create(:opportunity, :assignee => @user, :stage => 'won')
227
- @o7 = FactoryGirl.create(:opportunity, :assignee => @user, :stage => 'lost')
222
+ @o1 = FactoryGirl.create(:opportunity_in_pipeline, user: @user, stage: 'prospecting')
223
+ @o2 = FactoryGirl.create(:opportunity_in_pipeline, user: @user, assignee: FactoryGirl.create(:user), stage: 'prospecting')
224
+ @o3 = FactoryGirl.create(:opportunity_in_pipeline, user: FactoryGirl.create(:user), assignee: @user, stage: 'prospecting')
225
+ @o4 = FactoryGirl.create(:opportunity_in_pipeline, user: FactoryGirl.create(:user), assignee: FactoryGirl.create(:user), stage: 'prospecting')
226
+ @o5 = FactoryGirl.create(:opportunity_in_pipeline, user: FactoryGirl.create(:user), assignee: @user, stage: 'prospecting')
227
+ @o6 = FactoryGirl.create(:opportunity, assignee: @user, stage: 'won')
228
+ @o7 = FactoryGirl.create(:opportunity, assignee: @user, stage: 'lost')
228
229
  end
229
230
 
230
231
  it "should show opportunities which have been created by the user and are unassigned" do
231
- Opportunity.visible_on_dashboard(@user).should include(@o1)
232
+ expect(Opportunity.visible_on_dashboard(@user)).to include(@o1)
232
233
  end
233
234
 
234
235
  it "should show opportunities which are assigned to the user" do
235
- Opportunity.visible_on_dashboard(@user).should include(@o3, @o5)
236
+ expect(Opportunity.visible_on_dashboard(@user)).to include(@o3, @o5)
236
237
  end
237
238
 
238
239
  it "should not show opportunities which are not assigned to the user" do
239
- Opportunity.visible_on_dashboard(@user).should_not include(@o4)
240
+ expect(Opportunity.visible_on_dashboard(@user)).not_to include(@o4)
240
241
  end
241
242
 
242
243
  it "should not show opportunities which are created by the user but assigned" do
243
- Opportunity.visible_on_dashboard(@user).should_not include(@o2)
244
+ expect(Opportunity.visible_on_dashboard(@user)).not_to include(@o2)
244
245
  end
245
246
 
246
247
  it "does not include won or lost opportunities" do
247
- Opportunity.visible_on_dashboard(@user).should_not include(@o6)
248
- Opportunity.visible_on_dashboard(@user).should_not include(@o7)
248
+ expect(Opportunity.visible_on_dashboard(@user)).not_to include(@o6)
249
+ expect(Opportunity.visible_on_dashboard(@user)).not_to include(@o7)
249
250
  end
250
251
  end
251
252
 
252
253
  context "by_closes_on" do
253
- let(:o1) { FactoryGirl.create(:opportunity, :closes_on => 3.days.from_now) }
254
- let(:o2) { FactoryGirl.create(:opportunity, :closes_on => 7.days.from_now) }
255
- let(:o3) { FactoryGirl.create(:opportunity, :closes_on => 5.days.from_now) }
254
+ let(:o1) { FactoryGirl.create(:opportunity, closes_on: 3.days.from_now) }
255
+ let(:o2) { FactoryGirl.create(:opportunity, closes_on: 7.days.from_now) }
256
+ let(:o3) { FactoryGirl.create(:opportunity, closes_on: 5.days.from_now) }
256
257
 
257
258
  it "should show opportunities ordered by closes on" do
258
- Opportunity.by_closes_on.should == [o1, o3, o2]
259
+ expect(Opportunity.by_closes_on).to eq([o1, o3, o2])
259
260
  end
260
261
  end
261
262
 
262
263
  context "by_amount" do
263
- let(:o1) { FactoryGirl.create(:opportunity, :amount => 50000) }
264
- let(:o2) { FactoryGirl.create(:opportunity, :amount => 10000) }
265
- let(:o3) { FactoryGirl.create(:opportunity, :amount => 750000) }
264
+ let(:o1) { FactoryGirl.create(:opportunity, amount: 50_000) }
265
+ let(:o2) { FactoryGirl.create(:opportunity, amount: 10_000) }
266
+ let(:o3) { FactoryGirl.create(:opportunity, amount: 750_000) }
266
267
 
267
268
  it "should show opportunities ordered by amount" do
268
- Opportunity.by_amount.should == [o3, o1, o2]
269
+ expect(Opportunity.by_amount).to eq([o3, o1, o2])
269
270
  end
270
271
  end
271
272
 
272
273
  context "not lost" do
273
- let(:o1) { FactoryGirl.create(:opportunity, :stage => 'won') }
274
- let(:o2) { FactoryGirl.create(:opportunity, :stage => 'lost') }
275
- let(:o3) { FactoryGirl.create(:opportunity, :stage => 'analysis') }
274
+ let(:o1) { FactoryGirl.create(:opportunity, stage: 'won') }
275
+ let(:o2) { FactoryGirl.create(:opportunity, stage: 'lost') }
276
+ let(:o3) { FactoryGirl.create(:opportunity, stage: 'analysis') }
276
277
 
277
278
  it "should show opportunities which are not lost" do
278
- Opportunity.not_lost.should include(o1, o3)
279
+ expect(Opportunity.not_lost).to include(o1, o3)
279
280
  end
280
281
 
281
282
  it "should not show opportunities which are lost" do
282
- Opportunity.not_lost.should_not include(o2)
283
+ expect(Opportunity.not_lost).not_to include(o2)
283
284
  end
284
285
  end
285
286
  end