fat_free_crm 0.18.1 → 0.20.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 (385) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/brakeman-analysis.yml +46 -0
  3. data/.github/workflows/rubocop-analysis.yml +40 -0
  4. data/.github/workflows/ruby.yml +52 -0
  5. data/.rubocop_todo.yml +80 -173
  6. data/.travis.yml +17 -20
  7. data/CHANGELOG.md +63 -3
  8. data/CONTRIBUTORS.md +1 -0
  9. data/Dockerfile +45 -14
  10. data/Gemfile +21 -11
  11. data/Gemfile.lock +315 -263
  12. data/Procfile +1 -1
  13. data/README.md +6 -5
  14. data/Rakefile +1 -1
  15. data/SECURITY.md +11 -0
  16. data/app/assets/javascripts/application.js.erb +3 -0
  17. data/app/assets/stylesheets/application.css.erb +1 -0
  18. data/app/assets/stylesheets/base.scss +9 -2
  19. data/app/assets/stylesheets/bootstrap-custom.scss +206 -0
  20. data/app/assets/stylesheets/common.scss +88 -68
  21. data/app/assets/stylesheets/header.scss +0 -8
  22. data/app/controllers/admin/application_controller.rb +1 -1
  23. data/app/controllers/admin/field_groups_controller.rb +2 -4
  24. data/app/controllers/admin/fields_controller.rb +1 -1
  25. data/app/controllers/admin/groups_controller.rb +1 -1
  26. data/app/controllers/admin/tags_controller.rb +3 -5
  27. data/app/controllers/admin/users_controller.rb +7 -9
  28. data/app/controllers/application_controller.rb +21 -45
  29. data/app/controllers/comments_controller.rb +3 -6
  30. data/{config/initializers/authlogic.rb → app/controllers/confirmations_controller.rb} +4 -2
  31. data/app/controllers/emails_controller.rb +0 -2
  32. data/app/controllers/entities/accounts_controller.rb +2 -4
  33. data/app/controllers/entities/campaigns_controller.rb +2 -4
  34. data/app/controllers/entities/contacts_controller.rb +4 -24
  35. data/app/controllers/entities/leads_controller.rb +7 -10
  36. data/app/controllers/entities/opportunities_controller.rb +4 -14
  37. data/app/controllers/entities_controller.rb +21 -7
  38. data/app/controllers/home_controller.rb +5 -5
  39. data/app/controllers/lists_controller.rb +1 -1
  40. data/app/controllers/passwords_controller.rb +3 -59
  41. data/{spec/features/support/maintain_sessions.rb → app/controllers/registrations_controller.rb} +12 -5
  42. data/{lib/development_tasks/gem.rake → app/controllers/sessions_controller.rb} +6 -6
  43. data/app/controllers/tasks_controller.rb +11 -20
  44. data/app/controllers/users_controller.rb +11 -30
  45. data/app/helpers/accounts_helper.rb +12 -0
  46. data/app/helpers/admin/users_helper.rb +1 -1
  47. data/app/helpers/application_helper.rb +30 -37
  48. data/app/helpers/campaigns_helper.rb +1 -1
  49. data/app/helpers/contacts_helper.rb +1 -3
  50. data/app/helpers/opportunities_helper.rb +4 -12
  51. data/app/helpers/tasks_helper.rb +3 -3
  52. data/app/helpers/users_helper.rb +1 -3
  53. data/{config/initializers/paper_trail.rb → app/mailers/devise_mailer.rb} +5 -1
  54. data/app/mailers/user_mailer.rb +0 -9
  55. data/app/models/entities/account.rb +11 -11
  56. data/app/models/entities/account_contact.rb +1 -1
  57. data/app/models/entities/account_opportunity.rb +1 -1
  58. data/app/models/entities/campaign.rb +5 -7
  59. data/app/models/entities/contact.rb +25 -13
  60. data/app/models/entities/lead.rb +8 -8
  61. data/app/models/entities/opportunity.rb +8 -10
  62. data/app/models/fields/custom_field.rb +1 -0
  63. data/app/models/fields/custom_field_date_pair.rb +2 -0
  64. data/app/models/fields/custom_field_pair.rb +2 -2
  65. data/app/models/fields/field.rb +1 -3
  66. data/app/models/list.rb +1 -1
  67. data/app/models/observers/entity_observer.rb +3 -7
  68. data/app/models/observers/lead_observer.rb +2 -4
  69. data/app/models/observers/opportunity_observer.rb +3 -5
  70. data/app/models/observers/task_observer.rb +1 -1
  71. data/app/models/polymorphic/address.rb +1 -1
  72. data/app/models/polymorphic/comment.rb +1 -1
  73. data/app/models/polymorphic/email.rb +3 -3
  74. data/app/models/polymorphic/task.rb +14 -10
  75. data/app/models/polymorphic/version.rb +3 -2
  76. data/app/models/setting.rb +5 -1
  77. data/app/models/users/permission.rb +3 -3
  78. data/app/models/users/preference.rb +4 -3
  79. data/app/models/users/user.rb +67 -42
  80. data/app/views/accounts/_edit.html.haml +2 -2
  81. data/app/views/accounts/_new.html.haml +2 -2
  82. data/app/views/accounts/_sidebar_index.html.haml +2 -2
  83. data/app/views/accounts/_sidebar_show.html.haml +19 -19
  84. data/app/views/accounts/_top_section.html.haml +1 -1
  85. data/app/views/accounts/create.js.haml +1 -2
  86. data/app/views/accounts/destroy.js.haml +1 -1
  87. data/app/views/accounts/edit.js.haml +1 -1
  88. data/app/views/accounts/show.html.haml +1 -0
  89. data/app/views/accounts/update.js.haml +4 -5
  90. data/app/views/admin/field_groups/create.js.haml +0 -1
  91. data/app/views/admin/field_groups/destroy.js.haml +0 -1
  92. data/app/views/admin/field_groups/update.js.haml +0 -1
  93. data/app/views/admin/fields/create.js.haml +0 -1
  94. data/app/views/admin/fields/destroy.js.haml +0 -1
  95. data/app/views/admin/fields/update.js.haml +0 -1
  96. data/app/views/admin/groups/create.js.haml +0 -1
  97. data/app/views/admin/groups/destroy.js.haml +0 -1
  98. data/app/views/admin/groups/update.js.haml +0 -1
  99. data/app/views/admin/tags/create.js.haml +0 -1
  100. data/app/views/admin/tags/destroy.js.haml +0 -1
  101. data/app/views/admin/tags/update.js.haml +0 -1
  102. data/app/views/admin/users/_user.html.haml +4 -4
  103. data/app/views/admin/users/create.js.haml +0 -1
  104. data/app/views/admin/users/destroy.js.haml +0 -1
  105. data/app/views/admin/users/update.js.haml +0 -1
  106. data/app/views/campaigns/_edit.html.haml +1 -1
  107. data/app/views/campaigns/_new.html.haml +1 -1
  108. data/app/views/campaigns/_sidebar_index.html.haml +2 -2
  109. data/app/views/campaigns/_sidebar_show.html.haml +68 -67
  110. data/app/views/campaigns/create.js.haml +1 -2
  111. data/app/views/campaigns/destroy.js.haml +1 -1
  112. data/app/views/campaigns/show.html.haml +1 -0
  113. data/app/views/campaigns/update.js.haml +3 -4
  114. data/app/views/comments/_edit.html.haml +1 -1
  115. data/app/views/comments/_new.html.haml +1 -1
  116. data/app/views/comments/update.js.haml +0 -1
  117. data/app/views/contacts/_edit.html.haml +1 -1
  118. data/app/views/contacts/_index_brief.html.haml +1 -1
  119. data/app/views/contacts/_index_full.html.haml +1 -1
  120. data/app/views/contacts/_index_long.html.haml +1 -1
  121. data/app/views/contacts/_new.html.haml +1 -1
  122. data/app/views/contacts/_sidebar_show.html.haml +18 -18
  123. data/app/views/contacts/create.js.haml +0 -1
  124. data/app/views/contacts/destroy.js.haml +1 -1
  125. data/app/views/contacts/show.html.haml +1 -0
  126. data/app/views/contacts/update.js.haml +2 -3
  127. data/app/views/devise/confirmations/new.html.haml +9 -0
  128. data/app/views/devise/mailer/confirmation_instructions.html.haml +4 -0
  129. data/app/views/devise/mailer/password_change.html.haml +3 -0
  130. data/app/views/devise/mailer/reset_password_instructions.html.haml +6 -0
  131. data/app/views/devise/passwords/edit.html.haml +18 -0
  132. data/app/views/devise/passwords/new.html.haml +10 -0
  133. data/app/views/devise/registrations/new.html.haml +21 -0
  134. data/app/views/devise/sessions/new.html.haml +32 -0
  135. data/app/views/entities/_title_bar.html.haml +1 -1
  136. data/app/views/entities/attach.js.haml +2 -2
  137. data/app/views/entities/discard.js.haml +2 -2
  138. data/app/views/home/_opportunity.html.haml +1 -1
  139. data/app/views/home/_task.html.haml +1 -1
  140. data/app/views/home/index.xls.builder +51 -0
  141. data/app/views/layouts/_about.html.haml +5 -5
  142. data/app/views/layouts/_header.html.haml +3 -3
  143. data/app/views/layouts/_sidebar.html.haml +2 -2
  144. data/app/views/layouts/_tabbed.html.haml +14 -11
  145. data/app/views/layouts/admin/_header.html.haml +1 -1
  146. data/app/views/layouts/application.html.haml +2 -2
  147. data/app/views/leads/_edit.html.haml +2 -2
  148. data/app/views/leads/_new.html.haml +2 -2
  149. data/app/views/leads/_sidebar_index.html.haml +2 -2
  150. data/app/views/leads/_sidebar_show.html.haml +30 -30
  151. data/app/views/leads/create.js.haml +2 -3
  152. data/app/views/leads/destroy.js.haml +2 -2
  153. data/app/views/leads/promote.js.haml +3 -4
  154. data/app/views/leads/reject.js.haml +3 -3
  155. data/app/views/leads/show.html.haml +1 -1
  156. data/app/views/leads/update.js.haml +4 -5
  157. data/app/views/lists/create.js.haml +0 -1
  158. data/app/views/opportunities/_edit.html.haml +1 -1
  159. data/app/views/opportunities/_index_brief.html.haml +1 -1
  160. data/app/views/opportunities/_index_long.html.haml +1 -1
  161. data/app/views/opportunities/_new.html.haml +1 -1
  162. data/app/views/opportunities/_sidebar_index.html.haml +2 -2
  163. data/app/views/opportunities/_sidebar_show.html.haml +47 -46
  164. data/app/views/opportunities/create.js.haml +3 -4
  165. data/app/views/opportunities/destroy.js.haml +3 -3
  166. data/app/views/opportunities/show.html.haml +1 -0
  167. data/app/views/opportunities/update.js.haml +5 -6
  168. data/app/views/shared/_address.html.haml +5 -5
  169. data/app/views/shared/_empty.html.haml +1 -1
  170. data/app/views/shared/_inline_styles.html.haml +0 -26
  171. data/app/views/shared/_paginate_with_per_page.html.haml +1 -0
  172. data/app/views/tasks/_assigned.html.haml +1 -1
  173. data/app/views/tasks/_completed.html.haml +1 -1
  174. data/app/views/tasks/_edit.html.haml +1 -1
  175. data/app/views/tasks/_new.html.haml +1 -1
  176. data/app/views/tasks/_pending.html.haml +1 -1
  177. data/app/views/tasks/_related.html.haml +1 -1
  178. data/app/views/tasks/_selector.html.haml +7 -8
  179. data/app/views/tasks/_sidebar_index.html.haml +2 -2
  180. data/app/views/tasks/_title.html.haml +1 -1
  181. data/app/views/tasks/complete.js.haml +1 -1
  182. data/app/views/tasks/create.js.haml +1 -2
  183. data/app/views/tasks/destroy.js.haml +1 -1
  184. data/app/views/tasks/uncomplete.js.haml +1 -2
  185. data/app/views/tasks/update.js.haml +0 -1
  186. data/app/views/users/_avatar.html.haml +1 -1
  187. data/app/views/users/change_password.js.haml +0 -1
  188. data/app/views/users/update.js.haml +0 -1
  189. data/app/views/users/upload_avatar.js.haml +0 -1
  190. data/app/views/versions/_version_item.html.haml +1 -1
  191. data/bin/bundle +1 -1
  192. data/bin/rails +1 -1
  193. data/bin/setup +38 -0
  194. data/bin/update +33 -0
  195. data/bin/yarn +13 -0
  196. data/config/application.rb +8 -6
  197. data/config/boot.rb +1 -1
  198. data/config/brakeman.ignore +2 -2
  199. data/config/database.postgres.docker.yml +5 -5
  200. data/config/environment.rb +2 -2
  201. data/config/environments/development.rb +1 -0
  202. data/config/environments/test.rb +7 -0
  203. data/config/initializers/action_mailer.rb +1 -3
  204. data/config/initializers/application_controller_renderer.rb +9 -0
  205. data/config/initializers/assets.rb +6 -11
  206. data/config/initializers/backtrace_silencers.rb +0 -6
  207. data/config/initializers/content_security_policy.rb +31 -0
  208. data/config/initializers/cookies_serializer.rb +3 -6
  209. data/config/initializers/devise.rb +289 -0
  210. data/config/initializers/filter_parameter_logging.rb +0 -5
  211. data/config/initializers/gravatar.rb +0 -1
  212. data/config/initializers/inflections.rb +0 -6
  213. data/config/initializers/mime_types.rb +1 -9
  214. data/config/initializers/new_framework_defaults_6_0.rb +46 -0
  215. data/config/initializers/relative_url_root.rb +1 -3
  216. data/config/initializers/session_store.rb +1 -3
  217. data/config/initializers/simple_form.rb +135 -55
  218. data/config/initializers/simple_form_bootstrap.rb +433 -0
  219. data/config/initializers/wrap_parameters.rb +4 -9
  220. data/config/locales/fat_free_crm.cs.yml +86 -47
  221. data/config/locales/fat_free_crm.en-GB.yml +5 -5
  222. data/config/locales/fat_free_crm.en-US.yml +5 -5
  223. data/config/locales/fat_free_crm.fr.yml +1 -1
  224. data/config/locales/fat_free_crm.ru.yml +2 -0
  225. data/config/routes.rb +20 -9
  226. data/config/settings.default.yml +0 -41
  227. data/db/demo/users.yml +62 -81
  228. data/db/migrate/20100928030620_remove_uuid.rb +1 -2
  229. data/db/migrate/20120316045804_activities_to_versions.rb +1 -0
  230. data/db/migrate/20120510025219_add_not_null_constraints_for_timestamp_columns.rb +1 -0
  231. data/db/migrate/20180107082701_authlogic_to_devise.rb +58 -0
  232. data/db/migrate/20200806004152_add_pattern_to_fields.rb +7 -0
  233. data/db/migrate/20200806004459_add_html5_to_fields.rb +10 -0
  234. data/db/schema.rb +58 -48
  235. data/docker-compose.yml +10 -0
  236. data/fat_free_crm.gemspec +13 -15
  237. data/lib/development_tasks/license.rake +2 -2
  238. data/lib/fat_free_crm/callback.rb +2 -2
  239. data/lib/fat_free_crm/comment_extensions.rb +2 -4
  240. data/lib/fat_free_crm/core_ext/string.rb +1 -1
  241. data/lib/fat_free_crm/core_ext.rb +1 -1
  242. data/lib/fat_free_crm/engine.rb +1 -1
  243. data/lib/fat_free_crm/errors.rb +1 -1
  244. data/lib/fat_free_crm/export_csv.rb +1 -0
  245. data/lib/fat_free_crm/exportable.rb +1 -1
  246. data/lib/fat_free_crm/fields.rb +1 -1
  247. data/lib/fat_free_crm/gem_dependencies.rb +1 -1
  248. data/lib/fat_free_crm/gem_ext.rb +0 -1
  249. data/lib/fat_free_crm/i18n.rb +2 -2
  250. data/lib/fat_free_crm/mail_processor/base.rb +4 -10
  251. data/lib/fat_free_crm/mail_processor/dropbox.rb +5 -15
  252. data/lib/fat_free_crm/permissions.rb +7 -4
  253. data/lib/fat_free_crm/sortable.rb +1 -1
  254. data/lib/fat_free_crm/tabs.rb +2 -2
  255. data/lib/fat_free_crm/version.rb +2 -2
  256. data/lib/gravatar_image_tag.rb +8 -9
  257. data/lib/missing_translation_detector.rb +1 -0
  258. data/lib/tasks/ffcrm/missing_translations.rake +1 -0
  259. data/lib/tasks/ffcrm/preference_update.rake +19 -0
  260. data/lib/tasks/ffcrm/setup.rake +11 -2
  261. data/lib/tasks/ffcrm/update_data.rake +2 -2
  262. data/lib/templates/erb/scaffold/_form.html.erb +4 -2
  263. data/script/rails +2 -2
  264. data/spec/controllers/admin/users_controller_spec.rb +0 -56
  265. data/spec/controllers/comments_controller_spec.rb +12 -12
  266. data/spec/controllers/entities/campaigns_controller_spec.rb +1 -1
  267. data/spec/controllers/entities/contacts_controller_spec.rb +2 -1
  268. data/spec/controllers/entities/leads_controller_spec.rb +2 -2
  269. data/spec/controllers/entities/opportunities_controller_spec.rb +1 -1
  270. data/spec/controllers/entities_controller_spec.rb +5 -0
  271. data/spec/controllers/home_controller_spec.rb +8 -8
  272. data/spec/controllers/tasks_controller_spec.rb +6 -4
  273. data/spec/controllers/users_controller_spec.rb +41 -99
  274. data/spec/factories/account_factories.rb +5 -5
  275. data/spec/factories/campaign_factories.rb +3 -3
  276. data/spec/factories/contact_factories.rb +8 -8
  277. data/spec/factories/field_factories.rb +4 -3
  278. data/spec/factories/lead_factories.rb +5 -5
  279. data/spec/factories/list_factories.rb +2 -2
  280. data/spec/factories/opportunity_factories.rb +3 -3
  281. data/spec/factories/setting_factories.rb +2 -2
  282. data/spec/factories/shared_factories.rb +11 -9
  283. data/spec/factories/task_factories.rb +7 -7
  284. data/spec/factories/user_factories.rb +21 -21
  285. data/spec/features/acceptance_helper.rb +1 -1
  286. data/spec/features/accounts_spec.rb +2 -2
  287. data/spec/features/admin/groups_spec.rb +2 -2
  288. data/spec/features/admin/users_spec.rb +4 -2
  289. data/spec/features/campaigns_spec.rb +3 -3
  290. data/spec/features/contacts_spec.rb +3 -6
  291. data/spec/features/dashboard_spec.rb +1 -1
  292. data/spec/features/devise/sign_in_spec.rb +58 -0
  293. data/spec/features/devise/sign_up_spec.rb +36 -0
  294. data/spec/features/leads_spec.rb +12 -8
  295. data/spec/features/opportunities_overview_spec.rb +1 -1
  296. data/spec/features/opportunities_spec.rb +7 -7
  297. data/spec/features/support/browser.rb +8 -3
  298. data/spec/features/support/selector_helpers.rb +10 -1
  299. data/spec/features/tasks_spec.rb +7 -7
  300. data/spec/helpers/accounts_helper_spec.rb +57 -0
  301. data/spec/helpers/admin/field_groups_helper_spec.rb +1 -1
  302. data/spec/helpers/users_helper_spec.rb +4 -4
  303. data/spec/lib/comment_extensions_spec.rb +10 -4
  304. data/spec/lib/errors_spec.rb +2 -2
  305. data/spec/lib/mail_processor/dropbox_spec.rb +1 -1
  306. data/spec/lib/mail_processor/sample_emails/dropbox.rb +8 -8
  307. data/spec/lib/permissions_spec.rb +8 -3
  308. data/spec/mailers/devise_mailer_spec.rb +35 -0
  309. data/spec/mailers/user_mailer_spec.rb +0 -26
  310. data/spec/models/entities/account_spec.rb +27 -0
  311. data/spec/models/entities/contact_spec.rb +96 -1
  312. data/spec/models/entities/opportunity_spec.rb +2 -2
  313. data/spec/models/fields/custom_field_date_pair_spec.rb +4 -2
  314. data/spec/models/fields/custom_field_pair_spec.rb +2 -2
  315. data/spec/models/fields/custom_field_spec.rb +4 -2
  316. data/spec/models/observers/entity_observer_spec.rb +4 -4
  317. data/spec/models/polymorphic/task_spec.rb +11 -11
  318. data/spec/models/polymorphic/version_spec.rb +9 -9
  319. data/spec/models/users/preference_spec.rb +1 -1
  320. data/spec/models/users/user_spec.rb +22 -26
  321. data/spec/routing/users_routing_spec.rb +30 -8
  322. data/spec/shared/controllers.rb +3 -9
  323. data/spec/spec_helper.rb +10 -2
  324. data/spec/support/assert_select.rb +1 -0
  325. data/spec/support/devise_helpers.rb +28 -0
  326. data/spec/{features/support/helpers.rb → support/feature_helpers.rb} +10 -10
  327. data/spec/support/macros.rb +4 -1
  328. data/spec/views/accounts/_edit.haml_spec.rb +1 -1
  329. data/spec/views/accounts/_new.haml_spec.rb +1 -1
  330. data/spec/views/accounts/create.js.haml_spec.rb +1 -2
  331. data/spec/views/accounts/update.js.haml_spec.rb +2 -5
  332. data/spec/views/admin/field_groups/create.js.haml_spec.rb +0 -1
  333. data/spec/views/admin/field_groups/update.js.haml_spec.rb +0 -1
  334. data/spec/views/admin/users/create.js.haml_spec.rb +0 -1
  335. data/spec/views/admin/users/destroy.js.haml_spec.rb +0 -6
  336. data/spec/views/admin/users/update.js.haml_spec.rb +1 -2
  337. data/spec/views/campaigns/_edit.haml_spec.rb +1 -1
  338. data/spec/views/campaigns/_new.haml_spec.rb +1 -1
  339. data/spec/views/campaigns/create.js.haml_spec.rb +1 -2
  340. data/spec/views/campaigns/destroy.js.haml_spec.rb +0 -1
  341. data/spec/views/campaigns/edit.js.haml_spec.rb +2 -2
  342. data/spec/views/campaigns/index.js.haml_spec.rb +1 -1
  343. data/spec/views/campaigns/update.js.haml_spec.rb +3 -7
  344. data/spec/views/contacts/_edit.haml_spec.rb +1 -1
  345. data/spec/views/contacts/_new.haml_spec.rb +1 -1
  346. data/spec/views/contacts/create.js.haml_spec.rb +1 -2
  347. data/spec/views/contacts/edit.js.haml_spec.rb +1 -1
  348. data/spec/views/contacts/index.js.html_spec.rb +1 -1
  349. data/spec/views/contacts/update.js.haml_spec.rb +6 -10
  350. data/spec/views/home/index.haml_spec.rb +2 -2
  351. data/spec/views/leads/_edit.haml_spec.rb +1 -1
  352. data/spec/views/leads/_new.haml_spec.rb +1 -1
  353. data/spec/views/leads/create.js.haml_spec.rb +0 -3
  354. data/spec/views/leads/destroy.js.haml_spec.rb +0 -2
  355. data/spec/views/leads/promote.js.haml_spec.rb +3 -11
  356. data/spec/views/leads/reject.js.haml_spec.rb +0 -3
  357. data/spec/views/leads/update.js.haml_spec.rb +3 -11
  358. data/spec/views/opportunities/_edit.haml_spec.rb +1 -1
  359. data/spec/views/opportunities/_new.haml_spec.rb +1 -1
  360. data/spec/views/opportunities/create.js.haml_spec.rb +0 -2
  361. data/spec/views/opportunities/destroy.js.haml_spec.rb +0 -3
  362. data/spec/views/opportunities/update.js.haml_spec.rb +4 -12
  363. data/spec/views/tasks/_edit.haml_spec.rb +1 -1
  364. data/spec/views/tasks/complete.js.haml_spec.rb +0 -1
  365. data/spec/views/tasks/create.js.haml_spec.rb +0 -2
  366. data/spec/views/tasks/destroy.js.haml_spec.rb +0 -1
  367. data/spec/views/tasks/uncomplete.js.haml_spec.rb +0 -1
  368. data/spec/views/tasks/update.js.haml_spec.rb +1 -4
  369. data/spec/views/users/change_password.js.haml_spec.rb +1 -2
  370. data/spec/views/users/update.js.haml_spec.rb +1 -2
  371. data/spec/views/users/upload_avatar.js.haml_spec.rb +1 -2
  372. metadata +63 -77
  373. data/app/controllers/authentications_controller.rb +0 -53
  374. data/app/models/users/authentication.rb +0 -56
  375. data/app/views/authentications/new.html.haml +0 -19
  376. data/app/views/passwords/edit.html.haml +0 -15
  377. data/app/views/passwords/new.html.haml +0 -10
  378. data/app/views/user_mailer/password_reset_instructions.html.haml +0 -6
  379. data/app/views/users/new.html.haml +0 -19
  380. data/lib/fat_free_crm/gem_ext/simple_form/action_view_extensions/form_helper.rb +0 -26
  381. data/spec/controllers/authentications_controller_spec.rb +0 -150
  382. data/spec/controllers/passwords_controller_spec.rb +0 -32
  383. data/spec/models/users/authentication_spec.rb +0 -19
  384. data/spec/support/auth_macros.rb +0 -49
  385. data/spec/views/authentications/new.haml_spec.rb +0 -31
@@ -7,9 +7,9 @@
7
7
  #------------------------------------------------------------------------------
8
8
  FactoryBot.define do
9
9
  factory :version do
10
- whodunnit ""
10
+ whodunnit { "" }
11
11
  item { raise "Please specify :item for the version" }
12
- event "create"
12
+ event { "create" }
13
13
  created_at { FactoryBot.generate(:time) }
14
14
  end
15
15
 
@@ -17,9 +17,11 @@ FactoryBot.define do
17
17
  user
18
18
  commentable { raise "Please specify :commentable for the comment" }
19
19
  title { FactoryBot.generate(:title) }
20
- private false
20
+
21
+ private { false }
22
+
21
23
  comment { FFaker::Lorem.paragraph }
22
- state "Expanded"
24
+ state { "Expanded" }
23
25
  updated_at { FactoryBot.generate(:time) }
24
26
  created_at { FactoryBot.generate(:time) }
25
27
  end
@@ -31,14 +33,14 @@ FactoryBot.define do
31
33
  sent_from { FFaker::Internet.email }
32
34
  sent_to { FFaker::Internet.email }
33
35
  cc { FFaker::Internet.email }
34
- bcc nil
36
+ bcc { nil }
35
37
  subject { FFaker::Lorem.sentence }
36
38
  body { FFaker::Lorem.paragraph[0, 255] }
37
- header nil
39
+ header { nil }
38
40
  sent_at { FactoryBot.generate(:time) }
39
41
  received_at { FactoryBot.generate(:time) }
40
- deleted_at nil
41
- state "Expanded"
42
+ deleted_at { nil }
43
+ state { "Expanded" }
42
44
  updated_at { FactoryBot.generate(:time) }
43
45
  created_at { FactoryBot.generate(:time) }
44
46
  end
@@ -55,7 +57,7 @@ FactoryBot.define do
55
57
  address_type { %w[Business Billing Shipping].sample }
56
58
  updated_at { FactoryBot.generate(:time) }
57
59
  created_at { FactoryBot.generate(:time) }
58
- deleted_at nil
60
+ deleted_at { nil }
59
61
  end
60
62
 
61
63
  factory :avatar do
@@ -8,17 +8,17 @@
8
8
  FactoryBot.define do
9
9
  factory :task do
10
10
  user
11
- asset nil
12
- assigned_to nil
13
- completed_by nil
11
+ asset { nil }
12
+ assigned_to { nil }
13
+ completed_by { nil }
14
14
  name { FFaker::Lorem.sentence[0, 64] }
15
- priority nil
15
+ priority { nil }
16
16
  category { %w[call email follow_up lunch meeting money presentation trip].sample }
17
- bucket "due_asap"
17
+ bucket { "due_asap" }
18
18
  due_at { FactoryBot.generate(:time) }
19
19
  background_info { FFaker::Lorem.paragraph[0, 255] }
20
- completed_at nil
21
- deleted_at nil
20
+ completed_at { nil }
21
+ deleted_at { nil }
22
22
  updated_at { FactoryBot.generate(:time) }
23
23
  created_at { FactoryBot.generate(:time) }
24
24
  end
@@ -7,7 +7,7 @@
7
7
  #------------------------------------------------------------------------------
8
8
  FactoryBot.define do
9
9
  factory :user do
10
- username { FactoryBot.generate(:username) }
10
+ username { FFaker::InternetSE.user_name_variant_short }
11
11
  email { FFaker::Internet.email }
12
12
  first_name { FFaker::Name.first_name }
13
13
  last_name { FFaker::Name.last_name }
@@ -16,31 +16,31 @@ FactoryBot.define do
16
16
  alt_email { FFaker::Internet.email }
17
17
  phone { FFaker::PhoneNumber.phone_number }
18
18
  mobile { FFaker::PhoneNumber.phone_number }
19
- aim nil
20
- yahoo nil
21
- google nil
22
- skype nil
23
- admin false
24
- password_hash { SecureRandom.hex(64) }
19
+ aim { nil }
20
+ yahoo { nil }
21
+ google { nil }
22
+ skype { nil }
23
+ admin { false }
24
+ encrypted_password { SecureRandom.hex(64) }
25
25
  password_salt { SecureRandom.hex(64) }
26
- persistence_token { SecureRandom.hex(64) }
27
- perishable_token { SecureRandom.hex(10) }
28
- single_access_token nil
29
- current_login_at { FactoryBot.generate(:time) }
30
- last_login_at { FactoryBot.generate(:time) }
31
- last_login_ip "127.0.0.1"
32
- current_login_ip "127.0.0.1"
33
- login_count { rand(1..100) }
34
- deleted_at nil
26
+ last_sign_in_at { FactoryBot.generate(:time) }
27
+ current_sign_in_at { FactoryBot.generate(:time) }
28
+ last_sign_in_ip { "127.0.0.1" }
29
+ current_sign_in_ip { "127.0.0.1" }
30
+ sign_in_count { rand(1..100) }
31
+ deleted_at { nil }
35
32
  updated_at { FactoryBot.generate(:time) }
36
33
  created_at { FactoryBot.generate(:time) }
37
- suspended_at nil
38
- password "password"
39
- password_confirmation "password"
40
- end
34
+ suspended_at { nil }
35
+ password { "password" }
36
+ password_confirmation { "password" }
41
37
 
38
+ # For unit tests, we dont need to enforce uniqueness
39
+ to_create { |instance| instance.save(validate: false) }
40
+ end
41
+
42
42
  factory :admin do
43
- admin true
43
+ admin { true }
44
44
  end
45
45
 
46
46
  factory :permission do
@@ -8,4 +8,4 @@
8
8
  require 'spec_helper'
9
9
 
10
10
  # Put your acceptance spec helpers inside /spec/features/support
11
- Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
11
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].sort.each { |f| require f }
@@ -31,8 +31,8 @@ feature 'Accounts', '
31
31
  click_link 'Create Account'
32
32
  expect(page).to have_selector('#account_name', visible: true)
33
33
  fill_in 'account_name', with: 'My new account'
34
- select 'Affiliate', from: 'account_category'
35
- select 'Myself', from: 'account_assigned_to'
34
+ select2 'Affiliate', from: 'Category:'
35
+ select2 'Myself', from: 'Assigned to:'
36
36
  click_link 'Contact Information'
37
37
  fill_in 'account_phone', with: '+1 2345 6789'
38
38
  fill_in 'account_website', with: 'http://www.example.com'
@@ -5,7 +5,7 @@
5
5
  # Fat Free CRM is freely distributable under the terms of MIT license.
6
6
  # See MIT-LICENSE file or http://www.opensource.org/licenses/mit-license.php
7
7
  #------------------------------------------------------------------------------
8
- require File.expand_path("../../acceptance_helper.rb", __FILE__)
8
+ require File.expand_path('../acceptance_helper.rb', __dir__)
9
9
 
10
10
  feature 'Groups tab', '
11
11
  In order to increase customer satisfaction
@@ -23,7 +23,7 @@ feature 'Groups tab', '
23
23
  click_link 'create a new group'
24
24
  expect(page).to have_selector('#group_name', visible: true)
25
25
  fill_in 'group_name', with: 'The Enterprise Bridge'
26
- select 'Mr Spock', from: 'group_user_ids'
26
+ select2 'Mr Spock', from: 'Users'
27
27
  click_button 'Create Group'
28
28
  expect(page).to have_content('The Enterprise Bridge')
29
29
  expect(page).to have_content('members: Mr Spock')
@@ -5,7 +5,7 @@
5
5
  # Fat Free CRM is freely distributable under the terms of MIT license.
6
6
  # See MIT-LICENSE file or http://www.opensource.org/licenses/mit-license.php
7
7
  #------------------------------------------------------------------------------
8
- require File.expand_path("../../acceptance_helper.rb", __FILE__)
8
+ require File.expand_path('../acceptance_helper.rb', __dir__)
9
9
 
10
10
  feature 'Users tab', '
11
11
  In order to increase customer satisfaction
@@ -25,9 +25,11 @@ feature 'Users tab', '
25
25
  fill_in 'user_email', with: 'lightning@example.com'
26
26
  fill_in 'user_first_name', with: 'Captain'
27
27
  fill_in 'user_last_name', with: 'Thunder'
28
+ fill_in 'user_password', with: 'password'
29
+ fill_in 'user_password_confirmation', with: 'password'
28
30
  fill_in 'user_title', with: 'Chief'
29
31
  fill_in 'user_company', with: 'Weather Inc.'
30
- select 'Superheroes', from: 'user_group_ids'
32
+ select2 'Superheroes', from: 'Groups:'
31
33
 
32
34
  click_button 'Create User'
33
35
  expect(find('#users')).to have_content('Captain Thunder')
@@ -5,7 +5,7 @@
5
5
  # Fat Free CRM is freely distributable under the terms of MIT license.
6
6
  # See MIT-LICENSE file or http://www.opensource.org/licenses/mit-license.php
7
7
  #------------------------------------------------------------------------------
8
- require File.expand_path("../acceptance_helper.rb", __FILE__)
8
+ require File.expand_path('acceptance_helper.rb', __dir__)
9
9
 
10
10
  feature 'Campaigns', '
11
11
  In order to increase customer satisfaction
@@ -31,7 +31,7 @@ feature 'Campaigns', '
31
31
  click_link 'Create Campaign'
32
32
  expect(page).to have_selector('#campaign_name', visible: true)
33
33
  fill_in 'campaign_name', with: 'Cool Campaign'
34
- select 'On Hold', from: 'campaign_status'
34
+ select2 'On Hold', from: 'Status:'
35
35
  click_link 'Comment'
36
36
  fill_in 'comment_body', with: 'This campaign is very important'
37
37
  click_button 'Create Campaign'
@@ -66,7 +66,7 @@ feature 'Campaigns', '
66
66
  click_link 'My Cool Campaign'
67
67
  click_link 'Edit'
68
68
  fill_in 'campaign_name', with: 'My Even Cooler Campaign'
69
- select 'Started', from: 'campaign_status'
69
+ select2 'Started', from: 'Status:'
70
70
  click_button 'Save Campaign'
71
71
  expect(page).to have_content('My Even Cooler Campaign')
72
72
  expect(page).to have_content('My Even Cooler Campaign')
@@ -5,7 +5,7 @@
5
5
  # Fat Free CRM is freely distributable under the terms of MIT license.
6
6
  # See MIT-LICENSE file or http://www.opensource.org/licenses/mit-license.php
7
7
  #------------------------------------------------------------------------------
8
- require File.expand_path("../acceptance_helper.rb", __FILE__)
8
+ require File.expand_path('acceptance_helper.rb', __dir__)
9
9
 
10
10
  feature 'Contacts', '
11
11
  In order to increase customer satisfaction
@@ -77,7 +77,8 @@ feature 'Contacts', '
77
77
  fill_in 'contact_last_name', with: 'Subject'
78
78
  fill_in 'contact_email', with: "test.subject@example.com"
79
79
  click_button 'Save Contact'
80
- expect(summary_element).to have_content('Test Subject')
80
+ sleep(3) # TODO: A better ajax wait, or redirect on save
81
+ expect(find('#edit_contact_title')).to have_content('Test Subject')
81
82
 
82
83
  click_link 'Dashboard'
83
84
  expect(activities_element).to have_content("Bill Murray updated contact Test Subject")
@@ -115,10 +116,6 @@ feature 'Contacts', '
115
116
  find('#main')
116
117
  end
117
118
 
118
- def summary_element
119
- find('#summary')
120
- end
121
-
122
119
  def menu_element
123
120
  find('#menu')
124
121
  end
@@ -5,7 +5,7 @@
5
5
  # Fat Free CRM is freely distributable under the terms of MIT license.
6
6
  # See MIT-LICENSE file or http://www.opensource.org/licenses/mit-license.php
7
7
  #------------------------------------------------------------------------------
8
- require File.expand_path("../acceptance_helper.rb", __FILE__)
8
+ require File.expand_path('acceptance_helper.rb', __dir__)
9
9
 
10
10
  feature 'Dashboard', '
11
11
  In order to monitor activity
@@ -0,0 +1,58 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright (c) 2008-2013 Michael Dvorkin and contributors.
4
+ #
5
+ # Fat Free CRM is freely distributable under the terms of MIT license.
6
+ # See MIT-LICENSE file or http://www.opensource.org/licenses/mit-license.php
7
+ #------------------------------------------------------------------------------
8
+ require 'features/acceptance_helper'
9
+
10
+ feature 'Devise Sign-in' do
11
+ background do
12
+ Setting.user_signup = :needs_approval
13
+ @user = create :user,
14
+ username: 'john',
15
+ password: 'password',
16
+ password_confirmation: 'password',
17
+ email: 'john@example.com',
18
+ sign_in_count: 0
19
+ end
20
+
21
+ scenario 'without confirmation' do
22
+ login_process('john', 'password')
23
+ expect(page).to have_content("You have to confirm your email address before continuing.")
24
+ end
25
+
26
+ scenario 'without approval' do
27
+ @user.confirm
28
+ login_process('john', 'password')
29
+ expect(page).to have_content("Your account has not been approved yet.")
30
+ end
31
+
32
+ scenario 'with approved and confirmed account' do
33
+ @user.confirm
34
+ @user.update_attribute(:suspended_at, nil)
35
+ login_process('john', 'password')
36
+ expect(page).to have_content("Signed in successfully.")
37
+ end
38
+
39
+ scenario 'invalid credentials' do
40
+ login_process('jo', 'pass')
41
+ expect(current_path).to eq "/users/sign_in"
42
+ expect(page).to have_content("Invalid Email or password")
43
+ end
44
+
45
+ scenario 'login with email' do
46
+ @user.confirm
47
+ @user.update_attribute(:suspended_at, nil)
48
+ login_process('john@example.com', 'password')
49
+ expect(page).to have_content("Signed in successfully")
50
+ end
51
+
52
+ def login_process(username, password)
53
+ visit '/users/sign_in'
54
+ fill_in 'user[email]', with: username
55
+ fill_in 'user[password]', with: password
56
+ click_button 'Login'
57
+ end
58
+ end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright (c) 2008-2013 Michael Dvorkin and contributors.
4
+ #
5
+ # Fat Free CRM is freely distributable under the terms of MIT license.
6
+ # See MIT-LICENSE file or http://www.opensource.org/licenses/mit-license.php
7
+ #------------------------------------------------------------------------------
8
+ require 'features/acceptance_helper'
9
+
10
+ feature 'Devise Sign-up' do
11
+ scenario 'with valid credentials' do
12
+ visit "/users/sign_up"
13
+
14
+ fill_in "user[email]", with: "john@example.com"
15
+ fill_in "user[username]", with: "john"
16
+ fill_in "user[password]", with: "password"
17
+ fill_in "user[password_confirmation]", with: "password"
18
+ click_button("Sign Up")
19
+
20
+ expect(current_path).to eq "/users/sign_in"
21
+ expect(page).to have_content("A message with a confirmation link has been sent to your email address. Please follow the link to activate your account.")
22
+ end
23
+
24
+ scenario 'without credentials' do
25
+ visit "/users/sign_up"
26
+ click_button("Sign Up")
27
+
28
+ expect(page).to have_content("6 errors prohibited this User from being saved")
29
+ expect(page).to have_content("Please specify email address")
30
+ expect(page).to have_content("Email is too short (minimum is 3 characters)")
31
+ expect(page).to have_content("Email is invalid")
32
+ expect(page).to have_content("Please specify username")
33
+ expect(page).to have_content("Username is invalid")
34
+ expect(page).to have_content("Password can't be blank")
35
+ end
36
+ end
@@ -5,7 +5,7 @@
5
5
  # Fat Free CRM is freely distributable under the terms of MIT license.
6
6
  # See MIT-LICENSE file or http://www.opensource.org/licenses/mit-license.php
7
7
  #------------------------------------------------------------------------------
8
- require File.expand_path("../acceptance_helper.rb", __FILE__)
8
+ require File.expand_path('acceptance_helper.rb', __dir__)
9
9
 
10
10
  feature 'Leads', '
11
11
  In order to increase sales
@@ -36,13 +36,16 @@ feature 'Leads', '
36
36
  fill_in 'lead_email', with: 'mr_lead@example.com'
37
37
  fill_in 'lead_phone', with: '+44 1234 567890'
38
38
  click_link 'Status'
39
- select 'Myself', from: 'lead_assigned_to'
40
- select 'Contacted', from: 'lead_status'
41
- select 'Campaign', from: 'lead_source'
39
+ select2 'Myself', from: 'Assigned to:'
40
+ select2 'Contacted', from: 'Status:'
41
+ select2 'Campaign', from: 'Source:'
42
42
  click_link 'Comment'
43
43
  fill_in 'comment_body', with: 'This is an important lead.'
44
- click_link 'Status'
45
- select 'Contacted', from: 'lead_status'
44
+
45
+ # TODO: Refactor to a page object
46
+ # This panel is already open, so clicking status again closed the div.
47
+ # click_link 'Status'
48
+ select2 'Contacted', from: 'Status:'
46
49
  click_button 'Create Lead'
47
50
  expect(leads_element).to have_content('Mr Lead')
48
51
 
@@ -79,9 +82,10 @@ feature 'Leads', '
79
82
  fill_in 'lead_first_name', with: 'Mrs'
80
83
  fill_in 'lead_phone', with: '+44 0987 654321'
81
84
  click_link('Status')
82
- select 'Rejected', from: 'lead_status'
85
+ select2 'Rejected', from: 'Status:'
83
86
  click_button 'Save Lead'
84
- expect(summary_element).to have_content('Mrs Lead')
87
+ sleep(3) # TODO: A better AJAX observing call, or just a redirect on save.
88
+ expect(find('#title')).to have_content('Mrs Lead')
85
89
 
86
90
  click_link "Dashboard"
87
91
  expect(activities_element).to have_content("Bill Murray updated lead Mrs Lead")
@@ -5,7 +5,7 @@
5
5
  # Fat Free CRM is freely distributable under the terms of MIT license.
6
6
  # See MIT-LICENSE file or http://www.opensource.org/licenses/mit-license.php
7
7
  #------------------------------------------------------------------------------
8
- require File.expand_path("../acceptance_helper.rb", __FILE__)
8
+ require File.expand_path('acceptance_helper.rb', __dir__)
9
9
 
10
10
  feature 'Opportunities Overview', "
11
11
  In order to keep track of my team's responsibilities
@@ -5,7 +5,7 @@
5
5
  # Fat Free CRM is freely distributable under the terms of MIT license.
6
6
  # See MIT-LICENSE file or http://www.opensource.org/licenses/mit-license.php
7
7
  #------------------------------------------------------------------------------
8
- require File.expand_path("../acceptance_helper.rb", __FILE__)
8
+ require File.expand_path('acceptance_helper.rb', __dir__)
9
9
 
10
10
  feature 'Opportunities', '
11
11
  In order to increase sales
@@ -38,7 +38,7 @@ feature 'Opportunities', '
38
38
  sleep(1)
39
39
  find('li', text: 'Example Account').click
40
40
  expect(page).to have_content('Example Account')
41
- select 'Prospecting', from: 'opportunity_stage'
41
+ select2 'Prospecting', from: 'Stage'
42
42
  click_link 'Comment'
43
43
  fill_in 'comment_body', with: 'This is a very important opportunity.'
44
44
  click_button 'Create Opportunity'
@@ -67,7 +67,7 @@ feature 'Opportunities', '
67
67
  scenario "remembers the comment field when the creation was unsuccessful", js: true do
68
68
  visit opportunities_page
69
69
  click_link 'Create Opportunity'
70
- select 'Prospecting', from: 'opportunity_stage'
70
+ select2 'Prospecting', from: 'Stage:'
71
71
 
72
72
  click_link 'Comment'
73
73
  fill_in 'comment_body', with: 'This is a very important opportunity.'
@@ -85,8 +85,8 @@ feature 'Opportunities', '
85
85
  click_link 'A Cool Opportunity'
86
86
  click_link 'Edit'
87
87
  fill_in 'opportunity_name', with: 'An Even Cooler Opportunity'
88
- select 'Other Example Account', from: 'account_id'
89
- select 'Analysis', from: 'opportunity_stage'
88
+ select2 'Other Example Account', from: 'Account (create new or select existing):'
89
+ select2 'Analysis', from: 'Stage:'
90
90
  click_button 'Save Opportunity'
91
91
  expect(page).to have_content('An Even Cooler Opportunity')
92
92
  click_link "Dashboard"
@@ -120,13 +120,13 @@ feature 'Opportunities', '
120
120
  expect(find('#opportunities')).not_to have_content("Opportunity 1")
121
121
  end
122
122
 
123
- scenario 'should add note to opportunity', js: true do
123
+ scenario 'should add comment to opportunity', js: true do
124
124
  opportunity = create(:opportunity, name: 'Awesome Opportunity')
125
125
  visit opportunities_page
126
126
  click_link 'Awesome Opportunity'
127
127
  find("#opportunity_#{opportunity.id}_post_new_note").click
128
128
  fill_in 'comment[comment]', with: 'Most awesome opportunity'
129
- click_button 'Add Note'
129
+ click_button 'Add Comment'
130
130
  expect(page).to have_content('Most awesome opportunity')
131
131
  end
132
132
  end
@@ -7,17 +7,22 @@
7
7
  #------------------------------------------------------------------------------
8
8
  Capaybara.app_host = ENV['APP_URL'] if ENV['APP_URL']
9
9
  Capybara.default_max_wait_time = 7
10
+ Capybara.server = :webrick
10
11
 
11
12
  if ENV['BROWSER'] == 'chrome'
12
13
  Capybara.register_driver :selenium do |app|
13
- capabilities = Selenium::WebDriver::Remote::Capabilities.chrome(chromeOptions: { args: ['no-sandbox', 'headless', 'disable-gpu'] })
14
+ capabilities = Selenium::WebDriver::Remote::Capabilities.chrome(chromeOptions: { args: %w[no-sandbox headless disable-gpu] })
14
15
  Capybara::Selenium::Driver.new(app, browser: :chrome, desired_capabilities: capabilities)
15
16
  end
16
17
  else
18
+ # For local testing in an environment with a display or remote X server configured
19
+ # such as WSL2, use NO_HEADLESS=1 bundle exec rspec spec/features
20
+ #
21
+ # For modern firefox, use MARIONETTE=1 bundle exec rspec spec/features
17
22
  Capybara.register_driver :selenium do |app|
18
23
  options = Selenium::WebDriver::Firefox::Options.new
19
- options.args << '--headless'
20
- capabilities = Selenium::WebDriver::Remote::Capabilities.firefox(marionette: false)
24
+ options.args << '--headless' unless ENV['NO_HEADLESS'].present?
25
+ capabilities = Selenium::WebDriver::Remote::Capabilities.firefox(marionette: ENV['MARIONETTE'].present?)
21
26
  Capybara::Selenium::Driver.new(app, browser: :firefox, options: options, desired_capabilities: capabilities)
22
27
  end
23
28
  end
@@ -7,7 +7,7 @@
7
7
  #------------------------------------------------------------------------------
8
8
  module SelectorHelpers
9
9
  def click_filter_tab(filter_name)
10
- tab = find(:xpath, "//div[@class='filters']//td[contains(text(), '#{filter_name}')]")
10
+ tab = find(:xpath, "//div[@class='filters']//a[contains(text(), '#{filter_name}')]")
11
11
  tab.click
12
12
  end
13
13
 
@@ -22,6 +22,15 @@ module SelectorHelpers
22
22
  page.execute_script "$('#task_#{task_id} a')[1].click()"
23
23
  end
24
24
  end
25
+
26
+ # See github.com/goodwill/capybara-select2
27
+ def select2(value, options = {})
28
+ select2_container = find("div.label", text: options[:from]).find(:xpath, '..').find('.select2-container')
29
+
30
+ select2_container.find(".select2-selection").click
31
+ drop_container = ".select2-dropdown"
32
+ find(:xpath, "//body").find("#{drop_container} li.select2-results__option", text: value).click
33
+ end
25
34
  end
26
35
 
27
36
  RSpec.configuration.include SelectorHelpers, type: :feature
@@ -5,7 +5,7 @@
5
5
  # Fat Free CRM is freely distributable under the terms of MIT license.
6
6
  # See MIT-LICENSE file or http://www.opensource.org/licenses/mit-license.php
7
7
  #------------------------------------------------------------------------------
8
- require File.expand_path("../acceptance_helper.rb", __FILE__)
8
+ require File.expand_path('acceptance_helper.rb', __dir__)
9
9
 
10
10
  feature 'Tasks', '
11
11
  In order to increase keep track of things
@@ -33,9 +33,9 @@ feature 'Tasks', '
33
33
  click_link 'Create Task'
34
34
  expect(page).to have_selector('#task_name', visible: true)
35
35
  fill_in 'task_name', with: 'Task I Need To Do'
36
- select 'Tomorrow', from: 'task_bucket'
37
- select 'Myself', from: 'task_assigned_to'
38
- select 'Call', from: 'task_category'
36
+ select2 'Tomorrow', from: 'Due:'
37
+ select2 'Myself', from: 'Assign to:'
38
+ select2 'Call', from: 'Category:'
39
39
  click_button 'Create Task'
40
40
  expect(page).to have_content('Task I Need To Do')
41
41
 
@@ -51,9 +51,9 @@ feature 'Tasks', '
51
51
  click_link 'Create Task'
52
52
  expect(page).to have_selector('#task_name', visible: true)
53
53
  fill_in 'task_name', with: 'Task For Someone Else'
54
- select 'Tomorrow', from: 'task_bucket'
55
- select 'Another User', from: 'task_assigned_to'
56
- select 'Call', from: 'task_category'
54
+ select2 'Tomorrow', from: 'Due:'
55
+ select2 'Another User', from: 'Assign to:'
56
+ select2 'Call', from: 'Category:'
57
57
  click_button 'Create Task'
58
58
  expect(page).to have_content('The task has been created and assigned to Another User')
59
59
 
@@ -8,9 +8,66 @@
8
8
  require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
9
9
 
10
10
  describe AccountsHelper do
11
+ let(:assignee) { create(:user) }
11
12
  # Delete this example and add some real ones or delete this file
12
13
  it "should be included in the object returned by #helper" do
13
14
  included_modules = (class << helper; self; end).send :included_modules
14
15
  expect(included_modules).to include(AccountsHelper)
15
16
  end
17
+ describe '#display_pipeline' do
18
+ context 'when the pipeline is zero' do
19
+ it 'returns "N/A"' do
20
+ expect(display_value(0)).to eq('N/A')
21
+ end
22
+ end
23
+ context 'when the pipeline is has 300' do
24
+ it 'returns "$300"' do
25
+ expect(display_value(300)).to eq('$300')
26
+ end
27
+ end
28
+ end
29
+ describe '#display_won' do
30
+ context 'when the won is zero' do
31
+ it 'returns "N/A"' do
32
+ expect(display_value(0)).to eq('N/A')
33
+ end
34
+ end
35
+ context 'when the won is has 300' do
36
+ it 'returns "$300"' do
37
+ expect(display_value(300)).to eq('$300')
38
+ end
39
+ end
40
+ end
41
+ describe '#display_lost' do
42
+ context 'when the lost is zero' do
43
+ it 'returns "N/A"' do
44
+ expect(display_value(0)).to eq('N/A')
45
+ end
46
+ end
47
+ context 'when the lost is has 300' do
48
+ it 'returns "$300"' do
49
+ expect(display_value(300)).to eq('$300')
50
+ end
51
+ end
52
+ end
53
+ describe '#display_assigned' do
54
+ context 'when the name is under 16 chars' do
55
+ it 'returns the name' do
56
+ @account = create(:account)
57
+ allow(@account).to receive(:assignee).and_return(assignee)
58
+ allow(assignee).to receive(:full_name).and_return('Abe Lincoln')
59
+ allow(@account).to receive(:assigned_to).and_return(1)
60
+ expect(display_assigned(@account)).to eq('Abe Lincoln')
61
+ end
62
+ end
63
+ context 'when the name is over 16 chars' do
64
+ it 'returns the truncated name' do
65
+ @account = create(:account)
66
+ allow(@account).to receive(:assignee).and_return(assignee)
67
+ allow(assignee).to receive(:full_name).and_return('Richard Milhouse Nixon')
68
+ allow(@account).to receive(:assigned_to).and_return(1)
69
+ expect(display_assigned(@account)).to eq('Richard Milho...')
70
+ end
71
+ end
72
+ end
16
73
  end
@@ -9,7 +9,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
9
9
 
10
10
  describe Admin::FieldGroupsHelper do
11
11
  it "should return the correct info text about tag restrictions and classes for groups" do
12
- field_group = build(:field_group, klass_name: "Contact", label: "Test Field Group")
12
+ field_group = create(:field_group, klass_name: "Contact", label: "Test Field Group")
13
13
  html = helper.field_group_subtitle(field_group)
14
14
  expect(html).to include("Test Field Group")
15
15
  expect(html).to include("This field group applies to contacts tagged with")