fat_free_crm 0.11.0

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

Potentially problematic release.


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

Files changed (850) hide show
  1. data/.gitignore +32 -0
  2. data/.travis.yml +48 -0
  3. data/CHANGELOG +1839 -0
  4. data/CONTRIBUTORS +50 -0
  5. data/Gemfile +40 -0
  6. data/Gemfile.ci +13 -0
  7. data/Gemfile.lock +256 -0
  8. data/Guardfile +45 -0
  9. data/LICENSE +620 -0
  10. data/Procfile +1 -0
  11. data/README.md +239 -0
  12. data/Rakefile +9 -0
  13. data/acceptance/acceptance_helper.rb +7 -0
  14. data/acceptance/accounts_spec.rb +74 -0
  15. data/acceptance/support/browser.rb +13 -0
  16. data/acceptance/support/database_cleaner.rb +16 -0
  17. data/acceptance/support/headless.rb +15 -0
  18. data/acceptance/support/helpers.rb +19 -0
  19. data/acceptance/support/maintain_sessions.rb +5 -0
  20. data/acceptance/support/paths.rb +9 -0
  21. data/app/assets/images/1x1.gif +0 -0
  22. data/app/assets/images/asterisk.gif +0 -0
  23. data/app/assets/images/avatar.jpg +0 -0
  24. data/app/assets/images/blog.gif +0 -0
  25. data/app/assets/images/facebook-close.gif +0 -0
  26. data/app/assets/images/facebook.gif +0 -0
  27. data/app/assets/images/iconset_attribution.png +0 -0
  28. data/app/assets/images/info.png +0 -0
  29. data/app/assets/images/info_tiny.png +0 -0
  30. data/app/assets/images/linkedin.gif +0 -0
  31. data/app/assets/images/loading.gif +0 -0
  32. data/app/assets/images/skype.gif +0 -0
  33. data/app/assets/images/sortable.gif +0 -0
  34. data/app/assets/images/stars.gif +0 -0
  35. data/app/assets/images/twitter.gif +0 -0
  36. data/app/assets/javascripts/admin/field_groups.js.coffee +3 -0
  37. data/app/assets/javascripts/application.js.erb +42 -0
  38. data/app/assets/javascripts/crm.js +487 -0
  39. data/app/assets/javascripts/crm_chosen.js.coffee +28 -0
  40. data/app/assets/javascripts/crm_classes.js +230 -0
  41. data/app/assets/javascripts/crm_fields.js +47 -0
  42. data/app/assets/javascripts/crm_loginout.js +41 -0
  43. data/app/assets/javascripts/jquery-noconflict.js +1 -0
  44. data/app/assets/javascripts/lists.js.coffee +37 -0
  45. data/app/assets/javascripts/search.js.coffee +40 -0
  46. data/app/assets/stylesheets/admin/field_groups.css.scss +3 -0
  47. data/app/assets/stylesheets/application.css.erb +37 -0
  48. data/app/assets/stylesheets/base.scss +90 -0
  49. data/app/assets/stylesheets/common.scss +688 -0
  50. data/app/assets/stylesheets/ffcrm_chosen.scss +64 -0
  51. data/app/assets/stylesheets/fields.scss +8 -0
  52. data/app/assets/stylesheets/header.scss +129 -0
  53. data/app/assets/stylesheets/lists.css.scss +3 -0
  54. data/app/assets/stylesheets/print.css.scss +80 -0
  55. data/app/assets/stylesheets/rails.scss +136 -0
  56. data/app/assets/stylesheets/safari.scss +23 -0
  57. data/app/controllers/accounts_controller.rb +207 -0
  58. data/app/controllers/admin/application_controller.rb +42 -0
  59. data/app/controllers/admin/field_groups_controller.rb +128 -0
  60. data/app/controllers/admin/fields_controller.rb +148 -0
  61. data/app/controllers/admin/plugins_controller.rb +33 -0
  62. data/app/controllers/admin/settings_controller.rb +31 -0
  63. data/app/controllers/admin/tags_controller.rb +131 -0
  64. data/app/controllers/admin/users_controller.rb +200 -0
  65. data/app/controllers/application_controller.rb +219 -0
  66. data/app/controllers/authentications_controller.rb +66 -0
  67. data/app/controllers/base_controller.rb +155 -0
  68. data/app/controllers/campaigns_controller.rb +205 -0
  69. data/app/controllers/comments_controller.rb +145 -0
  70. data/app/controllers/contacts_controller.rb +214 -0
  71. data/app/controllers/emails_controller.rb +64 -0
  72. data/app/controllers/home_controller.rb +170 -0
  73. data/app/controllers/leads_controller.rb +286 -0
  74. data/app/controllers/lists_controller.rb +27 -0
  75. data/app/controllers/opportunities_controller.rb +256 -0
  76. data/app/controllers/passwords_controller.rb +78 -0
  77. data/app/controllers/tasks_controller.rb +213 -0
  78. data/app/controllers/users_controller.rb +163 -0
  79. data/app/helpers/accounts_helper.rb +54 -0
  80. data/app/helpers/addresses_helper.rb +28 -0
  81. data/app/helpers/admin/application_helper.rb +29 -0
  82. data/app/helpers/admin/field_groups_helper.rb +36 -0
  83. data/app/helpers/admin/fields_helper.rb +32 -0
  84. data/app/helpers/admin/plugins_helper.rb +20 -0
  85. data/app/helpers/admin/settings_helper.rb +20 -0
  86. data/app/helpers/admin/tags_helper.rb +22 -0
  87. data/app/helpers/admin/users_helper.rb +65 -0
  88. data/app/helpers/application_helper.rb +421 -0
  89. data/app/helpers/authentications_helper.rb +20 -0
  90. data/app/helpers/campaigns_helper.rb +55 -0
  91. data/app/helpers/comments_helper.rb +20 -0
  92. data/app/helpers/contacts_helper.rb +34 -0
  93. data/app/helpers/crm_tags_helper.rb +50 -0
  94. data/app/helpers/emails_helper.rb +19 -0
  95. data/app/helpers/fields_helper.rb +20 -0
  96. data/app/helpers/home_helper.rb +70 -0
  97. data/app/helpers/leads_helper.rb +116 -0
  98. data/app/helpers/lists_helper.rb +2 -0
  99. data/app/helpers/opportunities_helper.rb +53 -0
  100. data/app/helpers/passwords_helper.rb +20 -0
  101. data/app/helpers/tasks_helper.rb +176 -0
  102. data/app/helpers/users_helper.rb +40 -0
  103. data/app/inputs/date_time_input.rb +39 -0
  104. data/app/inputs/text_input.rb +6 -0
  105. data/app/models/base/account.rb +138 -0
  106. data/app/models/base/account_contact.rb +37 -0
  107. data/app/models/base/account_opportunity.rb +37 -0
  108. data/app/models/base/campaign.rb +123 -0
  109. data/app/models/base/contact.rb +191 -0
  110. data/app/models/base/contact_opportunity.rb +38 -0
  111. data/app/models/base/lead.rb +188 -0
  112. data/app/models/base/opportunity.rb +188 -0
  113. data/app/models/base/task.rb +241 -0
  114. data/app/models/fields/core_field.rb +48 -0
  115. data/app/models/fields/custom_field.rb +138 -0
  116. data/app/models/fields/field.rb +124 -0
  117. data/app/models/fields/field_group.rb +81 -0
  118. data/app/models/list.rb +8 -0
  119. data/app/models/mailers/notifier.rb +44 -0
  120. data/app/models/observers/activity_observer.rb +84 -0
  121. data/app/models/polymorphic/activity.rb +106 -0
  122. data/app/models/polymorphic/address.rb +58 -0
  123. data/app/models/polymorphic/avatar.rb +58 -0
  124. data/app/models/polymorphic/comment.rb +55 -0
  125. data/app/models/polymorphic/email.rb +69 -0
  126. data/app/models/polymorphic/tag.rb +14 -0
  127. data/app/models/polymorphic/tagging.rb +2 -0
  128. data/app/models/setting.rb +142 -0
  129. data/app/models/users/authentication.rb +64 -0
  130. data/app/models/users/permission.rb +36 -0
  131. data/app/models/users/preference.rb +62 -0
  132. data/app/models/users/user.rb +171 -0
  133. data/app/views/accounts/_account.html.haml +35 -0
  134. data/app/views/accounts/_contact_info.html.haml +37 -0
  135. data/app/views/accounts/_edit.html.haml +19 -0
  136. data/app/views/accounts/_new.html.haml +19 -0
  137. data/app/views/accounts/_options.html.haml +20 -0
  138. data/app/views/accounts/_permissions.html.haml +24 -0
  139. data/app/views/accounts/_sidebar_index.html.haml +21 -0
  140. data/app/views/accounts/_sidebar_show.html.haml +57 -0
  141. data/app/views/accounts/_top_section.html.haml +29 -0
  142. data/app/views/accounts/contacts.js.rjs +3 -0
  143. data/app/views/accounts/create.js.rjs +15 -0
  144. data/app/views/accounts/destroy.js.rjs +3 -0
  145. data/app/views/accounts/edit.js.rjs +35 -0
  146. data/app/views/accounts/index.html.haml +25 -0
  147. data/app/views/accounts/index.js.rjs +6 -0
  148. data/app/views/accounts/new.js.rjs +11 -0
  149. data/app/views/accounts/opportunities.js.rjs +3 -0
  150. data/app/views/accounts/options.js.rjs +10 -0
  151. data/app/views/accounts/show.html.haml +42 -0
  152. data/app/views/accounts/update.js.rjs +17 -0
  153. data/app/views/admin/field_groups/_confirm.html.haml +5 -0
  154. data/app/views/admin/field_groups/_edit.html.haml +8 -0
  155. data/app/views/admin/field_groups/_field_group.html.haml +27 -0
  156. data/app/views/admin/field_groups/_new.html.haml +10 -0
  157. data/app/views/admin/field_groups/_top_section.html.haml +13 -0
  158. data/app/views/admin/field_groups/confirm.js.rjs +6 -0
  159. data/app/views/admin/field_groups/create.js.rjs +21 -0
  160. data/app/views/admin/field_groups/destroy.js.rjs +11 -0
  161. data/app/views/admin/field_groups/edit.js.rjs +14 -0
  162. data/app/views/admin/field_groups/new.js.rjs +9 -0
  163. data/app/views/admin/field_groups/update.js.rjs +9 -0
  164. data/app/views/admin/fields/_edit.html.haml +9 -0
  165. data/app/views/admin/fields/_field.html.haml +15 -0
  166. data/app/views/admin/fields/_new.html.haml +10 -0
  167. data/app/views/admin/fields/_options.html.haml +12 -0
  168. data/app/views/admin/fields/_sidebar_index.html.haml +1 -0
  169. data/app/views/admin/fields/_sidebar_show.html.haml +1 -0
  170. data/app/views/admin/fields/_sort_by.html.haml +10 -0
  171. data/app/views/admin/fields/_top_section.html.haml +54 -0
  172. data/app/views/admin/fields/create.js.rjs +16 -0
  173. data/app/views/admin/fields/destroy.js.rjs +11 -0
  174. data/app/views/admin/fields/edit.js.rjs +35 -0
  175. data/app/views/admin/fields/index.html.haml +36 -0
  176. data/app/views/admin/fields/index.js.rjs +6 -0
  177. data/app/views/admin/fields/new.js.rjs +8 -0
  178. data/app/views/admin/fields/options.js.rjs +10 -0
  179. data/app/views/admin/fields/show.html.haml +41 -0
  180. data/app/views/admin/fields/update.js.rjs +17 -0
  181. data/app/views/admin/plugins/_plugin.html.haml +13 -0
  182. data/app/views/admin/plugins/index.html.haml +9 -0
  183. data/app/views/admin/settings/index.html.haml +3 -0
  184. data/app/views/admin/tags/_confirm.html.haml +5 -0
  185. data/app/views/admin/tags/_edit.html.haml +9 -0
  186. data/app/views/admin/tags/_new.html.haml +10 -0
  187. data/app/views/admin/tags/_tag.html.haml +29 -0
  188. data/app/views/admin/tags/_top_section.html.haml +6 -0
  189. data/app/views/admin/tags/confirm.js.rjs +6 -0
  190. data/app/views/admin/tags/create.js.rjs +12 -0
  191. data/app/views/admin/tags/destroy.js.rjs +11 -0
  192. data/app/views/admin/tags/edit.js.rjs +21 -0
  193. data/app/views/admin/tags/index.html.haml +17 -0
  194. data/app/views/admin/tags/new.js.rjs +8 -0
  195. data/app/views/admin/tags/update.js.rjs +10 -0
  196. data/app/views/admin/users/_confirm.html.haml +5 -0
  197. data/app/views/admin/users/_edit.html.haml +11 -0
  198. data/app/views/admin/users/_new.html.haml +11 -0
  199. data/app/views/admin/users/_profile.html.haml +43 -0
  200. data/app/views/admin/users/_sidebar_index.html.haml +2 -0
  201. data/app/views/admin/users/_user.html.haml +56 -0
  202. data/app/views/admin/users/confirm.js.rjs +6 -0
  203. data/app/views/admin/users/create.js.rjs +11 -0
  204. data/app/views/admin/users/destroy.js.rjs +11 -0
  205. data/app/views/admin/users/edit.js.rjs +21 -0
  206. data/app/views/admin/users/index.html.haml +13 -0
  207. data/app/views/admin/users/index.js.rjs +2 -0
  208. data/app/views/admin/users/new.js.rjs +8 -0
  209. data/app/views/admin/users/reactivate.js.rjs +3 -0
  210. data/app/views/admin/users/show.html.haml +5 -0
  211. data/app/views/admin/users/suspend.js.rjs +3 -0
  212. data/app/views/admin/users/update.js.rjs +10 -0
  213. data/app/views/authentications/new.html.haml +31 -0
  214. data/app/views/base/_advanced_search.html.haml +12 -0
  215. data/app/views/base/_condition_fields.html.haml +14 -0
  216. data/app/views/base/_grouping_fields.html.haml +12 -0
  217. data/app/views/base/_sort_fields.html.haml +3 -0
  218. data/app/views/base/advanced_search.js.rjs +9 -0
  219. data/app/views/campaigns/_campaign.html.haml +17 -0
  220. data/app/views/campaigns/_edit.html.haml +16 -0
  221. data/app/views/campaigns/_metrics.html.haml +16 -0
  222. data/app/views/campaigns/_new.html.haml +15 -0
  223. data/app/views/campaigns/_objectives.html.haml +30 -0
  224. data/app/views/campaigns/_options.html.haml +20 -0
  225. data/app/views/campaigns/_permissions.html.haml +24 -0
  226. data/app/views/campaigns/_sidebar_index.html.haml +20 -0
  227. data/app/views/campaigns/_sidebar_show.html.haml +91 -0
  228. data/app/views/campaigns/_status.html.haml +24 -0
  229. data/app/views/campaigns/_top_section.html.haml +29 -0
  230. data/app/views/campaigns/create.js.rjs +21 -0
  231. data/app/views/campaigns/destroy.js.rjs +3 -0
  232. data/app/views/campaigns/edit.js.rjs +38 -0
  233. data/app/views/campaigns/index.html.haml +25 -0
  234. data/app/views/campaigns/index.js.rjs +6 -0
  235. data/app/views/campaigns/leads.js.rjs +3 -0
  236. data/app/views/campaigns/new.js.rjs +13 -0
  237. data/app/views/campaigns/opportunities.js.rjs +3 -0
  238. data/app/views/campaigns/options.js.rjs +10 -0
  239. data/app/views/campaigns/show.html.haml +44 -0
  240. data/app/views/campaigns/update.js.rjs +23 -0
  241. data/app/views/comments/_comment.html.haml +25 -0
  242. data/app/views/comments/_edit.html.haml +12 -0
  243. data/app/views/comments/_new.html.haml +27 -0
  244. data/app/views/comments/create.js.rjs +11 -0
  245. data/app/views/comments/destroy.js.rjs +6 -0
  246. data/app/views/comments/edit.js.rjs +11 -0
  247. data/app/views/comments/new.js.rjs +12 -0
  248. data/app/views/comments/update.js.rjs +11 -0
  249. data/app/views/contacts/_contact.html.haml +34 -0
  250. data/app/views/contacts/_edit.html.haml +17 -0
  251. data/app/views/contacts/_extra.html.haml +36 -0
  252. data/app/views/contacts/_new.html.haml +17 -0
  253. data/app/views/contacts/_options.html.haml +21 -0
  254. data/app/views/contacts/_permissions.html.haml +24 -0
  255. data/app/views/contacts/_sidebar_index.html.haml +3 -0
  256. data/app/views/contacts/_sidebar_show.html.haml +41 -0
  257. data/app/views/contacts/_top_section.html.haml +54 -0
  258. data/app/views/contacts/_web.html.haml +31 -0
  259. data/app/views/contacts/create.js.rjs +20 -0
  260. data/app/views/contacts/destroy.js.rjs +7 -0
  261. data/app/views/contacts/edit.js.rjs +38 -0
  262. data/app/views/contacts/index.html.haml +26 -0
  263. data/app/views/contacts/index.js.rjs +6 -0
  264. data/app/views/contacts/new.js.rjs +13 -0
  265. data/app/views/contacts/opportunities.js.rjs +3 -0
  266. data/app/views/contacts/options.js.rjs +10 -0
  267. data/app/views/contacts/show.html.haml +38 -0
  268. data/app/views/contacts/update.js.rjs +22 -0
  269. data/app/views/emails/_email.html.haml +27 -0
  270. data/app/views/emails/destroy.js.rjs +6 -0
  271. data/app/views/fields/_group.html.haml +20 -0
  272. data/app/views/fields/_groups.html.haml +11 -0
  273. data/app/views/fields/_sidebar_show.html.haml +8 -0
  274. data/app/views/fields/group.js.rjs +7 -0
  275. data/app/views/home/_actions_menu.html.haml +8 -0
  276. data/app/views/home/_activity.html.haml +22 -0
  277. data/app/views/home/_assets_menu.html.haml +7 -0
  278. data/app/views/home/_duration_menu.html.haml +8 -0
  279. data/app/views/home/_options.html.haml +14 -0
  280. data/app/views/home/_users_menu.html.haml +8 -0
  281. data/app/views/home/index.atom.builder +24 -0
  282. data/app/views/home/index.html.haml +19 -0
  283. data/app/views/home/index.js.rjs +6 -0
  284. data/app/views/home/index.rss.builder +20 -0
  285. data/app/views/home/options.js.rjs +8 -0
  286. data/app/views/layouts/500.html.haml +29 -0
  287. data/app/views/layouts/_about.html.haml +17 -0
  288. data/app/views/layouts/_footer.html.haml +13 -0
  289. data/app/views/layouts/_header.html.haml +20 -0
  290. data/app/views/layouts/_jumpbox.html.haml +32 -0
  291. data/app/views/layouts/_sidebar.html.haml +14 -0
  292. data/app/views/layouts/_tabbed.html.haml +19 -0
  293. data/app/views/layouts/_tabless.html.haml +3 -0
  294. data/app/views/layouts/admin/_header.html.haml +14 -0
  295. data/app/views/layouts/admin/application.html.haml +25 -0
  296. data/app/views/layouts/application.html.haml +43 -0
  297. data/app/views/leads/_contact.html.haml +38 -0
  298. data/app/views/leads/_convert.html.haml +36 -0
  299. data/app/views/leads/_convert_permissions.html.haml +26 -0
  300. data/app/views/leads/_edit.html.haml +21 -0
  301. data/app/views/leads/_lead.html.haml +43 -0
  302. data/app/views/leads/_new.html.haml +21 -0
  303. data/app/views/leads/_opportunity.html.haml +37 -0
  304. data/app/views/leads/_options.html.haml +21 -0
  305. data/app/views/leads/_permissions.html.haml +28 -0
  306. data/app/views/leads/_sidebar_index.html.haml +20 -0
  307. data/app/views/leads/_sidebar_show.html.haml +58 -0
  308. data/app/views/leads/_status.html.haml +36 -0
  309. data/app/views/leads/_top_section.html.haml +29 -0
  310. data/app/views/leads/_web.html.haml +31 -0
  311. data/app/views/leads/convert.js.rjs +38 -0
  312. data/app/views/leads/create.js.rjs +20 -0
  313. data/app/views/leads/destroy.js.rjs +7 -0
  314. data/app/views/leads/edit.js.rjs +38 -0
  315. data/app/views/leads/index.html.haml +25 -0
  316. data/app/views/leads/index.js.rjs +6 -0
  317. data/app/views/leads/new.js.rjs +11 -0
  318. data/app/views/leads/options.js.rjs +10 -0
  319. data/app/views/leads/promote.js.rjs +28 -0
  320. data/app/views/leads/reject.js.rjs +10 -0
  321. data/app/views/leads/show.html.haml +35 -0
  322. data/app/views/leads/update.js.rjs +27 -0
  323. data/app/views/lists/create.js.rjs +9 -0
  324. data/app/views/lists/destroy.js.rjs +1 -0
  325. data/app/views/notifier/dropbox_ack_notification.html.haml +9 -0
  326. data/app/views/notifier/password_reset_instructions.html.haml +6 -0
  327. data/app/views/opportunities/_edit.html.haml +16 -0
  328. data/app/views/opportunities/_new.html.haml +16 -0
  329. data/app/views/opportunities/_opportunity.html.haml +45 -0
  330. data/app/views/opportunities/_options.html.haml +20 -0
  331. data/app/views/opportunities/_permissions.html.haml +24 -0
  332. data/app/views/opportunities/_sidebar_index.html.haml +20 -0
  333. data/app/views/opportunities/_sidebar_show.html.haml +61 -0
  334. data/app/views/opportunities/_top_section.html.haml +65 -0
  335. data/app/views/opportunities/contacts.js.rjs +3 -0
  336. data/app/views/opportunities/create.js.rjs +31 -0
  337. data/app/views/opportunities/destroy.js.rjs +11 -0
  338. data/app/views/opportunities/edit.js.rjs +39 -0
  339. data/app/views/opportunities/index.html.haml +28 -0
  340. data/app/views/opportunities/index.js.rjs +6 -0
  341. data/app/views/opportunities/new.js.rjs +16 -0
  342. data/app/views/opportunities/options.js.rjs +10 -0
  343. data/app/views/opportunities/show.html.haml +36 -0
  344. data/app/views/opportunities/update.js.rjs +27 -0
  345. data/app/views/passwords/edit.html.haml +15 -0
  346. data/app/views/passwords/new.html.haml +10 -0
  347. data/app/views/shared/_address.html.haml +44 -0
  348. data/app/views/shared/_address_show.html.haml +24 -0
  349. data/app/views/shared/_comment.html.haml +11 -0
  350. data/app/views/shared/_edit_comment.html.haml +13 -0
  351. data/app/views/shared/_empty.html.haml +8 -0
  352. data/app/views/shared/_export.html.haml +1 -0
  353. data/app/views/shared/_inline_styles.html.haml +31 -0
  354. data/app/views/shared/_lists.html.haml +25 -0
  355. data/app/views/shared/_naming.html.haml +9 -0
  356. data/app/views/shared/_outline.html.haml +9 -0
  357. data/app/views/shared/_paginate.haml +1 -0
  358. data/app/views/shared/_per_page.html.haml +10 -0
  359. data/app/views/shared/_recent.html.haml +4 -0
  360. data/app/views/shared/_recently.html.haml +7 -0
  361. data/app/views/shared/_search.html.haml +11 -0
  362. data/app/views/shared/_select_popup.html.haml +21 -0
  363. data/app/views/shared/_sort_by.html.haml +10 -0
  364. data/app/views/shared/_tags.html.haml +9 -0
  365. data/app/views/shared/_tasks.html.haml +10 -0
  366. data/app/views/shared/_timeline.html.haml +3 -0
  367. data/app/views/shared/_total.html.haml +4 -0
  368. data/app/views/shared/attach.js.rjs +24 -0
  369. data/app/views/shared/auto_complete.html.haml +10 -0
  370. data/app/views/shared/discard.rjs +7 -0
  371. data/app/views/shared/index.atom.builder +34 -0
  372. data/app/views/shared/index.rss.builder +31 -0
  373. data/app/views/tasks/_assigned.html.haml +47 -0
  374. data/app/views/tasks/_completed.html.haml +23 -0
  375. data/app/views/tasks/_edit.html.haml +19 -0
  376. data/app/views/tasks/_empty.html.haml +4 -0
  377. data/app/views/tasks/_new.html.haml +14 -0
  378. data/app/views/tasks/_pending.html.haml +52 -0
  379. data/app/views/tasks/_related.html.haml +33 -0
  380. data/app/views/tasks/_selector.html.haml +8 -0
  381. data/app/views/tasks/_sidebar_index.html.haml +18 -0
  382. data/app/views/tasks/_title.html.haml +8 -0
  383. data/app/views/tasks/_top_section.html.haml +32 -0
  384. data/app/views/tasks/complete.js.rjs +17 -0
  385. data/app/views/tasks/create.js.rjs +42 -0
  386. data/app/views/tasks/destroy.js.rjs +7 -0
  387. data/app/views/tasks/discard.rjs +1 -0
  388. data/app/views/tasks/edit.js.rjs +25 -0
  389. data/app/views/tasks/filter.js.rjs +1 -0
  390. data/app/views/tasks/index.html.haml +20 -0
  391. data/app/views/tasks/new.js.rjs +11 -0
  392. data/app/views/tasks/update.js.rjs +22 -0
  393. data/app/views/users/_avatar.html.haml +20 -0
  394. data/app/views/users/_languages.html.haml +9 -0
  395. data/app/views/users/_password.html.haml +27 -0
  396. data/app/views/users/_profile.html.haml +67 -0
  397. data/app/views/users/_user.html.haml +28 -0
  398. data/app/views/users/avatar.js.rjs +10 -0
  399. data/app/views/users/change_password.js.rjs +15 -0
  400. data/app/views/users/edit.js.rjs +10 -0
  401. data/app/views/users/index.html.haml +3 -0
  402. data/app/views/users/new.html.haml +19 -0
  403. data/app/views/users/password.js.rjs +11 -0
  404. data/app/views/users/show.html.haml +16 -0
  405. data/app/views/users/update.js.rjs +10 -0
  406. data/app/views/users/upload_avatar.js.rjs +8 -0
  407. data/app/views/versions/_version.html.haml +30 -0
  408. data/config.ru +4 -0
  409. data/config/application.rb +75 -0
  410. data/config/boot.rb +6 -0
  411. data/config/database.mysql.mac.yml +31 -0
  412. data/config/database.mysql.yml +32 -0
  413. data/config/database.postgres.yml +25 -0
  414. data/config/database.sqlite.yml +22 -0
  415. data/config/environment.rb +5 -0
  416. data/config/environments/development.rb +39 -0
  417. data/config/environments/production.rb +67 -0
  418. data/config/environments/staging.rb +14 -0
  419. data/config/environments/test.rb +48 -0
  420. data/config/initializers/action_mailer.rb +3 -0
  421. data/config/initializers/authlogic.rb +1 -0
  422. data/config/initializers/mime_types.rb +8 -0
  423. data/config/initializers/paginate_arrays.rb +7 -0
  424. data/config/initializers/paper_trail.rb +1 -0
  425. data/config/initializers/sass.rb +13 -0
  426. data/config/initializers/secret_token.rb +13 -0
  427. data/config/initializers/simple_form.rb +96 -0
  428. data/config/locales/cz.yml +213 -0
  429. data/config/locales/cz_fat_free_crm.yml +695 -0
  430. data/config/locales/de.yml +193 -0
  431. data/config/locales/de_fat_free_crm.yml +637 -0
  432. data/config/locales/en-GB.yml +180 -0
  433. data/config/locales/en-GB_fat_free_crm.yml +670 -0
  434. data/config/locales/en-US.yml +182 -0
  435. data/config/locales/en-US_fat_free_crm.yml +832 -0
  436. data/config/locales/es.yml +184 -0
  437. data/config/locales/es_fat_free_crm.yml +642 -0
  438. data/config/locales/fr-CA.yml +187 -0
  439. data/config/locales/fr-CA_fat_free_crm.yml +635 -0
  440. data/config/locales/fr.yml +182 -0
  441. data/config/locales/fr_fat_free_crm.yml +633 -0
  442. data/config/locales/it.yml +183 -0
  443. data/config/locales/it_fat_free_crm.yml +665 -0
  444. data/config/locales/ja.yml +188 -0
  445. data/config/locales/ja_fat_free_crm.yml +636 -0
  446. data/config/locales/pl.yml +194 -0
  447. data/config/locales/pl_fat_free_crm.yml +646 -0
  448. data/config/locales/pt-BR.yml +199 -0
  449. data/config/locales/pt-BR_fat_free_crm.yml +639 -0
  450. data/config/locales/ru.yml +303 -0
  451. data/config/locales/ru_fat_free_crm.yml +661 -0
  452. data/config/locales/simple_form.en.yml +24 -0
  453. data/config/locales/sv-SE.yml +232 -0
  454. data/config/locales/sv-SE_fat_free_crm.yml +638 -0
  455. data/config/locales/th.rb +200 -0
  456. data/config/locales/th_fat_free_crm.yml +643 -0
  457. data/config/locales/zh-CN.yml +210 -0
  458. data/config/locales/zh-CN_fat_free_crm.yml +631 -0
  459. data/config/routes.rb +172 -0
  460. data/config/settings.default.yml +325 -0
  461. data/db/demo/account_contacts.yml +24 -0
  462. data/db/demo/account_opportunities.yml +24 -0
  463. data/db/demo/accounts.yml +48 -0
  464. data/db/demo/activities.yml +16 -0
  465. data/db/demo/addresses.yml +46 -0
  466. data/db/demo/avatars.yml +16 -0
  467. data/db/demo/campaigns.yml +144 -0
  468. data/db/demo/comments.yml +30 -0
  469. data/db/demo/contact_opportunities.yml +25 -0
  470. data/db/demo/contacts.yml +70 -0
  471. data/db/demo/emails.yml +53 -0
  472. data/db/demo/leads.yml +71 -0
  473. data/db/demo/opportunities.yml +48 -0
  474. data/db/demo/permissions.yml +13 -0
  475. data/db/demo/preferences.yml +13 -0
  476. data/db/demo/settings.yml +12 -0
  477. data/db/demo/tasks.yml +64 -0
  478. data/db/demo/users.yml +249 -0
  479. data/db/migrate/20100928030598_create_sessions.rb +17 -0
  480. data/db/migrate/20100928030599_create_users.rb +46 -0
  481. data/db/migrate/20100928030600_create_openid_tables.rb +24 -0
  482. data/db/migrate/20100928030601_create_accounts.rb +27 -0
  483. data/db/migrate/20100928030602_create_permissions.rb +16 -0
  484. data/db/migrate/20100928030603_create_settings.rb +16 -0
  485. data/db/migrate/20100928030604_create_preferences.rb +16 -0
  486. data/db/migrate/20100928030605_create_campaigns.rb +35 -0
  487. data/db/migrate/20100928030606_create_leads.rb +39 -0
  488. data/db/migrate/20100928030607_create_contacts.rb +39 -0
  489. data/db/migrate/20100928030608_create_opportunities.rb +28 -0
  490. data/db/migrate/20100928030609_create_account_contacts.rb +15 -0
  491. data/db/migrate/20100928030610_create_account_opportunities.rb +15 -0
  492. data/db/migrate/20100928030611_create_contact_opportunities.rb +16 -0
  493. data/db/migrate/20100928030612_create_tasks.rb +27 -0
  494. data/db/migrate/20100928030613_create_comments.rb +17 -0
  495. data/db/migrate/20100928030614_create_activities.rb +20 -0
  496. data/db/migrate/20100928030615_create_avatars.rb +17 -0
  497. data/db/migrate/20100928030616_rename_remember_token.rb +12 -0
  498. data/db/migrate/20100928030617_drop_openid_tables.rb +23 -0
  499. data/db/migrate/20100928030618_add_admin_to_users.rb +12 -0
  500. data/db/migrate/20100928030619_add_suspended_to_users.rb +12 -0
  501. data/db/migrate/20100928030620_remove_uuid.rb +24 -0
  502. data/db/migrate/20100928030621_add_email_to_accounts.rb +10 -0
  503. data/db/migrate/20100928030622_add_background_info_to_models.rb +20 -0
  504. data/db/migrate/20100928030623_create_addresses.rb +51 -0
  505. data/db/migrate/20100928030624_add_index_on_permissions.rb +10 -0
  506. data/db/migrate/20100928030625_create_emails.rb +27 -0
  507. data/db/migrate/20100928030626_add_state_to_timeline_objects.rb +14 -0
  508. data/db/migrate/20100928030627_acts_as_taggable_on_migration.rb +30 -0
  509. data/db/migrate/20101221123456_add_single_access_token_to_users.rb +10 -0
  510. data/db/migrate/20101221345678_add_rating_and_category_to_accounts.rb +12 -0
  511. data/db/migrate/20110719082054_add_skype_to_contacts_and_leads.rb +12 -0
  512. data/db/migrate/20111101083437_create_fields.rb +28 -0
  513. data/db/migrate/20111101090312_create_field_groups.rb +16 -0
  514. data/db/migrate/20111116091952_add_field_groups_tag_id.rb +10 -0
  515. data/db/migrate/20111117041311_change_fields_collection_to_text.rb +10 -0
  516. data/db/migrate/20111201030535_add_field_groups_klass_name.rb +21 -0
  517. data/db/migrate/20120121054235_create_lists.rb +10 -0
  518. data/db/migrate/20120216031616_create_versions.rb +18 -0
  519. data/db/migrate/20120216042541_is_paranoid_to_paper_trail.rb +13 -0
  520. data/db/migrate/20120220233724_add_versions_object_changes.rb +9 -0
  521. data/db/migrate/20120224073107_remove_default_value_and_clear_settings.rb +16 -0
  522. data/db/schema.rb +415 -0
  523. data/db/seeds.rb +10 -0
  524. data/db/seeds/fields.rb +94 -0
  525. data/fat_free_crm.gemspec +45 -0
  526. data/lib/country_select/MIT-LICENSE +20 -0
  527. data/lib/country_select/README +14 -0
  528. data/lib/country_select/init.rb +1 -0
  529. data/lib/country_select/install.rb +2 -0
  530. data/lib/country_select/lib/country_select.rb +551 -0
  531. data/lib/country_select/uninstall.rb +2 -0
  532. data/lib/development_tasks/gem.rake +8 -0
  533. data/lib/development_tasks/license.rake +99 -0
  534. data/lib/development_tasks/rdoc.rake +15 -0
  535. data/lib/development_tasks/rspec.rake +23 -0
  536. data/lib/dynamic_form/MIT-LICENSE +20 -0
  537. data/lib/dynamic_form/README +13 -0
  538. data/lib/dynamic_form/Rakefile +10 -0
  539. data/lib/dynamic_form/dynamic_form.gemspec +12 -0
  540. data/lib/dynamic_form/init.rb +2 -0
  541. data/lib/dynamic_form/lib/action_view/helpers/dynamic_form.rb +301 -0
  542. data/lib/dynamic_form/lib/action_view/locale/en-US.yml +8 -0
  543. data/lib/dynamic_form/lib/dynamic_form.rb +6 -0
  544. data/lib/dynamic_form/test/dynamic_form_i18n_test.rb +42 -0
  545. data/lib/dynamic_form/test/dynamic_form_test.rb +370 -0
  546. data/lib/dynamic_form/test/test_helper.rb +10 -0
  547. data/lib/fat_free_crm.rb +52 -0
  548. data/lib/fat_free_crm/callback.rb +144 -0
  549. data/lib/fat_free_crm/core_ext.rb +18 -0
  550. data/lib/fat_free_crm/core_ext/array.rb +95 -0
  551. data/lib/fat_free_crm/core_ext/nil.rb +29 -0
  552. data/lib/fat_free_crm/core_ext/string.rb +74 -0
  553. data/lib/fat_free_crm/dropbox.rb +429 -0
  554. data/lib/fat_free_crm/engine.rb +9 -0
  555. data/lib/fat_free_crm/errors.rb +51 -0
  556. data/lib/fat_free_crm/exceptions.rb +34 -0
  557. data/lib/fat_free_crm/exportable.rb +63 -0
  558. data/lib/fat_free_crm/fields.rb +76 -0
  559. data/lib/fat_free_crm/gem_dependencies.rb +16 -0
  560. data/lib/fat_free_crm/gem_ext.rb +8 -0
  561. data/lib/fat_free_crm/gem_ext/action_controller/base.rb +28 -0
  562. data/lib/fat_free_crm/gem_ext/active_model/serializers/xml/serializer/attribute.rb +29 -0
  563. data/lib/fat_free_crm/gem_ext/active_record/schema_dumper.rb +22 -0
  564. data/lib/fat_free_crm/gem_ext/active_support/buffered_logger.rb +32 -0
  565. data/lib/fat_free_crm/gem_ext/authlogic/session/cookies.rb +11 -0
  566. data/lib/fat_free_crm/gem_ext/rails/engine.rb +17 -0
  567. data/lib/fat_free_crm/gem_ext/rails/text_helper.rb +125 -0
  568. data/lib/fat_free_crm/gem_ext/rake/task.rb +8 -0
  569. data/lib/fat_free_crm/gem_ext/simple_form/action_view_extensions/form_helper.rb +20 -0
  570. data/lib/fat_free_crm/i18n.rb +51 -0
  571. data/lib/fat_free_crm/permissions.rb +111 -0
  572. data/lib/fat_free_crm/plugin.rb +106 -0
  573. data/lib/fat_free_crm/plugin_dependencies.rb +6 -0
  574. data/lib/fat_free_crm/renderers.rb +21 -0
  575. data/lib/fat_free_crm/sortable.rb +59 -0
  576. data/lib/fat_free_crm/syck_yaml.rb +4 -0
  577. data/lib/fat_free_crm/tabs.rb +35 -0
  578. data/lib/fat_free_crm/version.rb +27 -0
  579. data/lib/gravatar_image_tag/Gemfile +8 -0
  580. data/lib/gravatar_image_tag/README.textile +108 -0
  581. data/lib/gravatar_image_tag/ROADMAP.textile +33 -0
  582. data/lib/gravatar_image_tag/Rakefile +50 -0
  583. data/lib/gravatar_image_tag/VERSION +1 -0
  584. data/lib/gravatar_image_tag/gravatar_image_tag.gemspec +45 -0
  585. data/lib/gravatar_image_tag/init.rb +2 -0
  586. data/lib/gravatar_image_tag/lib/gravatar_image_tag.rb +63 -0
  587. data/lib/gravatar_image_tag/spec/gravatar_image_tag_spec.rb +83 -0
  588. data/lib/gravatar_image_tag/spec/test_helper.rb +12 -0
  589. data/lib/responds_to_parent/MIT-LICENSE +20 -0
  590. data/lib/responds_to_parent/README +47 -0
  591. data/lib/responds_to_parent/Rakefile +22 -0
  592. data/lib/responds_to_parent/init.rb +2 -0
  593. data/lib/responds_to_parent/install.rb +2 -0
  594. data/lib/responds_to_parent/lib/responds_to_parent.rb +70 -0
  595. data/lib/responds_to_parent/test/responds_to_parent_test.rb +11 -0
  596. data/lib/responds_to_parent/test/test_helper.rb +7 -0
  597. data/lib/responds_to_parent/uninstall.rb +2 -0
  598. data/lib/tasks/.gitkeep +0 -0
  599. data/lib/tasks/.gitkeep~master +0 -0
  600. data/lib/tasks/demo.rake +72 -0
  601. data/lib/tasks/dropbox.rake +32 -0
  602. data/lib/tasks/fat_free_crm.rake +130 -0
  603. data/lib/tasks/plugins.rake +77 -0
  604. data/lib/tasks/schema_upgrade.rake +31 -0
  605. data/lib/templates/erb/scaffold/_form.html.erb +13 -0
  606. data/public/404.html +26 -0
  607. data/public/422.html +26 -0
  608. data/public/500.html +26 -0
  609. data/public/blank_iframe.html +2 -0
  610. data/public/favicon.ico +0 -0
  611. data/public/robots.txt +5 -0
  612. data/script/rails +6 -0
  613. data/spec/controllers/accounts_controller_spec.rb +626 -0
  614. data/spec/controllers/admin/users_controller_spec.rb +309 -0
  615. data/spec/controllers/authentications_controller_spec.rb +147 -0
  616. data/spec/controllers/campaigns_controller_spec.rb +666 -0
  617. data/spec/controllers/comments_controller_spec.rb +274 -0
  618. data/spec/controllers/contacts_controller_spec.rb +699 -0
  619. data/spec/controllers/emails_controller_spec.rb +32 -0
  620. data/spec/controllers/home_controller_spec.rb +99 -0
  621. data/spec/controllers/leads_controller_spec.rb +1047 -0
  622. data/spec/controllers/lists_controller_spec.rb +5 -0
  623. data/spec/controllers/opportunities_controller_spec.rb +932 -0
  624. data/spec/controllers/passwords_controller_spec.rb +11 -0
  625. data/spec/controllers/tasks_controller_spec.rb +508 -0
  626. data/spec/controllers/users_controller_spec.rb +344 -0
  627. data/spec/factories/account_factories.rb +35 -0
  628. data/spec/factories/campaign_factories.rb +23 -0
  629. data/spec/factories/contact_factories.rb +39 -0
  630. data/spec/factories/field_factories.rb +34 -0
  631. data/spec/factories/lead_factories.rb +29 -0
  632. data/spec/factories/list_factories.rb +6 -0
  633. data/spec/factories/opportunity_factories.rb +20 -0
  634. data/spec/factories/sequences.rb +26 -0
  635. data/spec/factories/setting_factories.rb +8 -0
  636. data/spec/factories/shared_factories.rb +70 -0
  637. data/spec/factories/tag_factories.rb +5 -0
  638. data/spec/factories/task_factories.rb +18 -0
  639. data/spec/factories/user_factories.rb +57 -0
  640. data/spec/fixtures/rails.png +0 -0
  641. data/spec/helpers/accounts_helper_spec.rb +12 -0
  642. data/spec/helpers/admin/field_groups_helper_spec.rb +13 -0
  643. data/spec/helpers/admin/plugins_helper_spec.rb +5 -0
  644. data/spec/helpers/admin/settings_helper_spec.rb +5 -0
  645. data/spec/helpers/admin/users_helper_spec.rb +5 -0
  646. data/spec/helpers/application_helper_spec.rb +67 -0
  647. data/spec/helpers/authentications_helper_spec.rb +12 -0
  648. data/spec/helpers/campaigns_helper_spec.rb +12 -0
  649. data/spec/helpers/comments_helper_spec.rb +12 -0
  650. data/spec/helpers/contacts_helper_spec.rb +12 -0
  651. data/spec/helpers/emails_helper_spec.rb +5 -0
  652. data/spec/helpers/fields_helper_spec.rb +6 -0
  653. data/spec/helpers/home_helper_spec.rb +12 -0
  654. data/spec/helpers/leads_helper_spec.rb +12 -0
  655. data/spec/helpers/lists_helper_spec.rb +15 -0
  656. data/spec/helpers/opportunities_helper_spec.rb +12 -0
  657. data/spec/helpers/passwords_helper_spec.rb +12 -0
  658. data/spec/helpers/tasks_helper_spec.rb +12 -0
  659. data/spec/helpers/users_helper_spec.rb +12 -0
  660. data/spec/lib/core_ext/string.rb +17 -0
  661. data/spec/lib/dropbox/email_samples.rb +77 -0
  662. data/spec/lib/dropbox_spec.rb +410 -0
  663. data/spec/lib/errors_spec.rb +25 -0
  664. data/spec/models/base/account_contact_spec.rb +27 -0
  665. data/spec/models/base/account_opportunity_spec.rb +27 -0
  666. data/spec/models/base/account_spec.rb +136 -0
  667. data/spec/models/base/campaign_spec.rb +135 -0
  668. data/spec/models/base/contact_opportunity_spec.rb +28 -0
  669. data/spec/models/base/contact_spec.rb +160 -0
  670. data/spec/models/base/lead_spec.rb +101 -0
  671. data/spec/models/base/opportunity_spec.rb +173 -0
  672. data/spec/models/base/task_spec.rb +263 -0
  673. data/spec/models/fields/custom_field_spec.rb +106 -0
  674. data/spec/models/fields/field_group_spec.rb +23 -0
  675. data/spec/models/fields/field_spec.rb +64 -0
  676. data/spec/models/list_spec.rb +12 -0
  677. data/spec/models/polymorphic/activity_spec.rb +303 -0
  678. data/spec/models/polymorphic/address_spec.rb +33 -0
  679. data/spec/models/polymorphic/avatar_spec.rb +41 -0
  680. data/spec/models/polymorphic/comment_spec.rb +29 -0
  681. data/spec/models/polymorphic/email_spec.rb +36 -0
  682. data/spec/models/setting_spec.rb +51 -0
  683. data/spec/models/users/authentication_spec.rb +13 -0
  684. data/spec/models/users/permission_spec.rb +27 -0
  685. data/spec/models/users/preference_spec.rb +60 -0
  686. data/spec/models/users/user_spec.rb +169 -0
  687. data/spec/routing/accounts_routing_spec.rb +55 -0
  688. data/spec/routing/admin/users_routing_spec.rb +35 -0
  689. data/spec/routing/campaigns_routing_spec.rb +58 -0
  690. data/spec/routing/comments_routing_spec.rb +35 -0
  691. data/spec/routing/contacts_routing_spec.rb +55 -0
  692. data/spec/routing/emails_routing_spec.rb +35 -0
  693. data/spec/routing/leads_routing_spec.rb +83 -0
  694. data/spec/routing/opportunities_routing_spec.rb +59 -0
  695. data/spec/routing/tasks_routing_spec.rb +62 -0
  696. data/spec/routing/users_routing_spec.rb +79 -0
  697. data/spec/shared/controllers.rb +102 -0
  698. data/spec/shared/models.rb +37 -0
  699. data/spec/spec_helper.rb +110 -0
  700. data/spec/support/assert_select.rb +158 -0
  701. data/spec/support/auth_macros.rb +44 -0
  702. data/spec/support/macros.rb +40 -0
  703. data/spec/support/rjs_support.rb +9 -0
  704. data/spec/views/accounts/_edit.haml_spec.rb +38 -0
  705. data/spec/views/accounts/_new.haml_spec.rb +37 -0
  706. data/spec/views/accounts/create.rjs_spec.rb +54 -0
  707. data/spec/views/accounts/destroy.rjs_spec.rb +30 -0
  708. data/spec/views/accounts/edit.rjs_spec.rb +69 -0
  709. data/spec/views/accounts/index.haml_spec.rb +33 -0
  710. data/spec/views/accounts/index.rjs_spec.rb +32 -0
  711. data/spec/views/accounts/new.rjs_spec.rb +47 -0
  712. data/spec/views/accounts/options.rjs_spec.rb +59 -0
  713. data/spec/views/accounts/show.haml_spec.rb +30 -0
  714. data/spec/views/accounts/update.rjs_spec.rb +99 -0
  715. data/spec/views/admin/users/_create.haml_spec.rb +17 -0
  716. data/spec/views/admin/users/create.rjs_spec.rb +42 -0
  717. data/spec/views/admin/users/destroy.rjs_spec.rb +47 -0
  718. data/spec/views/admin/users/edit.rjs_spec.rb +45 -0
  719. data/spec/views/admin/users/index.haml_spec.rb +16 -0
  720. data/spec/views/admin/users/index.rjs_spec.rb +23 -0
  721. data/spec/views/admin/users/new.rjs_spec.rb +31 -0
  722. data/spec/views/admin/users/reactivate.rjs_spec.rb +17 -0
  723. data/spec/views/admin/users/show.haml_spec.rb +12 -0
  724. data/spec/views/admin/users/suspend.rjs_spec.rb +17 -0
  725. data/spec/views/admin/users/update.rjs_spec.rb +36 -0
  726. data/spec/views/authentications/new.haml_spec.rb +25 -0
  727. data/spec/views/campaigns/_edit.haml_spec.rb +37 -0
  728. data/spec/views/campaigns/_new.haml_spec.rb +35 -0
  729. data/spec/views/campaigns/create.rjs_spec.rb +52 -0
  730. data/spec/views/campaigns/destroy.rjs_spec.rb +28 -0
  731. data/spec/views/campaigns/edit.rjs_spec.rb +78 -0
  732. data/spec/views/campaigns/index.haml_spec.rb +28 -0
  733. data/spec/views/campaigns/index.rjs_spec.rb +32 -0
  734. data/spec/views/campaigns/new.rjs_spec.rb +57 -0
  735. data/spec/views/campaigns/options.rjs_spec.rb +60 -0
  736. data/spec/views/campaigns/show.haml_spec.rb +31 -0
  737. data/spec/views/campaigns/update.rjs_spec.rb +87 -0
  738. data/spec/views/comments/new.rjs_spec.rb +21 -0
  739. data/spec/views/common/auto_complete.haml_spec.rb +43 -0
  740. data/spec/views/contacts/_edit.haml_spec.rb +67 -0
  741. data/spec/views/contacts/_new.haml_spec.rb +47 -0
  742. data/spec/views/contacts/create.rjs_spec.rb +69 -0
  743. data/spec/views/contacts/destroy.rjs_spec.rb +41 -0
  744. data/spec/views/contacts/edit.rjs_spec.rb +77 -0
  745. data/spec/views/contacts/index.haml_spec.rb +28 -0
  746. data/spec/views/contacts/index.rjs_spec.rb +32 -0
  747. data/spec/views/contacts/new.rjs_spec.rb +51 -0
  748. data/spec/views/contacts/options.rjs_spec.rb +61 -0
  749. data/spec/views/contacts/show.haml_spec.rb +27 -0
  750. data/spec/views/contacts/update.rjs_spec.rb +141 -0
  751. data/spec/views/home/index.haml_spec.rb +26 -0
  752. data/spec/views/home/index.rjs_spec.rb +30 -0
  753. data/spec/views/home/options.rjs_spec.rb +52 -0
  754. data/spec/views/leads/_convert.haml_spec.rb +25 -0
  755. data/spec/views/leads/_edit.haml_spec.rb +41 -0
  756. data/spec/views/leads/_new.haml_spec.rb +39 -0
  757. data/spec/views/leads/_sidebar_show.haml_spec.rb +25 -0
  758. data/spec/views/leads/convert.rjs_spec.rb +83 -0
  759. data/spec/views/leads/create.rjs_spec.rb +70 -0
  760. data/spec/views/leads/destroy.rjs_spec.rb +46 -0
  761. data/spec/views/leads/edit.rjs_spec.rb +79 -0
  762. data/spec/views/leads/index.haml_spec.rb +28 -0
  763. data/spec/views/leads/index.rjs_spec.rb +32 -0
  764. data/spec/views/leads/new.rjs_spec.rb +52 -0
  765. data/spec/views/leads/options.rjs_spec.rb +61 -0
  766. data/spec/views/leads/promote.rjs_spec.rb +154 -0
  767. data/spec/views/leads/reject.rjs_spec.rb +49 -0
  768. data/spec/views/leads/show.haml_spec.rb +24 -0
  769. data/spec/views/leads/update.rjs_spec.rb +134 -0
  770. data/spec/views/opportunities/_edit.haml_spec.rb +64 -0
  771. data/spec/views/opportunities/_new.haml_spec.rb +46 -0
  772. data/spec/views/opportunities/create.rjs_spec.rb +94 -0
  773. data/spec/views/opportunities/destroy.rjs_spec.rb +64 -0
  774. data/spec/views/opportunities/edit.rjs_spec.rb +79 -0
  775. data/spec/views/opportunities/index.haml_spec.rb +29 -0
  776. data/spec/views/opportunities/index.rjs_spec.rb +34 -0
  777. data/spec/views/opportunities/new.rjs_spec.rb +60 -0
  778. data/spec/views/opportunities/options.rjs_spec.rb +60 -0
  779. data/spec/views/opportunities/show.haml_spec.rb +27 -0
  780. data/spec/views/opportunities/update.rjs_spec.rb +162 -0
  781. data/spec/views/tasks/_edit.haml_spec.rb +45 -0
  782. data/spec/views/tasks/complete.rjs_spec.rb +68 -0
  783. data/spec/views/tasks/create.rjs_spec.rb +124 -0
  784. data/spec/views/tasks/destroy.rjs_spec.rb +53 -0
  785. data/spec/views/tasks/edit.rjs_spec.rb +78 -0
  786. data/spec/views/tasks/index.haml_spec.rb +40 -0
  787. data/spec/views/tasks/new.rjs_spec.rb +62 -0
  788. data/spec/views/tasks/update.rjs_spec.rb +152 -0
  789. data/spec/views/users/avatar.rjs_spec.rb +32 -0
  790. data/spec/views/users/change_password.rjs_spec.rb +49 -0
  791. data/spec/views/users/edit.rjs_spec.rb +32 -0
  792. data/spec/views/users/password.rjs_spec.rb +32 -0
  793. data/spec/views/users/update.rjs_spec.rb +50 -0
  794. data/spec/views/users/upload_avatar.rjs_spec.rb +42 -0
  795. data/vendor/assets/images/calendar_date_select/calendar.gif +0 -0
  796. data/vendor/assets/images/delete.png +0 -0
  797. data/vendor/assets/images/tab_icons/accounts.png +0 -0
  798. data/vendor/assets/images/tab_icons/accounts_active.png +0 -0
  799. data/vendor/assets/images/tab_icons/campaigns.png +0 -0
  800. data/vendor/assets/images/tab_icons/campaigns_active.png +0 -0
  801. data/vendor/assets/images/tab_icons/contacts.png +0 -0
  802. data/vendor/assets/images/tab_icons/contacts_active.png +0 -0
  803. data/vendor/assets/images/tab_icons/dashboard.png +0 -0
  804. data/vendor/assets/images/tab_icons/dashboard_active.png +0 -0
  805. data/vendor/assets/images/tab_icons/leads.png +0 -0
  806. data/vendor/assets/images/tab_icons/leads_active.png +0 -0
  807. data/vendor/assets/images/tab_icons/opportunities.png +0 -0
  808. data/vendor/assets/images/tab_icons/opportunities_active.png +0 -0
  809. data/vendor/assets/images/tab_icons/tasks.png +0 -0
  810. data/vendor/assets/images/tab_icons/tasks_active.png +0 -0
  811. data/vendor/assets/javascripts/calendar_date_select/calendar_date_select.js +446 -0
  812. data/vendor/assets/javascripts/calendar_date_select/format_american.js +35 -0
  813. data/vendor/assets/javascripts/calendar_date_select/format_danish.js +31 -0
  814. data/vendor/assets/javascripts/calendar_date_select/format_db.js +27 -0
  815. data/vendor/assets/javascripts/calendar_date_select/format_euro_24hr.js +7 -0
  816. data/vendor/assets/javascripts/calendar_date_select/format_euro_24hr_ymd.js +7 -0
  817. data/vendor/assets/javascripts/calendar_date_select/format_finnish.js +32 -0
  818. data/vendor/assets/javascripts/calendar_date_select/format_hyphen_ampm.js +37 -0
  819. data/vendor/assets/javascripts/calendar_date_select/format_iso_date.js +29 -0
  820. data/vendor/assets/javascripts/calendar_date_select/format_italian.js +24 -0
  821. data/vendor/assets/javascripts/calendar_date_select/locale/ar.js +10 -0
  822. data/vendor/assets/javascripts/calendar_date_select/locale/da.js +11 -0
  823. data/vendor/assets/javascripts/calendar_date_select/locale/de.js +11 -0
  824. data/vendor/assets/javascripts/calendar_date_select/locale/es.js +11 -0
  825. data/vendor/assets/javascripts/calendar_date_select/locale/fi.js +10 -0
  826. data/vendor/assets/javascripts/calendar_date_select/locale/fr.js +11 -0
  827. data/vendor/assets/javascripts/calendar_date_select/locale/it.js +9 -0
  828. data/vendor/assets/javascripts/calendar_date_select/locale/ja.js +11 -0
  829. data/vendor/assets/javascripts/calendar_date_select/locale/nl.js +11 -0
  830. data/vendor/assets/javascripts/calendar_date_select/locale/pl.js +11 -0
  831. data/vendor/assets/javascripts/calendar_date_select/locale/pt.js +11 -0
  832. data/vendor/assets/javascripts/calendar_date_select/locale/ru.js +10 -0
  833. data/vendor/assets/javascripts/calendar_date_select/locale/sl.js +11 -0
  834. data/vendor/assets/javascripts/calendar_date_select/locale/sv.js +9 -0
  835. data/vendor/assets/javascripts/event.simulate.js +64 -0
  836. data/vendor/assets/javascripts/facebooklist.js +548 -0
  837. data/vendor/assets/javascripts/facebooklist.simulate.js +28 -0
  838. data/vendor/assets/javascripts/modalbox.js +506 -0
  839. data/vendor/assets/javascripts/rating.js +162 -0
  840. data/vendor/assets/stylesheets/calendar_date_select/blue.css +130 -0
  841. data/vendor/assets/stylesheets/calendar_date_select/default.css +135 -0
  842. data/vendor/assets/stylesheets/calendar_date_select/green.css +142 -0
  843. data/vendor/assets/stylesheets/calendar_date_select/plain.css +128 -0
  844. data/vendor/assets/stylesheets/calendar_date_select/red.css +135 -0
  845. data/vendor/assets/stylesheets/calendar_date_select/silver.css +133 -0
  846. data/vendor/assets/stylesheets/facebooklist.css +47 -0
  847. data/vendor/assets/stylesheets/modalbox.css +107 -0
  848. data/vendor/plugins/.gitkeep +0 -0
  849. data/vendor/plugins/.gitkeep~master +0 -0
  850. metadata +1196 -0
@@ -0,0 +1,274 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+
3
+ describe CommentsController do
4
+
5
+ COMMENTABLE = [ :account, :campaign, :contact, :lead, :opportunity ].freeze
6
+
7
+ before(:each) do
8
+ require_user
9
+ end
10
+
11
+ # GET /comments
12
+ # GET /comments.xml
13
+ #----------------------------------------------------------------------------
14
+ describe "responding to GET index" do
15
+ COMMENTABLE.each do |asset|
16
+ describe "(HTML)" do
17
+ before(:each) do
18
+ @asset = FactoryGirl.create(asset)
19
+ end
20
+
21
+ it "should redirect to the asset landing page if the asset is found" do
22
+ get :index, :"#{asset}_id" => @asset.id
23
+ response.should redirect_to(:controller => asset.to_s.pluralize, :action => :show, :id => @asset.id)
24
+ end
25
+
26
+ it "should redirect to root url with warning if the asset is not found" do
27
+ get :index, :"#{asset}_id" => @asset.id + 42
28
+ flash[:warning].should_not == nil
29
+ response.should redirect_to(root_path)
30
+ end
31
+ end # HTML
32
+
33
+ describe "(JSON)" do
34
+ before(:each) do
35
+ @asset = FactoryGirl.create(asset)
36
+ @asset.comments = [ FactoryGirl.create(:comment, :commentable => @asset) ]
37
+ request.env["HTTP_ACCEPT"] = "application/json"
38
+ end
39
+
40
+ it "should render all comments as JSON if the asset is found found" do
41
+ get :index, :"#{asset}_id" => @asset.id
42
+ response.body.should == @asset.comments.to_json
43
+ end
44
+
45
+ it "JSON: should return 404 (Not Found) JSON error if the asset is not found" do
46
+ get :index, :"#{asset}_id" => @asset.id + 42
47
+ flash[:warning].should_not == nil
48
+ response.code.should == "404"
49
+ end
50
+ end # JSON
51
+
52
+ describe "(XML)" do
53
+ before(:each) do
54
+ @asset = FactoryGirl.create(asset)
55
+ @asset.comments = [ FactoryGirl.create(:comment, :commentable => @asset) ]
56
+ request.env["HTTP_ACCEPT"] = "application/xml"
57
+ end
58
+
59
+ it "should render all comments as XML if the asset is found found" do
60
+ get :index, :"#{asset}_id" => @asset.id
61
+ response.body.should == @asset.comments.to_xml
62
+ end
63
+
64
+ it "XML: should return 404 (Not Found) XML error if the asset is not found" do
65
+ get :index, :"#{asset}_id" => @asset.id + 42
66
+ flash[:warning].should_not == nil
67
+ response.code.should == "404"
68
+ end
69
+ end # XML
70
+ end # COMMENTABLE.each
71
+
72
+ end
73
+
74
+ # GET /comments/1
75
+ # GET /comments/1.xml not implemented
76
+ #----------------------------------------------------------------------------
77
+ # describe "responding to GET show" do
78
+ #
79
+ # it "should expose the requested comment as @comment" do
80
+ # Comment.should_receive(:find).with("37").and_return(mock_comment)
81
+ # get :show, :id => "37"
82
+ # assigns[:comment].should equal(mock_comment)
83
+ # end
84
+ #
85
+ # describe "with mime type of xml" do
86
+ # it "should render the requested comment as xml" do
87
+ # request.env["HTTP_ACCEPT"] = "application/xml"
88
+ # Comment.should_receive(:find).with("37").and_return(mock_comment)
89
+ # mock_comment.should_receive(:to_xml).and_return("generated XML")
90
+ # get :show, :id => "37"
91
+ # response.body.should == "generated XML"
92
+ # end
93
+ # end
94
+ #
95
+ # end
96
+
97
+ # GET /comments/new
98
+ # GET /comments/new.xml AJAX
99
+ #----------------------------------------------------------------------------
100
+ describe "responding to GET new" do
101
+
102
+ COMMENTABLE.each do |asset|
103
+ it "should expose a new comment as @comment for #{asset}" do
104
+ @asset = FactoryGirl.create(asset)
105
+ @comment = Comment.new
106
+
107
+ xhr :get, :new, "#{asset}_id".to_sym => @asset.id
108
+ assigns[:comment].attributes.should == @comment.attributes
109
+ assigns[:commentable].should == asset.to_s
110
+ response.should render_template("comments/new")
111
+ end
112
+
113
+ it "should save the fact that a comment gets added to #{asset}" do
114
+ @asset = FactoryGirl.create(asset)
115
+ @comment = Comment.new
116
+
117
+ xhr :get, :new, "#{asset}_id".to_sym => @asset.id
118
+ session["#{asset}_new_comment"].should == true
119
+ end
120
+
121
+ it "should clear the session if user cancels a comment for #{asset}" do
122
+ @asset = FactoryGirl.create(asset)
123
+ @comment = Comment.new
124
+
125
+ xhr :get, :new, "#{asset}_id".to_sym => @asset.id, :cancel => "true"
126
+ session["#{asset}_new_comment"].should == nil
127
+ end
128
+
129
+ it "should redirect to #{asset}'s index page with the message if the #{asset} got deleted" do
130
+ @asset = FactoryGirl.create(asset)
131
+ @asset.destroy
132
+ @comment = Comment.new
133
+
134
+ xhr :get, :new, "#{asset}_id".to_sym => @asset.id
135
+ flash[:warning].should_not == nil
136
+ response.body.should =~ %r(window.location.href)m
137
+ response.body.should =~ %r(#{asset.to_s.pluralize})m
138
+ end
139
+
140
+ it "should redirect to #{asset}'s index page with the message if the #{asset} got protected" do
141
+ @asset = FactoryGirl.create(asset, :access => "Private")
142
+ @comment = Comment.new
143
+
144
+ xhr :get, :new, "#{asset}_id".to_sym => @asset.id
145
+ flash[:warning].should_not == nil
146
+ response.body.should =~ %r(window.location.href)m
147
+ response.body.should =~ %r(#{asset.to_s.pluralize})m
148
+ end
149
+ end
150
+ end
151
+
152
+ # GET /comments/1/edit AJAX
153
+ #----------------------------------------------------------------------------
154
+ describe "responding to GET edit" do
155
+
156
+ COMMENTABLE.each do |asset|
157
+ it "should expose the requested comment as @commment and render [edit] template" do
158
+ @asset = FactoryGirl.create(asset)
159
+ @comment = FactoryGirl.create(:comment, :id => 42, :commentable => @asset, :user => @current_user)
160
+ Comment.stub!(:new).and_return(@comment)
161
+
162
+ xhr :get, :edit, :id => 42
163
+ assigns[:comment].should == @comment
164
+ response.should render_template("comments/edit")
165
+ end
166
+ end
167
+
168
+ end
169
+
170
+ # POST /comments
171
+ # POST /comments.xml AJAX
172
+ #----------------------------------------------------------------------------
173
+ describe "responding to POST create" do
174
+
175
+ describe "with valid params" do
176
+ COMMENTABLE.each do |asset|
177
+ it "should expose a newly created comment as @comment for the #{asset}" do
178
+ @asset = FactoryGirl.create(asset)
179
+ @comment = FactoryGirl.build(:comment, :commentable => @asset, :user => @current_user)
180
+ Comment.stub!(:new).and_return(@comment)
181
+
182
+ xhr :post, :create, :comment => { :commentable_type => asset.to_s.classify, :commentable_id => @asset.id, :user_id => @current_user.id, :comment => "Hello" }
183
+ assigns[:comment].should == @comment
184
+ response.should render_template("comments/create")
185
+ end
186
+ end
187
+ end
188
+
189
+ describe "with invalid params" do
190
+ COMMENTABLE.each do |asset|
191
+ it "should expose a newly created but unsaved comment as @comment for #{asset}" do
192
+ @asset = FactoryGirl.create(asset)
193
+ @comment = FactoryGirl.build(:comment, :commentable => @asset, :user => @current_user)
194
+ Comment.stub!(:new).and_return(@comment)
195
+
196
+ xhr :post, :create, :comment => {}
197
+ assigns[:comment].should == @comment
198
+ response.should render_template("comments/create")
199
+ end
200
+ end
201
+ end
202
+
203
+ end
204
+
205
+ # PUT /comments/1
206
+ # PUT /comments/1.xml not implemened
207
+ #----------------------------------------------------------------------------
208
+ # describe "responding to PUT update" do
209
+ #
210
+ # describe "with valid params" do
211
+ # it "should update the requested comment" do
212
+ # Comment.should_receive(:find).with("37").and_return(mock_comment)
213
+ # mock_comment.should_receive(:update_attributes).with({'these' => 'params'})
214
+ # put :update, :id => "37", :comment => {:these => 'params'}
215
+ # end
216
+ #
217
+ # it "should expose the requested comment as @comment" do
218
+ # Comment.stub!(:find).and_return(mock_comment(:update_attributes => true))
219
+ # put :update, :id => "1"
220
+ # assigns(:comment).should equal(mock_comment)
221
+ # end
222
+ #
223
+ # it "should redirect to the comment" do
224
+ # Comment.stub!(:find).and_return(mock_comment(:update_attributes => true))
225
+ # put :update, :id => "1"
226
+ # response.should redirect_to(comment_path(mock_comment))
227
+ # end
228
+ # end
229
+ #
230
+ # describe "with invalid params" do
231
+ # it "should update the requested comment" do
232
+ # Comment.should_receive(:find).with("37").and_return(mock_comment)
233
+ # mock_comment.should_receive(:update_attributes).with({'these' => 'params'})
234
+ # put :update, :id => "37", :comment => {:these => 'params'}
235
+ # end
236
+ #
237
+ # it "should expose the comment as @comment" do
238
+ # Comment.stub!(:find).and_return(mock_comment(:update_attributes => false))
239
+ # put :update, :id => "1"
240
+ # assigns(:comment).should equal(mock_comment)
241
+ # end
242
+ #
243
+ # it "should re-render the 'edit' template" do
244
+ # Comment.stub!(:find).and_return(mock_comment(:update_attributes => false))
245
+ # put :update, :id => "1"
246
+ # response.should render_template('edit')
247
+ # end
248
+ # end
249
+ #
250
+ # end
251
+
252
+ # DELETE /comments/1
253
+ # DELETE /comments/1.xml AJAX
254
+ #----------------------------------------------------------------------------
255
+ describe "responding to DELETE destroy" do
256
+ describe "AJAX request" do
257
+ describe "with valid params" do
258
+ COMMENTABLE.each do |asset|
259
+ it "should destroy the requested comment and render [destroy] template" do
260
+ @asset = FactoryGirl.create(asset)
261
+ @comment = FactoryGirl.create(:comment, :commentable => @asset, :user => @current_user)
262
+ Comment.stub!(:new).and_return(@comment)
263
+
264
+ xhr :delete, :destroy, :id => @comment.id
265
+ lambda { Comment.find(@comment) }.should raise_error(ActiveRecord::RecordNotFound)
266
+ response.should render_template("comments/destroy")
267
+ end
268
+ end
269
+ end
270
+ end
271
+ end
272
+
273
+ end
274
+
@@ -0,0 +1,699 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+
3
+ describe ContactsController do
4
+
5
+ before(:each) do
6
+ require_user
7
+ set_current_tab(:contacts)
8
+ end
9
+
10
+ # GET /contacts
11
+ # GET /contacts.xml
12
+ #----------------------------------------------------------------------------
13
+ describe "responding to GET index" do
14
+
15
+ it "should expose all contacts as @contacts and render [index] template" do
16
+ @contacts = [ FactoryGirl.create(:contact, :user => @current_user) ]
17
+ get :index
18
+ assigns[:contacts].should == @contacts
19
+ response.should render_template("contacts/index")
20
+ end
21
+
22
+ it "should perform lookup using query string" do
23
+ @billy_bones = FactoryGirl.create(:contact, :user => @current_user, :first_name => "Billy", :last_name => "Bones")
24
+ @captain_flint = FactoryGirl.create(:contact, :user => @current_user, :first_name => "Captain", :last_name => "Flint")
25
+
26
+ get :index, :query => "bill"
27
+ assigns[:contacts].should == [ @billy_bones ]
28
+ assigns[:current_query].should == "bill"
29
+ session[:contacts_current_query].should == "bill"
30
+ end
31
+
32
+ describe "AJAX pagination" do
33
+ it "should pick up page number from params" do
34
+ @contacts = [ FactoryGirl.create(:contact, :user => @current_user) ]
35
+ xhr :get, :index, :page => 42
36
+
37
+ assigns[:current_page].to_i.should == 42
38
+ assigns[:contacts].should == [] # page #42 should be empty if there's only one contact ;-)
39
+ session[:contacts_current_page].to_i.should == 42
40
+ response.should render_template("contacts/index")
41
+ end
42
+
43
+ it "should pick up saved page number from session" do
44
+ session[:contacts_current_page] = 42
45
+ @contacts = [ FactoryGirl.create(:contact, :user => @current_user) ]
46
+ xhr :get, :index
47
+
48
+ assigns[:current_page].should == 42
49
+ assigns[:contacts].should == []
50
+ response.should render_template("contacts/index")
51
+ end
52
+ end
53
+
54
+ describe "with mime type of JSON" do
55
+ it "should render all contacts as JSON" do
56
+ @controller.should_receive(:get_list_of_records).and_return(contacts = mock("Array of Contacts"))
57
+ contacts.should_receive(:to_json).and_return("generated JSON")
58
+
59
+ request.env["HTTP_ACCEPT"] = "application/json"
60
+ get :index
61
+ response.body.should == "generated JSON"
62
+ end
63
+ end
64
+
65
+ describe "with mime type of XML" do
66
+ it "should render all contacts as xml" do
67
+ @controller.should_receive(:get_list_of_records).and_return(contacts = mock("Array of Contacts"))
68
+ contacts.should_receive(:to_xml).and_return("generated XML")
69
+
70
+ request.env["HTTP_ACCEPT"] = "application/xml"
71
+ get :index
72
+ response.body.should == "generated XML"
73
+ end
74
+ end
75
+ end
76
+
77
+ # GET /contacts/1
78
+ # GET /contacts/1.xml HTML
79
+ #----------------------------------------------------------------------------
80
+ describe "responding to GET show" do
81
+
82
+ describe "with mime type of HTML" do
83
+ before(:each) do
84
+ @contact = FactoryGirl.create(:contact, :id => 42)
85
+ @stage = Setting.unroll(:opportunity_stage)
86
+ @comment = Comment.new
87
+ end
88
+
89
+ it "should expose the requested contact as @contact" do
90
+ get :show, :id => 42
91
+ assigns[:contact].should == @contact
92
+ assigns[:stage].should == @stage
93
+ assigns[:comment].attributes.should == @comment.attributes
94
+ response.should render_template("contacts/show")
95
+ end
96
+
97
+ it "should update an activity when viewing the contact" do
98
+ Activity.should_receive(:log).with(@current_user, @contact, :viewed).once
99
+ get :show, :id => @contact.id
100
+ end
101
+ end
102
+
103
+ describe "with mime type of JSON" do
104
+ it "should render the requested contact as JSON" do
105
+ Contact.stub_chain(:my, :find).and_return(contact = mock_model(Contact, :name => ''))
106
+ contact.should_receive(:to_json).and_return("generated JSON")
107
+
108
+ request.env["HTTP_ACCEPT"] = "application/json"
109
+ get :show, :id => 42
110
+ response.body.should == "generated JSON"
111
+ end
112
+ end
113
+
114
+ describe "with mime type of XML" do
115
+ it "should render the requested contact as xml" do
116
+ Contact.stub_chain(:my, :find).and_return(contact = mock_model(Contact, :name => ''))
117
+ contact.should_receive(:to_xml).and_return("generated XML")
118
+
119
+ request.env["HTTP_ACCEPT"] = "application/xml"
120
+ get :show, :id => 42
121
+ response.body.should == "generated XML"
122
+ end
123
+ end
124
+
125
+ describe "contact got deleted or otherwise unavailable" do
126
+ it "should redirect to contact index if the contact got deleted" do
127
+ @contact = FactoryGirl.create(:contact, :user => @current_user)
128
+ @contact.destroy
129
+
130
+ get :show, :id => @contact.id
131
+ flash[:warning].should_not == nil
132
+ response.should redirect_to(contacts_path)
133
+ end
134
+
135
+ it "should redirect to contact index if the contact is protected" do
136
+ @private = FactoryGirl.create(:contact, :user => FactoryGirl.create(:user), :access => "Private")
137
+
138
+ get :show, :id => @private.id
139
+ flash[:warning].should_not == nil
140
+ response.should redirect_to(contacts_path)
141
+ end
142
+
143
+ it "should return 404 (Not Found) XML error" do
144
+ @contact = FactoryGirl.create(:contact, :user => @current_user)
145
+ @contact.destroy
146
+ request.env["HTTP_ACCEPT"] = "application/xml"
147
+
148
+ get :show, :id => @contact.id
149
+ response.code.should == "404" # :not_found
150
+ end
151
+ end
152
+
153
+ end
154
+
155
+ # GET /contacts/new
156
+ # GET /contacts/new.xml AJAX
157
+ #----------------------------------------------------------------------------
158
+ describe "responding to GET new" do
159
+
160
+ it "should expose a new contact as @contact and render [new] template" do
161
+ @contact = Contact.new(:user => @current_user)
162
+ @account = Account.new(:user => @current_user)
163
+ @users = [ FactoryGirl.create(:user) ]
164
+ @accounts = [ FactoryGirl.create(:account, :user => @current_user) ]
165
+
166
+ xhr :get, :new
167
+ assigns[:contact].attributes.should == @contact.attributes
168
+ assigns[:account].attributes.should == @account.attributes
169
+ assigns[:users].should == @users
170
+ assigns[:accounts].should == @accounts
171
+ assigns[:opportunity].should == nil
172
+ response.should render_template("contacts/new")
173
+ end
174
+
175
+ it "should created an instance of related object when necessary" do
176
+ @opportunity = FactoryGirl.create(:opportunity)
177
+
178
+ xhr :get, :new, :related => "opportunity_#{@opportunity.id}"
179
+ assigns[:opportunity].should == @opportunity
180
+ end
181
+
182
+ describe "(when creating related contact)" do
183
+ it "should redirect to parent asset's index page with the message if parent asset got deleted" do
184
+ @account = FactoryGirl.create(:account)
185
+ @account.destroy
186
+
187
+ xhr :get, :new, :related => "account_#{@account.id}"
188
+ flash[:warning].should_not == nil
189
+ response.body.should == 'window.location.href = "/accounts";'
190
+ end
191
+
192
+ it "should redirect to parent asset's index page with the message if parent asset got protected" do
193
+ @account = FactoryGirl.create(:account, :access => "Private")
194
+
195
+ xhr :get, :new, :related => "account_#{@account.id}"
196
+ flash[:warning].should_not == nil
197
+ response.body.should == 'window.location.href = "/accounts";'
198
+ end
199
+ end
200
+ end
201
+
202
+ # GET /contacts/1/edit AJAX
203
+ #----------------------------------------------------------------------------
204
+ describe "responding to GET edit" do
205
+
206
+ it "should expose the requested contact as @contact and render [edit] template" do
207
+ @contact = FactoryGirl.create(:contact, :id => 42, :user => @current_user, :lead => nil)
208
+ @users = [ FactoryGirl.create(:user) ]
209
+ @account = Account.new(:user => @current_user)
210
+
211
+ xhr :get, :edit, :id => 42
212
+ assigns[:contact].should == @contact
213
+ assigns[:users].should == @users
214
+ assigns[:account].attributes.should == @account.attributes
215
+ assigns[:previous].should == nil
216
+ response.should render_template("contacts/edit")
217
+ end
218
+
219
+ it "should expose the requested contact as @contact and linked account as @account" do
220
+ @account = FactoryGirl.create(:account, :id => 99)
221
+ @contact = FactoryGirl.create(:contact, :id => 42, :user => @current_user, :lead => nil)
222
+ FactoryGirl.create(:account_contact, :account => @account, :contact => @contact)
223
+
224
+ xhr :get, :edit, :id => 42
225
+ assigns[:contact].should == @contact
226
+ assigns[:account].should == @account
227
+ end
228
+
229
+ it "should expose previous contact as @previous when necessary" do
230
+ @contact = FactoryGirl.create(:contact, :id => 42)
231
+ @previous = FactoryGirl.create(:contact, :id => 1992)
232
+
233
+ xhr :get, :edit, :id => 42, :previous => 1992
234
+ assigns[:previous].should == @previous
235
+ end
236
+
237
+ describe "(contact got deleted or is otherwise unavailable)" do
238
+ it "should reload current page with the flash message if the contact got deleted" do
239
+ @contact = FactoryGirl.create(:contact, :user => @current_user)
240
+ @contact.destroy
241
+
242
+ xhr :get, :edit, :id => @contact.id
243
+ flash[:warning].should_not == nil
244
+ response.body.should == "window.location.reload();"
245
+ end
246
+
247
+ it "should reload current page with the flash message if the contact is protected" do
248
+ @private = FactoryGirl.create(:contact, :user => FactoryGirl.create(:user), :access => "Private")
249
+
250
+ xhr :get, :edit, :id => @private.id
251
+ flash[:warning].should_not == nil
252
+ response.body.should == "window.location.reload();"
253
+ end
254
+ end
255
+
256
+ describe "(previous contact got deleted or is otherwise unavailable)" do
257
+ before(:each) do
258
+ @contact = FactoryGirl.create(:contact, :user => @current_user)
259
+ @previous = FactoryGirl.create(:contact, :user => FactoryGirl.create(:user))
260
+ end
261
+
262
+ it "should notify the view if previous contact got deleted" do
263
+ @previous.destroy
264
+
265
+ xhr :get, :edit, :id => @contact.id, :previous => @previous.id
266
+ flash[:warning].should == nil
267
+ assigns[:previous].should == @previous.id
268
+ response.should render_template("contacts/edit")
269
+ end
270
+
271
+ it "should notify the view if previous contact got protected" do
272
+ @previous.update_attribute(:access, "Private")
273
+
274
+ xhr :get, :edit, :id => @contact.id, :previous => @previous.id
275
+ flash[:warning].should == nil
276
+ assigns[:previous].should == @previous.id
277
+ response.should render_template("contacts/edit")
278
+ end
279
+ end
280
+
281
+ end
282
+
283
+ # POST /contacts
284
+ # POST /contacts.xml AJAX
285
+ #----------------------------------------------------------------------------
286
+ describe "responding to POST create" do
287
+
288
+ describe "with valid params" do
289
+
290
+ it "should expose a newly created contact as @contact and render [create] template" do
291
+ @contact = FactoryGirl.build(:contact, :first_name => "Billy", :last_name => "Bones")
292
+ Contact.stub!(:new).and_return(@contact)
293
+
294
+ xhr :post, :create, :contact => { :first_name => "Billy", :last_name => "Bones" }, :account => { :name => "Hello world" }, :users => %w(1 2 3)
295
+ assigns(:contact).should == @contact
296
+ assigns(:contact).account.name.should == "Hello world"
297
+ response.should render_template("contacts/create")
298
+ end
299
+
300
+ it "should be able to associate newly created contact with the opportunity" do
301
+ @opportunity = FactoryGirl.create(:opportunity, :id => 987);
302
+ @contact = FactoryGirl.build(:contact)
303
+ Contact.stub!(:new).and_return(@contact)
304
+
305
+ xhr :post, :create, :contact => { :first_name => "Billy"}, :account => {}, :opportunity => 987
306
+ assigns(:contact).opportunities.should include(@opportunity)
307
+ response.should render_template("contacts/create")
308
+ end
309
+
310
+ it "should reload contacts to update pagination if called from contacts index" do
311
+ @contact = FactoryGirl.build(:contact, :user => @current_user)
312
+ Contact.stub!(:new).and_return(@contact)
313
+
314
+ request.env["HTTP_REFERER"] = "http://localhost/contacts"
315
+ xhr :post, :create, :contact => { :first_name => "Billy", :last_name => "Bones" }, :account => {}, :users => %w(1 2 3)
316
+ assigns[:contacts].should == [ @contact ]
317
+ end
318
+ end
319
+
320
+ describe "with invalid params" do
321
+
322
+ before(:each) do
323
+ @contact = FactoryGirl.build(:contact, :first_name => nil, :user => @current_user, :lead => nil)
324
+ Contact.stub!(:new).and_return(@contact)
325
+ @users = [ FactoryGirl.create(:user) ]
326
+ end
327
+
328
+ # Redraw [create] form with selected account.
329
+ it "should redraw [Create Contact] form with selected account" do
330
+ @account = FactoryGirl.create(:account, :id => 42, :user => @current_user)
331
+
332
+ # This redraws [create] form with blank account.
333
+ xhr :post, :create, :contact => {}, :account => { :id => 42, :user_id => @current_user.id }
334
+ assigns(:contact).should == @contact
335
+ assigns(:users).should == @users
336
+ assigns(:account).should == @account
337
+ assigns(:accounts).should == [ @account ]
338
+ response.should render_template("contacts/create")
339
+ end
340
+
341
+ # Redraw [create] form with related account.
342
+ it "should redraw [Create Contact] form with related account" do
343
+ @account = FactoryGirl.create(:account, :id => 123, :user => @current_user)
344
+
345
+ request.env["HTTP_REFERER"] = "http://localhost/accounts/123"
346
+ xhr :post, :create, :contact => { :first_name => nil }, :account => { :name => nil, :user_id => @current_user.id }
347
+ assigns(:contact).should == @contact
348
+ assigns(:users).should == @users
349
+ assigns(:account).should == @account
350
+ assigns(:accounts).should == [ @account ]
351
+ response.should render_template("contacts/create")
352
+ end
353
+
354
+ it "should redraw [Create Contact] form with blank account" do
355
+ @accounts = [ FactoryGirl.create(:account, :user => @current_user) ]
356
+ @account = Account.new(:user => @current_user)
357
+
358
+ xhr :post, :create, :contact => { :first_name => nil }, :account => { :name => nil, :user_id => @current_user.id }
359
+ assigns(:contact).should == @contact
360
+ assigns(:users).should == @users
361
+ assigns(:account).attributes.should == @account.attributes
362
+ assigns(:accounts).should == @accounts
363
+ response.should render_template("contacts/create")
364
+ end
365
+
366
+ it "should preserve Opportunity when called from Oppotuunity page" do
367
+ @opportunity = FactoryGirl.create(:opportunity, :id => 987);
368
+
369
+ xhr :post, :create, :contact => {}, :account => {}, :opportunity => 987
370
+ assigns(:opportunity).should == @opportunity
371
+ response.should render_template("contacts/create")
372
+ end
373
+
374
+ end
375
+
376
+ end
377
+
378
+ # PUT /contacts/1
379
+ # PUT /contacts/1.xml AJAX
380
+ #----------------------------------------------------------------------------
381
+ describe "responding to PUT update" do
382
+
383
+ describe "with valid params" do
384
+
385
+ it "should update the requested contact and render [update] template" do
386
+ @contact = FactoryGirl.create(:contact, :id => 42, :first_name => "Billy")
387
+
388
+ xhr :put, :update, :id => 42, :contact => { :first_name => "Bones" }, :account => {}
389
+ @contact.reload.first_name.should == "Bones"
390
+ assigns(:contact).should == @contact
391
+ response.should render_template("contacts/update")
392
+ end
393
+
394
+ it "should be able to create a new account and link it to the contact" do
395
+ @contact = FactoryGirl.create(:contact, :id => 42, :first_name => "Billy")
396
+
397
+ xhr :put, :update, :id => 42, :contact => { :first_name => "Bones" }, :account => { :name => "new account" }
398
+ @contact.reload.first_name.should == "Bones"
399
+ @contact.account.name.should == "new account"
400
+ end
401
+
402
+ it "should be able to link existing account with the contact" do
403
+ @account = FactoryGirl.create(:account, :id => 99, :name => "Hello world")
404
+ @contact = FactoryGirl.create(:contact, :id => 42, :first_name => "Billy")
405
+
406
+ xhr :put, :update, :id => 42, :contact => { :first_name => "Bones" }, :account => { :id => 99 }
407
+ @contact.reload.first_name.should == "Bones"
408
+ @contact.account.id.should == 99
409
+ end
410
+
411
+ it "should update contact permissions when sharing with specific users" do
412
+ @contact = FactoryGirl.create(:contact, :id => 42, :access => "Public")
413
+ he = FactoryGirl.create(:user, :id => 7)
414
+ she = FactoryGirl.create(:user, :id => 8)
415
+
416
+ xhr :put, :update, :id => 42, :contact => { :first_name => "Hello", :access => "Shared" }, :users => %w(7 8), :account => {}
417
+ @contact.reload.access.should == "Shared"
418
+ @contact.permissions.map(&:user_id).sort.should == [ 7, 8 ]
419
+ assigns[:contact].should == @contact
420
+ end
421
+
422
+ describe "contact got deleted or otherwise unavailable" do
423
+ it "should reload current page is the contact got deleted" do
424
+ @contact = FactoryGirl.create(:contact, :user => @current_user)
425
+ @contact.destroy
426
+
427
+ xhr :put, :update, :id => @contact.id
428
+ flash[:warning].should_not == nil
429
+ response.body.should == "window.location.reload();"
430
+ end
431
+
432
+ it "should reload current page with the flash message if the contact is protected" do
433
+ @private = FactoryGirl.create(:contact, :user => FactoryGirl.create(:user), :access => "Private")
434
+
435
+ xhr :put, :update, :id => @private.id
436
+ flash[:warning].should_not == nil
437
+ response.body.should == "window.location.reload();"
438
+ end
439
+ end
440
+
441
+ end
442
+
443
+ describe "with invalid params" do
444
+
445
+ it "should not update the contact, but still expose it as @contact and render [update] template" do
446
+ @contact = FactoryGirl.create(:contact, :id => 42, :user => @current_user, :first_name => "Billy", :lead => nil)
447
+ @account = Account.new(:user => @current_user)
448
+ @users = [ FactoryGirl.create(:user) ]
449
+
450
+ xhr :put, :update, :id => 42, :contact => { :first_name => nil }, :account => {}
451
+ @contact.reload.first_name.should == "Billy"
452
+ assigns(:contact).should == @contact
453
+ assigns(:account).attributes.should == @account.attributes
454
+ assigns(:users).should == @users
455
+ response.should render_template("contacts/update")
456
+ end
457
+
458
+ it "should expose existing account as @account if selected" do
459
+ @account = FactoryGirl.create(:account, :id => 99)
460
+ @contact = FactoryGirl.create(:contact, :id => 42, :account => @account)
461
+
462
+ xhr :put, :update, :id => 42, :contact => { :first_name => nil }, :account => { :id => 99 }
463
+ assigns(:account).should == @account
464
+ end
465
+
466
+ end
467
+
468
+ end
469
+
470
+ # DELETE /contacts/1
471
+ # DELETE /contacts/1.xml AJAX
472
+ #----------------------------------------------------------------------------
473
+ describe "responding to DELETE destroy" do
474
+ before(:each) do
475
+ @contact = FactoryGirl.create(:contact, :user => @current_user)
476
+ end
477
+
478
+ describe "AJAX request" do
479
+ it "should destroy the requested contact and render [destroy] template" do
480
+ xhr :delete, :destroy, :id => @contact.id
481
+
482
+ lambda { Contact.find(@contact) }.should raise_error(ActiveRecord::RecordNotFound)
483
+ response.should render_template("contacts/destroy")
484
+ end
485
+
486
+ describe "when called from Contacts index page" do
487
+ before(:each) do
488
+ request.env["HTTP_REFERER"] = "http://localhost/contacts"
489
+ end
490
+
491
+ it "should try previous page and render index action if current page has no contacts" do
492
+ session[:contacts_current_page] = 42
493
+ xhr :delete, :destroy, :id => @contact.id
494
+
495
+ session[:contacts_current_page].should == 41
496
+ response.should render_template("contacts/index")
497
+ end
498
+
499
+ it "should render index action when deleting last contact" do
500
+ session[:contacts_current_page] = 1
501
+ xhr :delete, :destroy, :id => @contact.id
502
+
503
+ session[:contacts_current_page].should == 1
504
+ response.should render_template("contacts/index")
505
+ end
506
+ end
507
+
508
+ describe "when called from related asset page page" do
509
+ it "should reset current page to 1" do
510
+ request.env["HTTP_REFERER"] = "http://localhost/accounts/123"
511
+ xhr :delete, :destroy, :id => @contact.id
512
+
513
+ session[:contacts_current_page].should == 1
514
+ response.should render_template("contacts/destroy")
515
+ end
516
+ end
517
+
518
+ describe "contact got deleted or otherwise unavailable" do
519
+ it "should reload current page is the contact got deleted" do
520
+ @contact = FactoryGirl.create(:contact, :user => @current_user)
521
+ @contact.destroy
522
+
523
+ xhr :delete, :destroy, :id => @contact.id
524
+ flash[:warning].should_not == nil
525
+ response.body.should == "window.location.reload();"
526
+ end
527
+
528
+ it "should reload current page with the flash message if the contact is protected" do
529
+ @private = FactoryGirl.create(:contact, :user => FactoryGirl.create(:user), :access => "Private")
530
+
531
+ xhr :delete, :destroy, :id => @private.id
532
+ flash[:warning].should_not == nil
533
+ response.body.should == "window.location.reload();"
534
+ end
535
+ end
536
+ end
537
+
538
+ describe "HTML request" do
539
+ it "should redirect to Contacts index when a contact gets deleted from its landing page" do
540
+ delete :destroy, :id => @contact.id
541
+
542
+ flash[:notice].should_not == nil
543
+ response.should redirect_to(contacts_path)
544
+ end
545
+
546
+ it "should redirect to contact index with the flash message is the contact got deleted" do
547
+ @contact = FactoryGirl.create(:contact, :user => @current_user)
548
+ @contact.destroy
549
+
550
+ delete :destroy, :id => @contact.id
551
+ flash[:warning].should_not == nil
552
+ response.should redirect_to(contacts_path)
553
+ end
554
+
555
+ it "should redirect to contact index with the flash message if the contact is protected" do
556
+ @private = FactoryGirl.create(:contact, :user => FactoryGirl.create(:user), :access => "Private")
557
+
558
+ delete :destroy, :id => @private.id
559
+ flash[:warning].should_not == nil
560
+ response.should redirect_to(contacts_path)
561
+ end
562
+ end
563
+ end
564
+
565
+ # PUT /contacts/1/attach
566
+ # PUT /contacts/1/attach.xml AJAX
567
+ #----------------------------------------------------------------------------
568
+ describe "responding to PUT attach" do
569
+ describe "tasks" do
570
+ before do
571
+ @model = FactoryGirl.create(:contact)
572
+ @attachment = FactoryGirl.create(:task, :asset => nil)
573
+ end
574
+ it_should_behave_like("attach")
575
+ end
576
+
577
+ describe "opportunities" do
578
+ before do
579
+ @model = FactoryGirl.create(:contact)
580
+ @attachment = FactoryGirl.create(:opportunity)
581
+ end
582
+ it_should_behave_like("attach")
583
+ end
584
+ end
585
+
586
+ # PUT /contacts/1/attach
587
+ # PUT /contacts/1/attach.xml AJAX
588
+ #----------------------------------------------------------------------------
589
+ describe "responding to PUT attach" do
590
+ describe "tasks" do
591
+ before do
592
+ @model = FactoryGirl.create(:contact)
593
+ @attachment = FactoryGirl.create(:task, :asset => nil)
594
+ end
595
+ it_should_behave_like("attach")
596
+ end
597
+
598
+ describe "opportunities" do
599
+ before do
600
+ @model = FactoryGirl.create(:contact)
601
+ @attachment = FactoryGirl.create(:opportunity)
602
+ end
603
+ it_should_behave_like("attach")
604
+ end
605
+ end
606
+
607
+ # POST /contacts/1/discard
608
+ # POST /contacts/1/discard.xml AJAX
609
+ #----------------------------------------------------------------------------
610
+ describe "responding to POST discard" do
611
+ describe "tasks" do
612
+ before do
613
+ @model = FactoryGirl.create(:contact)
614
+ @attachment = FactoryGirl.create(:task, :asset => @model)
615
+ end
616
+ it_should_behave_like("discard")
617
+ end
618
+
619
+ describe "opportunities" do
620
+ before do
621
+ @attachment = FactoryGirl.create(:opportunity)
622
+ @model = FactoryGirl.create(:contact)
623
+ @model.opportunities << @attachment
624
+ end
625
+ it_should_behave_like("discard")
626
+ end
627
+ end
628
+
629
+ # POST /contacts/auto_complete/query AJAX
630
+ #----------------------------------------------------------------------------
631
+ describe "responding to POST auto_complete" do
632
+ before(:each) do
633
+ @auto_complete_matches = [ FactoryGirl.create(:contact, :first_name => "Hello", :last_name => "World", :user => @current_user) ]
634
+ end
635
+
636
+ it_should_behave_like("auto complete")
637
+ end
638
+
639
+ # GET /contacts/options AJAX
640
+ #----------------------------------------------------------------------------
641
+ describe "responding to GET options" do
642
+ it "should set current user preferences when showing options" do
643
+ @per_page = FactoryGirl.create(:preference, :user => @current_user, :name => "contacts_per_page", :value => Base64.encode64(Marshal.dump(42)))
644
+ @outline = FactoryGirl.create(:preference, :user => @current_user, :name => "contacts_outline", :value => Base64.encode64(Marshal.dump("option_long")))
645
+ @sort_by = FactoryGirl.create(:preference, :user => @current_user, :name => "contacts_sort_by", :value => Base64.encode64(Marshal.dump("contacts.first_name ASC")))
646
+ @naming = FactoryGirl.create(:preference, :user => @current_user, :name => "contacts_naming", :value => Base64.encode64(Marshal.dump("option_after")))
647
+
648
+ xhr :get, :options
649
+ assigns[:per_page].should == 42
650
+ assigns[:outline].should == "option_long"
651
+ assigns[:sort_by].should == "contacts.first_name ASC"
652
+ assigns[:naming].should == "option_after"
653
+ end
654
+
655
+ it "should not assign instance variables when hiding options" do
656
+ xhr :get, :options, :cancel => "true"
657
+ assigns[:per_page].should == nil
658
+ assigns[:outline].should == nil
659
+ assigns[:sort_by].should == nil
660
+ assigns[:naming].should == nil
661
+ end
662
+ end
663
+
664
+ # POST /contacts/redraw AJAX
665
+ #----------------------------------------------------------------------------
666
+ describe "responding to POST redraw" do
667
+ it "should save user selected contact preference" do
668
+ xhr :post, :redraw, :per_page => 42, :outline => "long", :sort_by => "first_name", :naming => "after"
669
+ @current_user.preference[:contacts_per_page].to_i.should == 42
670
+ @current_user.preference[:contacts_outline].should == "long"
671
+ @current_user.preference[:contacts_sort_by].should == "contacts.first_name ASC"
672
+ @current_user.preference[:contacts_naming].should == "after"
673
+ end
674
+
675
+ it "should set similar options for Leads" do
676
+ xhr :post, :redraw, :sort_by => "first_name", :naming => "after"
677
+ @current_user.pref[:leads_sort_by].should == "leads.first_name ASC"
678
+ @current_user.pref[:leads_naming].should == "after"
679
+ end
680
+
681
+ it "should reset current page to 1" do
682
+ xhr :post, :redraw, :per_page => 42, :outline => "long", :sort_by => "first_name", :naming => "after"
683
+ session[:contacts_current_page].should == 1
684
+ end
685
+
686
+ it "should select @contacts and render [index] template" do
687
+ @contacts = [
688
+ FactoryGirl.create(:contact, :first_name => "Alice", :user => @current_user),
689
+ FactoryGirl.create(:contact, :first_name => "Bobby", :user => @current_user)
690
+ ]
691
+
692
+ xhr :post, :redraw, :per_page => 1, :sort_by => "first_name"
693
+ assigns(:contacts).should == [ @contacts.first ]
694
+ response.should render_template("contacts/index")
695
+ end
696
+ end
697
+
698
+ end
699
+