fat_free_crm 0.11.3 → 0.11.4

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

Potentially problematic release.


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

Files changed (637) hide show
  1. data/.gitignore +1 -0
  2. data/.travis.yml +2 -2
  3. data/CHANGELOG +6 -1
  4. data/CONTRIBUTORS +40 -1
  5. data/Capfile +5 -0
  6. data/Gemfile +25 -6
  7. data/Gemfile.lock +128 -86
  8. data/README.md +23 -16
  9. data/{vendor → app}/assets/images/delete.png +0 -0
  10. data/app/assets/javascripts/admin/fields.js.coffee +62 -0
  11. data/app/assets/javascripts/application.js.erb +8 -1
  12. data/app/assets/javascripts/crm.js +44 -46
  13. data/app/assets/javascripts/crm_chosen.js.coffee +10 -7
  14. data/app/assets/javascripts/datepicker.js.coffee +15 -0
  15. data/app/assets/javascripts/format_buttons.js.coffee +48 -0
  16. data/app/assets/javascripts/{admin/field_groups.js.coffee → groups.js.coffee} +0 -0
  17. data/app/assets/javascripts/lists.js.coffee +1 -1
  18. data/app/assets/javascripts/search.js.coffee +56 -38
  19. data/app/assets/stylesheets/admin/{field_groups.css.scss → fields.css.scss} +4 -0
  20. data/app/assets/stylesheets/advanced_search.css.scss +79 -0
  21. data/app/assets/stylesheets/application.css.erb +4 -0
  22. data/app/assets/stylesheets/base.scss +3 -3
  23. data/app/assets/stylesheets/common.scss +72 -25
  24. data/app/assets/stylesheets/fields.scss +14 -0
  25. data/app/assets/stylesheets/format_buttons.css.scss +30 -0
  26. data/app/assets/stylesheets/groups.css.scss +3 -0
  27. data/app/assets/stylesheets/header.scss +7 -6
  28. data/{vendor/plugins/.gitkeep → app/assets/stylesheets/index_headers.css.scss} +0 -0
  29. data/app/assets/stylesheets/print.css.scss +12 -3
  30. data/app/assets/stylesheets/rails.scss +12 -3
  31. data/app/controllers/admin/application_controller.rb +1 -1
  32. data/app/controllers/admin/field_groups_controller.rb +2 -0
  33. data/app/controllers/admin/fields_controller.rb +41 -17
  34. data/app/controllers/admin/groups_controller.rb +70 -0
  35. data/app/controllers/admin/tags_controller.rb +1 -0
  36. data/app/controllers/admin/users_controller.rb +8 -7
  37. data/app/controllers/application_controller.rb +34 -5
  38. data/app/controllers/comments_controller.rb +2 -3
  39. data/app/controllers/entities/accounts_controller.rb +30 -37
  40. data/app/controllers/entities/campaigns_controller.rb +56 -29
  41. data/app/controllers/entities/contacts_controller.rb +24 -26
  42. data/app/controllers/entities/leads_controller.rb +38 -37
  43. data/app/controllers/entities/opportunities_controller.rb +28 -34
  44. data/app/controllers/entities_controller.rb +71 -43
  45. data/app/controllers/home_controller.rb +29 -27
  46. data/app/controllers/tasks_controller.rb +18 -17
  47. data/app/controllers/users_controller.rb +12 -8
  48. data/app/helpers/accounts_helper.rb +58 -16
  49. data/app/helpers/addresses_helper.rb +4 -1
  50. data/app/helpers/admin/fields_helper.rb +3 -4
  51. data/app/helpers/application_helper.rb +147 -100
  52. data/app/helpers/campaigns_helper.rb +2 -9
  53. data/app/helpers/fields_helper.rb +0 -1
  54. data/app/helpers/groups_helper.rb +2 -0
  55. data/app/helpers/home_helper.rb +11 -0
  56. data/app/helpers/leads_helper.rb +2 -9
  57. data/app/helpers/opportunities_helper.rb +2 -9
  58. data/app/helpers/{crm_tags_helper.rb → tags_helper.rb} +9 -8
  59. data/app/helpers/tasks_helper.rb +5 -21
  60. data/app/helpers/users_helper.rb +14 -7
  61. data/app/helpers/versions_helper.rb +46 -0
  62. data/app/inputs/date_time_input.rb +8 -25
  63. data/app/inputs/datepair_input.rb +77 -0
  64. data/app/inputs/datetimepair_input.rb +37 -0
  65. data/app/mailers/user_mailer.rb +10 -0
  66. data/app/models/entities/account.rb +18 -11
  67. data/app/models/entities/account_contact.rb +4 -3
  68. data/app/models/entities/account_opportunity.rb +0 -1
  69. data/app/models/entities/campaign.rb +6 -7
  70. data/app/models/entities/contact.rb +53 -25
  71. data/app/models/entities/contact_opportunity.rb +0 -1
  72. data/app/models/entities/lead.rb +24 -13
  73. data/app/models/entities/opportunity.rb +34 -16
  74. data/app/models/fields/custom_field.rb +29 -13
  75. data/app/models/fields/custom_field_date_pair.rb +58 -0
  76. data/app/models/fields/custom_field_datetime_pair.rb +28 -0
  77. data/app/models/fields/custom_field_pair.rb +54 -0
  78. data/app/models/fields/field.rb +60 -43
  79. data/app/models/fields/field_group.rb +0 -9
  80. data/app/models/observers/entity_observer.rb +29 -0
  81. data/app/models/observers/opportunity_observer.rb +3 -0
  82. data/app/models/polymorphic/address.rb +14 -0
  83. data/app/models/polymorphic/avatar.rb +13 -1
  84. data/app/models/polymorphic/email.rb +1 -1
  85. data/app/models/polymorphic/task.rb +14 -13
  86. data/app/models/setting.rb +14 -21
  87. data/app/models/users/ability.rb +25 -4
  88. data/app/models/users/group.rb +13 -0
  89. data/app/models/users/permission.rb +3 -1
  90. data/app/models/users/preference.rb +1 -2
  91. data/app/models/users/user.rb +25 -3
  92. data/app/views/accounts/_account.html.haml +5 -39
  93. data/app/views/accounts/_edit.html.haml +3 -2
  94. data/app/views/accounts/_index_brief.html.haml +32 -0
  95. data/app/views/accounts/_index_long.html.haml +42 -0
  96. data/app/views/accounts/_new.html.haml +3 -2
  97. data/app/views/accounts/_sidebar_index.html.haml +3 -4
  98. data/app/views/accounts/_sidebar_show.html.haml +2 -2
  99. data/app/views/accounts/_title_bar.html.haml +11 -0
  100. data/app/views/accounts/_top_section.html.haml +1 -1
  101. data/app/views/accounts/create.js.rjs +1 -2
  102. data/app/views/accounts/destroy.js.rjs +1 -1
  103. data/app/views/accounts/edit.js.rjs +0 -2
  104. data/app/views/accounts/index.html.haml +6 -13
  105. data/app/views/accounts/index.js.rjs +3 -1
  106. data/app/views/accounts/index.xls.builder +82 -0
  107. data/app/views/accounts/new.js.rjs +0 -2
  108. data/app/views/accounts/show.html.haml +17 -15
  109. data/app/views/accounts/show.js.erb +2 -0
  110. data/app/views/admin/custom_fields/_base_field.html.haml +21 -0
  111. data/app/views/admin/custom_fields/_check_boxes_field.html.haml +6 -0
  112. data/app/views/admin/custom_fields/_date_field.html.haml +14 -0
  113. data/app/views/admin/custom_fields/_date_pair_field.html.haml +21 -0
  114. data/app/views/admin/custom_fields/_datetime_field.html.haml +14 -0
  115. data/app/views/admin/custom_fields/_datetime_pair_field.html.haml +21 -0
  116. data/app/views/admin/custom_fields/_radio_field.html.haml +6 -0
  117. data/app/views/admin/custom_fields/_select_field.html.haml +25 -0
  118. data/app/views/admin/custom_fields/_string_field.html.haml +2 -0
  119. data/app/views/admin/field_groups/_field_group.html.haml +7 -5
  120. data/app/views/admin/field_groups/_top_section.html.haml +4 -3
  121. data/app/views/admin/field_groups/create.js.rjs +1 -2
  122. data/app/views/admin/fields/_field.html.haml +5 -3
  123. data/app/views/admin/fields/_form.html.haml +35 -0
  124. data/app/views/admin/fields/_subform.html.haml +6 -0
  125. data/app/views/admin/fields/create.js.erb +19 -0
  126. data/app/views/admin/fields/destroy.js.erb +9 -0
  127. data/app/views/admin/fields/edit.js.erb +1 -0
  128. data/app/views/admin/fields/index.html.haml +11 -8
  129. data/app/views/admin/fields/update.js.erb +13 -0
  130. data/app/views/admin/groups/_edit.html.haml +12 -0
  131. data/app/views/admin/groups/_form.html.haml +13 -0
  132. data/app/views/admin/groups/_group.html.haml +15 -0
  133. data/app/views/admin/groups/_new.html.haml +12 -0
  134. data/app/views/admin/groups/create.js.rjs +11 -0
  135. data/app/views/admin/{fields → groups}/destroy.js.rjs +3 -3
  136. data/app/views/admin/groups/edit.js.rjs +21 -0
  137. data/app/views/admin/groups/index.html.haml +18 -0
  138. data/app/views/admin/groups/index.js.rjs +2 -0
  139. data/app/views/admin/groups/new.js.rjs +9 -0
  140. data/app/views/admin/groups/show.html.haml +11 -0
  141. data/app/views/admin/groups/update.js.rjs +10 -0
  142. data/app/views/admin/users/_profile.html.haml +13 -1
  143. data/app/views/admin/users/_user.html.haml +7 -2
  144. data/app/views/admin/users/index.js.rjs +1 -0
  145. data/app/views/application/index.atom.builder +1 -1
  146. data/app/views/application/index.rss.builder +1 -1
  147. data/app/views/application/show.atom.builder +32 -0
  148. data/app/views/application/show.rss.builder +29 -0
  149. data/app/views/campaigns/_campaign.html.haml +5 -21
  150. data/app/views/campaigns/_edit.html.haml +3 -2
  151. data/app/views/campaigns/_index_brief.html.haml +15 -0
  152. data/app/views/campaigns/_index_long.html.haml +20 -0
  153. data/app/views/campaigns/_new.html.haml +4 -2
  154. data/app/views/campaigns/_sidebar_index.html.haml +3 -3
  155. data/app/views/campaigns/_title_bar.html.haml +11 -0
  156. data/app/views/campaigns/_top_section.html.haml +2 -2
  157. data/app/views/campaigns/create.js.rjs +1 -4
  158. data/app/views/campaigns/destroy.js.rjs +1 -1
  159. data/app/views/campaigns/edit.js.rjs +0 -4
  160. data/app/views/campaigns/index.html.haml +6 -13
  161. data/app/views/campaigns/index.js.rjs +3 -1
  162. data/app/views/campaigns/index.xls.builder +75 -0
  163. data/app/views/campaigns/new.js.rjs +0 -4
  164. data/app/views/campaigns/show.html.haml +17 -15
  165. data/app/views/campaigns/show.js.erb +2 -0
  166. data/app/views/campaigns/update.js.rjs +0 -2
  167. data/app/views/comments/_comment.html.haml +6 -5
  168. data/app/views/comments/_edit.html.haml +5 -5
  169. data/app/views/comments/_new.html.haml +6 -5
  170. data/app/views/comments/create.js.rjs +1 -1
  171. data/app/views/contacts/_contact.html.haml +5 -52
  172. data/app/views/contacts/_contacts.html.haml +1 -0
  173. data/app/views/contacts/_edit.html.haml +3 -2
  174. data/app/views/contacts/_index_brief.html.haml +25 -0
  175. data/app/views/contacts/_index_full.html.haml +57 -0
  176. data/app/views/contacts/_index_long.html.haml +43 -0
  177. data/app/views/contacts/_new.html.haml +4 -2
  178. data/app/views/contacts/_section_extra.html.haml +26 -0
  179. data/app/views/contacts/_section_general.html.haml +22 -0
  180. data/app/views/contacts/_sidebar_index.html.haml +0 -3
  181. data/app/views/contacts/_sidebar_show.html.haml +2 -10
  182. data/app/views/contacts/_title_bar.html.haml +11 -0
  183. data/app/views/contacts/_top_section.html.haml +1 -1
  184. data/app/views/contacts/create.js.rjs +1 -2
  185. data/app/views/contacts/destroy.js.rjs +1 -1
  186. data/app/views/contacts/edit.js.rjs +0 -2
  187. data/app/views/contacts/index.html.haml +6 -14
  188. data/app/views/contacts/index.js.rjs +3 -1
  189. data/app/views/contacts/index.xls.builder +102 -0
  190. data/app/views/contacts/new.js.rjs +0 -2
  191. data/app/views/contacts/show.html.haml +15 -15
  192. data/app/views/contacts/show.js.erb +2 -0
  193. data/app/views/entities/_basic_search.html.haml +22 -0
  194. data/app/views/entities/_permissions.html.haml +41 -0
  195. data/app/views/entities/_search.html.haml +15 -0
  196. data/app/views/entities/_section_custom_fields.html.haml +11 -0
  197. data/app/views/entities/_title_bar.html.haml +12 -0
  198. data/app/views/entities/attach.js.rjs +1 -1
  199. data/app/views/entities/opportunities.js.rjs +1 -1
  200. data/app/views/entities/versions.js.erb +3 -0
  201. data/app/views/fields/_edit_custom_field_group.html.haml +8 -0
  202. data/app/views/fields/_group.html.haml +11 -20
  203. data/app/views/fields/_group_table.html.haml +13 -0
  204. data/app/views/fields/_group_view.html.haml +7 -0
  205. data/app/views/fields/_groups.html.haml +1 -4
  206. data/app/views/fields/_sidebar_show.html.haml +5 -4
  207. data/app/views/home/_account.html.haml +29 -0
  208. data/app/views/home/_activity.html.haml +16 -6
  209. data/app/views/home/_opportunity.html.haml +41 -0
  210. data/app/views/home/_options.html.haml +1 -1
  211. data/app/views/home/_task.html.haml +46 -0
  212. data/app/views/home/index.html.haml +32 -1
  213. data/app/views/home/index.js.rjs +1 -0
  214. data/app/views/layouts/_header.html.haml +3 -3
  215. data/app/views/layouts/_sidebar.html.haml +1 -3
  216. data/app/views/layouts/_tabbed.html.haml +2 -3
  217. data/app/views/layouts/_tabless.html.haml +1 -1
  218. data/app/views/layouts/admin/_header.html.haml +1 -1
  219. data/app/views/layouts/application.html.haml +7 -8
  220. data/app/views/layouts/header.xls.builder +8 -0
  221. data/app/views/leads/_contact.html.haml +1 -2
  222. data/app/views/leads/_convert.html.haml +1 -2
  223. data/app/views/leads/_convert_permissions.html.haml +21 -11
  224. data/app/views/leads/_edit.html.haml +3 -2
  225. data/app/views/leads/_index_brief.html.haml +41 -0
  226. data/app/views/leads/_index_long.html.haml +62 -0
  227. data/app/views/leads/_lead.html.haml +5 -62
  228. data/app/views/leads/_new.html.haml +4 -2
  229. data/app/views/leads/_opportunity.html.haml +1 -1
  230. data/app/views/leads/_sidebar_index.html.haml +3 -3
  231. data/app/views/leads/_sidebar_show.html.haml +3 -3
  232. data/app/views/leads/_status.html.haml +1 -1
  233. data/app/views/leads/_title_bar.html.haml +16 -0
  234. data/app/views/leads/convert.js.rjs +0 -1
  235. data/app/views/leads/create.js.rjs +1 -2
  236. data/app/views/leads/destroy.js.rjs +1 -1
  237. data/app/views/leads/edit.js.rjs +0 -2
  238. data/app/views/leads/index.html.haml +6 -13
  239. data/app/views/leads/index.js.rjs +3 -1
  240. data/app/views/leads/index.xls.builder +100 -0
  241. data/app/views/leads/new.js.rjs +0 -2
  242. data/app/views/leads/promote.js.rjs +0 -1
  243. data/app/views/leads/show.html.haml +13 -18
  244. data/app/views/leads/show.js.erb +2 -0
  245. data/app/views/{shared/_lists.html.haml → lists/_sidebar.html.haml} +0 -0
  246. data/app/views/lists/create.js.rjs +1 -1
  247. data/app/views/opportunities/_edit.html.haml +3 -2
  248. data/app/views/opportunities/_index_brief.html.haml +29 -0
  249. data/app/views/opportunities/_index_long.html.haml +59 -0
  250. data/app/views/opportunities/_new.html.haml +4 -2
  251. data/app/views/opportunities/_opportunity.html.haml +5 -57
  252. data/app/views/opportunities/_sidebar_index.html.haml +3 -3
  253. data/app/views/opportunities/_sidebar_show.html.haml +2 -2
  254. data/app/views/opportunities/_title_bar.html.haml +11 -0
  255. data/app/views/opportunities/_top_section.html.haml +2 -2
  256. data/app/views/opportunities/create.js.rjs +4 -6
  257. data/app/views/opportunities/destroy.js.rjs +1 -1
  258. data/app/views/opportunities/edit.js.rjs +0 -3
  259. data/app/views/opportunities/index.html.haml +6 -14
  260. data/app/views/opportunities/index.js.rjs +3 -1
  261. data/app/views/opportunities/index.xls.builder +69 -0
  262. data/app/views/opportunities/new.js.rjs +1 -5
  263. data/app/views/opportunities/show.html.haml +14 -14
  264. data/app/views/opportunities/show.js.erb +2 -0
  265. data/app/views/opportunities/update.js.rjs +0 -1
  266. data/app/views/passwords/new.html.haml +1 -1
  267. data/app/views/shared/_add_comment.html.haml +8 -0
  268. data/app/views/shared/_address.html.haml +1 -1
  269. data/app/views/shared/_address_show.html.haml +1 -1
  270. data/app/views/shared/_edit_comment.html.haml +2 -2
  271. data/app/views/shared/_export.html.haml +2 -1
  272. data/app/views/shared/_paginate_with_per_page.html.haml +14 -0
  273. data/app/views/shared/_recently.html.haml +1 -1
  274. data/app/views/shared/_search.html.haml +1 -1
  275. data/app/views/shared/_tags.html.haml +1 -2
  276. data/app/views/shared/_tasks.html.haml +2 -2
  277. data/app/views/tasks/_completed.html.haml +3 -3
  278. data/app/views/tasks/_new.html.haml +1 -1
  279. data/app/views/tasks/_pending.html.haml +2 -3
  280. data/app/views/tasks/_sidebar_index.html.haml +2 -2
  281. data/app/views/tasks/_top_section.html.haml +5 -3
  282. data/app/views/tasks/create.js.rjs +3 -4
  283. data/app/views/tasks/edit.js.rjs +2 -4
  284. data/app/views/tasks/index.html.haml +1 -1
  285. data/app/views/tasks/index.xls.builder +47 -0
  286. data/app/views/tasks/new.js.rjs +0 -2
  287. data/app/views/tasks/update.js.rjs +0 -1
  288. data/app/views/user_mailer/assigned_entity_notification.html.haml +3 -0
  289. data/app/views/users/_user.html.haml +2 -2
  290. data/app/views/users/_user_report.html.haml +6 -0
  291. data/app/views/users/opportunities_overview.html.haml +16 -0
  292. data/app/views/users/show.html.haml +2 -3
  293. data/app/views/users/update.js.rjs +1 -1
  294. data/app/views/versions/_version.html.haml +4 -19
  295. data/app/views/versions/_version_item.html.haml +8 -0
  296. data/app/views/versions/_versions.html.haml +9 -9
  297. data/config/application.rb +10 -2
  298. data/config/deploy.example.rb +47 -0
  299. data/config/environments/development.rb +1 -0
  300. data/config/environments/production.rb +1 -3
  301. data/config/environments/staging.rb +1 -1
  302. data/config/initializers/action_mailer.rb +10 -8
  303. data/config/initializers/custom_fields.rb +21 -0
  304. data/config/initializers/gravatar.rb +7 -0
  305. data/config/initializers/paper_trail.rb +1 -0
  306. data/config/initializers/ransack.rb +15 -0
  307. data/config/initializers/simple_form.rb +1 -2
  308. data/config/initializers/views.rb +42 -0
  309. data/config/locales/cz_fat_free_crm.yml +0 -10
  310. data/config/locales/de_fat_free_crm.yml +23 -21
  311. data/config/locales/en-GB_fat_free_crm.yml +241 -25
  312. data/config/locales/en-US_fat_free_crm.yml +139 -57
  313. data/config/locales/en-US_ransack.yml +92 -0
  314. data/config/locales/es_fat_free_crm.yml +0 -6
  315. data/config/locales/fr-CA_fat_free_crm.yml +0 -6
  316. data/config/locales/fr_fat_free_crm.yml +3 -14
  317. data/config/locales/it_fat_free_crm.yml +0 -11
  318. data/config/locales/ja_fat_free_crm.yml +0 -10
  319. data/config/locales/pl_fat_free_crm.yml +0 -6
  320. data/config/locales/pt-BR_fat_free_crm.yml +0 -6
  321. data/config/locales/ru_fat_free_crm.yml +0 -9
  322. data/config/locales/sv-SE_fat_free_crm.yml +0 -10
  323. data/config/locales/th_fat_free_crm.yml +0 -6
  324. data/config/locales/zh-CN.yml +4 -0
  325. data/config/locales/zh-CN_fat_free_crm.yml +78 -47
  326. data/config/routes.rb +13 -0
  327. data/config/settings.default.yml +20 -20
  328. data/db/demo/addresses.yml +2 -2
  329. data/db/migrate/20100928030598_create_sessions.rb +5 -0
  330. data/db/migrate/20100928030627_acts_as_taggable_on_migration.rb +6 -6
  331. data/db/migrate/20111201030535_add_field_groups_klass_name.rb +2 -1
  332. data/db/migrate/20120406082136_create_groups.rb +19 -0
  333. data/db/migrate/20120510025219_add_not_null_constraints_for_timestamp_columns.rb +21 -0
  334. data/db/migrate/20120528102124_increase_length_of_version_events.rb +9 -0
  335. data/db/migrate/20120801032706_add_pair_id_to_fields.rb +5 -0
  336. data/db/migrate/20121003063155_add_settings_to_custom_fields.rb +5 -0
  337. data/db/migrate/20121221033947_fix_country_mapping.rb +32 -0
  338. data/db/schema.rb +25 -6
  339. data/fat_free_crm.gemspec +16 -13
  340. data/lib/fat_free_crm.rb +2 -0
  341. data/lib/fat_free_crm/comment_extensions.rb +23 -0
  342. data/lib/fat_free_crm/core_ext/array.rb +8 -2
  343. data/lib/fat_free_crm/fields.rb +24 -2
  344. data/lib/fat_free_crm/gem_dependencies.rb +7 -1
  345. data/lib/fat_free_crm/permissions.rb +47 -26
  346. data/lib/fat_free_crm/version.rb +1 -1
  347. data/lib/fat_free_crm/view_factory.rb +95 -0
  348. data/lib/plugins/country_select/lib/country_select.rb +393 -374
  349. data/lib/tasks/{plugins.rake → db/migrate.rake} +1 -1
  350. data/lib/tasks/{schema_upgrade.rake → db/schema.rake} +2 -1
  351. data/lib/tasks/{mail_processing.rake → ffcrm/comment_replies.rake} +2 -21
  352. data/lib/tasks/ffcrm/config.rake +33 -0
  353. data/lib/tasks/{demo.rake → ffcrm/demo.rake} +3 -2
  354. data/lib/tasks/ffcrm/dropbox.rake +42 -0
  355. data/lib/tasks/ffcrm/settings.rake +46 -0
  356. data/lib/tasks/{fat_free_crm.rake → ffcrm/setup.rake} +1 -39
  357. data/lib/tasks/ffcrm/update_data.rake +256 -0
  358. data/{acceptance → spec/acceptance}/acceptance_helper.rb +5 -4
  359. data/{acceptance → spec/acceptance}/accounts_spec.rb +36 -10
  360. data/spec/acceptance/admin/groups_spec.rb +26 -0
  361. data/spec/acceptance/admin/users_spec.rb +34 -0
  362. data/spec/acceptance/campaigns_spec.rb +101 -0
  363. data/spec/acceptance/contacts_spec.rb +101 -0
  364. data/spec/acceptance/dashboard_spec.rb +62 -0
  365. data/spec/acceptance/leads_spec.rb +109 -0
  366. data/spec/acceptance/opportunities_overview_spec.rb +82 -0
  367. data/spec/acceptance/opportunities_spec.rb +103 -0
  368. data/{acceptance → spec/acceptance}/support/browser.rb +0 -0
  369. data/{acceptance → spec/acceptance}/support/headless.rb +0 -0
  370. data/{acceptance → spec/acceptance}/support/helpers.rb +8 -1
  371. data/{acceptance → spec/acceptance}/support/maintain_sessions.rb +0 -0
  372. data/spec/acceptance/support/paths.rb +42 -0
  373. data/spec/acceptance/support/selector_helpers.rb +31 -0
  374. data/spec/acceptance/tasks_spec.rb +85 -0
  375. data/spec/controllers/admin/groups_controller_spec.rb +5 -0
  376. data/spec/controllers/admin/users_controller_spec.rb +2 -3
  377. data/spec/controllers/applications_controller_spec.rb +40 -0
  378. data/spec/controllers/comments_controller_spec.rb +5 -6
  379. data/spec/controllers/emails_controller_spec.rb +1 -2
  380. data/spec/controllers/entities/accounts_controller_spec.rb +65 -81
  381. data/spec/controllers/entities/campaigns_controller_spec.rb +69 -85
  382. data/spec/controllers/entities/contacts_controller_spec.rb +78 -95
  383. data/spec/controllers/entities/leads_controller_spec.rb +105 -127
  384. data/spec/controllers/entities/opportunities_controller_spec.rb +88 -103
  385. data/spec/controllers/entities_controller_spec.rb +39 -0
  386. data/spec/controllers/home_controller_spec.rb +101 -11
  387. data/spec/controllers/tasks_controller_spec.rb +27 -32
  388. data/spec/controllers/users_controller_spec.rb +95 -28
  389. data/spec/factories/account_factories.rb +2 -2
  390. data/spec/factories/opportunity_factories.rb +12 -4
  391. data/spec/factories/task_factories.rb +4 -0
  392. data/spec/factories/user_factories.rb +9 -2
  393. data/spec/helpers/application_helper_spec.rb +15 -1
  394. data/spec/helpers/groups_helper_spec.rb +15 -0
  395. data/spec/helpers/users_helper_spec.rb +26 -4
  396. data/spec/lib/comment_extensions_spec.rb +29 -0
  397. data/spec/lib/core_ext/{string.rb → string_spec.rb} +0 -1
  398. data/spec/lib/fields_spec.rb +104 -0
  399. data/spec/lib/permissions_spec.rb +144 -0
  400. data/spec/lib/view_factory_spec.rb +68 -0
  401. data/spec/mailers/subscription_mailer_spec.rb +18 -4
  402. data/spec/mailers/user_mailer_spec.rb +134 -0
  403. data/spec/models/entities/account_spec.rb +44 -4
  404. data/spec/models/entities/campaign_spec.rb +3 -4
  405. data/spec/models/entities/contact_spec.rb +45 -5
  406. data/spec/models/entities/lead_spec.rb +3 -4
  407. data/spec/models/entities/opportunity_spec.rb +105 -9
  408. data/spec/models/fields/custom_field_date_pair_spec.rb +106 -0
  409. data/spec/models/fields/custom_field_pair_spec.rb +94 -0
  410. data/spec/models/fields/custom_field_spec.rb +43 -23
  411. data/spec/models/fields/field_spec.rb +3 -5
  412. data/spec/models/observers/entity_observer_spec.rb +65 -0
  413. data/spec/models/polymorphic/task_spec.rb +74 -118
  414. data/spec/models/polymorphic/version_spec.rb +18 -18
  415. data/spec/models/users/group_spec.rb +5 -0
  416. data/spec/models/users/permission_spec.rb +18 -1
  417. data/spec/models/users/preference_spec.rb +5 -1
  418. data/spec/models/users/user_spec.rb +55 -8
  419. data/spec/shared/models.rb +54 -0
  420. data/spec/spec_helper.rb +82 -87
  421. data/spec/support/auth_macros.rb +2 -3
  422. data/spec/views/accounts/_edit.haml_spec.rb +1 -2
  423. data/spec/views/accounts/_new.haml_spec.rb +1 -2
  424. data/spec/views/accounts/create.rjs_spec.rb +1 -3
  425. data/spec/views/accounts/edit.rjs_spec.rb +3 -4
  426. data/spec/views/accounts/index.haml_spec.rb +9 -6
  427. data/spec/views/accounts/new.rjs_spec.rb +2 -9
  428. data/spec/views/accounts/show.haml_spec.rb +1 -2
  429. data/spec/views/accounts/update.rjs_spec.rb +2 -3
  430. data/spec/views/admin/users/_create.haml_spec.rb +1 -2
  431. data/spec/views/admin/users/create.rjs_spec.rb +1 -2
  432. data/spec/views/campaigns/_edit.haml_spec.rb +2 -3
  433. data/spec/views/campaigns/_new.haml_spec.rb +2 -3
  434. data/spec/views/campaigns/create.rjs_spec.rb +0 -3
  435. data/spec/views/campaigns/destroy.rjs_spec.rb +1 -2
  436. data/spec/views/campaigns/edit.rjs_spec.rb +3 -6
  437. data/spec/views/campaigns/index.haml_spec.rb +6 -3
  438. data/spec/views/campaigns/new.rjs_spec.rb +2 -13
  439. data/spec/views/campaigns/show.haml_spec.rb +4 -6
  440. data/spec/views/campaigns/update.rjs_spec.rb +2 -7
  441. data/spec/views/contacts/_edit.haml_spec.rb +6 -7
  442. data/spec/views/contacts/_new.haml_spec.rb +2 -3
  443. data/spec/views/contacts/create.rjs_spec.rb +1 -3
  444. data/spec/views/contacts/edit.rjs_spec.rb +3 -4
  445. data/spec/views/contacts/index.haml_spec.rb +6 -3
  446. data/spec/views/contacts/new.rjs_spec.rb +2 -11
  447. data/spec/views/contacts/show.haml_spec.rb +1 -2
  448. data/spec/views/contacts/update.rjs_spec.rb +2 -3
  449. data/spec/views/home/index.haml_spec.rb +6 -2
  450. data/spec/views/home/index.rjs_spec.rb +1 -2
  451. data/spec/views/home/options.rjs_spec.rb +1 -2
  452. data/spec/views/leads/_convert.haml_spec.rb +1 -2
  453. data/spec/views/leads/_edit.haml_spec.rb +2 -3
  454. data/spec/views/leads/_new.haml_spec.rb +2 -3
  455. data/spec/views/leads/_sidebar_show.haml_spec.rb +1 -2
  456. data/spec/views/leads/convert.rjs_spec.rb +3 -5
  457. data/spec/views/leads/edit.rjs_spec.rb +4 -5
  458. data/spec/views/leads/index.haml_spec.rb +6 -3
  459. data/spec/views/leads/new.rjs_spec.rb +2 -11
  460. data/spec/views/leads/promote.rjs_spec.rb +3 -5
  461. data/spec/views/leads/show.haml_spec.rb +1 -2
  462. data/spec/views/leads/update.rjs_spec.rb +2 -3
  463. data/spec/views/opportunities/_edit.haml_spec.rb +5 -6
  464. data/spec/views/opportunities/_new.haml_spec.rb +2 -4
  465. data/spec/views/opportunities/create.rjs_spec.rb +0 -2
  466. data/spec/views/opportunities/edit.rjs_spec.rb +3 -4
  467. data/spec/views/opportunities/index.haml_spec.rb +7 -4
  468. data/spec/views/opportunities/new.rjs_spec.rb +2 -12
  469. data/spec/views/opportunities/show.haml_spec.rb +1 -2
  470. data/spec/views/opportunities/update.rjs_spec.rb +2 -3
  471. data/spec/views/tasks/_edit.haml_spec.rb +1 -3
  472. data/spec/views/tasks/complete.rjs_spec.rb +2 -3
  473. data/spec/views/tasks/create.rjs_spec.rb +2 -2
  474. data/spec/views/tasks/edit.rjs_spec.rb +1 -2
  475. data/spec/views/tasks/new.rjs_spec.rb +1 -18
  476. data/spec/views/users/avatar.rjs_spec.rb +1 -2
  477. data/spec/views/users/change_password.rjs_spec.rb +1 -2
  478. data/spec/views/users/edit.rjs_spec.rb +1 -2
  479. data/spec/views/users/password.rjs_spec.rb +1 -1
  480. data/spec/views/users/update.rjs_spec.rb +1 -2
  481. data/spec/views/users/upload_avatar.rjs_spec.rb +6 -7
  482. data/vendor/assets/images/brief.png +0 -0
  483. data/vendor/assets/images/chosen-sprite.png +0 -0
  484. data/vendor/assets/images/full.png +0 -0
  485. data/vendor/assets/images/jquery-ui/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  486. data/vendor/assets/images/jquery-ui/ui-bg_flat_0_eeeeee_40x100.png +0 -0
  487. data/vendor/assets/images/jquery-ui/ui-bg_flat_100_ffffff_40x100.png +0 -0
  488. data/vendor/assets/images/jquery-ui/ui-bg_flat_25_3875d7_40x100.png +0 -0
  489. data/vendor/assets/images/jquery-ui/ui-bg_flat_55_ffffff_40x100.png +0 -0
  490. data/vendor/assets/images/jquery-ui/ui-bg_flat_65_3875d7_40x100.png +0 -0
  491. data/vendor/assets/images/jquery-ui/ui-bg_flat_75_ffffff_40x100.png +0 -0
  492. data/vendor/assets/images/jquery-ui/ui-bg_highlight-soft_50_dddddd_1x100.png +0 -0
  493. data/vendor/assets/images/jquery-ui/{ui-icons_ef8c08_256x240.png → ui-icons_0073ea_256x240.png} +0 -0
  494. data/vendor/assets/images/jquery-ui/ui-icons_466bb1_256x240.png +0 -0
  495. data/vendor/assets/images/jquery-ui/{ui-icons_ffd27a_256x240.png → ui-icons_ff0084_256x240.png} +0 -0
  496. data/vendor/assets/images/long.png +0 -0
  497. data/vendor/assets/javascripts/chosen-jquery.js +3 -0
  498. data/vendor/assets/javascripts/chosen-prototype.js +3 -0
  499. data/vendor/assets/javascripts/chosen.jquery.coffee +574 -0
  500. data/vendor/assets/javascripts/chosen.proto.coffee +580 -0
  501. data/vendor/assets/javascripts/jquery.disable.js +23 -0
  502. data/vendor/assets/javascripts/jquery_ui_datepicker/jquery-ui-timepicker-addon.js +1882 -0
  503. data/vendor/assets/javascripts/jquery_ui_datepicker/jquery-ui-timepicker-af.js +20 -0
  504. data/vendor/assets/javascripts/jquery_ui_datepicker/jquery-ui-timepicker-ca.js +20 -0
  505. data/vendor/assets/javascripts/jquery_ui_datepicker/jquery-ui-timepicker-cz.js +20 -0
  506. data/vendor/assets/javascripts/jquery_ui_datepicker/jquery-ui-timepicker-de.js +20 -0
  507. data/vendor/assets/javascripts/jquery_ui_datepicker/jquery-ui-timepicker-el.js +20 -0
  508. data/vendor/assets/javascripts/jquery_ui_datepicker/jquery-ui-timepicker-es.js +20 -0
  509. data/vendor/assets/javascripts/jquery_ui_datepicker/jquery-ui-timepicker-et.js +20 -0
  510. data/vendor/assets/javascripts/jquery_ui_datepicker/jquery-ui-timepicker-fi.js +20 -0
  511. data/vendor/assets/javascripts/jquery_ui_datepicker/jquery-ui-timepicker-fr-CA.js +20 -0
  512. data/vendor/assets/javascripts/jquery_ui_datepicker/jquery-ui-timepicker-fr.js +20 -0
  513. data/vendor/assets/javascripts/jquery_ui_datepicker/jquery-ui-timepicker-gl.js +20 -0
  514. data/vendor/assets/javascripts/jquery_ui_datepicker/jquery-ui-timepicker-he.js +20 -0
  515. data/vendor/assets/javascripts/jquery_ui_datepicker/jquery-ui-timepicker-hu.js +20 -0
  516. data/vendor/assets/javascripts/jquery_ui_datepicker/jquery-ui-timepicker-id.js +20 -0
  517. data/vendor/assets/javascripts/jquery_ui_datepicker/jquery-ui-timepicker-it.js +20 -0
  518. data/vendor/assets/javascripts/jquery_ui_datepicker/jquery-ui-timepicker-ja.js +20 -0
  519. data/vendor/assets/javascripts/jquery_ui_datepicker/jquery-ui-timepicker-ko.js +20 -0
  520. data/vendor/assets/javascripts/jquery_ui_datepicker/jquery-ui-timepicker-lt.js +20 -0
  521. data/vendor/assets/javascripts/jquery_ui_datepicker/jquery-ui-timepicker-nl.js +20 -0
  522. data/vendor/assets/javascripts/jquery_ui_datepicker/jquery-ui-timepicker-no.js +20 -0
  523. data/vendor/assets/javascripts/jquery_ui_datepicker/jquery-ui-timepicker-pl.js +20 -0
  524. data/vendor/assets/javascripts/jquery_ui_datepicker/jquery-ui-timepicker-pt.js +20 -0
  525. data/vendor/assets/javascripts/jquery_ui_datepicker/jquery-ui-timepicker-ro.js +20 -0
  526. data/vendor/assets/javascripts/jquery_ui_datepicker/jquery-ui-timepicker-ru.js +20 -0
  527. data/vendor/assets/javascripts/jquery_ui_datepicker/jquery-ui-timepicker-sk.js +20 -0
  528. data/vendor/assets/javascripts/jquery_ui_datepicker/jquery-ui-timepicker-sv.js +20 -0
  529. data/vendor/assets/javascripts/jquery_ui_datepicker/jquery-ui-timepicker-tr.js +20 -0
  530. data/vendor/assets/javascripts/jquery_ui_datepicker/jquery-ui-timepicker-vi.js +20 -0
  531. data/vendor/assets/javascripts/jquery_ui_datepicker/jquery-ui-timepicker-zh-CN.js +20 -0
  532. data/vendor/assets/javascripts/jquery_ui_datepicker/jquery-ui-timepicker-zh-TW.js +20 -0
  533. data/vendor/assets/javascripts/jquery_ui_datepicker/jquery.ui.datepicker-cz.js +23 -0
  534. data/vendor/assets/javascripts/jquery_ui_datepicker/jquery.ui.datepicker-de.js +23 -0
  535. data/vendor/assets/javascripts/jquery_ui_datepicker/jquery.ui.datepicker-en-GB.js +23 -0
  536. data/vendor/assets/javascripts/jquery_ui_datepicker/jquery.ui.datepicker-es.js +23 -0
  537. data/vendor/assets/javascripts/jquery_ui_datepicker/jquery.ui.datepicker-fr.js +23 -0
  538. data/vendor/assets/javascripts/jquery_ui_datepicker/jquery.ui.datepicker-it.js +23 -0
  539. data/vendor/assets/javascripts/jquery_ui_datepicker/jquery.ui.datepicker-ja.js +23 -0
  540. data/vendor/assets/javascripts/jquery_ui_datepicker/jquery.ui.datepicker-pl.js +23 -0
  541. data/vendor/assets/javascripts/jquery_ui_datepicker/jquery.ui.datepicker-pt-BR.js +23 -0
  542. data/vendor/assets/javascripts/jquery_ui_datepicker/jquery.ui.datepicker-ru.js +23 -0
  543. data/vendor/assets/javascripts/jquery_ui_datepicker/jquery.ui.datepicker-sv-SE.js +23 -0
  544. data/vendor/assets/javascripts/jquery_ui_datepicker/jquery.ui.datepicker-th.js +23 -0
  545. data/vendor/assets/javascripts/jquery_ui_datepicker/jquery.ui.datepicker-zh-CN.js +23 -0
  546. data/vendor/assets/javascripts/lib/abstract-chosen.coffee +110 -0
  547. data/vendor/assets/javascripts/lib/select-parser.coffee +51 -0
  548. data/vendor/assets/stylesheets/chosen.css.sass +361 -0
  549. data/vendor/assets/stylesheets/{jquery-ui.custom.css.erb → jquery-ui.custom.css} +70 -70
  550. data/zeus.json +21 -0
  551. metadata +304 -140
  552. data/acceptance/support/database_cleaner.rb +0 -16
  553. data/acceptance/support/paths.rb +0 -9
  554. data/app/views/accounts/_options.html.haml +0 -20
  555. data/app/views/accounts/_permissions.html.haml +0 -24
  556. data/app/views/accounts/options.js.rjs +0 -10
  557. data/app/views/admin/fields/_edit.html.haml +0 -9
  558. data/app/views/admin/fields/_new.html.haml +0 -10
  559. data/app/views/admin/fields/_options.html.haml +0 -12
  560. data/app/views/admin/fields/_top_section.html.haml +0 -54
  561. data/app/views/admin/fields/create.js.rjs +0 -16
  562. data/app/views/admin/fields/edit.js.rjs +0 -35
  563. data/app/views/admin/fields/index.js.rjs +0 -6
  564. data/app/views/admin/fields/new.js.rjs +0 -8
  565. data/app/views/admin/fields/options.js.rjs +0 -10
  566. data/app/views/admin/fields/update.js.rjs +0 -17
  567. data/app/views/campaigns/_options.html.haml +0 -20
  568. data/app/views/campaigns/_permissions.html.haml +0 -24
  569. data/app/views/campaigns/options.js.rjs +0 -10
  570. data/app/views/contacts/_options.html.haml +0 -21
  571. data/app/views/contacts/_permissions.html.haml +0 -24
  572. data/app/views/contacts/options.js.rjs +0 -10
  573. data/app/views/entities/_advanced_search.html.haml +0 -12
  574. data/app/views/entities/_condition_fields.html.haml +0 -14
  575. data/app/views/entities/_grouping_fields.html.haml +0 -12
  576. data/app/views/entities/advanced_search.js.rjs +0 -9
  577. data/app/views/entities/versions.js.rjs +0 -3
  578. data/app/views/leads/_options.html.haml +0 -21
  579. data/app/views/leads/_permissions.html.haml +0 -28
  580. data/app/views/leads/options.js.rjs +0 -10
  581. data/app/views/opportunities/_options.html.haml +0 -20
  582. data/app/views/opportunities/_permissions.html.haml +0 -24
  583. data/app/views/opportunities/options.js.rjs +0 -10
  584. data/app/views/shared/_outline.html.haml +0 -9
  585. data/app/views/shared/_per_page.html.haml +0 -10
  586. data/app/views/shared/_sort_by.html.haml +0 -10
  587. data/config/initializers/cancan.rb +0 -151
  588. data/config/initializers/squeel.rb +0 -5
  589. data/public/blank_iframe.html +0 -2
  590. data/spec/views/accounts/options.rjs_spec.rb +0 -59
  591. data/spec/views/campaigns/options.rjs_spec.rb +0 -60
  592. data/spec/views/contacts/options.rjs_spec.rb +0 -61
  593. data/spec/views/leads/options.rjs_spec.rb +0 -61
  594. data/spec/views/opportunities/options.rjs_spec.rb +0 -60
  595. data/vendor/assets/images/jquery-ui/ui-bg_diagonals-thick_18_b81900_40x40.png +0 -0
  596. data/vendor/assets/images/jquery-ui/ui-bg_diagonals-thick_20_666666_40x40.png +0 -0
  597. data/vendor/assets/images/jquery-ui/ui-bg_flat_10_000000_40x100.png +0 -0
  598. data/vendor/assets/images/jquery-ui/ui-bg_glass_100_f6f6f6_1x400.png +0 -0
  599. data/vendor/assets/images/jquery-ui/ui-bg_glass_100_fdf5ce_1x400.png +0 -0
  600. data/vendor/assets/images/jquery-ui/ui-bg_glass_65_ffffff_1x400.png +0 -0
  601. data/vendor/assets/images/jquery-ui/ui-bg_gloss-wave_35_f6a828_500x100.png +0 -0
  602. data/vendor/assets/images/jquery-ui/ui-bg_highlight-soft_100_eeeeee_1x100.png +0 -0
  603. data/vendor/assets/images/jquery-ui/ui-bg_highlight-soft_75_ffe45c_1x100.png +0 -0
  604. data/vendor/assets/images/jquery-ui/ui-icons_222222_256x240.png +0 -0
  605. data/vendor/assets/images/jquery-ui/ui-icons_228ef1_256x240.png +0 -0
  606. data/vendor/assets/javascripts/calendar_date_select/calendar_date_select.js +0 -446
  607. data/vendor/assets/javascripts/calendar_date_select/format_american.js +0 -35
  608. data/vendor/assets/javascripts/calendar_date_select/format_danish.js +0 -31
  609. data/vendor/assets/javascripts/calendar_date_select/format_db.js +0 -27
  610. data/vendor/assets/javascripts/calendar_date_select/format_euro_24hr.js +0 -7
  611. data/vendor/assets/javascripts/calendar_date_select/format_euro_24hr_ymd.js +0 -7
  612. data/vendor/assets/javascripts/calendar_date_select/format_finnish.js +0 -32
  613. data/vendor/assets/javascripts/calendar_date_select/format_french.js +0 -24
  614. data/vendor/assets/javascripts/calendar_date_select/format_hyphen_ampm.js +0 -37
  615. data/vendor/assets/javascripts/calendar_date_select/format_iso_date.js +0 -29
  616. data/vendor/assets/javascripts/calendar_date_select/format_italian.js +0 -24
  617. data/vendor/assets/javascripts/calendar_date_select/locale/ar.js +0 -10
  618. data/vendor/assets/javascripts/calendar_date_select/locale/da.js +0 -11
  619. data/vendor/assets/javascripts/calendar_date_select/locale/de.js +0 -11
  620. data/vendor/assets/javascripts/calendar_date_select/locale/es.js +0 -11
  621. data/vendor/assets/javascripts/calendar_date_select/locale/fi.js +0 -10
  622. data/vendor/assets/javascripts/calendar_date_select/locale/fr.js +0 -11
  623. data/vendor/assets/javascripts/calendar_date_select/locale/it.js +0 -9
  624. data/vendor/assets/javascripts/calendar_date_select/locale/ja.js +0 -11
  625. data/vendor/assets/javascripts/calendar_date_select/locale/nl.js +0 -11
  626. data/vendor/assets/javascripts/calendar_date_select/locale/pl.js +0 -11
  627. data/vendor/assets/javascripts/calendar_date_select/locale/pt.js +0 -11
  628. data/vendor/assets/javascripts/calendar_date_select/locale/ru.js +0 -10
  629. data/vendor/assets/javascripts/calendar_date_select/locale/sl.js +0 -11
  630. data/vendor/assets/javascripts/calendar_date_select/locale/sv.js +0 -9
  631. data/vendor/assets/stylesheets/calendar_date_select/blue.css +0 -130
  632. data/vendor/assets/stylesheets/calendar_date_select/default.css +0 -135
  633. data/vendor/assets/stylesheets/calendar_date_select/green.css +0 -142
  634. data/vendor/assets/stylesheets/calendar_date_select/plain.css +0 -128
  635. data/vendor/assets/stylesheets/calendar_date_select/red.css +0 -135
  636. data/vendor/assets/stylesheets/calendar_date_select/silver.css +0 -133
  637. data/vendor/plugins/.gitkeep~master +0 -0
@@ -21,7 +21,7 @@ describe OpportunitiesController do
21
21
  end
22
22
 
23
23
  it "should expose all opportunities as @opportunities and render [index] template" do
24
- @opportunities = [ FactoryGirl.create(:opportunity, :user => @current_user) ]
24
+ @opportunities = [ FactoryGirl.create(:opportunity, :user => current_user) ]
25
25
 
26
26
  get :index
27
27
  assigns[:opportunities].should == @opportunities
@@ -37,11 +37,11 @@ describe OpportunitiesController do
37
37
  it "should filter out opportunities by stage" do
38
38
  controller.session[:opportunities_filter] = "prospecting,negotiation"
39
39
  @opportunities = [
40
- FactoryGirl.create(:opportunity, :user => @current_user, :stage => "negotiation"),
41
- FactoryGirl.create(:opportunity, :user => @current_user, :stage => "prospecting")
40
+ FactoryGirl.create(:opportunity, :user => current_user, :stage => "negotiation"),
41
+ FactoryGirl.create(:opportunity, :user => current_user, :stage => "prospecting")
42
42
  ]
43
43
  # This one should be filtered out.
44
- FactoryGirl.create(:opportunity, :user => @current_user, :stage => "analysis")
44
+ FactoryGirl.create(:opportunity, :user => current_user, :stage => "analysis")
45
45
 
46
46
  get :index
47
47
  # Note: can't compare opportunities directly because of BigDecimal objects.
@@ -50,8 +50,8 @@ describe OpportunitiesController do
50
50
  end
51
51
 
52
52
  it "should perform lookup using query string" do
53
- @first = FactoryGirl.create(:opportunity, :user => @current_user, :name => "The first one")
54
- @second = FactoryGirl.create(:opportunity, :user => @current_user, :name => "The second one")
53
+ @first = FactoryGirl.create(:opportunity, :user => current_user, :name => "The first one")
54
+ @second = FactoryGirl.create(:opportunity, :user => current_user, :name => "The second one")
55
55
 
56
56
  get :index, :query => "second"
57
57
  assigns[:opportunities].should == [ @second ]
@@ -61,7 +61,7 @@ describe OpportunitiesController do
61
61
 
62
62
  describe "AJAX pagination" do
63
63
  it "should pick up page number from params" do
64
- @opportunities = [ FactoryGirl.create(:opportunity, :user => @current_user) ]
64
+ @opportunities = [ FactoryGirl.create(:opportunity, :user => current_user) ]
65
65
  xhr :get, :index, :page => 42
66
66
 
67
67
  assigns[:current_page].to_i.should == 42
@@ -72,13 +72,24 @@ describe OpportunitiesController do
72
72
 
73
73
  it "should pick up saved page number from session" do
74
74
  session[:opportunities_current_page] = 42
75
- @opportunities = [ FactoryGirl.create(:opportunity, :user => @current_user) ]
75
+ @opportunities = [ FactoryGirl.create(:opportunity, :user => current_user) ]
76
76
  xhr :get, :index
77
77
 
78
78
  assigns[:current_page].should == 42
79
79
  assigns[:opportunities].should == []
80
80
  response.should render_template("opportunities/index")
81
81
  end
82
+
83
+ it "should reset current_page when query is altered" do
84
+ session[:opportunities_current_page] = 42
85
+ session[:opportunities_current_query] = "bill"
86
+ @opportunities = [ FactoryGirl.create(:opportunity, :user => current_user) ]
87
+ xhr :get, :index
88
+
89
+ assigns[:current_page].should == 1
90
+ assigns[:opportunities].should == @opportunities
91
+ response.should render_template("opportunities/index")
92
+ end
82
93
  end
83
94
 
84
95
  describe "with mime type of JSON" do
@@ -167,7 +178,7 @@ describe OpportunitiesController do
167
178
 
168
179
  describe "opportunity got deleted or otherwise unavailable" do
169
180
  it "should redirect to opportunity index if the opportunity got deleted" do
170
- @opportunity = FactoryGirl.create(:opportunity, :user => @current_user)
181
+ @opportunity = FactoryGirl.create(:opportunity, :user => current_user)
171
182
  @opportunity.destroy
172
183
 
173
184
  get :show, :id => @opportunity.id
@@ -184,7 +195,7 @@ describe OpportunitiesController do
184
195
  end
185
196
 
186
197
  it "should return 404 (Not Found) JSON error" do
187
- @opportunity = FactoryGirl.create(:opportunity, :user => @current_user)
198
+ @opportunity = FactoryGirl.create(:opportunity, :user => current_user)
188
199
  @opportunity.destroy
189
200
  request.env["HTTP_ACCEPT"] = "application/json"
190
201
 
@@ -193,7 +204,7 @@ describe OpportunitiesController do
193
204
  end
194
205
 
195
206
  it "should return 404 (Not Found) XML error" do
196
- @opportunity = FactoryGirl.create(:opportunity, :user => @current_user)
207
+ @opportunity = FactoryGirl.create(:opportunity, :user => current_user)
197
208
  @opportunity.destroy
198
209
  request.env["HTTP_ACCEPT"] = "application/xml"
199
210
 
@@ -209,15 +220,13 @@ describe OpportunitiesController do
209
220
  describe "responding to GET new" do
210
221
 
211
222
  it "should expose a new opportunity as @opportunity and render [new] template" do
212
- @opportunity = Opportunity.new(:user => @current_user, :access => Setting.default_access, :stage => "prospecting")
213
- @account = Account.new(:user => @current_user, :access => Setting.default_access)
214
- @users = [ FactoryGirl.create(:user) ]
215
- @accounts = [ FactoryGirl.create(:account, :user => @current_user) ]
223
+ @opportunity = Opportunity.new(:user => current_user, :access => Setting.default_access, :stage => "prospecting")
224
+ @account = Account.new(:user => current_user, :access => Setting.default_access)
225
+ @accounts = [ FactoryGirl.create(:account, :user => current_user) ]
216
226
 
217
227
  xhr :get, :new
218
228
  assigns[:opportunity].attributes.should == @opportunity.attributes
219
229
  assigns[:account].attributes.should == @account.attributes
220
- assigns[:users].should == @users
221
230
  assigns[:accounts].should == @accounts
222
231
  response.should render_template("opportunities/new")
223
232
  end
@@ -256,10 +265,9 @@ describe OpportunitiesController do
256
265
  it "should expose the requested opportunity as @opportunity and render [edit] template" do
257
266
  # Note: campaign => nil makes sure campaign factory is not invoked which has a side
258
267
  # effect of creating an extra (campaign) user.
259
- @account = FactoryGirl.create(:account, :user => @current_user)
260
- @opportunity = FactoryGirl.create(:opportunity, :id => 42, :user => @current_user, :campaign => nil,
268
+ @account = FactoryGirl.create(:account, :user => current_user)
269
+ @opportunity = FactoryGirl.create(:opportunity, :id => 42, :user => current_user, :campaign => nil,
261
270
  :account => @account)
262
- @users = [ FactoryGirl.create(:user) ]
263
271
  @stage = Setting.unroll(:opportunity_stage)
264
272
  @accounts = [ @account ]
265
273
 
@@ -268,7 +276,6 @@ describe OpportunitiesController do
268
276
  assigns[:opportunity].should == @opportunity
269
277
  assigns[:account].attributes.should == @opportunity.account.attributes
270
278
  assigns[:accounts].should == @accounts
271
- assigns[:users].should == @users
272
279
  assigns[:stage].should == @stage
273
280
  assigns[:previous].should == nil
274
281
  response.should render_template("opportunities/edit")
@@ -284,7 +291,7 @@ describe OpportunitiesController do
284
291
 
285
292
  describe "opportunity got deleted or is otherwise unavailable" do
286
293
  it "should reload current page with the flash message if the opportunity got deleted" do
287
- @opportunity = FactoryGirl.create(:opportunity, :user => @current_user)
294
+ @opportunity = FactoryGirl.create(:opportunity, :user => current_user)
288
295
  @opportunity.destroy
289
296
 
290
297
  xhr :get, :edit, :id => @opportunity.id
@@ -303,7 +310,7 @@ describe OpportunitiesController do
303
310
 
304
311
  describe "(previous opportunity got deleted or is otherwise unavailable)" do
305
312
  before do
306
- @opportunity = FactoryGirl.create(:opportunity, :user => @current_user)
313
+ @opportunity = FactoryGirl.create(:opportunity, :user => current_user)
307
314
  @previous = FactoryGirl.create(:opportunity, :user => FactoryGirl.create(:user))
308
315
  end
309
316
 
@@ -335,13 +342,13 @@ describe OpportunitiesController do
335
342
  describe "with valid params" do
336
343
 
337
344
  before do
338
- @opportunity = FactoryGirl.build(:opportunity, :user => @current_user)
345
+ @opportunity = FactoryGirl.build(:opportunity, :user => current_user)
339
346
  Opportunity.stub!(:new).and_return(@opportunity)
340
347
  @stage = Setting.unroll(:opportunity_stage)
341
348
  end
342
349
 
343
350
  it "should expose a newly created opportunity as @opportunity and render [create] template" do
344
- xhr :post, :create, :opportunity => { :name => "Hello" }, :account => { :name => "Hello again" }, :users => %w(1 2 3)
351
+ xhr :post, :create, :opportunity => { :name => "Hello" }, :account => { :name => "Hello again" }
345
352
  assigns(:opportunity).should == @opportunity
346
353
  assigns(:stage).should == @stage
347
354
  assigns(:opportunity_stage_total).should be_nil
@@ -350,29 +357,29 @@ describe OpportunitiesController do
350
357
 
351
358
  it "should get sidebar data if called from opportunities index" do
352
359
  request.env["HTTP_REFERER"] = "http://localhost/opportunities"
353
- xhr :post, :create, :opportunity => { :name => "Hello" }, :account => { :name => "Hello again" }, :users => %w(1 2 3)
360
+ xhr :post, :create, :opportunity => { :name => "Hello" }, :account => { :name => "Hello again" }
354
361
  assigns(:opportunity_stage_total).should be_an_instance_of(HashWithIndifferentAccess)
355
362
  end
356
363
 
357
364
  it "should find related account if called from account landing page" do
358
- @account = FactoryGirl.create(:account, :user => @current_user)
365
+ @account = FactoryGirl.create(:account, :user => current_user)
359
366
  request.env["HTTP_REFERER"] = "http://localhost/accounts/#{@account.id}"
360
367
 
361
- xhr :post, :create, :opportunity => { :name => "Hello" }, :account => { :id => @account.id }, :users => %w(1 2 3)
368
+ xhr :post, :create, :opportunity => { :name => "Hello" }, :account => { :id => @account.id }
362
369
  assigns(:account).should == @account
363
370
  end
364
371
 
365
372
  it "should find related campaign if called from campaign landing page" do
366
- @campaign = FactoryGirl.create(:campaign, :user => @current_user)
373
+ @campaign = FactoryGirl.create(:campaign, :user => current_user)
367
374
  request.env["HTTP_REFERER"] = "http://localhost/campaigns/#{@campaign.id}"
368
375
 
369
- xhr :post, :create, :opportunity => { :name => "Hello" }, :campaign => @campaign.id, :account => { :name => "Hello again" }, :users => %w(1 2 3)
376
+ xhr :post, :create, :opportunity => { :name => "Hello" }, :campaign => @campaign.id, :account => { :name => "Hello again" }
370
377
  assigns(:campaign).should == @campaign
371
378
  end
372
379
 
373
380
  it "should reload opportunities to update pagination if called from opportunities index" do
374
381
  request.env["HTTP_REFERER"] = "http://localhost/opportunities"
375
- xhr :post, :create, :opportunity => { :name => "Hello" }, :account => { :name => "Hello again" }, :users => %w(1 2 3)
382
+ xhr :post, :create, :opportunity => { :name => "Hello" }, :account => { :name => "Hello again" }
376
383
  assigns[:opportunities].should == [ @opportunity ]
377
384
  end
378
385
 
@@ -380,7 +387,7 @@ describe OpportunitiesController do
380
387
  @campaign = FactoryGirl.create(:campaign)
381
388
 
382
389
  request.env["HTTP_REFERER"] = "http://localhost/campaigns/#{@campaign.id}"
383
- xhr :post, :create, :opportunity => { :name => "Hello" }, :campaign => @campaign.id, :account => { :name => "Test Account" }, :users => []
390
+ xhr :post, :create, :opportunity => { :name => "Hello" }, :campaign => @campaign.id, :account => { :name => "Test Account" }
384
391
  assigns(:opportunity).should == @opportunity
385
392
  assigns(:campaign).should == @campaign
386
393
  @opportunity.campaign.should == @campaign
@@ -390,7 +397,7 @@ describe OpportunitiesController do
390
397
  @contact = FactoryGirl.create(:contact, :id => 42)
391
398
 
392
399
  request.env["HTTP_REFERER"] = "http://localhost/contacts/42"
393
- xhr :post, :create, :opportunity => { :name => "Hello" }, :contact => 42, :account => { :name => "Hello again" }, :users => []
400
+ xhr :post, :create, :opportunity => { :name => "Hello" }, :contact => 42, :account => { :name => "Hello again" }
394
401
  assigns(:opportunity).should == @opportunity
395
402
  @opportunity.contacts.should include(@contact)
396
403
  @contact.opportunities.should include(@opportunity)
@@ -405,7 +412,7 @@ describe OpportunitiesController do
405
412
  it "should associate opportunity with the existing account" do
406
413
  @account = FactoryGirl.create(:account, :id => 42)
407
414
 
408
- xhr :post, :create, :opportunity => { :name => "Hello world" }, :account => { :id => 42 }, :users => []
415
+ xhr :post, :create, :opportunity => { :name => "Hello world" }, :account => { :id => 42 }
409
416
  assigns(:opportunity).should == @opportunity
410
417
  @opportunity.account.should == @account
411
418
  @account.opportunities.should include(@opportunity)
@@ -413,7 +420,7 @@ describe OpportunitiesController do
413
420
 
414
421
  it "should update related campaign revenue if won" do
415
422
  @campaign = FactoryGirl.create(:campaign, :revenue => 0)
416
- @opportunity = FactoryGirl.build(:opportunity, :user => @current_user, :stage => "won", :amount => 1100, :discount => 100)
423
+ @opportunity = FactoryGirl.build(:opportunity, :user => current_user, :stage => "won", :amount => 1100, :discount => 100)
417
424
  Opportunity.stub!(:new).and_return(@opportunity)
418
425
 
419
426
  xhr :post, :create, :opportunity => { :name => "Hello world" }, :campaign => @campaign.id, :account => { :name => "Test Account" }
@@ -421,40 +428,44 @@ describe OpportunitiesController do
421
428
  @opportunity.campaign.should == @campaign.reload
422
429
  @campaign.revenue.to_i.should == 1000 # 1000 - 100 discount.
423
430
  end
431
+
432
+ it "should add a new comment to the newly created opportunity when specified" do
433
+ @opportunity = FactoryGirl.build(:opportunity, :user => current_user)
434
+ Opportunity.stub!(:new).and_return(@opportunity)
435
+
436
+ xhr :post, :create, :opportunity => { :name => "Opportunity Knocks" }, :account => { :name => "My Account" }, :comment_body => "Awesome comment is awesome"
437
+ @opportunity.reload.comments.map(&:comment).should include("Awesome comment is awesome")
438
+ end
424
439
  end
425
440
 
426
441
  describe "with invalid params" do
427
442
 
428
443
  it "should expose a newly created but unsaved opportunity as @opportunity with blank @account and render [create] template" do
429
- @account = Account.new(:user => @current_user)
430
- @opportunity = FactoryGirl.build(:opportunity, :name => nil, :campaign => nil, :user => @current_user,
444
+ @account = Account.new(:user => current_user)
445
+ @opportunity = FactoryGirl.build(:opportunity, :name => nil, :campaign => nil, :user => current_user,
431
446
  :account => @account)
432
447
  Opportunity.stub!(:new).and_return(@opportunity)
433
448
  @stage = Setting.unroll(:opportunity_stage)
434
- @users = [ FactoryGirl.create(:user) ]
435
- @accounts = [ FactoryGirl.create(:account, :user => @current_user) ]
449
+ @accounts = [ FactoryGirl.create(:account, :user => current_user) ]
436
450
 
437
451
  # Expect to redraw [create] form with blank account.
438
- xhr :post, :create, :opportunity => {}, :account => { :user_id => @current_user.id }
452
+ xhr :post, :create, :opportunity => {}, :account => { :user_id => current_user.id }
439
453
  assigns(:opportunity).should == @opportunity
440
- assigns(:users).should == @users
441
454
  assigns(:account).attributes.should == @account.attributes
442
455
  assigns(:accounts).should == @accounts
443
456
  response.should render_template("opportunities/create")
444
457
  end
445
458
 
446
459
  it "should expose a newly created but unsaved opportunity as @opportunity with existing @account and render [create] template" do
447
- @account = FactoryGirl.create(:account, :id => 42, :user => @current_user)
448
- @opportunity = FactoryGirl.build(:opportunity, :name => nil, :campaign => nil, :user => @current_user,
460
+ @account = FactoryGirl.create(:account, :id => 42, :user => current_user)
461
+ @opportunity = FactoryGirl.build(:opportunity, :name => nil, :campaign => nil, :user => current_user,
449
462
  :account => @account)
450
463
  Opportunity.stub!(:new).and_return(@opportunity)
451
464
  @stage = Setting.unroll(:opportunity_stage)
452
- @users = [ FactoryGirl.create(:user) ]
453
465
 
454
466
  # Expect to redraw [create] form with selected account.
455
- xhr :post, :create, :opportunity => {}, :account => { :id => 42, :user_id => @current_user.id }
467
+ xhr :post, :create, :opportunity => {}, :account => { :id => 42, :user_id => current_user.id }
456
468
  assigns(:opportunity).should == @opportunity
457
- assigns(:users).should == @users
458
469
  assigns(:account).should == @account
459
470
  assigns(:accounts).should == [ @account ]
460
471
  response.should render_template("opportunities/create")
@@ -464,7 +475,7 @@ describe OpportunitiesController do
464
475
  @campaign = FactoryGirl.create(:campaign, :id => 42)
465
476
 
466
477
  request.env["HTTP_REFERER"] = "http://localhost/campaigns/42"
467
- xhr :post, :create, :opportunity => { :name => nil }, :campaign => 42, :account => { :name => "Test Account" }, :users => []
478
+ xhr :post, :create, :opportunity => { :name => nil }, :campaign => 42, :account => { :name => "Test Account" }
468
479
  assigns(:campaign).should == @campaign
469
480
  response.should render_template("opportunities/create")
470
481
  end
@@ -473,7 +484,7 @@ describe OpportunitiesController do
473
484
  @contact = FactoryGirl.create(:contact, :id => 42)
474
485
 
475
486
  request.env["HTTP_REFERER"] = "http://localhost/contacts/42"
476
- xhr :post, :create, :opportunity => { :name => nil }, :contact => 42, :account => { :name => "Test Account" }, :users => []
487
+ xhr :post, :create, :opportunity => { :name => nil }, :contact => 42, :account => { :name => "Test Account" }
477
488
  assigns(:contact).should == @contact
478
489
  response.should render_template("opportunities/create")
479
490
  end
@@ -493,7 +504,7 @@ describe OpportunitiesController do
493
504
  @opportunity = FactoryGirl.create(:opportunity, :id => 42)
494
505
  @stage = Setting.unroll(:opportunity_stage)
495
506
 
496
- xhr :put, :update, :id => 42, :opportunity => { :name => "Hello world" }, :account => { :name => "Test Account" }, :users => %w(1 2 3)
507
+ xhr :put, :update, :id => 42, :opportunity => { :name => "Hello world" }, :account => { :name => "Test Account" }
497
508
  @opportunity.reload.name.should == "Hello world"
498
509
  assigns(:opportunity).should == @opportunity
499
510
  assigns(:stage).should == @stage
@@ -510,7 +521,7 @@ describe OpportunitiesController do
510
521
  end
511
522
 
512
523
  it "should find related account if called from account landing page" do
513
- @account = FactoryGirl.create(:account, :user => @current_user)
524
+ @account = FactoryGirl.create(:account, :user => current_user)
514
525
  @opportunity = FactoryGirl.create(:opportunity, :id => 42, :account => @account)
515
526
  request.env["HTTP_REFERER"] = "http://localhost/accounts/#{@account.id}"
516
527
 
@@ -519,7 +530,7 @@ describe OpportunitiesController do
519
530
  end
520
531
 
521
532
  it "should remove related account if blank :account param is given" do
522
- @account = FactoryGirl.create(:account, :user => @current_user)
533
+ @account = FactoryGirl.create(:account, :user => current_user)
523
534
  @opportunity = FactoryGirl.create(:opportunity, :id => 42, :account => @account)
524
535
  request.env["HTTP_REFERER"] = "http://localhost/accounts/#{@account.id}"
525
536
 
@@ -528,8 +539,8 @@ describe OpportunitiesController do
528
539
  end
529
540
 
530
541
  it "should find related campaign if called from campaign landing page" do
531
- @campaign = FactoryGirl.create(:campaign, :user => @current_user)
532
- @opportunity = FactoryGirl.create(:opportunity, :id => 42, :user => @current_user)
542
+ @campaign = FactoryGirl.create(:campaign, :user => current_user)
543
+ @opportunity = FactoryGirl.create(:opportunity, :id => 42, :user => current_user)
533
544
  @campaign.opportunities << @opportunity
534
545
  request.env["HTTP_REFERER"] = "http://localhost/campaigns/#{@campaign.id}"
535
546
 
@@ -553,20 +564,16 @@ describe OpportunitiesController do
553
564
  @opportunity = FactoryGirl.create(:opportunity, :id => 42, :account => @old_account)
554
565
 
555
566
  xhr :put, :update, :id => 42, :opportunity => { :name => "Hello" }, :account => { :id => 999 }
556
- @opportunity.reload
557
567
  assigns[:opportunity].should == @opportunity
558
- @opportunity.account.should == @new_account
568
+ assigns[:opportunity].account.should == @new_account
559
569
  end
560
570
 
561
571
  it "should update opportunity permissions when sharing with specific users" do
562
572
  @opportunity = FactoryGirl.create(:opportunity, :id => 42, :access => "Public")
563
- he = FactoryGirl.create(:user, :id => 7)
564
- she = FactoryGirl.create(:user, :id => 8)
565
573
 
566
- xhr :put, :update, :id => 42, :opportunity => { :name => "Hello", :access => "Shared" }, :users => %w(7 8), :account => { :name => "Test Account" }
567
- @opportunity.reload.access.should == "Shared"
568
- @opportunity.permissions.map(&:user_id).sort.should == [ 7, 8 ]
569
- assigns[:opportunity].should == @opportunity
574
+ xhr :put, :update, :id => 42, :opportunity => { :name => "Hello", :access => "Shared", :user_ids => [7, 8] }, :account => { :name => "Test Account" }
575
+ assigns[:opportunity].access.should == "Shared"
576
+ assigns[:opportunity].user_ids.sort.should == [ 7, 8 ]
570
577
  end
571
578
 
572
579
  it "should reload opportunity campaign if called from campaign landing page" do
@@ -581,7 +588,7 @@ describe OpportunitiesController do
581
588
  describe "updating campaign revenue (same campaign)" do
582
589
  it "should add to actual revenue when opportunity is closed/won" do
583
590
  @campaign = FactoryGirl.create(:campaign, :revenue => 1000)
584
- @opportunity = FactoryGirl.create(:opportunity, :campaign => @campaign, :stage => nil, :amount => 1100, :discount => 100)
591
+ @opportunity = FactoryGirl.create(:opportunity, :campaign => @campaign, :stage => 'prospecting', :amount => 1100, :discount => 100)
585
592
 
586
593
  xhr :put, :update, :id => @opportunity, :opportunity => { :stage => "won" }, :account => { :name => "Test Account" }
587
594
  @campaign.reload.revenue.to_i.should == 2000 # 1000 -> 2000
@@ -592,13 +599,13 @@ describe OpportunitiesController do
592
599
  @opportunity = FactoryGirl.create(:opportunity, :campaign => @campaign, :stage => "won", :amount => 1100, :discount => 100)
593
600
  # @campaign.revenue is now $2000 since we created winning opportunity.
594
601
 
595
- xhr :put, :update, :id => @opportunity, :opportunity => { :stage => nil }, :account => { :name => "Test Account" }
602
+ xhr :put, :update, :id => @opportunity, :opportunity => { :stage => 'prospecting' }, :account => { :name => "Test Account" }
596
603
  @campaign.reload.revenue.to_i.should == 1000 # Should be adjusted back to $1000.
597
604
  end
598
605
 
599
606
  it "should not update actual revenue when opportunity is not closed/won" do
600
607
  @campaign = FactoryGirl.create(:campaign, :revenue => 1000)
601
- @opportunity = FactoryGirl.create(:opportunity, :campaign => @campaign, :stage => nil, :amount => 1100, :discount => 100)
608
+ @opportunity = FactoryGirl.create(:opportunity, :campaign => @campaign, :stage => 'prospecting', :amount => 1100, :discount => 100)
602
609
 
603
610
  xhr :put, :update, :id => @opportunity, :opportunity => { :stage => "lost" }, :account => { :name => "Test Account" }
604
611
  @campaign.reload.revenue.to_i.should == 1000 # Stays the same.
@@ -608,7 +615,7 @@ describe OpportunitiesController do
608
615
  describe "updating campaign revenue (diferent campaigns)" do
609
616
  it "should update newly assigned campaign when opportunity is closed/won" do
610
617
  @campaigns = { :old => FactoryGirl.create(:campaign, :revenue => 1000), :new => FactoryGirl.create(:campaign, :revenue => 1000) }
611
- @opportunity = FactoryGirl.create(:opportunity, :campaign => @campaigns[:old], :stage => nil, :amount => 1100, :discount => 100)
618
+ @opportunity = FactoryGirl.create(:opportunity, :campaign => @campaigns[:old], :stage => 'prospecting', :amount => 1100, :discount => 100)
612
619
 
613
620
  xhr :put, :update, :id => @opportunity, :opportunity => { :stage => "won", :campaign_id => @campaigns[:new].id }, :account => { :name => "Test Account" }
614
621
 
@@ -621,14 +628,14 @@ describe OpportunitiesController do
621
628
  @opportunity = FactoryGirl.create(:opportunity, :campaign => @campaigns[:old], :stage => "won", :amount => 1100, :discount => 100)
622
629
  # @campaign.revenue is now $2000 since we created winning opportunity.
623
630
 
624
- xhr :put, :update, :id => @opportunity, :opportunity => { :stage => nil, :campaign_id => @campaigns[:new].id }, :account => { :name => "Test Account" }
631
+ xhr :put, :update, :id => @opportunity, :opportunity => { :stage => 'prospecting', :campaign_id => @campaigns[:new].id }, :account => { :name => "Test Account" }
625
632
  @campaigns[:old].reload.revenue.to_i.should == 1000 # Should be adjusted back to $1000.
626
633
  @campaigns[:new].reload.revenue.to_i.should == 1000 # Stays the same.
627
634
  end
628
635
 
629
636
  it "should not update campaigns when opportunity is not closed/won" do
630
637
  @campaigns = { :old => FactoryGirl.create(:campaign, :revenue => 1000), :new => FactoryGirl.create(:campaign, :revenue => 1000) }
631
- @opportunity = FactoryGirl.create(:opportunity, :campaign => @campaigns[:old], :stage => nil, :amount => 1100, :discount => 100)
638
+ @opportunity = FactoryGirl.create(:opportunity, :campaign => @campaigns[:old], :stage => 'prospecting', :amount => 1100, :discount => 100)
632
639
 
633
640
  xhr :put, :update, :id => @opportunity, :opportunity => { :stage => "lost", :campaign_id => @campaigns[:new].id }, :account => { :name => "Test Account" }
634
641
  @campaigns[:old].reload.revenue.to_i.should == 1000 # Stays the same.
@@ -638,7 +645,7 @@ describe OpportunitiesController do
638
645
 
639
646
  describe "opportunity got deleted or otherwise unavailable" do
640
647
  it "should reload current page with the flash message if the opportunity got deleted" do
641
- @opportunity = FactoryGirl.create(:opportunity, :user => @current_user)
648
+ @opportunity = FactoryGirl.create(:opportunity, :user => current_user)
642
649
  @opportunity.destroy
643
650
 
644
651
  xhr :put, :update, :id => @opportunity.id
@@ -684,7 +691,7 @@ describe OpportunitiesController do
684
691
  #----------------------------------------------------------------------------
685
692
  describe "responding to DELETE destroy" do
686
693
  before do
687
- @opportunity = FactoryGirl.create(:opportunity, :user => @current_user)
694
+ @opportunity = FactoryGirl.create(:opportunity, :user => current_user)
688
695
  end
689
696
 
690
697
  describe "AJAX request" do
@@ -734,7 +741,7 @@ describe OpportunitiesController do
734
741
 
735
742
  it "should reload campaiign to be able to refresh its summary" do
736
743
  @account = FactoryGirl.create(:account)
737
- @opportunity = FactoryGirl.create(:opportunity, :user => @current_user, :account => @account)
744
+ @opportunity = FactoryGirl.create(:opportunity, :user => current_user, :account => @account)
738
745
  request.env["HTTP_REFERER"] = "http://localhost/accounts/#{@account.id}"
739
746
 
740
747
  xhr :delete, :destroy, :id => @opportunity.id
@@ -744,7 +751,7 @@ describe OpportunitiesController do
744
751
 
745
752
  it "should reload campaiign to be able to refresh its summary" do
746
753
  @campaign = FactoryGirl.create(:campaign)
747
- @opportunity = FactoryGirl.create(:opportunity, :user => @current_user, :campaign => @campaign)
754
+ @opportunity = FactoryGirl.create(:opportunity, :user => current_user, :campaign => @campaign)
748
755
  request.env["HTTP_REFERER"] = "http://localhost/campaigns/#{@campaign.id}"
749
756
 
750
757
  xhr :delete, :destroy, :id => @opportunity.id
@@ -755,7 +762,7 @@ describe OpportunitiesController do
755
762
 
756
763
  describe "opportunity got deleted or otherwise unavailable" do
757
764
  it "should reload current page is the opportunity got deleted" do
758
- @opportunity = FactoryGirl.create(:opportunity, :user => @current_user)
765
+ @opportunity = FactoryGirl.create(:opportunity, :user => current_user)
759
766
  @opportunity.destroy
760
767
 
761
768
  xhr :delete, :destroy, :id => @opportunity.id
@@ -781,7 +788,7 @@ describe OpportunitiesController do
781
788
  end
782
789
 
783
790
  it "should redirect to opportunity index with the flash message is the opportunity got deleted" do
784
- @opportunity = FactoryGirl.create(:opportunity, :user => @current_user)
791
+ @opportunity = FactoryGirl.create(:opportunity, :user => current_user)
785
792
  @opportunity.destroy
786
793
 
787
794
  delete :destroy, :id => @opportunity.id
@@ -846,53 +853,31 @@ describe OpportunitiesController do
846
853
  #----------------------------------------------------------------------------
847
854
  describe "responding to POST auto_complete" do
848
855
  before do
849
- @auto_complete_matches = [ FactoryGirl.create(:opportunity, :name => "Hello World", :user => @current_user) ]
856
+ @auto_complete_matches = [ FactoryGirl.create(:opportunity, :name => "Hello World", :user => current_user) ]
850
857
  end
851
858
 
852
859
  it_should_behave_like("auto complete")
853
860
  end
854
861
 
855
- # GET /opportunities/options AJAX
856
- #----------------------------------------------------------------------------
857
- describe "responding to GET options" do
858
- it "should set current user preferences when showing options" do
859
- @per_page = FactoryGirl.create(:preference, :user => @current_user, :name => "opportunities_per_page", :value => Base64.encode64(Marshal.dump(42)))
860
- @outline = FactoryGirl.create(:preference, :user => @current_user, :name => "opportunities_outline", :value => Base64.encode64(Marshal.dump("option_long")))
861
- @sort_by = FactoryGirl.create(:preference, :user => @current_user, :name => "opportunities_sort_by", :value => Base64.encode64(Marshal.dump("opportunities.name ASC")))
862
-
863
- xhr :get, :options
864
- assigns[:per_page].should == 42
865
- assigns[:outline].should == "option_long"
866
- assigns[:sort_by].should == "opportunities.name ASC"
867
- end
868
-
869
- it "should not assign instance variables when hiding options" do
870
- xhr :get, :options, :cancel => "true"
871
- assigns[:per_page].should == nil
872
- assigns[:outline].should == nil
873
- assigns[:sort_by].should == nil
874
- end
875
- end
876
-
877
862
  # POST /opportunities/redraw AJAX
878
863
  #----------------------------------------------------------------------------
879
864
  describe "responding to POST redraw" do
880
865
  it "should save user selected opportunity preference" do
881
- xhr :post, :redraw, :per_page => 42, :outline => "brief", :sort_by => "name"
882
- @current_user.preference[:opportunities_per_page].should == "42"
883
- @current_user.preference[:opportunities_outline].should == "brief"
884
- @current_user.preference[:opportunities_sort_by].should == "opportunities.name ASC"
866
+ xhr :post, :redraw, :per_page => 42, :view => "brief", :sort_by => "name"
867
+ current_user.preference[:opportunities_per_page].should == "42"
868
+ current_user.preference[:opportunities_index_view].should == "brief"
869
+ current_user.preference[:opportunities_sort_by].should == "opportunities.name ASC"
885
870
  end
886
871
 
887
872
  it "should reset current page to 1" do
888
- xhr :post, :redraw, :per_page => 42, :outline => "brief", :sort_by => "name"
873
+ xhr :post, :redraw, :per_page => 42, :view => "brief", :sort_by => "name"
889
874
  session[:opportunities_current_page].should == 1
890
875
  end
891
876
 
892
877
  it "should select @opportunities and render [index] template" do
893
878
  @opportunities = [
894
- FactoryGirl.create(:opportunity, :name => "A", :user => @current_user),
895
- FactoryGirl.create(:opportunity, :name => "B", :user => @current_user)
879
+ FactoryGirl.create(:opportunity, :name => "A", :user => current_user),
880
+ FactoryGirl.create(:opportunity, :name => "B", :user => current_user)
896
881
  ]
897
882
 
898
883
  xhr :post, :redraw, :per_page => 1, :sort_by => "name"
@@ -907,7 +892,7 @@ describe OpportunitiesController do
907
892
 
908
893
  it "should expose filtered opportunities as @opportunity and render [filter] template" do
909
894
  session[:opportunities_filter] = "negotiation,analysis"
910
- @opportunities = [ FactoryGirl.create(:opportunity, :stage => "prospecting", :user => @current_user) ]
895
+ @opportunities = [ FactoryGirl.create(:opportunity, :stage => "prospecting", :user => current_user) ]
911
896
  @stage = Setting.unroll(:opportunity_stage)
912
897
 
913
898
  xhr :get, :filter, :stage => "prospecting"