reduced_fat_crm 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (1042) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +36 -0
  3. data/.rubocop.yml +5 -0
  4. data/.teatro.yml +3 -0
  5. data/.travis.yml +41 -0
  6. data/CHANGELOG +1923 -0
  7. data/CONTRIBUTORS +91 -0
  8. data/Capfile +25 -0
  9. data/Dockerfile +18 -0
  10. data/Gemfile +88 -0
  11. data/Gemfile.lock +430 -0
  12. data/Guardfile +24 -0
  13. data/MIT-LICENSE +21 -0
  14. data/Procfile +1 -0
  15. data/README.md +153 -0
  16. data/Rakefile +9 -0
  17. data/app/assets/images/1x1.gif +0 -0
  18. data/app/assets/images/asterisk.gif +0 -0
  19. data/app/assets/images/avatar.jpg +0 -0
  20. data/app/assets/images/blog.gif +0 -0
  21. data/app/assets/images/facebook.gif +0 -0
  22. data/app/assets/images/info.png +0 -0
  23. data/app/assets/images/info_tiny.png +0 -0
  24. data/app/assets/images/linkedin.gif +0 -0
  25. data/app/assets/images/loading.gif +0 -0
  26. data/app/assets/images/notifications.png +0 -0
  27. data/app/assets/images/skype.gif +0 -0
  28. data/app/assets/images/sortable.gif +0 -0
  29. data/app/assets/images/stars.gif +0 -0
  30. data/app/assets/images/twitter.gif +0 -0
  31. data/app/assets/javascripts/admin/fields.js.coffee +72 -0
  32. data/app/assets/javascripts/application.js.erb +41 -0
  33. data/app/assets/javascripts/crm.js.coffee +428 -0
  34. data/app/assets/javascripts/crm_chosen.js.coffee +29 -0
  35. data/app/assets/javascripts/crm_classes.js.coffee +215 -0
  36. data/app/assets/javascripts/crm_comments.js.coffee +28 -0
  37. data/app/assets/javascripts/crm_loginout.js.coffee +27 -0
  38. data/app/assets/javascripts/crm_select2.js.coffee +31 -0
  39. data/app/assets/javascripts/crm_sortable.js.coffee +32 -0
  40. data/app/assets/javascripts/crm_tags.js.coffee +22 -0
  41. data/app/assets/javascripts/crm_textarea_autocomplete.js.coffee +33 -0
  42. data/app/assets/javascripts/datepicker.js.coffee +20 -0
  43. data/app/assets/javascripts/format_buttons.js.coffee +52 -0
  44. data/app/assets/javascripts/lists.js.coffee +54 -0
  45. data/app/assets/javascripts/pagination.js.coffee +16 -0
  46. data/app/assets/javascripts/search.js.coffee +55 -0
  47. data/app/assets/javascripts/timeago.js.coffee +21 -0
  48. data/app/assets/stylesheets/about.css.scss +10 -0
  49. data/app/assets/stylesheets/admin/fields.css.scss +17 -0
  50. data/app/assets/stylesheets/advanced_search.css.scss +108 -0
  51. data/app/assets/stylesheets/application.css.erb +37 -0
  52. data/app/assets/stylesheets/base.scss +78 -0
  53. data/app/assets/stylesheets/common.scss +765 -0
  54. data/app/assets/stylesheets/ffcrm_chosen.scss +69 -0
  55. data/app/assets/stylesheets/fields.scss +27 -0
  56. data/app/assets/stylesheets/format_buttons.css.scss +40 -0
  57. data/app/assets/stylesheets/groups.css.scss +8 -0
  58. data/app/assets/stylesheets/header.scss +121 -0
  59. data/app/assets/stylesheets/index_headers.css.scss +5 -0
  60. data/app/assets/stylesheets/lists.css.scss +26 -0
  61. data/app/assets/stylesheets/print.css.scss +77 -0
  62. data/app/assets/stylesheets/rails.scss +133 -0
  63. data/app/assets/stylesheets/safari.scss +11 -0
  64. data/app/assets/stylesheets/textarea_autocomplete.scss +47 -0
  65. data/app/controllers/admin/application_controller.rb +30 -0
  66. data/app/controllers/admin/field_groups_controller.rb +83 -0
  67. data/app/controllers/admin/fields_controller.rb +118 -0
  68. data/app/controllers/admin/groups_controller.rb +65 -0
  69. data/app/controllers/admin/plugins_controller.rb +17 -0
  70. data/app/controllers/admin/settings_controller.rb +14 -0
  71. data/app/controllers/admin/tags_controller.rb +71 -0
  72. data/app/controllers/admin/users_controller.rb +144 -0
  73. data/app/controllers/application_controller.rb +276 -0
  74. data/app/controllers/authentications_controller.rb +51 -0
  75. data/app/controllers/comments_controller.rb +93 -0
  76. data/app/controllers/emails_controller.rb +18 -0
  77. data/app/controllers/entities/accounts_controller.rb +158 -0
  78. data/app/controllers/entities/campaigns_controller.rb +197 -0
  79. data/app/controllers/entities/contacts_controller.rb +178 -0
  80. data/app/controllers/entities/leads_controller.rb +256 -0
  81. data/app/controllers/entities/opportunities_controller.rb +222 -0
  82. data/app/controllers/entities_controller.rb +214 -0
  83. data/app/controllers/home_controller.rb +156 -0
  84. data/app/controllers/lists_controller.rb +40 -0
  85. data/app/controllers/passwords_controller.rb +65 -0
  86. data/app/controllers/tasks_controller.rb +219 -0
  87. data/app/controllers/users_controller.rb +159 -0
  88. data/app/helpers/accounts_helper.rb +110 -0
  89. data/app/helpers/addresses_helper.rb +17 -0
  90. data/app/helpers/admin/application_helper.rb +15 -0
  91. data/app/helpers/admin/field_groups_helper.rb +25 -0
  92. data/app/helpers/admin/fields_helper.rb +18 -0
  93. data/app/helpers/admin/plugins_helper.rb +7 -0
  94. data/app/helpers/admin/settings_helper.rb +7 -0
  95. data/app/helpers/admin/tags_helper.rb +10 -0
  96. data/app/helpers/admin/users_helper.rb +51 -0
  97. data/app/helpers/application_helper.rb +527 -0
  98. data/app/helpers/authentications_helper.rb +7 -0
  99. data/app/helpers/campaigns_helper.rb +34 -0
  100. data/app/helpers/comments_helper.rb +11 -0
  101. data/app/helpers/contacts_helper.rb +21 -0
  102. data/app/helpers/emails_helper.rb +7 -0
  103. data/app/helpers/fields_helper.rb +7 -0
  104. data/app/helpers/groups_helper.rb +7 -0
  105. data/app/helpers/home_helper.rb +66 -0
  106. data/app/helpers/javascript_helper.rb +30 -0
  107. data/app/helpers/leads_helper.rb +85 -0
  108. data/app/helpers/lists_helper.rb +7 -0
  109. data/app/helpers/opportunities_helper.rb +46 -0
  110. data/app/helpers/passwords_helper.rb +7 -0
  111. data/app/helpers/remote_link_pagination_helper.rb +8 -0
  112. data/app/helpers/tags_helper.rb +29 -0
  113. data/app/helpers/tasks_helper.rb +139 -0
  114. data/app/helpers/users_helper.rb +35 -0
  115. data/app/helpers/versions_helper.rb +32 -0
  116. data/app/inputs/date_pair_input.rb +65 -0
  117. data/app/inputs/date_time_input.rb +36 -0
  118. data/app/inputs/datetime_pair_input.rb +25 -0
  119. data/app/inputs/text_input.rb +12 -0
  120. data/app/mailers/dropbox_mailer.rb +18 -0
  121. data/app/mailers/subscription_mailer.rb +30 -0
  122. data/app/mailers/user_mailer.rb +32 -0
  123. data/app/models/entities/account.rb +142 -0
  124. data/app/models/entities/account_contact.rb +28 -0
  125. data/app/models/entities/account_opportunity.rb +26 -0
  126. data/app/models/entities/campaign.rb +116 -0
  127. data/app/models/entities/contact.rb +215 -0
  128. data/app/models/entities/contact_opportunity.rb +27 -0
  129. data/app/models/entities/lead.rb +197 -0
  130. data/app/models/entities/opportunity.rb +190 -0
  131. data/app/models/fields/core_field.rb +37 -0
  132. data/app/models/fields/custom_field.rb +148 -0
  133. data/app/models/fields/custom_field_date_pair.rb +42 -0
  134. data/app/models/fields/custom_field_datetime_pair.rb +12 -0
  135. data/app/models/fields/custom_field_pair.rb +42 -0
  136. data/app/models/fields/field.rb +129 -0
  137. data/app/models/fields/field_group.rb +63 -0
  138. data/app/models/list.rb +17 -0
  139. data/app/models/observers/entity_observer.rb +43 -0
  140. data/app/models/observers/lead_observer.rb +29 -0
  141. data/app/models/observers/opportunity_observer.rb +47 -0
  142. data/app/models/observers/task_observer.rb +31 -0
  143. data/app/models/polymorphic/address.rb +59 -0
  144. data/app/models/polymorphic/avatar.rb +55 -0
  145. data/app/models/polymorphic/comment.rb +73 -0
  146. data/app/models/polymorphic/email.rb +59 -0
  147. data/app/models/polymorphic/tag.rb +21 -0
  148. data/app/models/polymorphic/tagging.rb +8 -0
  149. data/app/models/polymorphic/task.rb +284 -0
  150. data/app/models/polymorphic/version.rb +81 -0
  151. data/app/models/setting.rb +103 -0
  152. data/app/models/users/ability.rb +59 -0
  153. data/app/models/users/authentication.rb +54 -0
  154. data/app/models/users/group.rb +13 -0
  155. data/app/models/users/permission.rb +27 -0
  156. data/app/models/users/preference.rb +50 -0
  157. data/app/models/users/user.rb +184 -0
  158. data/app/views/accounts/_account.html.haml +5 -0
  159. data/app/views/accounts/_contact_info.html.haml +37 -0
  160. data/app/views/accounts/_edit.html.haml +21 -0
  161. data/app/views/accounts/_index_brief.html.haml +32 -0
  162. data/app/views/accounts/_index_long.html.haml +42 -0
  163. data/app/views/accounts/_new.html.haml +21 -0
  164. data/app/views/accounts/_sidebar_index.html.haml +20 -0
  165. data/app/views/accounts/_sidebar_show.html.haml +57 -0
  166. data/app/views/accounts/_title_bar.html.haml +11 -0
  167. data/app/views/accounts/_top_section.html.haml +29 -0
  168. data/app/views/accounts/create.js.haml +17 -0
  169. data/app/views/accounts/destroy.js.haml +6 -0
  170. data/app/views/accounts/edit.js.haml +31 -0
  171. data/app/views/accounts/index.html.haml +18 -0
  172. data/app/views/accounts/index.js.haml +11 -0
  173. data/app/views/accounts/index.xls.builder +84 -0
  174. data/app/views/accounts/new.js.haml +11 -0
  175. data/app/views/accounts/show.html.haml +26 -0
  176. data/app/views/accounts/show.js.haml +5 -0
  177. data/app/views/accounts/update.js.haml +19 -0
  178. data/app/views/admin/custom_fields/_base_field.html.haml +21 -0
  179. data/app/views/admin/custom_fields/_check_boxes_field.html.haml +6 -0
  180. data/app/views/admin/custom_fields/_date_field.html.haml +14 -0
  181. data/app/views/admin/custom_fields/_date_pair_field.html.haml +21 -0
  182. data/app/views/admin/custom_fields/_datetime_field.html.haml +14 -0
  183. data/app/views/admin/custom_fields/_datetime_pair_field.html.haml +21 -0
  184. data/app/views/admin/custom_fields/_radio_field.html.haml +6 -0
  185. data/app/views/admin/custom_fields/_select_field.html.haml +25 -0
  186. data/app/views/admin/custom_fields/_string_field.html.haml +2 -0
  187. data/app/views/admin/field_groups/_confirm.html.haml +5 -0
  188. data/app/views/admin/field_groups/_edit.html.haml +8 -0
  189. data/app/views/admin/field_groups/_field_group.html.haml +28 -0
  190. data/app/views/admin/field_groups/_new.html.haml +10 -0
  191. data/app/views/admin/field_groups/_top_section.html.haml +14 -0
  192. data/app/views/admin/field_groups/confirm.js.haml +7 -0
  193. data/app/views/admin/field_groups/create.js.haml +14 -0
  194. data/app/views/admin/field_groups/destroy.js.haml +9 -0
  195. data/app/views/admin/field_groups/edit.js.haml +12 -0
  196. data/app/views/admin/field_groups/new.js.haml +8 -0
  197. data/app/views/admin/field_groups/update.js.haml +8 -0
  198. data/app/views/admin/fields/_field.html.haml +17 -0
  199. data/app/views/admin/fields/_form.html.haml +35 -0
  200. data/app/views/admin/fields/_sidebar_index.html.haml +1 -0
  201. data/app/views/admin/fields/_sidebar_show.html.haml +1 -0
  202. data/app/views/admin/fields/_sort_by.html.haml +10 -0
  203. data/app/views/admin/fields/_subform.html.haml +6 -0
  204. data/app/views/admin/fields/create.js.haml +17 -0
  205. data/app/views/admin/fields/destroy.js.haml +8 -0
  206. data/app/views/admin/fields/edit.js.haml +3 -0
  207. data/app/views/admin/fields/index.html.haml +34 -0
  208. data/app/views/admin/fields/show.html.haml +41 -0
  209. data/app/views/admin/fields/update.js.haml +13 -0
  210. data/app/views/admin/groups/_edit.html.haml +12 -0
  211. data/app/views/admin/groups/_form.html.haml +11 -0
  212. data/app/views/admin/groups/_group.html.haml +16 -0
  213. data/app/views/admin/groups/_new.html.haml +12 -0
  214. data/app/views/admin/groups/create.js.haml +10 -0
  215. data/app/views/admin/groups/destroy.js.haml +9 -0
  216. data/app/views/admin/groups/edit.js.haml +14 -0
  217. data/app/views/admin/groups/index.html.haml +18 -0
  218. data/app/views/admin/groups/index.js.haml +2 -0
  219. data/app/views/admin/groups/new.js.haml +9 -0
  220. data/app/views/admin/groups/show.html.haml +11 -0
  221. data/app/views/admin/groups/update.js.haml +9 -0
  222. data/app/views/admin/plugins/_plugin.html.haml +13 -0
  223. data/app/views/admin/plugins/index.html.haml +3 -0
  224. data/app/views/admin/settings/index.html.haml +3 -0
  225. data/app/views/admin/tags/_confirm.html.haml +5 -0
  226. data/app/views/admin/tags/_edit.html.haml +9 -0
  227. data/app/views/admin/tags/_new.html.haml +10 -0
  228. data/app/views/admin/tags/_tag.html.haml +29 -0
  229. data/app/views/admin/tags/_top_section.html.haml +6 -0
  230. data/app/views/admin/tags/confirm.js.haml +7 -0
  231. data/app/views/admin/tags/create.js.haml +11 -0
  232. data/app/views/admin/tags/destroy.js.haml +10 -0
  233. data/app/views/admin/tags/edit.js.haml +20 -0
  234. data/app/views/admin/tags/index.html.haml +17 -0
  235. data/app/views/admin/tags/new.js.haml +7 -0
  236. data/app/views/admin/tags/update.js.haml +9 -0
  237. data/app/views/admin/users/_confirm.html.haml +5 -0
  238. data/app/views/admin/users/_edit.html.haml +11 -0
  239. data/app/views/admin/users/_new.html.haml +11 -0
  240. data/app/views/admin/users/_profile.html.haml +54 -0
  241. data/app/views/admin/users/_sidebar_index.html.haml +2 -0
  242. data/app/views/admin/users/_user.html.haml +66 -0
  243. data/app/views/admin/users/confirm.js.haml +7 -0
  244. data/app/views/admin/users/create.js.haml +10 -0
  245. data/app/views/admin/users/destroy.js.haml +10 -0
  246. data/app/views/admin/users/edit.js.haml +20 -0
  247. data/app/views/admin/users/index.html.haml +13 -0
  248. data/app/views/admin/users/index.js.haml +2 -0
  249. data/app/views/admin/users/new.js.haml +9 -0
  250. data/app/views/admin/users/reactivate.js.haml +3 -0
  251. data/app/views/admin/users/show.html.haml +5 -0
  252. data/app/views/admin/users/suspend.js.haml +3 -0
  253. data/app/views/admin/users/update.js.haml +9 -0
  254. data/app/views/application/_auto_complete.html.haml +10 -0
  255. data/app/views/application/index.atom.builder +34 -0
  256. data/app/views/application/index.rss.builder +31 -0
  257. data/app/views/application/show.atom.builder +32 -0
  258. data/app/views/application/show.rss.builder +29 -0
  259. data/app/views/authentications/new.html.haml +19 -0
  260. data/app/views/campaigns/_campaign.html.haml +5 -0
  261. data/app/views/campaigns/_edit.html.haml +18 -0
  262. data/app/views/campaigns/_index_brief.html.haml +15 -0
  263. data/app/views/campaigns/_index_long.html.haml +20 -0
  264. data/app/views/campaigns/_metrics.html.haml +16 -0
  265. data/app/views/campaigns/_new.html.haml +18 -0
  266. data/app/views/campaigns/_objectives.html.haml +30 -0
  267. data/app/views/campaigns/_sidebar_index.html.haml +20 -0
  268. data/app/views/campaigns/_sidebar_show.html.haml +91 -0
  269. data/app/views/campaigns/_status.html.haml +24 -0
  270. data/app/views/campaigns/_title_bar.html.haml +11 -0
  271. data/app/views/campaigns/_top_section.html.haml +29 -0
  272. data/app/views/campaigns/create.js.haml +20 -0
  273. data/app/views/campaigns/destroy.js.haml +6 -0
  274. data/app/views/campaigns/edit.js.haml +31 -0
  275. data/app/views/campaigns/index.html.haml +18 -0
  276. data/app/views/campaigns/index.js.haml +11 -0
  277. data/app/views/campaigns/index.xls.builder +77 -0
  278. data/app/views/campaigns/new.js.haml +11 -0
  279. data/app/views/campaigns/show.html.haml +26 -0
  280. data/app/views/campaigns/show.js.haml +5 -0
  281. data/app/views/campaigns/update.js.haml +22 -0
  282. data/app/views/comments/_comment.html.haml +29 -0
  283. data/app/views/comments/_edit.html.haml +11 -0
  284. data/app/views/comments/_new.html.haml +35 -0
  285. data/app/views/comments/_subscription_links.html.haml +13 -0
  286. data/app/views/comments/create.js.haml +14 -0
  287. data/app/views/comments/destroy.js.haml +5 -0
  288. data/app/views/comments/edit.js.haml +11 -0
  289. data/app/views/comments/update.js.haml +9 -0
  290. data/app/views/contacts/_contact.html.haml +5 -0
  291. data/app/views/contacts/_contacts.html.haml +7 -0
  292. data/app/views/contacts/_edit.html.haml +19 -0
  293. data/app/views/contacts/_extra.html.haml +36 -0
  294. data/app/views/contacts/_index_brief.html.haml +25 -0
  295. data/app/views/contacts/_index_full.html.haml +57 -0
  296. data/app/views/contacts/_index_long.html.haml +44 -0
  297. data/app/views/contacts/_new.html.haml +20 -0
  298. data/app/views/contacts/_section_extra.html.haml +26 -0
  299. data/app/views/contacts/_section_general.html.haml +26 -0
  300. data/app/views/contacts/_sidebar_index.html.haml +0 -0
  301. data/app/views/contacts/_sidebar_show.html.haml +52 -0
  302. data/app/views/contacts/_title_bar.html.haml +11 -0
  303. data/app/views/contacts/_top_section.html.haml +45 -0
  304. data/app/views/contacts/_web.html.haml +31 -0
  305. data/app/views/contacts/create.js.haml +23 -0
  306. data/app/views/contacts/destroy.js.haml +9 -0
  307. data/app/views/contacts/edit.js.haml +34 -0
  308. data/app/views/contacts/index.html.haml +18 -0
  309. data/app/views/contacts/index.js.haml +11 -0
  310. data/app/views/contacts/index.xls.builder +104 -0
  311. data/app/views/contacts/new.js.haml +13 -0
  312. data/app/views/contacts/show.html.haml +22 -0
  313. data/app/views/contacts/show.js.haml +5 -0
  314. data/app/views/contacts/update.js.haml +24 -0
  315. data/app/views/dropbox_mailer/dropbox_notification.html.haml +9 -0
  316. data/app/views/emails/_email.html.haml +36 -0
  317. data/app/views/emails/destroy.js.haml +5 -0
  318. data/app/views/entities/_basic_search.html.haml +24 -0
  319. data/app/views/entities/_permissions.html.haml +36 -0
  320. data/app/views/entities/_search.html.haml +16 -0
  321. data/app/views/entities/_section_custom_fields.html.haml +11 -0
  322. data/app/views/entities/_sort_fields.html.haml +3 -0
  323. data/app/views/entities/_title_bar.html.haml +12 -0
  324. data/app/views/entities/attach.js.haml +21 -0
  325. data/app/views/entities/contacts.js.haml +3 -0
  326. data/app/views/entities/discard.js.haml +6 -0
  327. data/app/views/entities/leads.js.haml +3 -0
  328. data/app/views/entities/opportunities.js.haml +3 -0
  329. data/app/views/entities/subscription_update.js.haml +4 -0
  330. data/app/views/entities/versions.js.haml +3 -0
  331. data/app/views/fields/_edit_custom_field_group.html.haml +8 -0
  332. data/app/views/fields/_group.html.haml +11 -0
  333. data/app/views/fields/_group_table.html.haml +13 -0
  334. data/app/views/fields/_group_view.html.haml +10 -0
  335. data/app/views/fields/_groups.html.haml +8 -0
  336. data/app/views/fields/_sidebar_show.html.haml +9 -0
  337. data/app/views/fields/group.js.erb +3 -0
  338. data/app/views/home/_account.html.haml +29 -0
  339. data/app/views/home/_activity.html.haml +35 -0
  340. data/app/views/home/_assets_menu.html.haml +7 -0
  341. data/app/views/home/_duration_menu.html.haml +8 -0
  342. data/app/views/home/_events_menu.html.haml +8 -0
  343. data/app/views/home/_opportunity.html.haml +41 -0
  344. data/app/views/home/_options.html.haml +12 -0
  345. data/app/views/home/_task.html.haml +48 -0
  346. data/app/views/home/_users_menu.html.haml +8 -0
  347. data/app/views/home/index.atom.builder +24 -0
  348. data/app/views/home/index.html.haml +46 -0
  349. data/app/views/home/index.js.haml +7 -0
  350. data/app/views/home/index.rss.builder +20 -0
  351. data/app/views/home/options.js.haml +7 -0
  352. data/app/views/layouts/500.html.haml +17 -0
  353. data/app/views/layouts/_about.html.haml +17 -0
  354. data/app/views/layouts/_footer.html.haml +9 -0
  355. data/app/views/layouts/_header.html.haml +20 -0
  356. data/app/views/layouts/_jumpbox.html.haml +34 -0
  357. data/app/views/layouts/_sidebar.html.haml +12 -0
  358. data/app/views/layouts/_tabbed.html.haml +15 -0
  359. data/app/views/layouts/_tabless.html.haml +3 -0
  360. data/app/views/layouts/admin/_header.html.haml +14 -0
  361. data/app/views/layouts/admin/application.html.haml +24 -0
  362. data/app/views/layouts/application.html.haml +48 -0
  363. data/app/views/layouts/header.xls.builder +8 -0
  364. data/app/views/leads/_contact.html.haml +35 -0
  365. data/app/views/leads/_convert.html.haml +25 -0
  366. data/app/views/leads/_convert_permissions.html.haml +31 -0
  367. data/app/views/leads/_edit.html.haml +23 -0
  368. data/app/views/leads/_index_brief.html.haml +41 -0
  369. data/app/views/leads/_index_long.html.haml +62 -0
  370. data/app/views/leads/_lead.html.haml +5 -0
  371. data/app/views/leads/_leads.html.haml +6 -0
  372. data/app/views/leads/_new.html.haml +24 -0
  373. data/app/views/leads/_opportunity.html.haml +37 -0
  374. data/app/views/leads/_sidebar_index.html.haml +20 -0
  375. data/app/views/leads/_sidebar_show.html.haml +65 -0
  376. data/app/views/leads/_status.html.haml +36 -0
  377. data/app/views/leads/_title_bar.html.haml +16 -0
  378. data/app/views/leads/_top_section.html.haml +30 -0
  379. data/app/views/leads/_web.html.haml +31 -0
  380. data/app/views/leads/convert.js.haml +35 -0
  381. data/app/views/leads/create.js.haml +21 -0
  382. data/app/views/leads/destroy.js.haml +9 -0
  383. data/app/views/leads/edit.js.haml +33 -0
  384. data/app/views/leads/index.html.haml +18 -0
  385. data/app/views/leads/index.js.haml +11 -0
  386. data/app/views/leads/index.xls.builder +102 -0
  387. data/app/views/leads/new.js.haml +11 -0
  388. data/app/views/leads/promote.js.haml +26 -0
  389. data/app/views/leads/reject.js.haml +12 -0
  390. data/app/views/leads/show.html.haml +20 -0
  391. data/app/views/leads/show.js.haml +5 -0
  392. data/app/views/leads/update.js.haml +28 -0
  393. data/app/views/lists/_lists.html.haml +6 -0
  394. data/app/views/lists/_sidebar.html.haml +29 -0
  395. data/app/views/lists/create.js.haml +9 -0
  396. data/app/views/lists/destroy.js.haml +1 -0
  397. data/app/views/opportunities/_edit.html.haml +18 -0
  398. data/app/views/opportunities/_index_brief.html.haml +29 -0
  399. data/app/views/opportunities/_index_long.html.haml +59 -0
  400. data/app/views/opportunities/_new.html.haml +18 -0
  401. data/app/views/opportunities/_opportunities.html.haml +6 -0
  402. data/app/views/opportunities/_opportunity.html.haml +5 -0
  403. data/app/views/opportunities/_sidebar_index.html.haml +20 -0
  404. data/app/views/opportunities/_sidebar_show.html.haml +61 -0
  405. data/app/views/opportunities/_title_bar.html.haml +11 -0
  406. data/app/views/opportunities/_top_section.html.haml +59 -0
  407. data/app/views/opportunities/contacts.js.haml +3 -0
  408. data/app/views/opportunities/create.js.haml +29 -0
  409. data/app/views/opportunities/destroy.js.haml +13 -0
  410. data/app/views/opportunities/edit.js.haml +34 -0
  411. data/app/views/opportunities/index.html.haml +20 -0
  412. data/app/views/opportunities/index.js.haml +11 -0
  413. data/app/views/opportunities/index.xls.builder +71 -0
  414. data/app/views/opportunities/new.js.haml +13 -0
  415. data/app/views/opportunities/show.html.haml +22 -0
  416. data/app/views/opportunities/show.js.haml +5 -0
  417. data/app/views/opportunities/update.js.haml +27 -0
  418. data/app/views/passwords/edit.html.haml +15 -0
  419. data/app/views/passwords/new.html.haml +10 -0
  420. data/app/views/shared/_add_comment.html.haml +8 -0
  421. data/app/views/shared/_address.html.haml +44 -0
  422. data/app/views/shared/_address_show.html.haml +24 -0
  423. data/app/views/shared/_comment.html.haml +11 -0
  424. data/app/views/shared/_edit_comment.html.haml +13 -0
  425. data/app/views/shared/_empty.html.haml +8 -0
  426. data/app/views/shared/_export.html.haml +2 -0
  427. data/app/views/shared/_inline_styles.html.haml +31 -0
  428. data/app/views/shared/_naming.html.haml +9 -0
  429. data/app/views/shared/_paginate.haml +2 -0
  430. data/app/views/shared/_paginate_with_per_page.html.haml +12 -0
  431. data/app/views/shared/_recent.html.haml +4 -0
  432. data/app/views/shared/_recently.html.haml +7 -0
  433. data/app/views/shared/_search.html.haml +15 -0
  434. data/app/views/shared/_select_popup.html.haml +19 -0
  435. data/app/views/shared/_tags.html.haml +10 -0
  436. data/app/views/shared/_tasks.html.haml +10 -0
  437. data/app/views/shared/_timeline.html.haml +2 -0
  438. data/app/views/shared/_total.html.haml +4 -0
  439. data/app/views/subscription_mailer/comment_notification.text.erb +7 -0
  440. data/app/views/tasks/_assigned.html.haml +47 -0
  441. data/app/views/tasks/_completed.html.haml +25 -0
  442. data/app/views/tasks/_edit.html.haml +18 -0
  443. data/app/views/tasks/_empty.html.haml +4 -0
  444. data/app/views/tasks/_new.html.haml +14 -0
  445. data/app/views/tasks/_pending.html.haml +52 -0
  446. data/app/views/tasks/_related.html.haml +32 -0
  447. data/app/views/tasks/_selector.html.haml +8 -0
  448. data/app/views/tasks/_sidebar_index.html.haml +18 -0
  449. data/app/views/tasks/_tasks.html.haml +3 -0
  450. data/app/views/tasks/_title.html.haml +8 -0
  451. data/app/views/tasks/_top_section.html.haml +34 -0
  452. data/app/views/tasks/complete.js.haml +14 -0
  453. data/app/views/tasks/create.js.haml +39 -0
  454. data/app/views/tasks/destroy.js.haml +7 -0
  455. data/app/views/tasks/discard.js.haml +1 -0
  456. data/app/views/tasks/edit.js.haml +26 -0
  457. data/app/views/tasks/filter.js.haml +4 -0
  458. data/app/views/tasks/index.html.haml +20 -0
  459. data/app/views/tasks/index.xls.builder +49 -0
  460. data/app/views/tasks/new.js.haml +8 -0
  461. data/app/views/tasks/uncomplete.js.haml +12 -0
  462. data/app/views/tasks/update.js.haml +19 -0
  463. data/app/views/user_mailer/assigned_entity_notification.html.haml +3 -0
  464. data/app/views/user_mailer/password_reset_instructions.html.haml +6 -0
  465. data/app/views/users/_avatar.html.haml +20 -0
  466. data/app/views/users/_languages.html.haml +9 -0
  467. data/app/views/users/_password.html.haml +27 -0
  468. data/app/views/users/_profile.html.haml +67 -0
  469. data/app/views/users/_user.html.haml +33 -0
  470. data/app/views/users/_user_report.html.haml +6 -0
  471. data/app/views/users/avatar.js.haml +9 -0
  472. data/app/views/users/change_password.js.haml +13 -0
  473. data/app/views/users/edit.js.haml +9 -0
  474. data/app/views/users/index.html.haml +3 -0
  475. data/app/views/users/new.html.haml +19 -0
  476. data/app/views/users/opportunities_overview.html.haml +16 -0
  477. data/app/views/users/password.js.haml +10 -0
  478. data/app/views/users/show.html.haml +15 -0
  479. data/app/views/users/update.js.haml +9 -0
  480. data/app/views/users/upload_avatar.js.haml +7 -0
  481. data/app/views/versions/_version.html.haml +17 -0
  482. data/app/views/versions/_version_item.html.haml +8 -0
  483. data/app/views/versions/_versions.html.haml +11 -0
  484. data/bin/bundle +3 -0
  485. data/bin/rails +4 -0
  486. data/bin/rake +4 -0
  487. data/config.ru +4 -0
  488. data/config/application.rb +77 -0
  489. data/config/boot.rb +10 -0
  490. data/config/database.mysql.mac.yml +32 -0
  491. data/config/database.mysql.yml +33 -0
  492. data/config/database.postgres.docker.yml +25 -0
  493. data/config/database.postgres.yml +26 -0
  494. data/config/database.sqlite.yml +23 -0
  495. data/config/deploy.example.rb +77 -0
  496. data/config/environment.rb +10 -0
  497. data/config/environments/development.rb +46 -0
  498. data/config/environments/production.rb +66 -0
  499. data/config/environments/staging.rb +66 -0
  500. data/config/environments/test.rb +54 -0
  501. data/config/initializers/action_mailer.rb +22 -0
  502. data/config/initializers/assets.rb +14 -0
  503. data/config/initializers/authlogic.rb +6 -0
  504. data/config/initializers/backtrace_silencers.rb +7 -0
  505. data/config/initializers/constants.rb +6 -0
  506. data/config/initializers/cookies_serializer.rb +3 -0
  507. data/config/initializers/custom_field_ransack_translations.rb +17 -0
  508. data/config/initializers/filter_parameter_logging.rb +4 -0
  509. data/config/initializers/gravatar.rb +12 -0
  510. data/config/initializers/inflections.rb +16 -0
  511. data/config/initializers/locale.rb +18 -0
  512. data/config/initializers/mime_types.rb +12 -0
  513. data/config/initializers/paginate_arrays.rb +11 -0
  514. data/config/initializers/ransack.rb +20 -0
  515. data/config/initializers/relative_url_root.rb +10 -0
  516. data/config/initializers/secret_token.rb +25 -0
  517. data/config/initializers/session_store.rb +5 -0
  518. data/config/initializers/simple_form.rb +100 -0
  519. data/config/initializers/views.rb +47 -0
  520. data/config/initializers/wrap_parameters.rb +14 -0
  521. data/config/locales/cz.yml +247 -0
  522. data/config/locales/cz_fat_free_crm.yml +610 -0
  523. data/config/locales/de.yml +237 -0
  524. data/config/locales/de_fat_free_crm.yml +842 -0
  525. data/config/locales/de_ransack.yml +91 -0
  526. data/config/locales/en-GB.yml +219 -0
  527. data/config/locales/en-GB_fat_free_crm.yml +937 -0
  528. data/config/locales/en-GB_ransack.yml +91 -0
  529. data/config/locales/en-US.yml +219 -0
  530. data/config/locales/en-US_fat_free_crm.yml +937 -0
  531. data/config/locales/en-US_ransack.yml +91 -0
  532. data/config/locales/en.yml +23 -0
  533. data/config/locales/es-CL.yml +227 -0
  534. data/config/locales/es-CL_fat_free_crm.yml +929 -0
  535. data/config/locales/es-CL_ransack.yml +91 -0
  536. data/config/locales/es.yml +219 -0
  537. data/config/locales/es_fat_free_crm.yml +917 -0
  538. data/config/locales/es_ransack.yml +91 -0
  539. data/config/locales/fr-CA.yml +224 -0
  540. data/config/locales/fr-CA_fat_free_crm.yml +570 -0
  541. data/config/locales/fr.yml +227 -0
  542. data/config/locales/fr_fat_free_crm.yml +934 -0
  543. data/config/locales/it.yml +219 -0
  544. data/config/locales/it_fat_free_crm.yml +592 -0
  545. data/config/locales/ja.yml +219 -0
  546. data/config/locales/ja_fat_free_crm.yml +557 -0
  547. data/config/locales/ja_ransack.yml +91 -0
  548. data/config/locales/nl.yml +210 -0
  549. data/config/locales/nl_fat_free_crm.yml +920 -0
  550. data/config/locales/nl_ransack.yml +91 -0
  551. data/config/locales/pl.yml +230 -0
  552. data/config/locales/pl_fat_free_crm.yml +570 -0
  553. data/config/locales/pt-BR.yml +232 -0
  554. data/config/locales/pt-BR_fat_free_crm.yml +650 -0
  555. data/config/locales/ru.yml +326 -0
  556. data/config/locales/ru_fat_free_crm.yml +977 -0
  557. data/config/locales/sv-SE.yml +215 -0
  558. data/config/locales/sv-SE_fat_free_crm.yml +565 -0
  559. data/config/locales/th.rb +204 -0
  560. data/config/locales/th_fat_free_crm.yml +558 -0
  561. data/config/locales/zh-CN.yml +241 -0
  562. data/config/locales/zh-CN_fat_free_crm.yml +937 -0
  563. data/config/locales/zh-CN_ransack.yml +91 -0
  564. data/config/routes.rb +199 -0
  565. data/config/settings.default.yml +400 -0
  566. data/config/unicorn.rb +32 -0
  567. data/custom_plan.rb +9 -0
  568. data/db/demo/account_contacts.yml +24 -0
  569. data/db/demo/account_opportunities.yml +24 -0
  570. data/db/demo/accounts.yml +47 -0
  571. data/db/demo/activities.yml +16 -0
  572. data/db/demo/addresses.yml +46 -0
  573. data/db/demo/avatars.yml +16 -0
  574. data/db/demo/campaigns.yml +144 -0
  575. data/db/demo/comments.yml +30 -0
  576. data/db/demo/contact_opportunities.yml +25 -0
  577. data/db/demo/contacts.yml +70 -0
  578. data/db/demo/emails.yml +53 -0
  579. data/db/demo/field_groups.yml +14 -0
  580. data/db/demo/leads.yml +71 -0
  581. data/db/demo/opportunities.yml +48 -0
  582. data/db/demo/permissions.yml +13 -0
  583. data/db/demo/preferences.yml +13 -0
  584. data/db/demo/settings.yml +12 -0
  585. data/db/demo/tasks.yml +64 -0
  586. data/db/demo/users.yml +245 -0
  587. data/db/migrate/20100928030598_create_sessions.rb +21 -0
  588. data/db/migrate/20100928030599_create_users.rb +45 -0
  589. data/db/migrate/20100928030600_create_openid_tables.rb +23 -0
  590. data/db/migrate/20100928030601_create_accounts.rb +26 -0
  591. data/db/migrate/20100928030602_create_permissions.rb +15 -0
  592. data/db/migrate/20100928030603_create_settings.rb +15 -0
  593. data/db/migrate/20100928030604_create_preferences.rb +15 -0
  594. data/db/migrate/20100928030605_create_campaigns.rb +34 -0
  595. data/db/migrate/20100928030606_create_leads.rb +38 -0
  596. data/db/migrate/20100928030607_create_contacts.rb +38 -0
  597. data/db/migrate/20100928030608_create_opportunities.rb +27 -0
  598. data/db/migrate/20100928030609_create_account_contacts.rb +14 -0
  599. data/db/migrate/20100928030610_create_account_opportunities.rb +14 -0
  600. data/db/migrate/20100928030611_create_contact_opportunities.rb +15 -0
  601. data/db/migrate/20100928030612_create_tasks.rb +26 -0
  602. data/db/migrate/20100928030613_create_comments.rb +16 -0
  603. data/db/migrate/20100928030614_create_activities.rb +19 -0
  604. data/db/migrate/20100928030615_create_avatars.rb +16 -0
  605. data/db/migrate/20100928030616_rename_remember_token.rb +11 -0
  606. data/db/migrate/20100928030617_drop_openid_tables.rb +23 -0
  607. data/db/migrate/20100928030618_add_admin_to_users.rb +11 -0
  608. data/db/migrate/20100928030619_add_suspended_to_users.rb +11 -0
  609. data/db/migrate/20100928030620_remove_uuid.rb +24 -0
  610. data/db/migrate/20100928030621_add_email_to_accounts.rb +9 -0
  611. data/db/migrate/20100928030622_add_background_info_to_models.rb +19 -0
  612. data/db/migrate/20100928030623_create_addresses.rb +49 -0
  613. data/db/migrate/20100928030624_add_index_on_permissions.rb +9 -0
  614. data/db/migrate/20100928030625_create_emails.rb +26 -0
  615. data/db/migrate/20100928030626_add_state_to_timeline_objects.rb +13 -0
  616. data/db/migrate/20100928030627_acts_as_taggable_on_migration.rb +29 -0
  617. data/db/migrate/20101221123456_add_single_access_token_to_users.rb +9 -0
  618. data/db/migrate/20101221345678_add_rating_and_category_to_accounts.rb +11 -0
  619. data/db/migrate/20110719082054_add_skype_to_contacts_and_leads.rb +11 -0
  620. data/db/migrate/20111101083437_create_fields.rb +27 -0
  621. data/db/migrate/20111101090312_create_field_groups.rb +15 -0
  622. data/db/migrate/20111116091952_add_field_groups_tag_id.rb +9 -0
  623. data/db/migrate/20111117041311_change_fields_collection_to_text.rb +9 -0
  624. data/db/migrate/20111201030535_add_field_groups_klass_name.rb +24 -0
  625. data/db/migrate/20120121054235_create_lists.rb +10 -0
  626. data/db/migrate/20120216031616_create_versions.rb +18 -0
  627. data/db/migrate/20120216042541_is_paranoid_to_paper_trail.rb +10 -0
  628. data/db/migrate/20120220233724_add_versions_object_changes.rb +9 -0
  629. data/db/migrate/20120224073107_remove_default_value_and_clear_settings.rb +16 -0
  630. data/db/migrate/20120309070209_add_versions_related.rb +6 -0
  631. data/db/migrate/20120314080441_add_subscribed_users_to_entities.rb +23 -0
  632. data/db/migrate/20120316045804_activities_to_versions.rb +35 -0
  633. data/db/migrate/20120405080727_change_subscribed_users_to_set.rb +24 -0
  634. data/db/migrate/20120405080742_change_further_subscribed_users_to_set.rb +27 -0
  635. data/db/migrate/20120406082136_create_groups.rb +19 -0
  636. data/db/migrate/20120413034923_add_index_on_versions_item_type.rb +5 -0
  637. data/db/migrate/20120510025219_add_not_null_constraints_for_timestamp_columns.rb +22 -0
  638. data/db/migrate/20120528102124_increase_length_of_version_events.rb +9 -0
  639. data/db/migrate/20120801032706_add_pair_id_to_fields.rb +5 -0
  640. data/db/migrate/20121003063155_add_settings_to_custom_fields.rb +5 -0
  641. data/db/migrate/20121221033947_fix_country_mapping.rb +31 -0
  642. data/db/migrate/20131207033244_add_user_id_to_lists.rb +6 -0
  643. data/db/migrate/20140916011927_add_created_at_index_on_versions.rb +5 -0
  644. data/db/migrate/20140916012922_add_indexes_to_model_associations.rb +6 -0
  645. data/db/migrate/20141126031837_increase_email_to254_chars.rb +21 -0
  646. data/db/migrate/20141230021159_add_transaction_id_column_to_versions.rb +11 -0
  647. data/db/migrate/20141230205453_add_missing_unique_indices.acts_as_taggable_on_engine.rb +20 -0
  648. data/db/migrate/20141230205454_add_taggings_counter_cache_to_tags.acts_as_taggable_on_engine.rb +15 -0
  649. data/db/migrate/20141230205455_add_missing_taggable_index.acts_as_taggable_on_engine.rb +10 -0
  650. data/db/migrate/20150123060900_convert_radio_to_radio_buttons.rb +10 -0
  651. data/db/migrate/20150227123054_remove_last_request_at_from_users.rb +5 -0
  652. data/db/migrate/20150427131956_create_index_related_type.rb +9 -0
  653. data/db/migrate/20160511053730_add_account_contacts_index.rb +5 -0
  654. data/db/schema.rb +459 -0
  655. data/db/seeds.rb +9 -0
  656. data/db/seeds/fields.rb +93 -0
  657. data/docker-compose.yml +13 -0
  658. data/fat_free_crm.gemspec +63 -0
  659. data/lib/development_tasks/gem.rake +13 -0
  660. data/lib/development_tasks/license.rake +77 -0
  661. data/lib/development_tasks/rdoc.rake +20 -0
  662. data/lib/development_tasks/rspec.rake +24 -0
  663. data/lib/fat_free_crm.rb +57 -0
  664. data/lib/fat_free_crm/callback.rb +144 -0
  665. data/lib/fat_free_crm/comment_extensions.rb +28 -0
  666. data/lib/fat_free_crm/core_ext.rb +6 -0
  667. data/lib/fat_free_crm/core_ext/nil.rb +14 -0
  668. data/lib/fat_free_crm/core_ext/string.rb +48 -0
  669. data/lib/fat_free_crm/custom_fields.rb +12 -0
  670. data/lib/fat_free_crm/engine.rb +27 -0
  671. data/lib/fat_free_crm/errors.rb +37 -0
  672. data/lib/fat_free_crm/exceptions.rb +21 -0
  673. data/lib/fat_free_crm/export_csv.rb +33 -0
  674. data/lib/fat_free_crm/exportable.rb +49 -0
  675. data/lib/fat_free_crm/fields.rb +95 -0
  676. data/lib/fat_free_crm/gem_dependencies.rb +40 -0
  677. data/lib/fat_free_crm/gem_ext.rb +10 -0
  678. data/lib/fat_free_crm/gem_ext/action_controller/base.rb +16 -0
  679. data/lib/fat_free_crm/gem_ext/active_record/schema_dumper.rb +27 -0
  680. data/lib/fat_free_crm/gem_ext/active_support/buffered_logger.rb +17 -0
  681. data/lib/fat_free_crm/gem_ext/rails/engine.rb +15 -0
  682. data/lib/fat_free_crm/gem_ext/rake/task.rb +13 -0
  683. data/lib/fat_free_crm/gem_ext/simple_form/action_view_extensions/form_helper.rb +24 -0
  684. data/lib/fat_free_crm/i18n.rb +42 -0
  685. data/lib/fat_free_crm/load_settings.rb +18 -0
  686. data/lib/fat_free_crm/mail_processor/base.rb +227 -0
  687. data/lib/fat_free_crm/mail_processor/comment_replies.rb +69 -0
  688. data/lib/fat_free_crm/mail_processor/dropbox.rb +273 -0
  689. data/lib/fat_free_crm/permissions.rb +109 -0
  690. data/lib/fat_free_crm/renderers.rb +11 -0
  691. data/lib/fat_free_crm/secret_token_generator.rb +59 -0
  692. data/lib/fat_free_crm/sortable.rb +43 -0
  693. data/lib/fat_free_crm/tabs.rb +23 -0
  694. data/lib/fat_free_crm/version.rb +15 -0
  695. data/lib/fat_free_crm/view_factory.rb +81 -0
  696. data/lib/gravatar_image_tag.rb +58 -0
  697. data/lib/missing_translation_detector.rb +50 -0
  698. data/lib/tasks/.gitkeep +0 -0
  699. data/lib/tasks/.gitkeep~master +0 -0
  700. data/lib/tasks/ffcrm/comment_replies.rake +27 -0
  701. data/lib/tasks/ffcrm/config.rake +40 -0
  702. data/lib/tasks/ffcrm/demo.rake +62 -0
  703. data/lib/tasks/ffcrm/dropbox.rake +28 -0
  704. data/lib/tasks/ffcrm/missing_translations.rake +34 -0
  705. data/lib/tasks/ffcrm/secret.rake +15 -0
  706. data/lib/tasks/ffcrm/settings.rake +20 -0
  707. data/lib/tasks/ffcrm/setup.rake +81 -0
  708. data/lib/tasks/ffcrm/update_data.rake +238 -0
  709. data/lib/templates/erb/scaffold/_form.html.erb +13 -0
  710. data/public/404.html +26 -0
  711. data/public/422.html +26 -0
  712. data/public/500.html +26 -0
  713. data/public/favicon.ico +0 -0
  714. data/public/robots.txt +5 -0
  715. data/script/rails +6 -0
  716. data/spec/controllers/admin/groups_controller_spec.rb +9 -0
  717. data/spec/controllers/admin/users_controller_spec.rb +305 -0
  718. data/spec/controllers/applications_controller_spec.rb +41 -0
  719. data/spec/controllers/authentications_controller_spec.rb +148 -0
  720. data/spec/controllers/comments_controller_spec.rb +193 -0
  721. data/spec/controllers/emails_controller_spec.rb +35 -0
  722. data/spec/controllers/entities/accounts_controller_spec.rb +605 -0
  723. data/spec/controllers/entities/campaigns_controller_spec.rb +643 -0
  724. data/spec/controllers/entities/contacts_controller_spec.rb +702 -0
  725. data/spec/controllers/entities/leads_controller_spec.rb +1007 -0
  726. data/spec/controllers/entities/opportunities_controller_spec.rb +902 -0
  727. data/spec/controllers/entities_controller_spec.rb +40 -0
  728. data/spec/controllers/home_controller_spec.rb +231 -0
  729. data/spec/controllers/lists_controller_spec.rb +9 -0
  730. data/spec/controllers/passwords_controller_spec.rb +30 -0
  731. data/spec/controllers/tasks_controller_spec.rb +512 -0
  732. data/spec/controllers/users_controller_spec.rb +431 -0
  733. data/spec/factories/account_factories.rb +38 -0
  734. data/spec/factories/campaign_factories.rb +28 -0
  735. data/spec/factories/contact_factories.rb +43 -0
  736. data/spec/factories/field_factories.rb +37 -0
  737. data/spec/factories/lead_factories.rb +34 -0
  738. data/spec/factories/list_factories.rb +11 -0
  739. data/spec/factories/opportunity_factories.rb +37 -0
  740. data/spec/factories/sequences.rb +31 -0
  741. data/spec/factories/setting_factories.rb +13 -0
  742. data/spec/factories/shared_factories.rb +66 -0
  743. data/spec/factories/subscription_factories.rb +11 -0
  744. data/spec/factories/tag_factories.rb +10 -0
  745. data/spec/factories/task_factories.rb +27 -0
  746. data/spec/factories/user_factories.rb +64 -0
  747. data/spec/features/acceptance_helper.rb +9 -0
  748. data/spec/features/accounts_spec.rb +109 -0
  749. data/spec/features/admin/groups_spec.rb +30 -0
  750. data/spec/features/admin/users_spec.rb +37 -0
  751. data/spec/features/campaigns_spec.rb +103 -0
  752. data/spec/features/contacts_spec.rb +129 -0
  753. data/spec/features/dashboard_spec.rb +66 -0
  754. data/spec/features/leads_spec.rb +129 -0
  755. data/spec/features/opportunities_overview_spec.rb +87 -0
  756. data/spec/features/opportunities_spec.rb +105 -0
  757. data/spec/features/support/browser.rb +18 -0
  758. data/spec/features/support/headless.rb +17 -0
  759. data/spec/features/support/helpers.rb +30 -0
  760. data/spec/features/support/maintain_sessions.rb +10 -0
  761. data/spec/features/support/paths.rb +46 -0
  762. data/spec/features/support/selector_helpers.rb +31 -0
  763. data/spec/features/tasks_spec.rb +93 -0
  764. data/spec/fixtures/rails.png +0 -0
  765. data/spec/helpers/accounts_helper_spec.rb +14 -0
  766. data/spec/helpers/admin/field_groups_helper_spec.rb +18 -0
  767. data/spec/helpers/admin/plugins_helper_spec.rb +9 -0
  768. data/spec/helpers/admin/settings_helper_spec.rb +9 -0
  769. data/spec/helpers/admin/users_helper_spec.rb +9 -0
  770. data/spec/helpers/application_helper_spec.rb +83 -0
  771. data/spec/helpers/authentications_helper_spec.rb +14 -0
  772. data/spec/helpers/campaigns_helper_spec.rb +14 -0
  773. data/spec/helpers/comments_helper_spec.rb +14 -0
  774. data/spec/helpers/contacts_helper_spec.rb +14 -0
  775. data/spec/helpers/emails_helper_spec.rb +9 -0
  776. data/spec/helpers/fields_helper_spec.rb +10 -0
  777. data/spec/helpers/groups_helper_spec.rb +19 -0
  778. data/spec/helpers/home_helper_spec.rb +14 -0
  779. data/spec/helpers/leads_helper_spec.rb +14 -0
  780. data/spec/helpers/lists_helper_spec.rb +19 -0
  781. data/spec/helpers/opportunities_helper_spec.rb +14 -0
  782. data/spec/helpers/passwords_helper_spec.rb +14 -0
  783. data/spec/helpers/tasks_helper_spec.rb +18 -0
  784. data/spec/helpers/users_helper_spec.rb +37 -0
  785. data/spec/lib/comment_extensions_spec.rb +34 -0
  786. data/spec/lib/core_ext/string_spec.rb +21 -0
  787. data/spec/lib/errors_spec.rb +30 -0
  788. data/spec/lib/fields_spec.rb +99 -0
  789. data/spec/lib/mail_processor/base_spec.rb +167 -0
  790. data/spec/lib/mail_processor/comment_replies_spec.rb +68 -0
  791. data/spec/lib/mail_processor/dropbox_spec.rb +304 -0
  792. data/spec/lib/mail_processor/sample_emails/dropbox.rb +171 -0
  793. data/spec/lib/permissions_spec.rb +134 -0
  794. data/spec/lib/secret_token_generator_spec.rb +67 -0
  795. data/spec/lib/view_factory_spec.rb +67 -0
  796. data/spec/mailers/subscription_mailer_spec.rb +47 -0
  797. data/spec/mailers/user_mailer_spec.rb +139 -0
  798. data/spec/models/entities/account_contact_spec.rb +31 -0
  799. data/spec/models/entities/account_opportunity_spec.rb +31 -0
  800. data/spec/models/entities/account_spec.rb +178 -0
  801. data/spec/models/entities/campaign_spec.rb +136 -0
  802. data/spec/models/entities/contact_opportunity_spec.rb +32 -0
  803. data/spec/models/entities/contact_spec.rb +208 -0
  804. data/spec/models/entities/lead_spec.rb +102 -0
  805. data/spec/models/entities/opportunity_spec.rb +287 -0
  806. data/spec/models/fields/custom_field_date_pair_spec.rb +88 -0
  807. data/spec/models/fields/custom_field_pair_spec.rb +74 -0
  808. data/spec/models/fields/custom_field_spec.rb +125 -0
  809. data/spec/models/fields/field_group_spec.rb +27 -0
  810. data/spec/models/fields/field_spec.rb +65 -0
  811. data/spec/models/list_spec.rb +17 -0
  812. data/spec/models/observers/entity_observer_spec.rb +72 -0
  813. data/spec/models/polymorphic/address_spec.rb +36 -0
  814. data/spec/models/polymorphic/avatar_spec.rb +44 -0
  815. data/spec/models/polymorphic/comment_spec.rb +47 -0
  816. data/spec/models/polymorphic/email_spec.rb +40 -0
  817. data/spec/models/polymorphic/task_spec.rb +385 -0
  818. data/spec/models/polymorphic/version_spec.rb +244 -0
  819. data/spec/models/setting_spec.rb +54 -0
  820. data/spec/models/users/abilities/user_ability_spec.rb +63 -0
  821. data/spec/models/users/authentication_spec.rb +17 -0
  822. data/spec/models/users/group_spec.rb +9 -0
  823. data/spec/models/users/permission_spec.rb +48 -0
  824. data/spec/models/users/preference_spec.rb +69 -0
  825. data/spec/models/users/user_spec.rb +237 -0
  826. data/spec/routing/accounts_routing_spec.rb +58 -0
  827. data/spec/routing/admin/users_routing_spec.rb +38 -0
  828. data/spec/routing/campaigns_routing_spec.rb +62 -0
  829. data/spec/routing/comments_routing_spec.rb +30 -0
  830. data/spec/routing/contacts_routing_spec.rb +58 -0
  831. data/spec/routing/emails_routing_spec.rb +38 -0
  832. data/spec/routing/leads_routing_spec.rb +86 -0
  833. data/spec/routing/opportunities_routing_spec.rb +62 -0
  834. data/spec/routing/tasks_routing_spec.rb +66 -0
  835. data/spec/routing/users_routing_spec.rb +82 -0
  836. data/spec/shared/controllers.rb +103 -0
  837. data/spec/shared/models.rb +139 -0
  838. data/spec/spec_helper.rb +107 -0
  839. data/spec/support/assert_select.rb +164 -0
  840. data/spec/support/auth_macros.rb +48 -0
  841. data/spec/support/macros.rb +44 -0
  842. data/spec/support/mail_processor_mocks.rb +35 -0
  843. data/spec/support/uploaded_file.rb +8 -0
  844. data/spec/views/accounts/_edit.haml_spec.rb +42 -0
  845. data/spec/views/accounts/_new.haml_spec.rb +40 -0
  846. data/spec/views/accounts/create.js.haml_spec.rb +51 -0
  847. data/spec/views/accounts/destroy.js.haml_spec.rb +32 -0
  848. data/spec/views/accounts/edit.js.haml_spec.rb +64 -0
  849. data/spec/views/accounts/index.haml_spec.rb +41 -0
  850. data/spec/views/accounts/index.js.haml_spec.rb +32 -0
  851. data/spec/views/accounts/new.js.haml_spec.rb +42 -0
  852. data/spec/views/accounts/show.haml_spec.rb +33 -0
  853. data/spec/views/accounts/update.js.haml_spec.rb +94 -0
  854. data/spec/views/admin/field_groups/create.js.haml_spec.rb +29 -0
  855. data/spec/views/admin/field_groups/destroy.js.haml_spec.rb +29 -0
  856. data/spec/views/admin/field_groups/edit.js.haml_spec.rb +22 -0
  857. data/spec/views/admin/field_groups/new.js.haml_spec.rb +23 -0
  858. data/spec/views/admin/field_groups/update.js.haml_spec.rb +28 -0
  859. data/spec/views/admin/users/_create.haml_spec.rb +21 -0
  860. data/spec/views/admin/users/create.js.haml_spec.rb +40 -0
  861. data/spec/views/admin/users/destroy.js.haml_spec.rb +51 -0
  862. data/spec/views/admin/users/edit.js.haml_spec.rb +42 -0
  863. data/spec/views/admin/users/index.haml_spec.rb +20 -0
  864. data/spec/views/admin/users/index.js.haml_spec.rb +24 -0
  865. data/spec/views/admin/users/new.js.haml_spec.rb +32 -0
  866. data/spec/views/admin/users/reactivate.js.haml_spec.rb +20 -0
  867. data/spec/views/admin/users/show.haml_spec.rb +16 -0
  868. data/spec/views/admin/users/suspend.js.haml_spec.rb +20 -0
  869. data/spec/views/admin/users/update.js.haml_spec.rb +36 -0
  870. data/spec/views/application/auto_complete.haml_spec.rb +46 -0
  871. data/spec/views/authentications/new.haml_spec.rb +29 -0
  872. data/spec/views/campaigns/_edit.haml_spec.rb +42 -0
  873. data/spec/views/campaigns/_new.haml_spec.rb +39 -0
  874. data/spec/views/campaigns/create.js.haml_spec.rb +48 -0
  875. data/spec/views/campaigns/destroy.js.haml_spec.rb +30 -0
  876. data/spec/views/campaigns/edit.js.haml_spec.rb +64 -0
  877. data/spec/views/campaigns/index.haml_spec.rb +35 -0
  878. data/spec/views/campaigns/index.js.haml_spec.rb +32 -0
  879. data/spec/views/campaigns/new.js.haml_spec.rb +48 -0
  880. data/spec/views/campaigns/show.haml_spec.rb +33 -0
  881. data/spec/views/campaigns/update.js.haml_spec.rb +80 -0
  882. data/spec/views/comments/edit.js.haml_spec.rb +29 -0
  883. data/spec/views/contacts/_edit.haml_spec.rb +71 -0
  884. data/spec/views/contacts/_new.haml_spec.rb +50 -0
  885. data/spec/views/contacts/create.js.haml_spec.rb +64 -0
  886. data/spec/views/contacts/destroy.js.haml_spec.rb +43 -0
  887. data/spec/views/contacts/edit.js.haml_spec.rb +72 -0
  888. data/spec/views/contacts/index.haml_spec.rb +35 -0
  889. data/spec/views/contacts/index.js.html_spec.rb +32 -0
  890. data/spec/views/contacts/new.js.haml_spec.rb +45 -0
  891. data/spec/views/contacts/show.haml_spec.rb +30 -0
  892. data/spec/views/contacts/update.js.haml_spec.rb +130 -0
  893. data/spec/views/home/index.haml_spec.rb +34 -0
  894. data/spec/views/home/index.js.haml_spec.rb +31 -0
  895. data/spec/views/home/options.js.haml_spec.rb +51 -0
  896. data/spec/views/leads/_convert.haml_spec.rb +28 -0
  897. data/spec/views/leads/_edit.haml_spec.rb +45 -0
  898. data/spec/views/leads/_new.haml_spec.rb +43 -0
  899. data/spec/views/leads/_sidebar_show.haml_spec.rb +29 -0
  900. data/spec/views/leads/convert.js.haml_spec.rb +77 -0
  901. data/spec/views/leads/create.js.haml_spec.rb +68 -0
  902. data/spec/views/leads/destroy.js.haml_spec.rb +47 -0
  903. data/spec/views/leads/edit.js.haml_spec.rb +74 -0
  904. data/spec/views/leads/index.haml_spec.rb +35 -0
  905. data/spec/views/leads/index.js.haml_spec.rb +32 -0
  906. data/spec/views/leads/new.js.haml_spec.rb +45 -0
  907. data/spec/views/leads/promote.js.haml_spec.rb +141 -0
  908. data/spec/views/leads/reject.js.haml_spec.rb +46 -0
  909. data/spec/views/leads/show.haml_spec.rb +27 -0
  910. data/spec/views/leads/update.js.haml_spec.rb +124 -0
  911. data/spec/views/opportunities/_edit.haml_spec.rb +68 -0
  912. data/spec/views/opportunities/_new.haml_spec.rb +49 -0
  913. data/spec/views/opportunities/create.js.haml_spec.rb +86 -0
  914. data/spec/views/opportunities/destroy.js.haml_spec.rb +65 -0
  915. data/spec/views/opportunities/edit.js.haml_spec.rb +73 -0
  916. data/spec/views/opportunities/index.haml_spec.rb +36 -0
  917. data/spec/views/opportunities/index.js.haml_spec.rb +33 -0
  918. data/spec/views/opportunities/new.js.haml_spec.rb +52 -0
  919. data/spec/views/opportunities/show.haml_spec.rb +30 -0
  920. data/spec/views/opportunities/update.js.haml_spec.rb +149 -0
  921. data/spec/views/tasks/_edit.haml_spec.rb +48 -0
  922. data/spec/views/tasks/complete.js.haml_spec.rb +66 -0
  923. data/spec/views/tasks/create.js.haml_spec.rb +119 -0
  924. data/spec/views/tasks/destroy.js.haml_spec.rb +56 -0
  925. data/spec/views/tasks/edit.js.haml_spec.rb +74 -0
  926. data/spec/views/tasks/index.haml_spec.rb +44 -0
  927. data/spec/views/tasks/new.js.haml_spec.rb +47 -0
  928. data/spec/views/tasks/uncomplete.js.haml_spec.rb +44 -0
  929. data/spec/views/tasks/update.js.haml_spec.rb +141 -0
  930. data/spec/views/users/avatar.js.haml_spec.rb +33 -0
  931. data/spec/views/users/change_password.js.haml_spec.rb +50 -0
  932. data/spec/views/users/edit.js.haml_spec.rb +33 -0
  933. data/spec/views/users/password.js.haml_spec.rb +34 -0
  934. data/spec/views/users/update.js.haml_spec.rb +45 -0
  935. data/spec/views/users/upload_avatar.js.haml_spec.rb +44 -0
  936. data/vendor/assets/images/calendar_date_select/calendar.gif +0 -0
  937. data/vendor/assets/images/chosen-sprite.png +0 -0
  938. data/vendor/assets/images/jquery-ui/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  939. data/vendor/assets/images/jquery-ui/ui-bg_flat_0_eeeeee_40x100.png +0 -0
  940. data/vendor/assets/images/jquery-ui/ui-bg_flat_100_ffffff_40x100.png +0 -0
  941. data/vendor/assets/images/jquery-ui/ui-bg_flat_25_3875d7_40x100.png +0 -0
  942. data/vendor/assets/images/jquery-ui/ui-bg_flat_55_ffffff_40x100.png +0 -0
  943. data/vendor/assets/images/jquery-ui/ui-bg_flat_65_3875d7_40x100.png +0 -0
  944. data/vendor/assets/images/jquery-ui/ui-bg_flat_75_ffffff_40x100.png +0 -0
  945. data/vendor/assets/images/jquery-ui/ui-bg_highlight-soft_50_dddddd_1x100.png +0 -0
  946. data/vendor/assets/images/jquery-ui/ui-icons_0073ea_256x240.png +0 -0
  947. data/vendor/assets/images/jquery-ui/ui-icons_466bb1_256x240.png +0 -0
  948. data/vendor/assets/images/jquery-ui/ui-icons_ff0084_256x240.png +0 -0
  949. data/vendor/assets/images/jquery-ui/ui-icons_ffffff_256x240.png +0 -0
  950. data/vendor/assets/javascripts/ajax-chosen-jquery.js +2 -0
  951. data/vendor/assets/javascripts/ajax-chosen.jquery.coffee +171 -0
  952. data/vendor/assets/javascripts/chosen-jquery.js +3 -0
  953. data/vendor/assets/javascripts/chosen.jquery.coffee +574 -0
  954. data/vendor/assets/javascripts/jquery.disable.js +23 -0
  955. data/vendor/assets/javascripts/jquery_timeago/index.js +19 -0
  956. data/vendor/assets/javascripts/jquery_timeago/jquery.timeago.cz.js +18 -0
  957. data/vendor/assets/javascripts/jquery_timeago/jquery.timeago.de.js +18 -0
  958. data/vendor/assets/javascripts/jquery_timeago/jquery.timeago.en-GB.js +20 -0
  959. data/vendor/assets/javascripts/jquery_timeago/jquery.timeago.en-US.js +20 -0
  960. data/vendor/assets/javascripts/jquery_timeago/jquery.timeago.es-CL.js +18 -0
  961. data/vendor/assets/javascripts/jquery_timeago/jquery.timeago.es.js +18 -0
  962. data/vendor/assets/javascripts/jquery_timeago/jquery.timeago.fr-CA.js +17 -0
  963. data/vendor/assets/javascripts/jquery_timeago/jquery.timeago.fr.js +17 -0
  964. data/vendor/assets/javascripts/jquery_timeago/jquery.timeago.it.js +16 -0
  965. data/vendor/assets/javascripts/jquery_timeago/jquery.timeago.ja.js +19 -0
  966. data/vendor/assets/javascripts/jquery_timeago/jquery.timeago.js +194 -0
  967. data/vendor/assets/javascripts/jquery_timeago/jquery.timeago.nl.js +20 -0
  968. data/vendor/assets/javascripts/jquery_timeago/jquery.timeago.pl.js +31 -0
  969. data/vendor/assets/javascripts/jquery_timeago/jquery.timeago.pt-BR.js +18 -0
  970. data/vendor/assets/javascripts/jquery_timeago/jquery.timeago.ru.js +34 -0
  971. data/vendor/assets/javascripts/jquery_timeago/jquery.timeago.sv-SE.js +18 -0
  972. data/vendor/assets/javascripts/jquery_timeago/jquery.timeago.th.js +20 -0
  973. data/vendor/assets/javascripts/jquery_timeago/jquery.timeago.zh-CN.js +20 -0
  974. data/vendor/assets/javascripts/jquery_ui_datepicker/jquery-ui-timepicker-addon.js +1882 -0
  975. data/vendor/assets/javascripts/jquery_ui_datepicker/jquery-ui-timepicker-af.js +20 -0
  976. data/vendor/assets/javascripts/jquery_ui_datepicker/jquery-ui-timepicker-ca.js +20 -0
  977. data/vendor/assets/javascripts/jquery_ui_datepicker/jquery-ui-timepicker-cz.js +20 -0
  978. data/vendor/assets/javascripts/jquery_ui_datepicker/jquery-ui-timepicker-de.js +20 -0
  979. data/vendor/assets/javascripts/jquery_ui_datepicker/jquery-ui-timepicker-el.js +20 -0
  980. data/vendor/assets/javascripts/jquery_ui_datepicker/jquery-ui-timepicker-es-CL.js +20 -0
  981. data/vendor/assets/javascripts/jquery_ui_datepicker/jquery-ui-timepicker-es.js +20 -0
  982. data/vendor/assets/javascripts/jquery_ui_datepicker/jquery-ui-timepicker-et.js +20 -0
  983. data/vendor/assets/javascripts/jquery_ui_datepicker/jquery-ui-timepicker-fi.js +20 -0
  984. data/vendor/assets/javascripts/jquery_ui_datepicker/jquery-ui-timepicker-fr-CA.js +20 -0
  985. data/vendor/assets/javascripts/jquery_ui_datepicker/jquery-ui-timepicker-fr.js +20 -0
  986. data/vendor/assets/javascripts/jquery_ui_datepicker/jquery-ui-timepicker-gl.js +20 -0
  987. data/vendor/assets/javascripts/jquery_ui_datepicker/jquery-ui-timepicker-he.js +20 -0
  988. data/vendor/assets/javascripts/jquery_ui_datepicker/jquery-ui-timepicker-hu.js +20 -0
  989. data/vendor/assets/javascripts/jquery_ui_datepicker/jquery-ui-timepicker-id.js +20 -0
  990. data/vendor/assets/javascripts/jquery_ui_datepicker/jquery-ui-timepicker-it.js +20 -0
  991. data/vendor/assets/javascripts/jquery_ui_datepicker/jquery-ui-timepicker-ja.js +20 -0
  992. data/vendor/assets/javascripts/jquery_ui_datepicker/jquery-ui-timepicker-ko.js +20 -0
  993. data/vendor/assets/javascripts/jquery_ui_datepicker/jquery-ui-timepicker-lt.js +20 -0
  994. data/vendor/assets/javascripts/jquery_ui_datepicker/jquery-ui-timepicker-nl.js +20 -0
  995. data/vendor/assets/javascripts/jquery_ui_datepicker/jquery-ui-timepicker-no.js +20 -0
  996. data/vendor/assets/javascripts/jquery_ui_datepicker/jquery-ui-timepicker-pl.js +20 -0
  997. data/vendor/assets/javascripts/jquery_ui_datepicker/jquery-ui-timepicker-pt-BR.js +22 -0
  998. data/vendor/assets/javascripts/jquery_ui_datepicker/jquery-ui-timepicker-pt.js +20 -0
  999. data/vendor/assets/javascripts/jquery_ui_datepicker/jquery-ui-timepicker-ro.js +20 -0
  1000. data/vendor/assets/javascripts/jquery_ui_datepicker/jquery-ui-timepicker-ru.js +20 -0
  1001. data/vendor/assets/javascripts/jquery_ui_datepicker/jquery-ui-timepicker-sk.js +20 -0
  1002. data/vendor/assets/javascripts/jquery_ui_datepicker/jquery-ui-timepicker-sv-SE.js +20 -0
  1003. data/vendor/assets/javascripts/jquery_ui_datepicker/jquery-ui-timepicker-th.js +19 -0
  1004. data/vendor/assets/javascripts/jquery_ui_datepicker/jquery-ui-timepicker-tr.js +20 -0
  1005. data/vendor/assets/javascripts/jquery_ui_datepicker/jquery-ui-timepicker-vi.js +20 -0
  1006. data/vendor/assets/javascripts/jquery_ui_datepicker/jquery-ui-timepicker-zh-CN.js +20 -0
  1007. data/vendor/assets/javascripts/jquery_ui_datepicker/jquery-ui-timepicker-zh-TW.js +20 -0
  1008. data/vendor/assets/javascripts/jquery_ui_datepicker/jquery.ui.datepicker-cz.js +23 -0
  1009. data/vendor/assets/javascripts/jquery_ui_datepicker/jquery.ui.datepicker-de.js +23 -0
  1010. data/vendor/assets/javascripts/jquery_ui_datepicker/jquery.ui.datepicker-en-GB.js +23 -0
  1011. data/vendor/assets/javascripts/jquery_ui_datepicker/jquery.ui.datepicker-es-CL.js +23 -0
  1012. data/vendor/assets/javascripts/jquery_ui_datepicker/jquery.ui.datepicker-es.js +23 -0
  1013. data/vendor/assets/javascripts/jquery_ui_datepicker/jquery.ui.datepicker-fr-CA.js +21 -0
  1014. data/vendor/assets/javascripts/jquery_ui_datepicker/jquery.ui.datepicker-fr.js +23 -0
  1015. data/vendor/assets/javascripts/jquery_ui_datepicker/jquery.ui.datepicker-it.js +23 -0
  1016. data/vendor/assets/javascripts/jquery_ui_datepicker/jquery.ui.datepicker-ja.js +23 -0
  1017. data/vendor/assets/javascripts/jquery_ui_datepicker/jquery.ui.datepicker-nl.js +21 -0
  1018. data/vendor/assets/javascripts/jquery_ui_datepicker/jquery.ui.datepicker-pl.js +23 -0
  1019. data/vendor/assets/javascripts/jquery_ui_datepicker/jquery.ui.datepicker-pt-BR.js +23 -0
  1020. data/vendor/assets/javascripts/jquery_ui_datepicker/jquery.ui.datepicker-pt.js +21 -0
  1021. data/vendor/assets/javascripts/jquery_ui_datepicker/jquery.ui.datepicker-ru.js +23 -0
  1022. data/vendor/assets/javascripts/jquery_ui_datepicker/jquery.ui.datepicker-sv-SE.js +23 -0
  1023. data/vendor/assets/javascripts/jquery_ui_datepicker/jquery.ui.datepicker-th.js +23 -0
  1024. data/vendor/assets/javascripts/jquery_ui_datepicker/jquery.ui.datepicker-zh-CN.js +23 -0
  1025. data/vendor/assets/javascripts/lib/abstract-chosen.coffee +110 -0
  1026. data/vendor/assets/javascripts/lib/select-parser.coffee +51 -0
  1027. data/vendor/assets/javascripts/rating.js +162 -0
  1028. data/vendor/assets/javascripts/textarea_autocomplete.js +605 -0
  1029. data/vendor/assets/stylesheets/chosen.css.sass +361 -0
  1030. data/vendor/assets/stylesheets/jquery-ui.custom.scss +566 -0
  1031. data/vendor/assets/stylesheets/modalbox.css +107 -0
  1032. data/vendor/gems/globby-0.1.2/LICENSE.txt +20 -0
  1033. data/vendor/gems/globby-0.1.2/README.md +65 -0
  1034. data/vendor/gems/globby-0.1.2/Rakefile +9 -0
  1035. data/vendor/gems/globby-0.1.2/lib/globby.rb +47 -0
  1036. data/vendor/gems/globby-0.1.2/lib/globby/glob.rb +90 -0
  1037. data/vendor/gems/globby-0.1.2/lib/globby/globject.rb +18 -0
  1038. data/vendor/gems/globby-0.1.2/lib/globby/result.rb +20 -0
  1039. data/vendor/gems/globby-0.1.2/spec/gitignore_spec.rb +109 -0
  1040. data/vendor/gems/globby-0.1.2/spec/globby_spec.rb +93 -0
  1041. data/zeus.json +22 -0
  1042. metadata +1566 -0
@@ -0,0 +1,902 @@
1
+ # Copyright (c) 2008-2013 Michael Dvorkin and contributors.
2
+ #
3
+ # Fat Free CRM is freely distributable under the terms of MIT license.
4
+ # See MIT-LICENSE file or http://www.opensource.org/licenses/mit-license.php
5
+ #------------------------------------------------------------------------------
6
+ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
7
+
8
+ describe OpportunitiesController do
9
+ def get_data_for_sidebar
10
+ @stage = Setting.unroll(:opportunity_stage)
11
+ end
12
+
13
+ before do
14
+ require_user
15
+ set_current_tab(:opportunities)
16
+ end
17
+
18
+ # GET /opportunities
19
+ # GET /opportunities.xml
20
+ #----------------------------------------------------------------------------
21
+ describe "responding to GET index" do
22
+ before do
23
+ get_data_for_sidebar
24
+ end
25
+
26
+ it "should expose all opportunities as @opportunities and render [index] template" do
27
+ @opportunities = [FactoryGirl.create(:opportunity, user: current_user)]
28
+
29
+ get :index
30
+ expect(assigns[:opportunities]).to eq(@opportunities)
31
+ expect(response).to render_template("opportunities/index")
32
+ end
33
+
34
+ it "should expose the data for the opportunities sidebar" do
35
+ get :index
36
+ expect(assigns[:stage]).to eq(@stage)
37
+ expect(assigns[:opportunity_stage_total].keys.map(&:to_sym) - (@stage.map(&:last) << :all << :other)).to eq([])
38
+ end
39
+
40
+ it "should filter out opportunities by stage" do
41
+ controller.session[:opportunities_filter] = "prospecting,negotiation"
42
+ @opportunities = [
43
+ FactoryGirl.create(:opportunity, user: current_user, stage: "negotiation"),
44
+ FactoryGirl.create(:opportunity, user: current_user, stage: "prospecting")
45
+ ]
46
+ # This one should be filtered out.
47
+ FactoryGirl.create(:opportunity, user: current_user, stage: "analysis")
48
+
49
+ get :index
50
+ # Note: can't compare opportunities directly because of BigDecimal objects.
51
+ expect(assigns[:opportunities].size).to eq(2)
52
+ expect(assigns[:opportunities].map(&:stage).sort).to eq(%w(negotiation prospecting))
53
+ end
54
+
55
+ it "should perform lookup using query string" do
56
+ @first = FactoryGirl.create(:opportunity, user: current_user, name: "The first one")
57
+ @second = FactoryGirl.create(:opportunity, user: current_user, name: "The second one")
58
+
59
+ get :index, query: "second"
60
+ expect(assigns[:opportunities]).to eq([@second])
61
+ expect(assigns[:current_query]).to eq("second")
62
+ expect(session[:opportunities_current_query]).to eq("second")
63
+ end
64
+
65
+ describe "AJAX pagination" do
66
+ it "should pick up page number from params" do
67
+ @opportunities = [FactoryGirl.create(:opportunity, user: current_user)]
68
+ xhr :get, :index, page: 42
69
+
70
+ expect(assigns[:current_page].to_i).to eq(42)
71
+ expect(assigns[:opportunities]).to eq([]) # page #42 should be empty if there's only one opportunity ;-)
72
+ expect(session[:opportunities_current_page].to_i).to eq(42)
73
+ expect(response).to render_template("opportunities/index")
74
+ end
75
+
76
+ it "should pick up saved page number from session" do
77
+ session[:opportunities_current_page] = 42
78
+ @opportunities = [FactoryGirl.create(:opportunity, user: current_user)]
79
+ xhr :get, :index
80
+
81
+ expect(assigns[:current_page]).to eq(42)
82
+ expect(assigns[:opportunities]).to eq([])
83
+ expect(response).to render_template("opportunities/index")
84
+ end
85
+
86
+ it "should reset current_page when query is altered" do
87
+ session[:opportunities_current_page] = 42
88
+ session[:opportunities_current_query] = "bill"
89
+ @opportunities = [FactoryGirl.create(:opportunity, user: current_user)]
90
+ xhr :get, :index
91
+
92
+ expect(assigns[:current_page]).to eq(1)
93
+ expect(assigns[:opportunities]).to eq(@opportunities)
94
+ expect(response).to render_template("opportunities/index")
95
+ end
96
+ end
97
+
98
+ describe "with mime type of JSON" do
99
+ it "should render all opportunities as JSON" do
100
+ expect(@controller).to receive(:get_opportunities).and_return(opportunities = double("Array of Opportunities"))
101
+ expect(opportunities).to receive(:to_json).and_return("generated JSON")
102
+
103
+ request.env["HTTP_ACCEPT"] = "application/json"
104
+ get :index
105
+ expect(response.body).to eq("generated JSON")
106
+ end
107
+ end
108
+
109
+ describe "with mime type of JSON" do
110
+ it "should render all opportunities as JSON" do
111
+ expect(@controller).to receive(:get_opportunities).and_return(opportunities = double("Array of Opportunities"))
112
+ expect(opportunities).to receive(:to_json).and_return("generated JSON")
113
+
114
+ request.env["HTTP_ACCEPT"] = "application/json"
115
+ get :index
116
+ expect(response.body).to eq("generated JSON")
117
+ end
118
+ end
119
+
120
+ describe "with mime type of XML" do
121
+ it "should render all opportunities as xml" do
122
+ expect(@controller).to receive(:get_opportunities).and_return(opportunities = double("Array of Opportunities"))
123
+ expect(opportunities).to receive(:to_xml).and_return("generated XML")
124
+
125
+ request.env["HTTP_ACCEPT"] = "application/xml"
126
+ get :index
127
+ expect(response.body).to eq("generated XML")
128
+ end
129
+ end
130
+ end
131
+
132
+ # GET /opportunities/1
133
+ # GET /opportunities/1.xml HTML
134
+ #----------------------------------------------------------------------------
135
+ describe "responding to GET show" do
136
+ describe "with mime type of HTML" do
137
+ before do
138
+ @opportunity = FactoryGirl.create(:opportunity, id: 42)
139
+ @stage = Setting.unroll(:opportunity_stage)
140
+ @comment = Comment.new
141
+ end
142
+
143
+ it "should expose the requested opportunity as @opportunity and render [show] template" do
144
+ get :show, id: 42
145
+ expect(assigns[:opportunity]).to eq(@opportunity)
146
+ expect(assigns[:stage]).to eq(@stage)
147
+ expect(assigns[:comment].attributes).to eq(@comment.attributes)
148
+ expect(response).to render_template("opportunities/show")
149
+ end
150
+
151
+ it "should update an activity when viewing the opportunity" do
152
+ get :show, id: @opportunity.id
153
+ expect(@opportunity.versions.last.event).to eq('view')
154
+ end
155
+ end
156
+
157
+ describe "with mime type of JSON" do
158
+ it "should render the requested opportunity as JSON" do
159
+ @opportunity = FactoryGirl.create(:opportunity, id: 42)
160
+ expect(Opportunity).to receive(:find).and_return(@opportunity)
161
+ expect(@opportunity).to receive(:to_json).and_return("generated JSON")
162
+
163
+ request.env["HTTP_ACCEPT"] = "application/json"
164
+ get :show, id: 42
165
+ expect(response.body).to eq("generated JSON")
166
+ end
167
+ end
168
+
169
+ describe "with mime type of XML" do
170
+ it "should render the requested opportunity as xml" do
171
+ @opportunity = FactoryGirl.create(:opportunity, id: 42)
172
+ expect(Opportunity).to receive(:find).and_return(@opportunity)
173
+ expect(@opportunity).to receive(:to_xml).and_return("generated XML")
174
+
175
+ request.env["HTTP_ACCEPT"] = "application/xml"
176
+ get :show, id: 42
177
+ expect(response.body).to eq("generated XML")
178
+ end
179
+ end
180
+
181
+ describe "opportunity got deleted or otherwise unavailable" do
182
+ it "should redirect to opportunity index if the opportunity got deleted" do
183
+ @opportunity = FactoryGirl.create(:opportunity, user: current_user)
184
+ @opportunity.destroy
185
+
186
+ get :show, id: @opportunity.id
187
+ expect(flash[:warning]).not_to eq(nil)
188
+ expect(response).to redirect_to(opportunities_path)
189
+ end
190
+
191
+ it "should redirect to opportunity index if the opportunity is protected" do
192
+ @private = FactoryGirl.create(:opportunity, user: FactoryGirl.create(:user), access: "Private")
193
+
194
+ get :show, id: @private.id
195
+ expect(flash[:warning]).not_to eq(nil)
196
+ expect(response).to redirect_to(opportunities_path)
197
+ end
198
+
199
+ it "should return 404 (Not Found) JSON error" do
200
+ @opportunity = FactoryGirl.create(:opportunity, user: current_user)
201
+ @opportunity.destroy
202
+ request.env["HTTP_ACCEPT"] = "application/json"
203
+
204
+ get :show, id: @opportunity.id
205
+ expect(response.code).to eq("404") # :not_found
206
+ end
207
+
208
+ it "should return 404 (Not Found) XML error" do
209
+ @opportunity = FactoryGirl.create(:opportunity, user: current_user)
210
+ @opportunity.destroy
211
+ request.env["HTTP_ACCEPT"] = "application/xml"
212
+
213
+ get :show, id: @opportunity.id
214
+ expect(response.code).to eq("404") # :not_found
215
+ end
216
+ end
217
+ end
218
+
219
+ # GET /opportunities/new
220
+ # GET /opportunities/new.xml AJAX
221
+ #----------------------------------------------------------------------------
222
+ describe "responding to GET new" do
223
+ it "should expose a new opportunity as @opportunity and render [new] template" do
224
+ @opportunity = Opportunity.new(user: current_user, access: Setting.default_access, stage: "prospecting")
225
+ @account = Account.new(user: current_user, access: Setting.default_access)
226
+ @accounts = [FactoryGirl.create(:account, user: current_user)]
227
+
228
+ xhr :get, :new
229
+ expect(assigns[:opportunity].attributes).to eq(@opportunity.attributes)
230
+ expect(assigns[:account].attributes).to eq(@account.attributes)
231
+ expect(assigns[:accounts]).to eq(@accounts)
232
+ expect(response).to render_template("opportunities/new")
233
+ end
234
+
235
+ it "should created an instance of related object when necessary" do
236
+ @contact = FactoryGirl.create(:contact, id: 42)
237
+
238
+ xhr :get, :new, related: "contact_42"
239
+ expect(assigns[:contact]).to eq(@contact)
240
+ end
241
+
242
+ describe "(when creating related opportunity)" do
243
+ it "should redirect to parent asset's index page with the message if parent asset got deleted" do
244
+ @account = FactoryGirl.create(:account)
245
+ @account.destroy
246
+
247
+ xhr :get, :new, related: "account_#{@account.id}"
248
+ expect(flash[:warning]).not_to eq(nil)
249
+ expect(response.body).to eq('window.location.href = "/accounts";')
250
+ end
251
+
252
+ it "should redirect to parent asset's index page with the message if parent asset got protected" do
253
+ @account = FactoryGirl.create(:account, access: "Private")
254
+
255
+ xhr :get, :new, related: "account_#{@account.id}"
256
+ expect(flash[:warning]).not_to eq(nil)
257
+ expect(response.body).to eq('window.location.href = "/accounts";')
258
+ end
259
+ end
260
+ end
261
+
262
+ # GET /opportunities/1/edit AJAX
263
+ #----------------------------------------------------------------------------
264
+ describe "responding to GET edit" do
265
+ it "should expose the requested opportunity as @opportunity and render [edit] template" do
266
+ # Note: campaign => nil makes sure campaign factory is not invoked which has a side
267
+ # effect of creating an extra (campaign) user.
268
+ @account = FactoryGirl.create(:account, user: current_user)
269
+ @opportunity = FactoryGirl.create(:opportunity, id: 42, user: current_user, campaign: nil,
270
+ account: @account)
271
+ @stage = Setting.unroll(:opportunity_stage)
272
+ @accounts = [@account]
273
+
274
+ xhr :get, :edit, id: 42
275
+ @opportunity.reload
276
+ expect(assigns[:opportunity]).to eq(@opportunity)
277
+ expect(assigns[:account].attributes).to eq(@opportunity.account.attributes)
278
+ expect(assigns[:accounts]).to eq(@accounts)
279
+ expect(assigns[:stage]).to eq(@stage)
280
+ expect(assigns[:previous]).to eq(nil)
281
+ expect(response).to render_template("opportunities/edit")
282
+ end
283
+
284
+ it "should expose previous opportunity as @previous when necessary" do
285
+ @opportunity = FactoryGirl.create(:opportunity, id: 42)
286
+ @previous = FactoryGirl.create(:opportunity, id: 41)
287
+
288
+ xhr :get, :edit, id: 42, previous: 41
289
+ expect(assigns[:previous]).to eq(@previous)
290
+ end
291
+
292
+ describe "opportunity got deleted or is otherwise unavailable" do
293
+ it "should reload current page with the flash message if the opportunity got deleted" do
294
+ @opportunity = FactoryGirl.create(:opportunity, user: current_user)
295
+ @opportunity.destroy
296
+
297
+ xhr :get, :edit, id: @opportunity.id
298
+ expect(flash[:warning]).not_to eq(nil)
299
+ expect(response.body).to eq("window.location.reload();")
300
+ end
301
+
302
+ it "should reload current page with the flash message if the opportunity is protected" do
303
+ @private = FactoryGirl.create(:opportunity, user: FactoryGirl.create(:user), access: "Private")
304
+
305
+ xhr :get, :edit, id: @private.id
306
+ expect(flash[:warning]).not_to eq(nil)
307
+ expect(response.body).to eq("window.location.reload();")
308
+ end
309
+ end
310
+
311
+ describe "(previous opportunity got deleted or is otherwise unavailable)" do
312
+ before do
313
+ @opportunity = FactoryGirl.create(:opportunity, user: current_user)
314
+ @previous = FactoryGirl.create(:opportunity, user: FactoryGirl.create(:user))
315
+ end
316
+
317
+ it "should notify the view if previous opportunity got deleted" do
318
+ @previous.destroy
319
+
320
+ xhr :get, :edit, id: @opportunity.id, previous: @previous.id
321
+ expect(flash[:warning]).to eq(nil) # no warning, just silently remove the div
322
+ expect(assigns[:previous]).to eq(@previous.id)
323
+ expect(response).to render_template("opportunities/edit")
324
+ end
325
+
326
+ it "should notify the view if previous opportunity got protected" do
327
+ @previous.update_attribute(:access, "Private")
328
+
329
+ xhr :get, :edit, id: @opportunity.id, previous: @previous.id
330
+ expect(flash[:warning]).to eq(nil)
331
+ expect(assigns[:previous]).to eq(@previous.id)
332
+ expect(response).to render_template("opportunities/edit")
333
+ end
334
+ end
335
+ end
336
+
337
+ # POST /opportunities
338
+ # POST /opportunities.xml AJAX
339
+ #----------------------------------------------------------------------------
340
+ describe "responding to POST create" do
341
+ describe "with valid params" do
342
+ before do
343
+ @opportunity = FactoryGirl.build(:opportunity, user: current_user)
344
+ allow(Opportunity).to receive(:new).and_return(@opportunity)
345
+ @stage = Setting.unroll(:opportunity_stage)
346
+ end
347
+
348
+ it "should expose a newly created opportunity as @opportunity and render [create] template" do
349
+ xhr :post, :create, opportunity: { name: "Hello" }, account: { name: "Hello again" }
350
+ expect(assigns(:opportunity)).to eq(@opportunity)
351
+ expect(assigns(:stage)).to eq(@stage)
352
+ expect(assigns(:opportunity_stage_total)).to be_nil
353
+ expect(response).to render_template("opportunities/create")
354
+ end
355
+
356
+ it "should get sidebar data if called from opportunities index" do
357
+ request.env["HTTP_REFERER"] = "http://localhost/opportunities"
358
+ xhr :post, :create, opportunity: { name: "Hello" }, account: { name: "Hello again" }
359
+ expect(assigns(:opportunity_stage_total)).to be_an_instance_of(HashWithIndifferentAccess)
360
+ end
361
+
362
+ it "should find related account if called from account landing page" do
363
+ @account = FactoryGirl.create(:account, user: current_user)
364
+ request.env["HTTP_REFERER"] = "http://localhost/accounts/#{@account.id}"
365
+
366
+ xhr :post, :create, opportunity: { name: "Hello" }, account: { id: @account.id }
367
+ expect(assigns(:account)).to eq(@account)
368
+ end
369
+
370
+ it "should find related campaign if called from campaign landing page" do
371
+ @campaign = FactoryGirl.create(:campaign, user: current_user)
372
+ request.env["HTTP_REFERER"] = "http://localhost/campaigns/#{@campaign.id}"
373
+
374
+ xhr :post, :create, opportunity: { name: "Hello" }, campaign: @campaign.id, account: { name: "Hello again" }
375
+ expect(assigns(:campaign)).to eq(@campaign)
376
+ end
377
+
378
+ it "should reload opportunities to update pagination if called from opportunities index" do
379
+ request.env["HTTP_REFERER"] = "http://localhost/opportunities"
380
+ xhr :post, :create, opportunity: { name: "Hello" }, account: { name: "Hello again" }
381
+ expect(assigns[:opportunities]).to eq([@opportunity])
382
+ end
383
+
384
+ it "should associate opportunity with the campaign when called from campaign landing page" do
385
+ @campaign = FactoryGirl.create(:campaign)
386
+
387
+ request.env["HTTP_REFERER"] = "http://localhost/campaigns/#{@campaign.id}"
388
+ xhr :post, :create, opportunity: { name: "Hello" }, campaign: @campaign.id, account: { name: "Test Account" }
389
+ expect(assigns(:opportunity)).to eq(@opportunity)
390
+ expect(assigns(:campaign)).to eq(@campaign)
391
+ expect(@opportunity.campaign).to eq(@campaign)
392
+ end
393
+
394
+ it "should associate opportunity with the contact when called from contact landing page" do
395
+ @contact = FactoryGirl.create(:contact, id: 42)
396
+
397
+ request.env["HTTP_REFERER"] = "http://localhost/contacts/42"
398
+ xhr :post, :create, opportunity: { name: "Hello" }, contact: 42, account: { name: "Hello again" }
399
+ expect(assigns(:opportunity)).to eq(@opportunity)
400
+ expect(@opportunity.contacts).to include(@contact)
401
+ expect(@contact.opportunities).to include(@opportunity)
402
+ end
403
+
404
+ it "should create new account and associate it with the opportunity" do
405
+ xhr :put, :create, opportunity: { name: "Hello" }, account: { name: "new account" }
406
+ expect(assigns(:opportunity)).to eq(@opportunity)
407
+ expect(@opportunity.account.name).to eq("new account")
408
+ end
409
+
410
+ it "should associate opportunity with the existing account" do
411
+ @account = FactoryGirl.create(:account, id: 42)
412
+
413
+ xhr :post, :create, opportunity: { name: "Hello world" }, account: { id: 42 }
414
+ expect(assigns(:opportunity)).to eq(@opportunity)
415
+ expect(@opportunity.account).to eq(@account)
416
+ expect(@account.opportunities).to include(@opportunity)
417
+ end
418
+
419
+ it "should update related campaign revenue if won" do
420
+ @campaign = FactoryGirl.create(:campaign, revenue: 0)
421
+ @opportunity = FactoryGirl.build(:opportunity, user: current_user, stage: "won", amount: 1100, discount: 100)
422
+ allow(Opportunity).to receive(:new).and_return(@opportunity)
423
+
424
+ xhr :post, :create, opportunity: { name: "Hello world" }, campaign: @campaign.id, account: { name: "Test Account" }
425
+ expect(assigns(:opportunity)).to eq(@opportunity)
426
+ expect(@opportunity.campaign).to eq(@campaign.reload)
427
+ expect(@campaign.revenue.to_i).to eq(1000) # 1000 - 100 discount.
428
+ end
429
+
430
+ it "should add a new comment to the newly created opportunity when specified" do
431
+ @opportunity = FactoryGirl.build(:opportunity, user: current_user)
432
+ allow(Opportunity).to receive(:new).and_return(@opportunity)
433
+
434
+ xhr :post, :create, opportunity: { name: "Opportunity Knocks" }, account: { name: "My Account" }, comment_body: "Awesome comment is awesome"
435
+ expect(@opportunity.reload.comments.map(&:comment)).to include("Awesome comment is awesome")
436
+ end
437
+ end
438
+
439
+ describe "with invalid params" do
440
+ it "should expose a newly created but unsaved opportunity as @opportunity with blank @account and render [create] template" do
441
+ @account = Account.new(user: current_user)
442
+ @opportunity = FactoryGirl.build(:opportunity, name: nil, campaign: nil, user: current_user,
443
+ account: @account)
444
+ allow(Opportunity).to receive(:new).and_return(@opportunity)
445
+ @stage = Setting.unroll(:opportunity_stage)
446
+ @accounts = [FactoryGirl.create(:account, user: current_user)]
447
+
448
+ # Expect to redraw [create] form with blank account.
449
+ xhr :post, :create, opportunity: {}, account: { user_id: current_user.id }
450
+ expect(assigns(:opportunity)).to eq(@opportunity)
451
+ expect(assigns(:account).attributes).to eq(@account.attributes)
452
+ expect(assigns(:accounts)).to eq(@accounts)
453
+ expect(response).to render_template("opportunities/create")
454
+ end
455
+
456
+ it "should expose a newly created but unsaved opportunity as @opportunity with existing @account and render [create] template" do
457
+ @account = FactoryGirl.create(:account, id: 42, user: current_user)
458
+ @opportunity = FactoryGirl.build(:opportunity, name: nil, campaign: nil, user: current_user,
459
+ account: @account)
460
+ allow(Opportunity).to receive(:new).and_return(@opportunity)
461
+ @stage = Setting.unroll(:opportunity_stage)
462
+
463
+ # Expect to redraw [create] form with selected account.
464
+ xhr :post, :create, opportunity: {}, account: { id: 42, user_id: current_user.id }
465
+ expect(assigns(:opportunity)).to eq(@opportunity)
466
+ expect(assigns(:account)).to eq(@account)
467
+ expect(assigns(:accounts)).to eq([@account])
468
+ expect(response).to render_template("opportunities/create")
469
+ end
470
+
471
+ it "should preserve the campaign when called from campaign landing page" do
472
+ @campaign = FactoryGirl.create(:campaign, id: 42)
473
+
474
+ request.env["HTTP_REFERER"] = "http://localhost/campaigns/42"
475
+ xhr :post, :create, opportunity: { name: nil }, campaign: 42, account: { name: "Test Account" }
476
+ expect(assigns(:campaign)).to eq(@campaign)
477
+ expect(response).to render_template("opportunities/create")
478
+ end
479
+
480
+ it "should preserve the contact when called from contact landing page" do
481
+ @contact = FactoryGirl.create(:contact, id: 42)
482
+
483
+ request.env["HTTP_REFERER"] = "http://localhost/contacts/42"
484
+ xhr :post, :create, opportunity: { name: nil }, contact: 42, account: { name: "Test Account" }
485
+ expect(assigns(:contact)).to eq(@contact)
486
+ expect(response).to render_template("opportunities/create")
487
+ end
488
+ end
489
+ end
490
+
491
+ # PUT /opportunities/1
492
+ # PUT /opportunities/1.xml AJAX
493
+ #----------------------------------------------------------------------------
494
+ describe "responding to PUT update" do
495
+ describe "with valid params" do
496
+ it "should update the requested opportunity, expose it as @opportunity, and render [update] template" do
497
+ @opportunity = FactoryGirl.create(:opportunity, id: 42)
498
+ @stage = Setting.unroll(:opportunity_stage)
499
+
500
+ xhr :put, :update, id: 42, opportunity: { name: "Hello world" }, account: { name: "Test Account" }
501
+ expect(@opportunity.reload.name).to eq("Hello world")
502
+ expect(assigns(:opportunity)).to eq(@opportunity)
503
+ expect(assigns(:stage)).to eq(@stage)
504
+ expect(assigns(:opportunity_stage_total)).to eq(nil)
505
+ expect(response).to render_template("opportunities/update")
506
+ end
507
+
508
+ it "should get sidebar data if called from opportunities index" do
509
+ @opportunity = FactoryGirl.create(:opportunity, id: 42)
510
+
511
+ request.env["HTTP_REFERER"] = "http://localhost/opportunities"
512
+ xhr :put, :update, id: 42, opportunity: { name: "Hello world" }, account: { name: "Test Account" }
513
+ expect(assigns(:opportunity_stage_total)).to be_an_instance_of(HashWithIndifferentAccess)
514
+ end
515
+
516
+ it "should find related account if called from account landing page" do
517
+ @account = FactoryGirl.create(:account, user: current_user)
518
+ @opportunity = FactoryGirl.create(:opportunity, id: 42, account: @account)
519
+ request.env["HTTP_REFERER"] = "http://localhost/accounts/#{@account.id}"
520
+
521
+ xhr :put, :update, id: 42, opportunity: { name: "Hello world" }
522
+ expect(assigns(:account)).to eq(@account)
523
+ end
524
+
525
+ it "should remove related account if blank :account param is given" do
526
+ @account = FactoryGirl.create(:account, user: current_user)
527
+ @opportunity = FactoryGirl.create(:opportunity, id: 42, account: @account)
528
+ request.env["HTTP_REFERER"] = "http://localhost/accounts/#{@account.id}"
529
+
530
+ xhr :put, :update, id: 42, opportunity: { name: "Hello world" }, account: { id: "" }
531
+ expect(assigns(:account)).to eq(nil)
532
+ end
533
+
534
+ it "should find related campaign if called from campaign landing page" do
535
+ @campaign = FactoryGirl.create(:campaign, user: current_user)
536
+ @opportunity = FactoryGirl.create(:opportunity, id: 42, user: current_user)
537
+ @campaign.opportunities << @opportunity
538
+ request.env["HTTP_REFERER"] = "http://localhost/campaigns/#{@campaign.id}"
539
+
540
+ xhr :put, :update, id: 42, opportunity: { name: "Hello world", campaign_id: @campaign.id }, account: {}
541
+ expect(assigns(:campaign)).to eq(@campaign)
542
+ end
543
+
544
+ it "should be able to create an account and associate it with updated opportunity" do
545
+ @opportunity = FactoryGirl.create(:opportunity, id: 42)
546
+
547
+ xhr :put, :update, id: 42, opportunity: { name: "Hello" }, account: { name: "new account" }
548
+ expect(assigns[:opportunity]).to eq(@opportunity)
549
+ expect(assigns[:opportunity].account).not_to be_nil
550
+ expect(assigns[:opportunity].account.name).to eq("new account")
551
+ end
552
+
553
+ it "should be able to create an account and associate it with updated opportunity" do
554
+ @old_account = FactoryGirl.create(:account, id: 111)
555
+ @new_account = FactoryGirl.create(:account, id: 999)
556
+ @opportunity = FactoryGirl.create(:opportunity, id: 42, account: @old_account)
557
+
558
+ xhr :put, :update, id: 42, opportunity: { name: "Hello" }, account: { id: 999 }
559
+ expect(assigns[:opportunity]).to eq(@opportunity)
560
+ expect(assigns[:opportunity].account).to eq(@new_account)
561
+ end
562
+
563
+ it "should update opportunity permissions when sharing with specific users" do
564
+ @opportunity = FactoryGirl.create(:opportunity, id: 42, access: "Public")
565
+
566
+ xhr :put, :update, id: 42, opportunity: { name: "Hello", access: "Shared", user_ids: [7, 8] }, account: { name: "Test Account" }
567
+ expect(assigns[:opportunity].access).to eq("Shared")
568
+ expect(assigns[:opportunity].user_ids.sort).to eq([7, 8])
569
+ end
570
+
571
+ it "should reload opportunity campaign if called from campaign landing page" do
572
+ @campaign = FactoryGirl.create(:campaign)
573
+ @opportunity = FactoryGirl.create(:opportunity, campaign: @campaign)
574
+
575
+ request.env["HTTP_REFERER"] = "http://localhost/campaigns/#{@campaign.id}"
576
+ xhr :put, :update, id: @opportunity.id, opportunity: { name: "Hello" }, account: { name: "Test Account" }
577
+ expect(assigns[:campaign]).to eq(@campaign)
578
+ end
579
+
580
+ describe "updating campaign revenue (same campaign)" do
581
+ it "should add to actual revenue when opportunity is closed/won" do
582
+ @campaign = FactoryGirl.create(:campaign, revenue: 1000)
583
+ @opportunity = FactoryGirl.create(:opportunity, campaign: @campaign, stage: 'prospecting', amount: 1100, discount: 100)
584
+
585
+ xhr :put, :update, id: @opportunity, opportunity: { stage: "won" }, account: { name: "Test Account" }
586
+ expect(@campaign.reload.revenue.to_i).to eq(2000) # 1000 -> 2000
587
+ end
588
+
589
+ it "should substract from actual revenue when opportunity is no longer closed/won" do
590
+ @campaign = FactoryGirl.create(:campaign, revenue: 1000)
591
+ @opportunity = FactoryGirl.create(:opportunity, campaign: @campaign, stage: "won", amount: 1100, discount: 100)
592
+ # @campaign.revenue is now $2000 since we created winning opportunity.
593
+
594
+ xhr :put, :update, id: @opportunity, opportunity: { stage: 'prospecting' }, account: { name: "Test Account" }
595
+ expect(@campaign.reload.revenue.to_i).to eq(1000) # Should be adjusted back to $1000.
596
+ end
597
+
598
+ it "should not update actual revenue when opportunity is not closed/won" do
599
+ @campaign = FactoryGirl.create(:campaign, revenue: 1000)
600
+ @opportunity = FactoryGirl.create(:opportunity, campaign: @campaign, stage: 'prospecting', amount: 1100, discount: 100)
601
+
602
+ xhr :put, :update, id: @opportunity, opportunity: { stage: "lost" }, account: { name: "Test Account" }
603
+ expect(@campaign.reload.revenue.to_i).to eq(1000) # Stays the same.
604
+ end
605
+ end
606
+
607
+ describe "updating campaign revenue (diferent campaigns)" do
608
+ it "should update newly assigned campaign when opportunity is closed/won" do
609
+ @campaigns = { old: FactoryGirl.create(:campaign, revenue: 1000), new: FactoryGirl.create(:campaign, revenue: 1000) }
610
+ @opportunity = FactoryGirl.create(:opportunity, campaign: @campaigns[:old], stage: 'prospecting', amount: 1100, discount: 100)
611
+
612
+ xhr :put, :update, id: @opportunity, opportunity: { stage: "won", campaign_id: @campaigns[:new].id }, account: { name: "Test Account" }
613
+
614
+ expect(@campaigns[:old].reload.revenue.to_i).to eq(1000) # Stays the same.
615
+ expect(@campaigns[:new].reload.revenue.to_i).to eq(2000) # 1000 -> 2000
616
+ end
617
+
618
+ it "should update old campaign when opportunity is no longer closed/won" do
619
+ @campaigns = { old: FactoryGirl.create(:campaign, revenue: 1000), new: FactoryGirl.create(:campaign, revenue: 1000) }
620
+ @opportunity = FactoryGirl.create(:opportunity, campaign: @campaigns[:old], stage: "won", amount: 1100, discount: 100)
621
+ # @campaign.revenue is now $2000 since we created winning opportunity.
622
+
623
+ xhr :put, :update, id: @opportunity, opportunity: { stage: 'prospecting', campaign_id: @campaigns[:new].id }, account: { name: "Test Account" }
624
+ expect(@campaigns[:old].reload.revenue.to_i).to eq(1000) # Should be adjusted back to $1000.
625
+ expect(@campaigns[:new].reload.revenue.to_i).to eq(1000) # Stays the same.
626
+ end
627
+
628
+ it "should not update campaigns when opportunity is not closed/won" do
629
+ @campaigns = { old: FactoryGirl.create(:campaign, revenue: 1000), new: FactoryGirl.create(:campaign, revenue: 1000) }
630
+ @opportunity = FactoryGirl.create(:opportunity, campaign: @campaigns[:old], stage: 'prospecting', amount: 1100, discount: 100)
631
+
632
+ xhr :put, :update, id: @opportunity, opportunity: { stage: "lost", campaign_id: @campaigns[:new].id }, account: { name: "Test Account" }
633
+ expect(@campaigns[:old].reload.revenue.to_i).to eq(1000) # Stays the same.
634
+ expect(@campaigns[:new].reload.revenue.to_i).to eq(1000) # Stays the same.
635
+ end
636
+ end
637
+
638
+ describe "opportunity got deleted or otherwise unavailable" do
639
+ it "should reload current page with the flash message if the opportunity got deleted" do
640
+ @opportunity = FactoryGirl.create(:opportunity, user: current_user)
641
+ @opportunity.destroy
642
+
643
+ xhr :put, :update, id: @opportunity.id
644
+ expect(flash[:warning]).not_to eq(nil)
645
+ expect(response.body).to eq("window.location.reload();")
646
+ end
647
+
648
+ it "should reload current page with the flash message if the opportunity is protected" do
649
+ @private = FactoryGirl.create(:opportunity, user: FactoryGirl.create(:user), access: "Private")
650
+
651
+ xhr :put, :update, id: @private.id
652
+ expect(flash[:warning]).not_to eq(nil)
653
+ expect(response.body).to eq("window.location.reload();")
654
+ end
655
+ end
656
+ end
657
+
658
+ describe "with invalid params" do
659
+ it "should not update the requested opportunity but still expose it as @opportunity, and render [update] template" do
660
+ @opportunity = FactoryGirl.create(:opportunity, id: 42, name: "Hello people")
661
+
662
+ xhr :put, :update, id: 42, opportunity: { name: nil }, account: { name: "Test Account" }
663
+ expect(@opportunity.reload.name).to eq("Hello people")
664
+ expect(assigns(:opportunity)).to eq(@opportunity)
665
+ expect(assigns(:opportunity_stage_total)).to eq(nil)
666
+ expect(response).to render_template("opportunities/update")
667
+ end
668
+
669
+ it "should expose existing account as @account if selected" do
670
+ @account = FactoryGirl.create(:account, id: 99)
671
+ @opportunity = FactoryGirl.create(:opportunity, id: 42)
672
+ FactoryGirl.create(:account_opportunity, account: @account, opportunity: @opportunity)
673
+
674
+ xhr :put, :update, id: 42, opportunity: { name: nil }, account: { id: 99 }
675
+ expect(assigns(:account)).to eq(@account)
676
+ end
677
+ end
678
+ end
679
+
680
+ # DELETE /opportunities/1
681
+ # DELETE /opportunities/1.xml AJAX
682
+ #----------------------------------------------------------------------------
683
+ describe "responding to DELETE destroy" do
684
+ before do
685
+ @opportunity = FactoryGirl.create(:opportunity, user: current_user)
686
+ end
687
+
688
+ describe "AJAX request" do
689
+ it "should destroy the requested opportunity and render [destroy] template" do
690
+ xhr :delete, :destroy, id: @opportunity.id
691
+
692
+ expect { Opportunity.find(@opportunity.id) }.to raise_error(ActiveRecord::RecordNotFound)
693
+ expect(assigns(:opportunity_stage_total)).to eq(nil)
694
+ expect(response).to render_template("opportunities/destroy")
695
+ end
696
+
697
+ describe "when called from Opportunities index page" do
698
+ before do
699
+ request.env["HTTP_REFERER"] = "http://localhost/opportunities"
700
+ end
701
+
702
+ it "should get sidebar data if called from opportunities index" do
703
+ xhr :delete, :destroy, id: @opportunity.id
704
+ expect(assigns(:opportunity_stage_total)).to be_an_instance_of(HashWithIndifferentAccess)
705
+ end
706
+
707
+ it "should try previous page and render index action if current page has no opportunities" do
708
+ session[:opportunities_current_page] = 42
709
+
710
+ xhr :delete, :destroy, id: @opportunity.id
711
+ expect(session[:opportunities_current_page]).to eq(41)
712
+ expect(response).to render_template("opportunities/index")
713
+ end
714
+
715
+ it "should render index action when deleting last opportunity" do
716
+ session[:opportunities_current_page] = 1
717
+
718
+ xhr :delete, :destroy, id: @opportunity.id
719
+ expect(session[:opportunities_current_page]).to eq(1)
720
+ expect(response).to render_template("opportunities/index")
721
+ end
722
+ end
723
+
724
+ describe "when called from related asset page" do
725
+ it "should reset current page to 1" do
726
+ request.env["HTTP_REFERER"] = "http://localhost/accounts/123"
727
+
728
+ xhr :delete, :destroy, id: @opportunity.id
729
+ expect(session[:opportunities_current_page]).to eq(1)
730
+ expect(response).to render_template("opportunities/destroy")
731
+ end
732
+
733
+ it "should reload campaiign to be able to refresh its summary" do
734
+ @account = FactoryGirl.create(:account)
735
+ @opportunity = FactoryGirl.create(:opportunity, user: current_user, account: @account)
736
+ request.env["HTTP_REFERER"] = "http://localhost/accounts/#{@account.id}"
737
+
738
+ xhr :delete, :destroy, id: @opportunity.id
739
+ expect(assigns[:account]).to eq(@account)
740
+ expect(response).to render_template("opportunities/destroy")
741
+ end
742
+
743
+ it "should reload campaiign to be able to refresh its summary" do
744
+ @campaign = FactoryGirl.create(:campaign)
745
+ @opportunity = FactoryGirl.create(:opportunity, user: current_user, campaign: @campaign)
746
+ request.env["HTTP_REFERER"] = "http://localhost/campaigns/#{@campaign.id}"
747
+
748
+ xhr :delete, :destroy, id: @opportunity.id
749
+ expect(assigns[:campaign]).to eq(@campaign)
750
+ expect(response).to render_template("opportunities/destroy")
751
+ end
752
+ end
753
+
754
+ describe "opportunity got deleted or otherwise unavailable" do
755
+ it "should reload current page is the opportunity got deleted" do
756
+ @opportunity = FactoryGirl.create(:opportunity, user: current_user)
757
+ @opportunity.destroy
758
+
759
+ xhr :delete, :destroy, id: @opportunity.id
760
+ expect(flash[:warning]).not_to eq(nil)
761
+ expect(response.body).to eq("window.location.reload();")
762
+ end
763
+
764
+ it "should reload current page with the flash message if the opportunity is protected" do
765
+ @private = FactoryGirl.create(:opportunity, user: FactoryGirl.create(:user), access: "Private")
766
+
767
+ xhr :delete, :destroy, id: @private.id
768
+ expect(flash[:warning]).not_to eq(nil)
769
+ expect(response.body).to eq("window.location.reload();")
770
+ end
771
+ end
772
+ end
773
+
774
+ describe "HTML request" do
775
+ it "should redirect to Opportunities index when an opportunity gets deleted from its landing page" do
776
+ delete :destroy, id: @opportunity.id
777
+ expect(flash[:notice]).not_to eq(nil)
778
+ expect(response).to redirect_to(opportunities_path)
779
+ end
780
+
781
+ it "should redirect to opportunity index with the flash message is the opportunity got deleted" do
782
+ @opportunity = FactoryGirl.create(:opportunity, user: current_user)
783
+ @opportunity.destroy
784
+
785
+ delete :destroy, id: @opportunity.id
786
+ expect(flash[:warning]).not_to eq(nil)
787
+ expect(response).to redirect_to(opportunities_path)
788
+ end
789
+
790
+ it "should redirect to opportunity index with the flash message if the opportunity is protected" do
791
+ @private = FactoryGirl.create(:opportunity, user: FactoryGirl.create(:user), access: "Private")
792
+
793
+ delete :destroy, id: @private.id
794
+ expect(flash[:warning]).not_to eq(nil)
795
+ expect(response).to redirect_to(opportunities_path)
796
+ end
797
+ end
798
+ end
799
+
800
+ # PUT /opportunities/1/attach
801
+ # PUT /opportunities/1/attach.xml AJAX
802
+ #----------------------------------------------------------------------------
803
+ describe "responding to PUT attach" do
804
+ describe "tasks" do
805
+ before do
806
+ @model = FactoryGirl.create(:opportunity)
807
+ @attachment = FactoryGirl.create(:task, asset: nil)
808
+ end
809
+ it_should_behave_like("attach")
810
+ end
811
+
812
+ describe "contacts" do
813
+ before do
814
+ @model = FactoryGirl.create(:opportunity)
815
+ @attachment = FactoryGirl.create(:contact)
816
+ end
817
+ it_should_behave_like("attach")
818
+ end
819
+ end
820
+
821
+ # POST /opportunities/1/discard
822
+ # POST /opportunities/1/discard.xml AJAX
823
+ #----------------------------------------------------------------------------
824
+ describe "responding to POST discard" do
825
+ describe "tasks" do
826
+ before do
827
+ @model = FactoryGirl.create(:opportunity)
828
+ @attachment = FactoryGirl.create(:task, asset: @model)
829
+ end
830
+ it_should_behave_like("discard")
831
+ end
832
+
833
+ describe "contacts" do
834
+ before do
835
+ @attachment = FactoryGirl.create(:contact)
836
+ @model = FactoryGirl.create(:opportunity)
837
+ @model.contacts << @attachment
838
+ end
839
+ it_should_behave_like("discard")
840
+ end
841
+ end
842
+
843
+ # POST /opportunities/auto_complete/query AJAX
844
+ #----------------------------------------------------------------------------
845
+ describe "responding to POST auto_complete" do
846
+ before do
847
+ @auto_complete_matches = [FactoryGirl.create(:opportunity, name: "Hello World", user: current_user)]
848
+ end
849
+
850
+ it_should_behave_like("auto complete")
851
+ end
852
+
853
+ # GET /opportunities/redraw AJAX
854
+ #----------------------------------------------------------------------------
855
+ describe "responding to GET redraw" do
856
+ it "should save user selected opportunity preference" do
857
+ xhr :get, :redraw, per_page: 42, view: "brief", sort_by: "name"
858
+ expect(current_user.preference[:opportunities_per_page]).to eq("42")
859
+ expect(current_user.preference[:opportunities_index_view]).to eq("brief")
860
+ expect(current_user.preference[:opportunities_sort_by]).to eq("opportunities.name ASC")
861
+ end
862
+
863
+ it "should reset current page to 1" do
864
+ xhr :get, :redraw, per_page: 42, view: "brief", sort_by: "name"
865
+ expect(session[:opportunities_current_page]).to eq(1)
866
+ end
867
+
868
+ it "should select @opportunities and render [index] template" do
869
+ @opportunities = [
870
+ FactoryGirl.create(:opportunity, name: "A", user: current_user),
871
+ FactoryGirl.create(:opportunity, name: "B", user: current_user)
872
+ ]
873
+
874
+ xhr :get, :redraw, per_page: 1, sort_by: "name"
875
+ expect(assigns(:opportunities)).to eq([@opportunities.first])
876
+ expect(response).to render_template("opportunities/index")
877
+ end
878
+ end
879
+
880
+ # POST /opportunities/filter AJAX
881
+ #----------------------------------------------------------------------------
882
+ describe "responding to GET filter" do
883
+ it "should expose filtered opportunities as @opportunity and render [filter] template" do
884
+ session[:opportunities_filter] = "negotiation,analysis"
885
+ @opportunities = [FactoryGirl.create(:opportunity, stage: "prospecting", user: current_user)]
886
+ @stage = Setting.unroll(:opportunity_stage)
887
+
888
+ xhr :get, :filter, stage: "prospecting"
889
+ expect(assigns(:opportunities)).to eq(@opportunities)
890
+ expect(assigns[:stage]).to eq(@stage)
891
+ expect(response).to be_a_success
892
+ expect(response).to render_template("opportunities/index")
893
+ end
894
+
895
+ it "should reset current page to 1" do
896
+ @opportunities = []
897
+ xhr :get, :filter, status: "new"
898
+
899
+ expect(session[:opportunities_current_page]).to eq(1)
900
+ end
901
+ end
902
+ end