brisk-bills 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (524) hide show
  1. data/CHANGELOG +8 -0
  2. data/COPYING +674 -0
  3. data/COPYING.LESSER +165 -0
  4. data/INSTALL +5 -0
  5. data/README +22 -0
  6. data/Rakefile +11 -0
  7. data/TODO.txt +112 -0
  8. data/app/controllers/admin/activities_controller.rb +151 -0
  9. data/app/controllers/admin/activities_controller/adjustment.rb +16 -0
  10. data/app/controllers/admin/activities_controller/labor.rb +119 -0
  11. data/app/controllers/admin/activities_controller/labor/slimtimer.rb +28 -0
  12. data/app/controllers/admin/activities_controller/material.rb +20 -0
  13. data/app/controllers/admin/activities_controller/proposal.rb +15 -0
  14. data/app/controllers/admin/activities_with_prices_controller.rb +68 -0
  15. data/app/controllers/admin/adjustments_controller.rb +22 -0
  16. data/app/controllers/admin/client_accounting_controller.rb +49 -0
  17. data/app/controllers/admin/client_financial_transactions_controller.rb +24 -0
  18. data/app/controllers/admin/client_representatives_controller.rb +31 -0
  19. data/app/controllers/admin/clients_controller.rb +31 -0
  20. data/app/controllers/admin/employee_client_labor_rate_controller.rb +30 -0
  21. data/app/controllers/admin/employees_controller.rb +32 -0
  22. data/app/controllers/admin/employees_controller/slimtimer.rb +29 -0
  23. data/app/controllers/admin/invoices_controller.rb +165 -0
  24. data/app/controllers/admin/labors_controller.rb +103 -0
  25. data/app/controllers/admin/labors_controller/slimtimer.rb +31 -0
  26. data/app/controllers/admin/materials_controller.rb +24 -0
  27. data/app/controllers/admin/payments_controller.rb +75 -0
  28. data/app/controllers/admin/proposals_controller.rb +22 -0
  29. data/app/controllers/admin/settings_controller.rb +23 -0
  30. data/app/controllers/application_controller.rb +22 -0
  31. data/app/controllers/authentication_controller.rb +131 -0
  32. data/app/helpers/activity_type_model_helper.rb +194 -0
  33. data/app/helpers/admin/activities_helper.rb +110 -0
  34. data/app/helpers/admin/activities_helper/labor_helper.rb +28 -0
  35. data/app/helpers/admin/activities_helper/proposal_helper.rb +11 -0
  36. data/app/helpers/admin/activities_helper/slimtimer_helper.rb +13 -0
  37. data/app/helpers/admin/activities_with_prices_helper.rb +17 -0
  38. data/app/helpers/admin/activity_tax_controller_helper.rb +48 -0
  39. data/app/helpers/admin/activity_tax_field_helper.rb +33 -0
  40. data/app/helpers/admin/activity_type_controller_helper.rb +83 -0
  41. data/app/helpers/admin/activity_type_field_helper.rb +45 -0
  42. data/app/helpers/admin/adjustments_helper.rb +5 -0
  43. data/app/helpers/admin/client_accounting_helper.rb +13 -0
  44. data/app/helpers/admin/client_financial_transactions_helper.rb +9 -0
  45. data/app/helpers/admin/client_representatives_helper.rb +26 -0
  46. data/app/helpers/admin/clients_helper.rb +6 -0
  47. data/app/helpers/admin/employee_client_labor_rate_helper.rb +77 -0
  48. data/app/helpers/admin/employees_helper.rb +9 -0
  49. data/app/helpers/admin/employees_helper/slimtimer_helper.rb +2 -0
  50. data/app/helpers/admin/has_credential_column_helper.rb +60 -0
  51. data/app/helpers/admin/invoices_helper.rb +59 -0
  52. data/app/helpers/admin/is_active_column_helper.rb +46 -0
  53. data/app/helpers/admin/labors_helper.rb +20 -0
  54. data/app/helpers/admin/labors_helper/slimtimer_helper.rb +13 -0
  55. data/app/helpers/admin/materials_helper.rb +5 -0
  56. data/app/helpers/admin/payments_helper.rb +41 -0
  57. data/app/helpers/admin/proposals_helper.rb +3 -0
  58. data/app/helpers/admin/settings_helper.rb +8 -0
  59. data/app/helpers/admin_layout_helper.rb +91 -0
  60. data/app/helpers/application_helper.rb +27 -0
  61. data/app/helpers/authentication_helper.rb +61 -0
  62. data/app/helpers/extensible_object_helper.rb +28 -0
  63. data/app/helpers/has_credential_model_helper.rb +39 -0
  64. data/app/helpers/invoice_pdf_helper.rb +71 -0
  65. data/app/helpers/is_active_model_helper.rb +40 -0
  66. data/app/helpers/money_model_helper.rb +21 -0
  67. data/app/model_views/client_accounting.rb +5 -0
  68. data/app/model_views/client_financial_transaction.rb +15 -0
  69. data/app/model_views/invoices_with_total.rb +36 -0
  70. data/app/models/activity.rb +104 -0
  71. data/app/models/activity/adjustment.rb +34 -0
  72. data/app/models/activity/labor.rb +91 -0
  73. data/app/models/activity/labor/slimtimer.rb +28 -0
  74. data/app/models/activity/material.rb +16 -0
  75. data/app/models/activity/proposal.rb +17 -0
  76. data/app/models/activity_type.rb +2 -0
  77. data/app/models/client.rb +93 -0
  78. data/app/models/client_eventlog.rb +5 -0
  79. data/app/models/client_representative.rb +22 -0
  80. data/app/models/credential.rb +195 -0
  81. data/app/models/employee.rb +49 -0
  82. data/app/models/employee/labor.rb +13 -0
  83. data/app/models/employee/slimtimer.rb +43 -0
  84. data/app/models/employee_client_labor_rate.rb +20 -0
  85. data/app/models/invoice.rb +280 -0
  86. data/app/models/invoice_payment.rb +8 -0
  87. data/app/models/notifier.rb +85 -0
  88. data/app/models/payment.rb +108 -0
  89. data/app/models/payment_method.rb +7 -0
  90. data/app/models/setting.rb +39 -0
  91. data/app/models/slimtimer_task.rb +6 -0
  92. data/app/models/slimtimer_time_entry.rb +69 -0
  93. data/app/views/admin/activities/_adjustment_column.rhtml +23 -0
  94. data/app/views/admin/activities/_form.rhtml +20 -0
  95. data/app/views/admin/activities/_form_attribute.rhtml +12 -0
  96. data/app/views/admin/activities/_labor_column.rhtml +17 -0
  97. data/app/views/admin/activities/_material_column.rhtml +10 -0
  98. data/app/views/admin/activities/_proposal_column.rhtml +11 -0
  99. data/app/views/admin/activities_with_prices/move_to_invoice.rhtml +44 -0
  100. data/app/views/admin/activities_with_prices/move_to_invoice.rjs +9 -0
  101. data/app/views/admin/invoices/download.rpdf +224 -0
  102. data/app/views/authentication/email.rjs +9 -0
  103. data/app/views/authentication/login.rhtml +75 -0
  104. data/app/views/authentication/login.rjs +14 -0
  105. data/app/views/authentication/reset_password_via_token.rhtml +16 -0
  106. data/app/views/authentication/reset_password_via_token.rjs +6 -0
  107. data/app/views/authentication/sign_in_error.rjs +2 -0
  108. data/app/views/layouts/_navigation_tree.rhtml +15 -0
  109. data/app/views/layouts/admin.rhtml +26 -0
  110. data/app/views/layouts/public.rhtml +18 -0
  111. data/app/views/notifier/_email_footer.html.rhtml +12 -0
  112. data/app/views/notifier/_email_footer.plain.rhtml +3 -0
  113. data/app/views/notifier/_email_header.html.rhtml +53 -0
  114. data/app/views/notifier/invoice_available.html.rhtml +5 -0
  115. data/app/views/notifier/invoice_available.plain.rhtml +4 -0
  116. data/app/views/notifier/reset_password_requested.html.rhtml +15 -0
  117. data/app/views/notifier/reset_password_requested.plain.rhtml +9 -0
  118. data/bin/brisk-bills +51 -0
  119. data/config/boot.rb +164 -0
  120. data/config/environment.rb +39 -0
  121. data/config/environments/development.rb +17 -0
  122. data/config/environments/production.rb +18 -0
  123. data/config/environments/test.rb +19 -0
  124. data/config/locale/en.rb +26 -0
  125. data/config/routes.rb +20 -0
  126. data/config/secrets.yml +2 -0
  127. data/db/migrate/001_create_employees.rb +14 -0
  128. data/db/migrate/002_create_employee_slimtimers.rb +14 -0
  129. data/db/migrate/003_create_slimtimer_tasks.rb +21 -0
  130. data/db/migrate/004_create_slimtimer_time_entries.rb +25 -0
  131. data/db/migrate/005_create_clients.rb +12 -0
  132. data/db/migrate/006_create_client_representatives.rb +16 -0
  133. data/db/migrate/007_create_client_eventlogs.rb +13 -0
  134. data/db/migrate/008_create_activities.rb +17 -0
  135. data/db/migrate/009_create_activity_labors.rb +16 -0
  136. data/db/migrate/010_create_employee_client_labor_rates.rb +19 -0
  137. data/db/migrate/011_create_activity_adjustments.rb +16 -0
  138. data/db/migrate/012_create_activity_materials.rb +16 -0
  139. data/db/migrate/013_create_activity_proposals.rb +18 -0
  140. data/db/migrate/014_create_invoices.rb +16 -0
  141. data/db/migrate/015_create_payments.rb +18 -0
  142. data/db/migrate/016_create_payment_methods.rb +18 -0
  143. data/db/migrate/017_create_invoice_payments.rb +14 -0
  144. data/db/migrate/018_create_activity_types.rb +37 -0
  145. data/db/migrate/019_create_settings.rb +45 -0
  146. data/db/migrate/020_is_active_employees_clients.rb +11 -0
  147. data/db/migrate/021_create_views_and_indexes.rb +78 -0
  148. data/db/migrate/022_create_client_financial_transactions.rb +32 -0
  149. data/db/migrate/023_create_credentials_migrate_representatives.rb +133 -0
  150. data/db/migrate/024_updates_for_sales_tax.rb +91 -0
  151. data/db/migrate/025_alter_credentials_for_reset.rb +11 -0
  152. data/db/migrate/026_create_st_settings.rb +17 -0
  153. data/db/migrate/027_create_sessions.rb +16 -0
  154. data/db/migrate/028_money_to_cents.rb +136 -0
  155. data/db/schema.rb +301 -0
  156. data/lib/brisk-bills.rb +17 -0
  157. data/lib/brisk-bills/initializer.rb +100 -0
  158. data/lib/dti-navigation-menu/lib/dti-navigation-menu.rb +27 -0
  159. data/lib/generators/generator_base_extension.rb +16 -0
  160. data/lib/generators/instance/instance_generator.rb +117 -0
  161. data/lib/generators/instance/templates/databases/mysql.yml +47 -0
  162. data/lib/generators/instance/templates/instance_boot.rb +166 -0
  163. data/lib/generators/instance/templates/instance_environment.rb +65 -0
  164. data/lib/generators/instance/templates/instance_generate +18 -0
  165. data/lib/generators/instance/templates/instance_rakefile +3 -0
  166. data/lib/generators/instance/templates/instance_routes.rb +1 -0
  167. data/lib/tasks/create_last_months_invoices.rake +37 -0
  168. data/lib/tasks/credential_tasks.rake +47 -0
  169. data/lib/tasks/first_time_setup.rake +96 -0
  170. data/lib/tasks/instance.rake +27 -0
  171. data/lib/tasks/invoice_as_csv.rake +32 -0
  172. data/lib/tasks/package.rake +120 -0
  173. data/lib/tasks/slimtimer_import.rake +198 -0
  174. data/lib/utilities.rb +18 -0
  175. data/log/.keep +0 -0
  176. data/public/.htaccess +40 -0
  177. data/public/404.html +30 -0
  178. data/public/500.html +30 -0
  179. data/public/blank.html +33 -0
  180. data/public/blank_iframe.html +2 -0
  181. data/public/dispatch.cgi +10 -0
  182. data/public/dispatch.fcgi +24 -0
  183. data/public/dispatch.rb +10 -0
  184. data/public/favicon.ico +0 -0
  185. data/public/images/active_scaffold/DO_NOT_EDIT +2 -0
  186. data/public/images/active_scaffold/default/add.gif +0 -0
  187. data/public/images/active_scaffold/default/arrow_down.gif +0 -0
  188. data/public/images/active_scaffold/default/arrow_up.gif +0 -0
  189. data/public/images/active_scaffold/default/close.gif +0 -0
  190. data/public/images/active_scaffold/default/cross.png +0 -0
  191. data/public/images/active_scaffold/default/indicator-small.gif +0 -0
  192. data/public/images/active_scaffold/default/indicator.gif +0 -0
  193. data/public/images/active_scaffold/default/magnifier.png +0 -0
  194. data/public/images/background.gif +0 -0
  195. data/public/images/brisk-bills-logo.gif +0 -0
  196. data/public/images/calendar_date_select/calendar.gif +0 -0
  197. data/public/images/dti-logo.gif +0 -0
  198. data/public/images/dti-logo.jpg +0 -0
  199. data/public/images/favicon.ico +0 -0
  200. data/public/images/invoice-background.jpg +0 -0
  201. data/public/images/login-form-spinner.gif +0 -0
  202. data/public/images/nav-arrow.gif +0 -0
  203. data/public/images/notice-error.gif +0 -0
  204. data/public/images/notice-info.gif +0 -0
  205. data/public/images/rails.png +0 -0
  206. data/public/javascripts/active_scaffold/DO_NOT_EDIT +2 -0
  207. data/public/javascripts/active_scaffold/default/active_scaffold.js +430 -0
  208. data/public/javascripts/active_scaffold/default/dhtml_history.js +867 -0
  209. data/public/javascripts/active_scaffold/default/form_enhancements.js +114 -0
  210. data/public/javascripts/active_scaffold/default/rico_corner.js +370 -0
  211. data/public/javascripts/application.js +2 -0
  212. data/public/javascripts/briskbills-quick-helpers.js +9 -0
  213. data/public/javascripts/builder.js +136 -0
  214. data/public/javascripts/controls.js +963 -0
  215. data/public/javascripts/dragdrop.js +973 -0
  216. data/public/javascripts/effects.js +1128 -0
  217. data/public/javascripts/modalbox.js +573 -0
  218. data/public/javascripts/prototype.js +4320 -0
  219. data/public/javascripts/scriptaculous.js +58 -0
  220. data/public/javascripts/shadedborder.js +249 -0
  221. data/public/javascripts/slider.js +275 -0
  222. data/public/javascripts/sound.js +55 -0
  223. data/public/javascripts/unittest.js +568 -0
  224. data/public/robots.txt +1 -0
  225. data/public/stylesheets/active_scaffold/DO_NOT_EDIT +2 -0
  226. data/public/stylesheets/active_scaffold/default/stylesheet-ie.css +35 -0
  227. data/public/stylesheets/active_scaffold/default/stylesheet.css +809 -0
  228. data/public/stylesheets/admin/global.css +152 -0
  229. data/public/stylesheets/admin/pages.css +137 -0
  230. data/public/stylesheets/admin/screen.css +3 -0
  231. data/public/stylesheets/admin/structure.css +88 -0
  232. data/public/stylesheets/modalbox.css +95 -0
  233. data/public/stylesheets/public/global.css +36 -0
  234. data/public/stylesheets/public/pages.css +105 -0
  235. data/public/stylesheets/public/screen.css +3 -0
  236. data/public/stylesheets/public/structure.css +0 -0
  237. data/public/stylesheets/spinner.gif +0 -0
  238. data/script/about +3 -0
  239. data/script/breakpointer +3 -0
  240. data/script/console +3 -0
  241. data/script/dbconsole +3 -0
  242. data/script/destroy +3 -0
  243. data/script/generate +3 -0
  244. data/script/performance/benchmarker +3 -0
  245. data/script/performance/profiler +3 -0
  246. data/script/performance/request +3 -0
  247. data/script/plugin +3 -0
  248. data/script/process/inspector +3 -0
  249. data/script/process/reaper +3 -0
  250. data/script/process/spawner +3 -0
  251. data/script/runner +3 -0
  252. data/script/server +3 -0
  253. data/test/fixtures/activities.yml +28 -0
  254. data/test/fixtures/activity_adjustments.yml +7 -0
  255. data/test/fixtures/activity_labors.yml +25 -0
  256. data/test/fixtures/activity_materials.yml +7 -0
  257. data/test/fixtures/activity_proposals.yml +7 -0
  258. data/test/fixtures/activity_types.yml +23 -0
  259. data/test/fixtures/client_eventlogs.yml +5 -0
  260. data/test/fixtures/client_financial_transactions.yml +7 -0
  261. data/test/fixtures/client_representatives.yml +56 -0
  262. data/test/fixtures/clients.yml +172 -0
  263. data/test/fixtures/credentials.yml +34 -0
  264. data/test/fixtures/employee_client_labor_rates.yml +365 -0
  265. data/test/fixtures/employee_slimtimers.yml +19 -0
  266. data/test/fixtures/employees.yml +22 -0
  267. data/test/fixtures/invoice_payments.yml +7 -0
  268. data/test/fixtures/invoices.yml +7 -0
  269. data/test/fixtures/payment_methods.yml +7 -0
  270. data/test/fixtures/payments.yml +7 -0
  271. data/test/fixtures/settings.yml +7 -0
  272. data/test/fixtures/slimtimer_tasks.yml +5 -0
  273. data/test/fixtures/slimtimer_time_entries.yml +5 -0
  274. data/test/functional/admin/activities_controller_test.rb +8 -0
  275. data/test/functional/admin/adjustments_controller_test.rb +8 -0
  276. data/test/functional/admin/client_accounting_controller_test.rb +8 -0
  277. data/test/functional/admin/client_financial_transactions_controller_test.rb +8 -0
  278. data/test/functional/admin/client_representatives_controller_test.rb +8 -0
  279. data/test/functional/admin/clients_controller_test.rb +8 -0
  280. data/test/functional/admin/employee_client_labor_rate_controller_test.rb +8 -0
  281. data/test/functional/admin/employees/slimtimer_controller_test.rb +8 -0
  282. data/test/functional/admin/employees_controller_test.rb +8 -0
  283. data/test/functional/admin/invoices_controller_test.rb +8 -0
  284. data/test/functional/admin/labors_controller_test.rb +8 -0
  285. data/test/functional/admin/materials_controller_test.rb +8 -0
  286. data/test/functional/admin/payments_controller_test.rb +8 -0
  287. data/test/functional/admin/proposals_controller_test.rb +8 -0
  288. data/test/functional/admin/settings_controller_test.rb +8 -0
  289. data/test/functional/authentication_controller_test.rb +8 -0
  290. data/test/test_helper.rb +30 -0
  291. data/test/test_unit_factory_helper.rb +154 -0
  292. data/test/unit/activity/adjustment_test.rb +8 -0
  293. data/test/unit/activity/labor_test.rb +279 -0
  294. data/test/unit/activity/material_test.rb +8 -0
  295. data/test/unit/activity/proposal_test.rb +8 -0
  296. data/test/unit/activity_test.rb +83 -0
  297. data/test/unit/activity_type_test.rb +8 -0
  298. data/test/unit/client_eventlog_test.rb +10 -0
  299. data/test/unit/client_financial_transaction_test.rb +8 -0
  300. data/test/unit/client_representative_test.rb +10 -0
  301. data/test/unit/client_test.rb +24 -0
  302. data/test/unit/credential_test.rb +217 -0
  303. data/test/unit/employee/slimtimer_test.rb +10 -0
  304. data/test/unit/employee_client_labor_rate_test.rb +8 -0
  305. data/test/unit/employee_test.rb +25 -0
  306. data/test/unit/invoice_payment_test.rb +8 -0
  307. data/test/unit/invoice_test.rb +459 -0
  308. data/test/unit/notifier_test.rb +9 -0
  309. data/test/unit/payment_method_test.rb +8 -0
  310. data/test/unit/payment_test.rb +155 -0
  311. data/test/unit/setting_test.rb +8 -0
  312. data/test/unit/slimtimer_task_test.rb +10 -0
  313. data/test/unit/slimtimer_time_entry_test.rb +132 -0
  314. data/vendor/plugins/InlineAttachment-0.3.0-modified/README +79 -0
  315. data/vendor/plugins/InlineAttachment-0.3.0-modified/init.rb +2 -0
  316. data/vendor/plugins/InlineAttachment-0.3.0-modified/lib/inline_attachment.rb +136 -0
  317. data/vendor/plugins/InlineAttachment-0.3.0-modified/lib/tmail_content_id.rb +40 -0
  318. data/vendor/plugins/active_scaffold/CHANGELOG +152 -0
  319. data/vendor/plugins/active_scaffold/MIT-LICENSE +20 -0
  320. data/vendor/plugins/active_scaffold/README +28 -0
  321. data/vendor/plugins/active_scaffold/Rakefile +24 -0
  322. data/vendor/plugins/active_scaffold/environment.rb +17 -0
  323. data/vendor/plugins/active_scaffold/frontends/default/images/add.gif +0 -0
  324. data/vendor/plugins/active_scaffold/frontends/default/images/arrow_down.gif +0 -0
  325. data/vendor/plugins/active_scaffold/frontends/default/images/arrow_up.gif +0 -0
  326. data/vendor/plugins/active_scaffold/frontends/default/images/close.gif +0 -0
  327. data/vendor/plugins/active_scaffold/frontends/default/images/cross.png +0 -0
  328. data/vendor/plugins/active_scaffold/frontends/default/images/indicator-small.gif +0 -0
  329. data/vendor/plugins/active_scaffold/frontends/default/images/indicator.gif +0 -0
  330. data/vendor/plugins/active_scaffold/frontends/default/images/magnifier.png +0 -0
  331. data/vendor/plugins/active_scaffold/frontends/default/javascripts/active_scaffold.js +430 -0
  332. data/vendor/plugins/active_scaffold/frontends/default/javascripts/dhtml_history.js +867 -0
  333. data/vendor/plugins/active_scaffold/frontends/default/javascripts/form_enhancements.js +114 -0
  334. data/vendor/plugins/active_scaffold/frontends/default/javascripts/rico_corner.js +370 -0
  335. data/vendor/plugins/active_scaffold/frontends/default/stylesheets/stylesheet-ie.css +35 -0
  336. data/vendor/plugins/active_scaffold/frontends/default/stylesheets/stylesheet.css +809 -0
  337. data/vendor/plugins/active_scaffold/frontends/default/views/_add_existing_form.html.erb +40 -0
  338. data/vendor/plugins/active_scaffold/frontends/default/views/_create_form.html.erb +49 -0
  339. data/vendor/plugins/active_scaffold/frontends/default/views/_create_form_on_list.html.erb +38 -0
  340. data/vendor/plugins/active_scaffold/frontends/default/views/_field_search.html.erb +45 -0
  341. data/vendor/plugins/active_scaffold/frontends/default/views/_form.html.erb +18 -0
  342. data/vendor/plugins/active_scaffold/frontends/default/views/_form_association.html.erb +20 -0
  343. data/vendor/plugins/active_scaffold/frontends/default/views/_form_association_footer.html.erb +42 -0
  344. data/vendor/plugins/active_scaffold/frontends/default/views/_form_association_header.html.erb +10 -0
  345. data/vendor/plugins/active_scaffold/frontends/default/views/_form_association_record.html.erb +27 -0
  346. data/vendor/plugins/active_scaffold/frontends/default/views/_form_attribute.html.erb +12 -0
  347. data/vendor/plugins/active_scaffold/frontends/default/views/_form_hidden_attribute.html.erb +1 -0
  348. data/vendor/plugins/active_scaffold/frontends/default/views/_form_messages.html.erb +5 -0
  349. data/vendor/plugins/active_scaffold/frontends/default/views/_horizontal_subform.html.erb +21 -0
  350. data/vendor/plugins/active_scaffold/frontends/default/views/_list.html.erb +37 -0
  351. data/vendor/plugins/active_scaffold/frontends/default/views/_list_actions.html.erb +13 -0
  352. data/vendor/plugins/active_scaffold/frontends/default/views/_list_calculations.html.erb +22 -0
  353. data/vendor/plugins/active_scaffold/frontends/default/views/_list_column_headings.html.erb +32 -0
  354. data/vendor/plugins/active_scaffold/frontends/default/views/_list_header.html.erb +14 -0
  355. data/vendor/plugins/active_scaffold/frontends/default/views/_list_inline_adapter.html.erb +9 -0
  356. data/vendor/plugins/active_scaffold/frontends/default/views/_list_pagination_links.html.erb +30 -0
  357. data/vendor/plugins/active_scaffold/frontends/default/views/_list_record.html.erb +35 -0
  358. data/vendor/plugins/active_scaffold/frontends/default/views/_live_search.html.erb +25 -0
  359. data/vendor/plugins/active_scaffold/frontends/default/views/_messages.html.erb +10 -0
  360. data/vendor/plugins/active_scaffold/frontends/default/views/_nested.html.erb +44 -0
  361. data/vendor/plugins/active_scaffold/frontends/default/views/_search.html.erb +21 -0
  362. data/vendor/plugins/active_scaffold/frontends/default/views/_show.html.erb +8 -0
  363. data/vendor/plugins/active_scaffold/frontends/default/views/_show_columns.html.erb +11 -0
  364. data/vendor/plugins/active_scaffold/frontends/default/views/_update_actions.html.erb +9 -0
  365. data/vendor/plugins/active_scaffold/frontends/default/views/_update_form.html.erb +53 -0
  366. data/vendor/plugins/active_scaffold/frontends/default/views/add_existing.js.rjs +16 -0
  367. data/vendor/plugins/active_scaffold/frontends/default/views/add_existing_form.html.erb +5 -0
  368. data/vendor/plugins/active_scaffold/frontends/default/views/create.html.erb +5 -0
  369. data/vendor/plugins/active_scaffold/frontends/default/views/delete.html.erb +13 -0
  370. data/vendor/plugins/active_scaffold/frontends/default/views/destroy.js.rjs +10 -0
  371. data/vendor/plugins/active_scaffold/frontends/default/views/edit_associated.js.rjs +15 -0
  372. data/vendor/plugins/active_scaffold/frontends/default/views/field_search.html.erb +5 -0
  373. data/vendor/plugins/active_scaffold/frontends/default/views/form_messages.js.rjs +1 -0
  374. data/vendor/plugins/active_scaffold/frontends/default/views/form_messages_on_create.js.rjs +2 -0
  375. data/vendor/plugins/active_scaffold/frontends/default/views/form_messages_on_update.js.rjs +2 -0
  376. data/vendor/plugins/active_scaffold/frontends/default/views/list.html.erb +44 -0
  377. data/vendor/plugins/active_scaffold/frontends/default/views/on_create.js.rjs +25 -0
  378. data/vendor/plugins/active_scaffold/frontends/default/views/on_update.js.rjs +11 -0
  379. data/vendor/plugins/active_scaffold/frontends/default/views/search.html.erb +5 -0
  380. data/vendor/plugins/active_scaffold/frontends/default/views/show.html.erb +5 -0
  381. data/vendor/plugins/active_scaffold/frontends/default/views/update.html.erb +8 -0
  382. data/vendor/plugins/active_scaffold/frontends/default/views/update_column.js.rjs +12 -0
  383. data/vendor/plugins/active_scaffold/init.rb +18 -0
  384. data/vendor/plugins/active_scaffold/install.rb +40 -0
  385. data/vendor/plugins/active_scaffold/install_assets.rb +36 -0
  386. data/vendor/plugins/active_scaffold/lib/active_record_permissions.rb +123 -0
  387. data/vendor/plugins/active_scaffold/lib/active_scaffold.rb +144 -0
  388. data/vendor/plugins/active_scaffold/lib/active_scaffold/actions/core.rb +102 -0
  389. data/vendor/plugins/active_scaffold/lib/active_scaffold/actions/create.rb +120 -0
  390. data/vendor/plugins/active_scaffold/lib/active_scaffold/actions/delete.rb +46 -0
  391. data/vendor/plugins/active_scaffold/lib/active_scaffold/actions/field_search.rb +46 -0
  392. data/vendor/plugins/active_scaffold/lib/active_scaffold/actions/list.rb +77 -0
  393. data/vendor/plugins/active_scaffold/lib/active_scaffold/actions/live_search.rb +46 -0
  394. data/vendor/plugins/active_scaffold/lib/active_scaffold/actions/nested.rb +215 -0
  395. data/vendor/plugins/active_scaffold/lib/active_scaffold/actions/search.rb +40 -0
  396. data/vendor/plugins/active_scaffold/lib/active_scaffold/actions/show.rb +34 -0
  397. data/vendor/plugins/active_scaffold/lib/active_scaffold/actions/subform.rb +17 -0
  398. data/vendor/plugins/active_scaffold/lib/active_scaffold/actions/update.rb +114 -0
  399. data/vendor/plugins/active_scaffold/lib/active_scaffold/attribute_params.rb +185 -0
  400. data/vendor/plugins/active_scaffold/lib/active_scaffold/config/base.rb +37 -0
  401. data/vendor/plugins/active_scaffold/lib/active_scaffold/config/core.rb +189 -0
  402. data/vendor/plugins/active_scaffold/lib/active_scaffold/config/create.rb +43 -0
  403. data/vendor/plugins/active_scaffold/lib/active_scaffold/config/delete.rb +25 -0
  404. data/vendor/plugins/active_scaffold/lib/active_scaffold/config/field_search.rb +53 -0
  405. data/vendor/plugins/active_scaffold/lib/active_scaffold/config/form.rb +49 -0
  406. data/vendor/plugins/active_scaffold/lib/active_scaffold/config/list.rb +134 -0
  407. data/vendor/plugins/active_scaffold/lib/active_scaffold/config/live_search.rb +52 -0
  408. data/vendor/plugins/active_scaffold/lib/active_scaffold/config/nested.rb +31 -0
  409. data/vendor/plugins/active_scaffold/lib/active_scaffold/config/search.rb +52 -0
  410. data/vendor/plugins/active_scaffold/lib/active_scaffold/config/show.rb +39 -0
  411. data/vendor/plugins/active_scaffold/lib/active_scaffold/config/subform.rb +33 -0
  412. data/vendor/plugins/active_scaffold/lib/active_scaffold/config/update.rb +32 -0
  413. data/vendor/plugins/active_scaffold/lib/active_scaffold/configurable.rb +29 -0
  414. data/vendor/plugins/active_scaffold/lib/active_scaffold/constraints.rb +178 -0
  415. data/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/action_columns.rb +97 -0
  416. data/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/action_link.rb +136 -0
  417. data/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/action_links.rb +47 -0
  418. data/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/actions.rb +45 -0
  419. data/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/column.rb +297 -0
  420. data/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/columns.rb +75 -0
  421. data/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/error_message.rb +24 -0
  422. data/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/set.rb +62 -0
  423. data/vendor/plugins/active_scaffold/lib/active_scaffold/data_structures/sorting.rb +89 -0
  424. data/vendor/plugins/active_scaffold/lib/active_scaffold/finder.rb +234 -0
  425. data/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/association_helpers.rb +40 -0
  426. data/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/controller_helpers.rb +25 -0
  427. data/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/country_helpers.rb +348 -0
  428. data/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/form_column_helpers.rb +267 -0
  429. data/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/id_helpers.rb +125 -0
  430. data/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/list_column_helpers.rb +178 -0
  431. data/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/pagination_helpers.rb +37 -0
  432. data/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/search_column_helpers.rb +172 -0
  433. data/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/show_column_helpers.rb +46 -0
  434. data/vendor/plugins/active_scaffold/lib/active_scaffold/helpers/view_helpers.rb +196 -0
  435. data/vendor/plugins/active_scaffold/lib/active_scaffold/locale/en.rb +66 -0
  436. data/vendor/plugins/active_scaffold/lib/active_scaffold/locale/es.yml +64 -0
  437. data/vendor/plugins/active_scaffold/lib/active_scaffold/locale/hu.yml +62 -0
  438. data/vendor/plugins/active_scaffold/lib/bridges/bridge.rb +52 -0
  439. data/vendor/plugins/active_scaffold/lib/bridges/calendar_date_select/bridge.rb +11 -0
  440. data/vendor/plugins/active_scaffold/lib/bridges/calendar_date_select/lib/as_cds_bridge.rb +53 -0
  441. data/vendor/plugins/active_scaffold/lib/bridges/file_column/bridge.rb +12 -0
  442. data/vendor/plugins/active_scaffold/lib/bridges/file_column/lib/as_file_column_bridge.rb +49 -0
  443. data/vendor/plugins/active_scaffold/lib/bridges/file_column/lib/file_column_helpers.rb +51 -0
  444. data/vendor/plugins/active_scaffold/lib/bridges/file_column/lib/form_ui.rb +32 -0
  445. data/vendor/plugins/active_scaffold/lib/bridges/file_column/lib/list_ui.rb +26 -0
  446. data/vendor/plugins/active_scaffold/lib/bridges/file_column/test/functional/file_column_keep_test.rb +43 -0
  447. data/vendor/plugins/active_scaffold/lib/bridges/file_column/test/mock_model.rb +9 -0
  448. data/vendor/plugins/active_scaffold/lib/bridges/file_column/test/test_helper.rb +15 -0
  449. data/vendor/plugins/active_scaffold/lib/dhtml_confirm.rb +54 -0
  450. data/vendor/plugins/active_scaffold/lib/extensions/action_controller_rendering.rb +20 -0
  451. data/vendor/plugins/active_scaffold/lib/extensions/action_view_rendering.rb +87 -0
  452. data/vendor/plugins/active_scaffold/lib/extensions/array.rb +7 -0
  453. data/vendor/plugins/active_scaffold/lib/extensions/component_response_with_namespacing.rb +17 -0
  454. data/vendor/plugins/active_scaffold/lib/extensions/generic_view_paths.rb +33 -0
  455. data/vendor/plugins/active_scaffold/lib/extensions/localize.rb +10 -0
  456. data/vendor/plugins/active_scaffold/lib/extensions/name_option_for_datetime.rb +12 -0
  457. data/vendor/plugins/active_scaffold/lib/extensions/nil_id_in_url_params.rb +7 -0
  458. data/vendor/plugins/active_scaffold/lib/extensions/resources.rb +26 -0
  459. data/vendor/plugins/active_scaffold/lib/extensions/reverse_associations.rb +56 -0
  460. data/vendor/plugins/active_scaffold/lib/extensions/to_label.rb +8 -0
  461. data/vendor/plugins/active_scaffold/lib/extensions/unsaved_associated.rb +61 -0
  462. data/vendor/plugins/active_scaffold/lib/extensions/unsaved_record.rb +20 -0
  463. data/vendor/plugins/active_scaffold/lib/extensions/usa_state.rb +46 -0
  464. data/vendor/plugins/active_scaffold/lib/paginator.rb +136 -0
  465. data/vendor/plugins/active_scaffold/lib/responds_to_parent.rb +68 -0
  466. data/vendor/plugins/active_scaffold/public/blank.html +33 -0
  467. data/vendor/plugins/active_scaffold/test/bridges/bridge_test.rb +47 -0
  468. data/vendor/plugins/active_scaffold/test/config/create_test.rb +55 -0
  469. data/vendor/plugins/active_scaffold/test/config/list_test.rb +74 -0
  470. data/vendor/plugins/active_scaffold/test/config/update_test.rb +17 -0
  471. data/vendor/plugins/active_scaffold/test/const_mocker.rb +36 -0
  472. data/vendor/plugins/active_scaffold/test/data_structures/action_columns_test.rb +119 -0
  473. data/vendor/plugins/active_scaffold/test/data_structures/action_link_test.rb +78 -0
  474. data/vendor/plugins/active_scaffold/test/data_structures/action_links_test.rb +78 -0
  475. data/vendor/plugins/active_scaffold/test/data_structures/actions_test.rb +25 -0
  476. data/vendor/plugins/active_scaffold/test/data_structures/association_column_test.rb +41 -0
  477. data/vendor/plugins/active_scaffold/test/data_structures/column_test.rb +161 -0
  478. data/vendor/plugins/active_scaffold/test/data_structures/columns_test.rb +69 -0
  479. data/vendor/plugins/active_scaffold/test/data_structures/error_message_test.rb +28 -0
  480. data/vendor/plugins/active_scaffold/test/data_structures/set_test.rb +86 -0
  481. data/vendor/plugins/active_scaffold/test/data_structures/sorting_test.rb +96 -0
  482. data/vendor/plugins/active_scaffold/test/data_structures/standard_column_test.rb +34 -0
  483. data/vendor/plugins/active_scaffold/test/data_structures/virtual_column_test.rb +34 -0
  484. data/vendor/plugins/active_scaffold/test/extensions/active_record_test.rb +45 -0
  485. data/vendor/plugins/active_scaffold/test/extensions/array.rb +12 -0
  486. data/vendor/plugins/active_scaffold/test/misc/active_record_permissions.rb +154 -0
  487. data/vendor/plugins/active_scaffold/test/misc/configurable_test.rb +96 -0
  488. data/vendor/plugins/active_scaffold/test/misc/constraints_test.rb +175 -0
  489. data/vendor/plugins/active_scaffold/test/misc/finder_test.rb +70 -0
  490. data/vendor/plugins/active_scaffold/test/misc/lang_test.rb +12 -0
  491. data/vendor/plugins/active_scaffold/test/model_stub.rb +39 -0
  492. data/vendor/plugins/active_scaffold/test/run_all.rb +8 -0
  493. data/vendor/plugins/active_scaffold/test/test_helper.rb +13 -0
  494. data/vendor/plugins/active_scaffold/uninstall.rb +12 -0
  495. data/vendor/plugins/active_scaffold_as_gem/init.rb +21 -0
  496. data/vendor/plugins/active_scaffold_form_observation/init.rb +4 -0
  497. data/vendor/plugins/active_scaffold_form_observation/lib/active_scaffold_form_observation.rb +99 -0
  498. data/vendor/plugins/active_scaffold_full_refresh/init.rb +7 -0
  499. data/vendor/plugins/active_scaffold_full_refresh/lib/active_scaffold_full_refresh.rb +46 -0
  500. data/vendor/plugins/active_scaffold_move_column_under/init.rb +17 -0
  501. data/vendor/plugins/acts_as_money/README +24 -0
  502. data/vendor/plugins/acts_as_money/Rakefile +22 -0
  503. data/vendor/plugins/acts_as_money/init.rb +3 -0
  504. data/vendor/plugins/acts_as_money/install.rb +1 -0
  505. data/vendor/plugins/acts_as_money/lib/acts_as_money.rb +27 -0
  506. data/vendor/plugins/acts_as_money/tasks/money_tasks.rake +4 -0
  507. data/vendor/plugins/acts_as_money/test/money_test.rb +8 -0
  508. data/vendor/plugins/association_hacks/init.rb +1 -0
  509. data/vendor/plugins/association_hacks/lib/association_hacks.rb +27 -0
  510. data/vendor/plugins/railspdf/CHANGELOG +5 -0
  511. data/vendor/plugins/railspdf/README +88 -0
  512. data/vendor/plugins/railspdf/Rakefile +22 -0
  513. data/vendor/plugins/railspdf/TODO +1 -0
  514. data/vendor/plugins/railspdf/init.rb +3 -0
  515. data/vendor/plugins/railspdf/lib/railspdf.rb +65 -0
  516. data/vendor/plugins/railspdf/test/railspdf_test.rb +14 -0
  517. data/vendor/plugins/railspdf/test/test_helper.rb +9 -0
  518. data/vendor/plugins/render_component/README +37 -0
  519. data/vendor/plugins/render_component/Rakefile +22 -0
  520. data/vendor/plugins/render_component/init.rb +2 -0
  521. data/vendor/plugins/render_component/lib/components.rb +142 -0
  522. data/vendor/plugins/render_component/test/abstract_unit.rb +8 -0
  523. data/vendor/plugins/render_component/test/components_test.rb +140 -0
  524. metadata +657 -0
@@ -0,0 +1,8 @@
1
+ require File.dirname(__FILE__) + '/../../test_helper'
2
+
3
+ class Activity::MaterialTest < ActiveSupport::TestCase
4
+ # Replace this with your real tests.
5
+ def test_truth
6
+ assert true
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ require File.dirname(__FILE__) + '/../../test_helper'
2
+
3
+ class Activity::ProposalTest < ActiveSupport::TestCase
4
+ # Replace this with your real tests.
5
+ def test_truth
6
+ assert true
7
+ end
8
+ end
@@ -0,0 +1,83 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+
3
+ class ActivityTest < ActiveSupport::TestCase
4
+ fixtures :activities, :clients
5
+
6
+ def test_activity_constraints
7
+
8
+ assert_raise( ActiveRecord::RecordInvalid ) do
9
+ Activity.create(
10
+ :is_published => false,
11
+ :occurred_on => Time.new,
12
+ :cost => 0
13
+ ).save!
14
+ end
15
+
16
+ assert_raise( ActiveRecord::RecordInvalid ) do
17
+ Activity.create(
18
+ :is_published => false,
19
+ :occurred_on => Time.new,
20
+ :activity_type => '',
21
+ :cost => 0
22
+ ).save!
23
+ end
24
+
25
+ # NOTE: I used to test the costs in here, but, since we've switched to acts_as money, this is no longer needed...
26
+
27
+ assert_nothing_raised do
28
+ Activity.create(
29
+ :is_published => false,
30
+ :occurred_on => Time.new,
31
+ :activity_type => 'n/a',
32
+ :cost => 6.66
33
+ ).save!
34
+ end
35
+
36
+ assert_nothing_raised do
37
+ Activity.create(
38
+ :is_published => false,
39
+ :occurred_on => Time.new,
40
+ :activity_type => 'n/a',
41
+ :cost => 0
42
+ ).save!
43
+ end
44
+
45
+ assert_nothing_raised do
46
+ Activity.create(
47
+ :is_published => false,
48
+ :occurred_on => Time.new,
49
+ :activity_type => 'n/a',
50
+ :client_id => 1,
51
+ :cost => nil
52
+ ).save!
53
+ end
54
+
55
+ assert_nothing_raised do
56
+ ddc = Client.find :first, :conditions => [ "company_name = ?","DeRose Design Consultants, Inc."]
57
+
58
+ a1 = Activity.create(
59
+ :is_published => false,
60
+ :occurred_on => Time.new,
61
+ :activity_type => 'n/a',
62
+ :cost => nil
63
+ )
64
+
65
+ a1.client = ddc
66
+ a1.save!
67
+
68
+ a2 = Activity.find a1.id, :include => [:client]
69
+
70
+ assert_equal a2.client_id, ddc.id
71
+ end
72
+
73
+ end
74
+
75
+ def test_validations
76
+ a1 = Activity.new :activity_type => nil
77
+
78
+ assert_nothing_raised { a1.valid? }
79
+
80
+ assert_equal 1, a1.errors.length
81
+ assert_equal true, a1.errors.invalid?(:activity_type)
82
+ end
83
+ end
@@ -0,0 +1,8 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+
3
+ class ActivityTypeTest < ActiveSupport::TestCase
4
+ # Replace this with your real tests.
5
+ def test_truth
6
+ assert true
7
+ end
8
+ end
@@ -0,0 +1,10 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+
3
+ class ClientEventlogTest < ActiveSupport::TestCase
4
+ fixtures :client_eventlogs
5
+
6
+ # Replace this with your real tests.
7
+ def test_truth
8
+ assert true
9
+ end
10
+ end
@@ -0,0 +1,8 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+
3
+ class ClientFinancialTransactionTest < ActiveSupport::TestCase
4
+ # Replace this with your real tests.
5
+ def test_truth
6
+ assert true
7
+ end
8
+ end
@@ -0,0 +1,10 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+
3
+ class ClientRepresentativesTest < ActiveSupport::TestCase
4
+ fixtures :client_representatives
5
+
6
+ # Replace this with your real tests.
7
+ def test_truth
8
+ assert true
9
+ end
10
+ end
@@ -0,0 +1,24 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+
3
+ class ClientTest < ActiveSupport::TestCase
4
+ fixtures :clients
5
+
6
+ def test_is_active
7
+ acme = Client.create! :company_name => 'ACME Inc.'
8
+
9
+ base_clients = ["DeRose Design Consultants, Inc.", "Ashbritt Environmental, Inc.", "CC1 Companies, Inc.", "Academy Roofing", "Affordable Air", "B'nai Congregation", "CC1 Companies, Inc.", "Worldwide Super Abrasives", "Chase Entertainment", "Flying Chimp Media", "GSA", "Lighting Dynamics, Inc.", "Noble Residence", "Garcia Architect", "Scott Rovenger PA", "SarSam", "Gary Slopey", "Thompkins Residence", "United Steel Building"]
10
+
11
+ assert_equal base_clients+["ACME Inc."], Client.find_active(:all).collect{|e| e.company_name}
12
+
13
+ acme.is_active = false
14
+ acme.save!
15
+
16
+ assert_equal base_clients, Client.find_active(:all).collect{|e| e.company_name}
17
+
18
+ assert_equal base_clients, Client.find_active(:all, :conditions => ['id > ?', 0]).collect{|e| e.company_name}
19
+
20
+ assert_equal base_clients, Client.find_active(:all, :conditions => 'id > 0').collect{|e| e.company_name}
21
+
22
+ assert_equal base_clients, Client.find_active(:all, :conditions => ['id > 0']).collect{|e| e.company_name}
23
+ end
24
+ end
@@ -0,0 +1,217 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+
3
+ class CredentialTest < ActiveSupport::TestCase
4
+
5
+ def setup
6
+ if Setting.exists? :account_lockout_threshold
7
+ Setting.set! :account_lockout_threshold, 3
8
+ else
9
+ Setting.create!(
10
+ :keyname => 'account_lockout_threshold',
11
+ :label => 'Account Lockout Threshold',
12
+ :description => 'Number of incorrect logins before an account is locked out',
13
+ :keyval => '3'
14
+ )
15
+ end
16
+
17
+ if Setting.exists? :account_lockout_duration
18
+ Setting.set! :account_lockout_duration, 54000
19
+ else
20
+ Setting.create!(
21
+ :keyname => 'account_lockout_duration',
22
+ :label => 'Account Lockout Duration',
23
+ :description => 'Number of seconds for an account to be locked out, after the lockout threshold has been reached',
24
+ :keyval => '54000'
25
+ )
26
+ end
27
+
28
+ end
29
+
30
+ # Replace this with your real tests.
31
+ def test_has_credential_helpers
32
+ [Employee, ClientRepresentative].each do |user_klass|
33
+ jsmith = user_klass.create!(
34
+ :first_name => 'John',
35
+ :last_name => 'Smith',
36
+ :email_address => 'jsmith@test.com',
37
+ :password => 'password'
38
+ )
39
+
40
+ assert_equal 'jsmith@test.com', jsmith.credential.email_address
41
+ assert_equal 'jsmith@test.com', jsmith.email_address
42
+
43
+ assert_not_equal 'password', jsmith.credential.password_hash
44
+ assert_not_equal 'password', jsmith.password_hash
45
+
46
+ assert_not_equal 0, jsmith.credential.password_hash.length
47
+ assert_not_equal 0, jsmith.password_hash.length
48
+
49
+ assert_equal false, jsmith.credential.login_enabled
50
+
51
+ jsmith_cred = Credential.find :first, :conditions => ['email_address = ? ','jsmith@test.com']
52
+
53
+ assert_equal user_klass.to_s, jsmith_cred.user.class.to_s
54
+ assert_equal jsmith.id, jsmith_cred.user.id
55
+
56
+ jsmith.destroy
57
+ end
58
+
59
+ end
60
+
61
+ def test_logins
62
+ Employee.create!(
63
+ :first_name => 'George',
64
+ :last_name => 'Washington',
65
+ :email_address => 'gwashington@whitehouse.gov',
66
+ :password => 'cherrytree',
67
+ :login_enabled => false
68
+ )
69
+
70
+ Employee.create!(
71
+ :first_name => 'John',
72
+ :last_name => 'Adams',
73
+ :email_address => 'jadams@whitehouse.gov',
74
+ :password => 'sedition',
75
+ :login_enabled => true
76
+ )
77
+
78
+ Employee.create!(
79
+ :first_name => 'Thomas',
80
+ :last_name => 'Jefferson',
81
+ :email_address => 'tjefferson@whitehouse.gov',
82
+ :password => 'monticello',
83
+ :login_enabled => true
84
+ )
85
+
86
+ Employee.create!(
87
+ :first_name => 'James',
88
+ :last_name => 'Madison',
89
+ :email_address => 'jmadison@whitehouse.gov',
90
+ :password => '$5000',
91
+ :login_enabled => true
92
+ )
93
+
94
+ # Make sure find_user_using_auth works
95
+ assert_nothing_raised do
96
+ assert_not_nil Credential.find_using_auth( 'tjefferson@whitehouse.gov', 'monticello' )
97
+ end
98
+
99
+ # Make sure wrong password doesn't work
100
+ assert_nothing_raised do
101
+ assert_nil Credential.find_using_auth( 'tjefferson@whitehouse.gov', 'crackattack!' )
102
+ end
103
+
104
+ # Make sure we can't login if the login is disabled...
105
+ assert_raise CredentialDisabled do
106
+ Credential.find_using_auth 'gwashington@whitehouse.gov', 'cherrytree'
107
+ end
108
+ end
109
+
110
+ def test_humanize_duration_in_seconds
111
+ # Probably this is silly - but whatever
112
+ [
113
+ [1, '1 second'],
114
+ [45, '45 seconds'],
115
+ [60, '1 minute'],
116
+ [3600, '1 hour'],
117
+ [3601, '1 hour 1 second'],
118
+ [777, '12 minutes 57 seconds'],
119
+ [3661, '1 hour 1 minute 1 second'],
120
+ [7200, '2 hours'],
121
+ [7260, '2 hours 1 minute'],
122
+ [7325, '2 hours 2 minutes 5 seconds'],
123
+ [100000, '27 hours 46 minutes 40 seconds']
124
+ ].each do |t|
125
+ assert_equal t[1], Credential.humanize_duration_from_seconds(t[0])
126
+ end
127
+ end
128
+
129
+ def test_lockout
130
+ Employee.create!(
131
+ :first_name => 'James',
132
+ :last_name => 'Monroe',
133
+ :email_address => 'jmonroe@whitehouse.gov',
134
+ :password => 'florida',
135
+ :login_enabled => true
136
+ )
137
+
138
+ # We'll use this to simulate the advancement of the clock:
139
+ time_now = Time.now
140
+ time_now = Time.local time_now.year, time_now.month, time_now.day, time_now.hour, time_now.min, time_now.sec # Removes usec's
141
+
142
+ args_crack = %w(jmonroe@whitehouse.gov crackattack!)
143
+ args_valid = %w(jmonroe@whitehouse.gov florida)
144
+
145
+ 2.times do
146
+ assert_nothing_raised{ Credential.find_using_auth(*args_crack+[time_now]) }
147
+ end
148
+
149
+ # Ensure we throw a lockout error
150
+ assert_raise(CredentialLockedOut) { Credential.find_using_auth(*args_crack+[time_now]) }
151
+
152
+ # Ensure we throw a lockout error despite this pass being right
153
+ assert_raise(CredentialLockedOut) { Credential.find_using_auth(*args_valid+[time_now]) }
154
+
155
+ # Do a success round to clear out the failures from above
156
+ time_now += 54000 # sleep
157
+ assert_nothing_raised{ Credential.find_using_auth(*args_valid+[time_now]) }
158
+
159
+ # Cause a lock-out
160
+ 2.times { Credential.find_using_auth(*args_crack+[time_now]) }
161
+
162
+ assert_raise(CredentialLockedOut) { Credential.find_using_auth(*args_crack+[time_now]) }
163
+
164
+ # Now we sleep out the multiplier
165
+ time_now += 54000 # sleep
166
+
167
+ # Cause another lockout
168
+ 2.times { Credential.find_using_auth(*args_crack+[time_now]) }
169
+ assert_raise(CredentialLockedOut) { Credential.find_using_auth(*args_crack+[time_now]) }
170
+
171
+ time_now += 54000 # sleep
172
+
173
+ # Despite being past the duration, this should nonetheless fail b/c of the multiplier
174
+ assert_raise(CredentialLockedOut) { Credential.find_using_auth(*args_valid+[time_now]) }
175
+ end
176
+
177
+ def test_password_reset
178
+ dvader = Employee.create!(
179
+ :first_name => 'Darth',
180
+ :last_name => 'Vader',
181
+ :email_address => 'dvader@deathstar.com',
182
+ :password => 'iamyourfather',
183
+ :login_enabled => true
184
+ )
185
+
186
+ valid_reset_token = nil
187
+
188
+ # Test Generation:
189
+ assert_nothing_raised{ valid_reset_token = dvader.credential.generate_reset_token! }
190
+
191
+ assert_not_nil valid_reset_token
192
+
193
+ assert_match /^[a-z0-9]{32}$/i, valid_reset_token
194
+
195
+ # Test use:
196
+ assert_equal false, dvader.credential.reset_password_by_token!( '????', 'badnewpassword')
197
+
198
+ assert_equal true, dvader.credential.reset_password_by_token!(valid_reset_token, 'darkside')
199
+
200
+ assert_not_nil Credential.find_using_auth('dvader@deathstar.com', 'darkside')
201
+
202
+ # Test Lockout:
203
+ assert_nothing_raised do
204
+ valid_reset_token = dvader.credential.generate_reset_token!
205
+
206
+ 2.times{ assert_equal false, dvader.credential.reset_password_by_token!('????', 'badnewpassword') }
207
+ end
208
+
209
+ # Ensure we throw a lockout error on next attempt:
210
+ assert_raise(CredentialLockedOut) { dvader.credential.reset_password_by_token!( '????', 'badnewpassword') }
211
+
212
+ # And make sure we continue to fail, now that they're locked out, even if we use a good token:
213
+ assert_raise(CredentialLockedOut) { dvader.credential.reset_password_by_token! valid_reset_token, 'badnewpassword' }
214
+
215
+ end
216
+
217
+ end
@@ -0,0 +1,10 @@
1
+ require File.dirname(__FILE__) + '/../../test_helper'
2
+
3
+ class Employee::SlimTimerTest < ActiveSupport::TestCase
4
+ # fixtures :employee_slim_timers
5
+
6
+ # Replace this with your real tests.
7
+ def test_truth
8
+ assert true
9
+ end
10
+ end
@@ -0,0 +1,8 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+
3
+ class EmployeeClientLaborRateTest < ActiveSupport::TestCase
4
+ # Replace this with your real tests.
5
+ def test_truth
6
+ assert true
7
+ end
8
+ end
@@ -0,0 +1,25 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+
3
+ class EmployeeTest < ActiveSupport::TestCase
4
+ fixtures :employees,:credentials
5
+
6
+ def test_is_active
7
+ jsmith = Employee.create! :first_name => 'John', :last_name => 'Smith', :email_address => 'jsmith@test.com'
8
+
9
+ base_employees = ["Chris DeRose", "Arian Amador", "Michael Bogle"]
10
+
11
+ assert_equal base_employees+["John Smith"], Employee.find_active(:all).collect{|e| e.name}
12
+
13
+ jsmith.is_active = false
14
+ jsmith.save!
15
+
16
+ assert_equal base_employees, Employee.find_active(:all).collect{|e| e.name}
17
+
18
+ assert_equal base_employees, Employee.find_active(:all, :conditions => ['id > ?', 0]).collect{|e| e.name}
19
+
20
+ assert_equal base_employees, Employee.find_active(:all, :conditions => 'id > 0').collect{|e| e.name}
21
+
22
+ assert_equal base_employees, Employee.find_active(:all, :conditions => ['id > 0']).collect{|e| e.name}
23
+
24
+ end
25
+ end
@@ -0,0 +1,8 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+
3
+ class InvoicePaymentTest < ActiveSupport::TestCase
4
+ # Replace this with your real tests.
5
+ def test_truth
6
+ assert true
7
+ end
8
+ end
@@ -0,0 +1,459 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+ require File.dirname(__FILE__) + '/../test_unit_factory_helper.rb'
3
+
4
+ require 'date'
5
+
6
+ class InvoiceTest < ActiveSupport::TestCase
7
+
8
+ fixtures :activity_types
9
+
10
+ def setup
11
+ @activity_types = ActivityType.find :all
12
+ end
13
+
14
+ def test_only_newest_invoice_can_be_unpublished
15
+ client = Factory.create_client
16
+
17
+ # Once they're published they cant be unpublished unless they're the newest invoice...
18
+ invoices = [
19
+ Factory.generate_invoice(100.00, :issued_on => (DateTime.now << 4), :is_published => true ),
20
+ Factory.generate_invoice(200.00, :issued_on => (DateTime.now << 3), :is_published => true ),
21
+ Factory.generate_invoice(300.00, :issued_on => (DateTime.now << 2), :is_published => true ),
22
+ Factory.generate_invoice(400.00, :issued_on => (DateTime.now << 1), :is_published => true )
23
+ ]
24
+
25
+ invoices[0...2].each do |inv|
26
+ assert_raise(ActiveRecord::RecordInvalid) {set_published inv, false}
27
+ end
28
+
29
+ assert_nothing_raised { set_published invoices[3], false }
30
+
31
+ end
32
+
33
+ def test_ensure_client_cant_be_changed
34
+ client = Factory.create_client
35
+ client2 = Factory.create_client :company_name => 'Client 2, Inc.'
36
+
37
+ invoice = Factory.generate_invoice 100.00, :client => client
38
+
39
+ assert_raise(ActiveRecord::RecordInvalid) do
40
+ invoice.client = client2
41
+ invoice.save!
42
+ end
43
+ end
44
+
45
+ def test_is_published_behavior
46
+ client = Factory.create_client
47
+
48
+ Payment.create!(
49
+ :client => client,
50
+ :payment_method_id => 1,
51
+ :amount => 2000.00,
52
+ :paid_on => (DateTime.now << 1)
53
+ )
54
+
55
+ inv = Factory.generate_invoice 1000.00, :issued_on => (DateTime.now >> 12)
56
+
57
+ # Change payment, save:
58
+ assert_nothing_raised do
59
+ inv.comments = 'This should be editable'
60
+ inv.save!
61
+ end
62
+
63
+ # Now we Mark it published
64
+ assert_nothing_raised do
65
+ inv.is_published = true
66
+ inv.save!
67
+ end
68
+
69
+ # Now make sure we raise something on edit
70
+ assert_raise( ActiveRecord::RecordInvalid ) do
71
+ inv.comments = 'This shouldnt actually work'
72
+ inv.save!
73
+ end
74
+
75
+ # Now we Mark it unpublished
76
+ assert_nothing_raised do
77
+ inv.is_published = false
78
+ inv.save!
79
+ end
80
+
81
+ # Change payment again, save:
82
+ assert_nothing_raised do
83
+ inv.comments = 'This time it should work'
84
+ inv.save!
85
+ end
86
+
87
+ end
88
+
89
+ def test_invoice_create_defaults
90
+ inv = Invoice.create
91
+
92
+ assert_equal Time.utc(*Time.now.to_a).last_month.end_of_month, inv.issued_on
93
+ assert_equal false, inv.is_published
94
+ end
95
+
96
+ def test_errors
97
+ client = Factory.create_client
98
+
99
+ # Make sure we cant create an invoice with no client :
100
+ assert_raise(ActiveRecord::RecordInvalid) { Invoice.create! :client => nil, :issued_on => DateTime.now }
101
+
102
+ # Make sure we can't edit the client once an invoice is created (for now ... that might change)
103
+ invoice = nil
104
+ assert_nothing_raised { invoice = Invoice.create! :client => client, :issued_on => DateTime.now }
105
+
106
+ invoice.client = Factory.create_client :company_name => 'PBR Inc.'
107
+
108
+ assert_raise(ActiveRecord::RecordInvalid) { invoice.save! }
109
+ end
110
+
111
+ def test_activity_assignment_on_create_delete
112
+ invoice = nil
113
+
114
+ client = Factory.create_client
115
+
116
+ # These are a ruse.. make sure these dont get added:
117
+ Factory.create_labor( {}, {:occurred_on => (DateTime.now >> 1)} ) # This is newer then issued_on
118
+ Factory.create_labor( {}, {:client_id => 6969} ) # This is a different client
119
+ Factory.create_labor( {}, {:is_published => false} ) # This isnt published yet
120
+
121
+ # These will be legit:
122
+ valid_activities = [
123
+ Factory.create_labor.activity.id,
124
+ Factory.create_material.activity.id,
125
+ Factory.create_proposal.activity.id,
126
+ Factory.create_adjustment.activity.id
127
+ ]
128
+
129
+ assert_nothing_raised { invoice = Invoice.create! :client => client, :issued_on => (DateTime.now+1), :activity_types => @activity_types }
130
+
131
+ # Make sure the right activities were included:
132
+ assert_equal 4, invoice.activities.length
133
+ invoice.activities.each { |a| assert_equal true, valid_activities.include?(a.id) }
134
+
135
+ # Make sure the cost adds up:
136
+ assert_equal 2421.0, invoice.amount
137
+
138
+ assert_equal 2421.0, (invoice.sub_total+invoice.taxes_total)
139
+
140
+ # Now Make sure we unassign on a delete:
141
+ assert_nothing_raised { invoice.destroy }
142
+
143
+ valid_activities.each { |a_id| assert_equal nil, Activity.find(a_id).invoice_id }
144
+ end
145
+
146
+ def test_uneditable_upon_is_published
147
+
148
+ client = Factory.create_client
149
+
150
+ labor = Factory.create_labor
151
+ material = Factory.create_material
152
+ proposal = Factory.create_proposal
153
+ adjustment = Factory.create_adjustment
154
+
155
+ invoice = nil
156
+
157
+ assert_nothing_raised do
158
+ invoice = Invoice.create!(
159
+ :client => client,
160
+ :issued_on => DateTime.now,
161
+ :activity_types => @activity_types
162
+ )
163
+
164
+ invoice.is_published = true
165
+ invoice.save!
166
+ end
167
+
168
+ # Make sure they can't destroy:
169
+ assert_equal false, invoice.destroy
170
+
171
+ # Make sure they can't update:
172
+ invoice.comments = "This shouldn't be retained!"
173
+ assert_raise(ActiveRecord::RecordInvalid) { invoice.save! }
174
+
175
+ # Make sure the right activities were included:
176
+ assert_equal 4, invoice.activities(true).size
177
+
178
+ # Now make sure we can't adjust any of them:
179
+ invoice.activities.each do |a|
180
+ # Make sure they can't destroy:
181
+ assert_equal false, a.destroy
182
+
183
+ # Make sure they can't update:
184
+ a.cost = 69.0
185
+ assert_raise(ActiveRecord::RecordInvalid) { a.save! }
186
+
187
+ # Make sure we can't adjust/destroy the subtype either
188
+ a_st = a.send(a.activity_type)
189
+
190
+ # Make sure they can't destroy:
191
+ assert_equal false, a_st.destroy
192
+
193
+ # Make sure they can't update:
194
+ a_st.comments = "THis Shouldn't get committed...."
195
+ assert_raise(ActiveRecord::RecordInvalid) { a_st.save! }
196
+ end
197
+
198
+ end
199
+
200
+ def test_issued_date_updates
201
+ # This make sure the activity adjustments are working the way they should be
202
+
203
+ client = Factory.create_client # This needs to get done here so the factory attaches the activities to it...
204
+
205
+ present_date = DateTime.now
206
+ past_date = (present_date << 1)
207
+ future_date = (present_date >> 1)
208
+
209
+ past_activities = [
210
+ Factory.create_labor({}, {:occurred_on => past_date}).activity.id,
211
+ Factory.create_material({}, {:occurred_on => past_date}).activity.id,
212
+ Factory.create_proposal({}, {:occurred_on => past_date}).activity.id,
213
+ Factory.create_adjustment({}, {:occurred_on => past_date}).activity.id
214
+ ]
215
+
216
+ future_activities = [
217
+ Factory.create_labor({}, {:occurred_on => future_date}).activity.id,
218
+ Factory.create_material({}, {:occurred_on => future_date}).activity.id,
219
+ Factory.create_proposal({}, {:occurred_on => future_date}).activity.id,
220
+ Factory.create_adjustment({}, {:occurred_on => future_date}).activity.id
221
+ ]
222
+
223
+ invoice = nil
224
+ assert_nothing_raised { invoice = Invoice.create! :client => client, :issued_on => present_date, :activity_types => @activity_types }
225
+
226
+ # Make sure the right activities were included:
227
+ assert_equal 4, invoice.activities(true).size
228
+
229
+ invoice.activities.each do |a|
230
+ assert_equal true, past_activities.include?(a.id)
231
+ assert_equal false, future_activities.include?(a.id)
232
+ end
233
+
234
+ # Now let's set to the way future:
235
+ assert_nothing_raised do
236
+ invoice.issued_on = present_date >> 2
237
+ invoice.save!
238
+ end
239
+
240
+ # Make sure everything ends up in there:
241
+ assert_equal 8, invoice.activities(true).size
242
+
243
+ invoice.activities(true).each do |a|
244
+ assert_equal true, (past_activities.include?(a.id) or future_activities.include?(a.id) )
245
+ end
246
+
247
+ # Now let's set back to present:
248
+ assert_nothing_raised do
249
+ invoice.issued_on = present_date
250
+ invoice.save!
251
+ end
252
+
253
+ # Make sure we're where we should be:
254
+ assert_equal 4, invoice.activities(true).size
255
+
256
+ invoice.activities.each do |a|
257
+ assert_equal true, past_activities.include?(a.id)
258
+ assert_equal false, future_activities.include?(a.id)
259
+ end
260
+
261
+ end
262
+
263
+ def test_invoice_deletes_only_if_recent
264
+ invoice_time = Time.new
265
+
266
+ invoices = [20,40,80,160,320,640,1280].collect do |amt|
267
+ invoice_time += 1.weeks
268
+ Factory.generate_invoice amt, :issued_on => invoice_time
269
+ end
270
+
271
+ while invoices.length > 0
272
+ 0.upto(invoices.length-2) { |i| assert_equal false, invoices[i].destroy }
273
+
274
+ assert_not_equal false, invoices.delete_at(invoices.length-1).destroy
275
+ end
276
+
277
+ end
278
+
279
+ def test_activity_type_inclusions
280
+ client = Factory.create_client
281
+
282
+ @activity_types = ActivityType.find :all
283
+
284
+ a_type_map = HashWithIndifferentAccess.new
285
+ @activity_types.each{|at| a_type_map[at.label.downcase] = at }
286
+
287
+ # First, let's Make sure this includion feature actually works during a create
288
+ present_date = DateTime.now
289
+ past_date = (present_date << 1)
290
+
291
+ activities = [
292
+ Factory.create_labor({}, {:occurred_on => past_date, :cost => 1.99 }),
293
+ Factory.create_labor({}, {:occurred_on => past_date, :cost => 1.99 }),
294
+ Factory.create_material({}, {:occurred_on => past_date}),
295
+ Factory.create_material({}, {:occurred_on => past_date}),
296
+ Factory.create_proposal({}, {:occurred_on => past_date}),
297
+ Factory.create_proposal({}, {:occurred_on => past_date}),
298
+ Factory.create_adjustment({}, {:occurred_on => past_date}),
299
+ Factory.create_adjustment({}, {:occurred_on => past_date})
300
+ ]
301
+
302
+ invoice = nil
303
+
304
+ assert_nothing_raised do
305
+ invoice = Invoice.create!(
306
+ :client => client,
307
+ :issued_on => present_date,
308
+ :activity_types => [ a_type_map[:material], a_type_map[:labor] ]
309
+ )
310
+ end
311
+
312
+ assert_equal 1805.96, invoice.amount
313
+
314
+ assert_equal 1805.96, (invoice.sub_total+invoice.taxes_total)
315
+
316
+ assert_equal(
317
+ invoice.activity_ids,
318
+ activities.select{|a| /^Activity::(Material|Labor)$/.match a.class.to_s}.collect{|a| a.activity.id}
319
+ )
320
+
321
+ # Let's remove a type and see if this works the way it should:
322
+ assert_nothing_raised do
323
+ invoice.activity_types.delete a_type_map[:material]
324
+ invoice.save!
325
+
326
+ # We have to expire the cache here....
327
+ invoice.activities(true)
328
+ end
329
+
330
+ assert_equal 3.98, invoice.amount
331
+
332
+ assert_equal 3.98, (invoice.sub_total+invoice.taxes_total)
333
+
334
+ assert_equal(
335
+ activities.select{|a| /^Activity::Labor$/.match a.class.to_s}.collect{|a| a.activity.id},
336
+ invoice.activity_ids
337
+ )
338
+
339
+ # Now let's add the rest of the types, and see if it works the way it should:
340
+ assert_nothing_raised do
341
+ invoice.activity_types.push a_type_map[:material], a_type_map[:proposal]
342
+ invoice.save!
343
+
344
+ # We have to expire the cache here....
345
+ invoice.activities(true)
346
+ end
347
+
348
+ assert_equal 4245.98, invoice.amount
349
+
350
+ assert_equal 4245.98, (invoice.sub_total+invoice.taxes_total)
351
+
352
+ assert_equal(
353
+ activities.select{|a| /^Activity::(Material|Labor|Proposal)$/.match a.class.to_s}.collect{|a| a.activity.id},
354
+ invoice.activity_ids
355
+ )
356
+
357
+ # Make sure we can't add/remove activity types for a published invoice
358
+ assert_nothing_raised{ set_published invoice, true }
359
+
360
+ assert_raise(RuntimeError) { invoice.activity_types.push a_type_map[:adjustment]}
361
+
362
+ assert_raise(RuntimeError) { invoice.activity_types.delete a_type_map[:material]}
363
+ end
364
+
365
+ def test_empty_invoice
366
+ # Create an invoice with no activities - even though it should have a balance of zero, also make sure things dont puke
367
+
368
+ inv = nil
369
+ assert_nothing_raised { inv = Invoice.create! :client => Factory.create_client }
370
+
371
+ assert_equal 0.0, inv.amount
372
+
373
+ assert_equal 0.0, (inv.sub_total+inv.taxes_total)
374
+
375
+ end
376
+
377
+ def test_activity_move
378
+
379
+ client_src = Factory.create_client
380
+ client_dest = Factory.create_client
381
+
382
+ create_act_args = {:occurred_on => (DateTime.now << 1), :client => client_src}
383
+
384
+ labor = Factory.create_labor( {}, create_act_args.merge({:cost => 1.99}) )
385
+ material = Factory.create_material( {}, create_act_args)
386
+ proposal = Factory.create_proposal( {}, create_act_args)
387
+ adjustment = Factory.create_adjustment( {}, create_act_args.merge({:tax => 26.00}))
388
+
389
+ subactivities = [labor, material, proposal, adjustment]
390
+
391
+ invoice_src = Invoice.create!(
392
+ :client => client_src,
393
+ :issued_on => DateTime.now,
394
+ :activity_types => @activity_types
395
+ )
396
+
397
+ invoice_dest = Invoice.create!(
398
+ :client => client_dest,
399
+ :issued_on => DateTime.now
400
+ )
401
+
402
+ subactivities.each do |activity_type|
403
+ activity_type.reload
404
+
405
+ assert_equal invoice_src.id, activity_type.activity.invoice_id
406
+ assert_equal client_src.id, activity_type.activity.client_id
407
+ end
408
+
409
+ assert_equal 2448.99, invoice_src.amount
410
+
411
+ assert_equal 2448.99, (invoice_src.sub_total+invoice_src.taxes_total)
412
+
413
+ assert_nothing_raised do
414
+ subactivities.each do |activity_type|
415
+ activity_type.activity.move_to_invoice invoice_dest
416
+ end
417
+ end
418
+
419
+ assert_equal 2448.99, invoice_dest.amount
420
+
421
+ assert_equal 2448.99, (invoice_dest.sub_total+invoice_dest.taxes_total)
422
+
423
+ subactivities.each do |at|
424
+ assert_equal invoice_dest.id, at.activity.invoice_id
425
+ assert_equal client_src.id, at.activity.client_id
426
+ end
427
+
428
+ assert_nothing_raised do
429
+ labor.activity.move_to_invoice invoice_src
430
+ end
431
+
432
+ assert_equal invoice_src.id, labor.activity.invoice_id
433
+ assert_equal client_src.id, labor.activity.client_id
434
+
435
+ assert_equal 2447.0, invoice_dest.amount
436
+
437
+ assert_equal 2447.0, (invoice_dest.sub_total+invoice_dest.taxes_total)
438
+
439
+ invoice_src.is_published = true
440
+ invoice_src.save!
441
+
442
+ # Assert fail!
443
+ labor.activity.reload
444
+ assert_raise(StandardError) { labor.activity.move_to_invoice invoice_dest }
445
+
446
+ # Assert fail!
447
+ material.activity.reload
448
+ assert_raise(StandardError) { material.activity.move_to_invoice invoice_src }
449
+
450
+ end
451
+
452
+ private
453
+
454
+ def set_published(inv, published_state)
455
+ inv.is_published = published_state
456
+ inv.save!
457
+ end
458
+
459
+ end