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,9 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+
3
+ class NotifierTest < ActionMailer::TestCase
4
+ tests Notifier
5
+ # replace this with your real tests
6
+ def test_truth
7
+ assert true
8
+ end
9
+ end
@@ -0,0 +1,8 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+
3
+ class PaymentMethodTest < ActiveSupport::TestCase
4
+ # Replace this with your real tests.
5
+ def test_truth
6
+ assert true
7
+ end
8
+ end
@@ -0,0 +1,155 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+ require File.dirname(__FILE__) + '/../test_unit_factory_helper.rb'
3
+
4
+ class PaymentTest < ActiveSupport::TestCase
5
+
6
+ fixtures :activity_types
7
+
8
+ def test_payment_allocations
9
+ client = Factory.create_client
10
+
11
+ invoices = []
12
+
13
+ [1200.00, 400, 99.99, 1500.99, 430.01].each do |amt|
14
+ inv = Factory.generate_invoice(amt)
15
+
16
+ assert_equal amt, inv.amount # THis was a weird bug we were having so I put this here...
17
+
18
+ invoices << inv
19
+ end
20
+
21
+ assert_equal 3630.99, client.balance
22
+
23
+ payments = []
24
+
25
+ [1200.00, 400.00, 99.99, 0.99, 1500, 400.0, 30.01].each do |amt|
26
+ payments << Factory.generate_payment(amt)
27
+ end
28
+
29
+ assert_equal 0.to_money, client.balance
30
+
31
+ payments.delete_at(1).destroy
32
+
33
+ assert_equal 400.00.to_money, client.balance
34
+
35
+ invoices.each_index { |i| assert_equal( ((i == 1) ? false : true), invoices[i].is_paid? ) }
36
+
37
+ payments << Factory.generate_payment(174.00)
38
+ payments << Factory.generate_payment(15.00)
39
+ payments << Factory.generate_payment(10.00)
40
+ payments << Factory.generate_payment(201.00)
41
+
42
+ assert_equal 0.0.to_money, client.balance
43
+
44
+ assert_equal true, invoices[1].is_paid?
45
+
46
+ payments << Factory.generate_payment(300.20)
47
+
48
+ assert_equal -300.20.to_money, client.balance
49
+
50
+ invoices << Factory.generate_invoice(300.20)
51
+
52
+ assert_equal 0.to_money, client.balance
53
+ end
54
+
55
+ def test_invoice_allocates_payment_credits
56
+ client = Factory.create_client
57
+
58
+ Factory.generate_payment 230.00
59
+ Factory.generate_payment 70.00
60
+
61
+ invoice_one = Factory.generate_invoice 290.00, :is_published => true
62
+
63
+ assert_equal true, invoice_one.is_paid?
64
+ assert_equal -10.00, client.balance
65
+
66
+ Factory.generate_payment 200.00
67
+
68
+ invoice_two = Factory.generate_invoice 220.00, :is_published => true
69
+
70
+ assert_equal false, invoice_two.is_paid?
71
+ assert_equal 10.00, client.balance
72
+
73
+ Factory.generate_payment 10.00
74
+
75
+ assert_equal true, invoice_two.is_paid?
76
+ assert_equal 0.00, client.balance
77
+
78
+ Factory.generate_payment 300.00
79
+
80
+ invoice_three = Factory.generate_invoice 300.00, :is_published => true
81
+
82
+ assert_equal true, invoice_three.is_paid?
83
+ assert_equal 0.00, client.balance
84
+ end
85
+
86
+ def test_invoice_paid_on
87
+ payment_one_on = sanitize_time(Time.now - 3.months)
88
+ payment_two_on = sanitize_time(Time.now - 2.months)
89
+ payment_three_on = sanitize_time(Time.now - 2.months)
90
+
91
+ Factory.generate_payment 200.00, :paid_on => payment_one_on
92
+
93
+ invoice = Factory.generate_invoice 600.00, :issued_on => payment_two_on, :is_published => true
94
+
95
+ payment_two = Factory.generate_payment 200.00, :paid_on => payment_two_on
96
+ Factory.generate_payment 200.00, :paid_on => payment_three_on
97
+
98
+ assert_equal true, invoice.is_paid?
99
+ assert_equal payment_two_on, invoice.paid_on
100
+
101
+ payment_two.destroy
102
+
103
+ assert_equal false, invoice.is_paid?
104
+ assert_equal nil, invoice.paid_on
105
+ end
106
+
107
+ def test_whacko_payment_deletes
108
+ running_time = sanitize_time(Time.now - 1.years)
109
+
110
+ payments = []
111
+ invoices = []
112
+
113
+ [2,4,8,16,32,64,128,256,512,1024].each do |amt|
114
+ invoice = Factory.generate_invoice( amt, :issued_on => (running_time += 2.weeks) )
115
+ payments << Factory.generate_payment( amt, :paid_on => (running_time += 2.weeks) )
116
+
117
+ assert_equal running_time, invoice.paid_on
118
+ invoices << invoice
119
+ end
120
+
121
+ assert_equal 0.to_money, Factory.create_client.balance
122
+
123
+ [9,7,5,3,1].each { |i| payments.delete_at(i).destroy }
124
+
125
+ assert_equal 1364.to_money, Factory.create_client.balance
126
+
127
+ [1,3,5,7,9].each do |i|
128
+ running_time += 2.weeks
129
+ payments << Factory.generate_payment( invoices[i].amount, :paid_on => running_time )
130
+
131
+ assert_equal true, invoices[i].is_paid?
132
+ assert_equal running_time, invoices[i].paid_on
133
+ end
134
+
135
+ assert_equal 0.to_money, Factory.create_client.balance
136
+
137
+ 5.times { payments.delete_at(0).destroy }
138
+
139
+ assert_equal 682.to_money, Factory.create_client.balance
140
+
141
+ Factory.generate_payment 682, :paid_on => (running_time += 2.weeks)
142
+
143
+ [0,2,4,6,8].each { |i| assert_equal running_time, invoices[i].paid_on }
144
+
145
+ assert_equal 0.to_money, Factory.create_client.balance
146
+ end
147
+
148
+ private
149
+
150
+ def sanitize_time(time)
151
+ # This removes the usec's
152
+ Time.utc time.sec, time.min, time.hour, time.day, time.month, time.year, time.wday, time.yday, time.isdst, time.gmt_offset unless time.nil?
153
+ end
154
+
155
+ end
@@ -0,0 +1,8 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+
3
+ class SettingTest < 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 SlimtimerTaskTest < ActiveSupport::TestCase
4
+ fixtures :slimtimer_tasks
5
+
6
+ # Replace this with your real tests.
7
+ def test_truth
8
+ assert true
9
+ end
10
+ end
@@ -0,0 +1,132 @@
1
+ require File.dirname(__FILE__) + '/../test_helper'
2
+
3
+ class SlimtimerTimeEntryTest < ActiveSupport::TestCase
4
+ fixtures :employees, :employee_slimtimers, :credentials
5
+
6
+ def test_basics
7
+ chris = Employee.find 1
8
+ assert_not_nil chris
9
+
10
+ ste = nil
11
+
12
+ # Create
13
+ assert_nothing_raised do
14
+
15
+ start_time = Time.local 1982, 1, 4, 1, 0, 0 ,0
16
+ end_time = start_time+3600 # plus 1h
17
+
18
+ acme_lawncare = SlimtimerTask.create :name => 'Acme Lawn Care', :owner_employee_slimtimer_id => chris.slimtimer.id
19
+ assert_not_nil acme_lawncare
20
+
21
+ ste = SlimtimerTimeEntry.create(
22
+ :employee_slimtimer_id => chris.slimtimer.id,
23
+ :comments => 'Trimmed Palm Trees',
24
+ :tags => 'billable',
25
+ :slimtimer_task => acme_lawncare,
26
+ :start_time => start_time,
27
+ :end_time => end_time
28
+ )
29
+ end
30
+
31
+ assert_not_nil ste
32
+ assert_not_nil ste.labor
33
+ assert_not_nil ste.labor.activity
34
+
35
+ assert_not_nil ste.id
36
+ assert_not_nil ste.labor.id
37
+ assert_not_nil ste.labor.activity.id
38
+
39
+ assert_equal 'Trimmed Palm Trees', ste.labor.comments
40
+ assert_equal 1, ste.labor.employee_id
41
+ assert_equal 60, ste.labor.minute_duration
42
+ assert_equal Time.local(1982, 1, 4, 1, 0, 0 ,0), ste.labor.activity.occurred_on
43
+ assert_equal 'Acme Lawn Care', ste.slimtimer_task.name
44
+
45
+ # Test Update
46
+
47
+ # We create this here, and reuse it a couple times below b/c thats very convenient, and makes sure nothing has changed:
48
+ assert_acmebio_ste = Proc.new() do |on_ste|
49
+ assert_equal 'Engineered shorter Palm Trees', on_ste.labor.comments
50
+ assert_equal 1, on_ste.labor.employee_id
51
+ assert_equal 30, on_ste.labor.minute_duration
52
+ assert_equal Time.local(1985, 2, 4, 5, 0, 0 ,0), on_ste.labor.activity.occurred_on
53
+ assert_equal 'Acme Bio', on_ste.slimtimer_task.name
54
+ end
55
+
56
+ assert_nothing_raised do
57
+ start_time = Time.local 1985, 2, 4, 5, 0, 0 ,0
58
+ end_time = start_time+1800 # plus 30m
59
+
60
+ acme_bio = SlimtimerTask.create :name => 'Acme Bio', :owner_employee_slimtimer_id => chris.slimtimer.id
61
+ assert_not_nil acme_bio
62
+
63
+ ste.comments = 'Engineered shorter Palm Trees'
64
+ ste.slimtimer_task = acme_bio
65
+ ste.start_time = start_time
66
+ ste.end_time = end_time
67
+
68
+ ste.save!
69
+ end
70
+ assert_acmebio_ste.call ste
71
+
72
+ # Test Re-create on activity Delete
73
+ # NOTE: I decided this shouldnt be happening to begin with, and thus we shouldnt be too smart about fixing it if it happens..
74
+
75
+ # Test Re-create on labor Delete
76
+ assert_nothing_raised do
77
+ ste.labor.destroy
78
+ ste.labor = nil
79
+
80
+ ste.save!
81
+ end
82
+ assert_acmebio_ste.call ste
83
+
84
+ # Set is_published and test destroy exceptions on delete, and on update
85
+ ste.labor.activity.is_published = true
86
+
87
+ ste.labor.comments = "These should cause a raise"
88
+ assert_raise(StandardError) { ste.save! }
89
+
90
+ assert_raise(StandardError) { ste.destroy }
91
+ end
92
+
93
+ def test_on_destroy
94
+
95
+ ste_id = nil
96
+ ste_labor_id = nil
97
+ ste_activity_id = nil
98
+
99
+ assert_nothing_raised do
100
+ chris = Employee.find 1
101
+ assert_not_nil chris
102
+
103
+ start_time = Time.local 1999, 12, 31, 11, 59, 0 ,0
104
+
105
+ acme_hairstyles = SlimtimerTask.create :name => 'Acme Hair Styles', :owner_employee_slimtimer_id => chris.slimtimer.id
106
+ assert_not_nil acme_hairstyles
107
+
108
+ ste = SlimtimerTimeEntry.create(
109
+ :employee_slimtimer_id => chris.slimtimer.id,
110
+ :comments => 'Cornrolled Head',
111
+ :tags => 'billable',
112
+ :slimtimer_task => acme_hairstyles,
113
+ :start_time => start_time,
114
+ :end_time => start_time+60 # plus 1m
115
+ )
116
+
117
+ ste_id = ste.id
118
+ ste_labor_id = ste.labor.id
119
+ ste_activity_id = ste.labor.activity.id
120
+
121
+ ste.destroy
122
+ end
123
+
124
+ assert_kind_of Integer, ste_id
125
+ assert_kind_of Integer, ste_labor_id
126
+ assert_kind_of Integer, ste_activity_id
127
+
128
+ assert_raise(ActiveRecord::RecordNotFound) { SlimtimerTimeEntry.find ste_id }
129
+ assert_raise(ActiveRecord::RecordNotFound) { Activity::Labor.find ste_labor_id }
130
+ assert_raise(ActiveRecord::RecordNotFound) { Activity.find ste_activity_id }
131
+ end
132
+ end
@@ -0,0 +1,79 @@
1
+ = Inline Attachment
2
+
3
+ This package adds full support for embedding inline images into your HTML emails
4
+ through ActionMailer.
5
+
6
+ It is created from a Rails patch #2179 (found at http://dev.rubyonrails.org/ticket/2179).
7
+
8
+ The goal of this gem is to remove the need for manual patching.
9
+
10
+ == Installation
11
+
12
+ To perform a system wide installation:
13
+
14
+ <tt>gem install inline_attachment</tt>
15
+
16
+ To use inline_attachment in your project, add the following line to your project's
17
+ config/environment.rb:
18
+
19
+ <tt>require 'inline_attachment'</tt>
20
+
21
+
22
+ == Usage
23
+
24
+ ==== Embed Images Manually
25
+
26
+ The code to add inline attachments into your HTML emails is pretty simple:
27
+
28
+ @cid = Time.now.to_f.to_s + "foobar.png@domain.com"
29
+
30
+ inline_attachment :content_type => "image/png",
31
+ :body => File.read("#{RAILS_ROOT}/public/images/foobar.png"),
32
+ :filename => "foobar.png",
33
+ :cid => "<#{@cid}>"
34
+
35
+ Note that the above code should go into your ActionMailer.
36
+
37
+ The instance variable @cid is the unique identifier your MIME email will be using to
38
+ locate the attached image. All you have to do is then pass it over to your email
39
+ template, and display it like so:
40
+
41
+ <img src="cid:<%= @cid %>" alt="Foo Bar" />
42
+
43
+ ==== Embed Images Automatically
44
+
45
+ As of version 0.2.0, Inline Attachment automatically embeds any images found within
46
+ your ActionMailer templates. There is no longer any extra code required when adding images
47
+ into your mail templates. Though, you must use rails image_tag helper when displaying
48
+ images within your mailer views.
49
+
50
+ With version 0.3.0, you are now able to embed images into nested parts by specifying
51
+ a part container to place the attached images into. For example:
52
+
53
+ class Notifier < ActionMailer::Base
54
+ def images
55
+ recipients "test@test.com"
56
+ from "test@test.com"
57
+ subject "Test"
58
+ content_type "multipart/alternative"
59
+
60
+ part "text/plain" do |p|
61
+ p.body = render_message("images.text.plain.rhtml", {})
62
+ p.content_disposition = ""
63
+ p.transfer_encoding = "7bit"
64
+ p.charset = "ISO-8859-15"
65
+ end
66
+
67
+ part "multipart/related" do |p|
68
+ p.parts << ActionMailer::Part.new(
69
+ :content_type => "text/html", :body => render_message("images.text.html.rhtml", :part_container => p),
70
+ :disposition => "",
71
+ :charset => "ISO-8859-15",
72
+ :transfer_encoding => "7bit"
73
+ )
74
+ end
75
+ end
76
+ end
77
+
78
+ You can see that we passed in the variable :part_container => p into the body of the nested part.
79
+ This needs to be done so that the images are embedded into the part that they are used in.
@@ -0,0 +1,2 @@
1
+ require 'inline_attachment'
2
+ require 'tmail_content_id'
@@ -0,0 +1,136 @@
1
+ module ActionMailer
2
+ module PartContainer
3
+ # Add an inline attachment to a multipart message.
4
+ def inline_attachment(params, &block)
5
+ params = { :content_type => params } if String === params
6
+ params = { :disposition => "inline",
7
+ :transfer_encoding => "base64" }.merge(params)
8
+ params[:headers] ||= {}
9
+ params[:headers]['Content-ID'] = params[:cid]
10
+ part(params, &block)
11
+ end
12
+ end
13
+
14
+ class Part
15
+ def to_mail(defaults)
16
+ part = TMail::Mail.new
17
+
18
+ if @parts.empty?
19
+ part.content_transfer_encoding = transfer_encoding || "quoted-printable"
20
+ case (transfer_encoding || "").downcase
21
+ when "base64" then
22
+ part.body = TMail::Base64.folding_encode(body)
23
+ when "quoted-printable"
24
+ part.body = [Utils.normalize_new_lines(body)].pack("M*")
25
+ else
26
+ part.body = body
27
+ end
28
+
29
+ # Always set the content_type after setting the body and or parts
30
+
31
+ # CHANGE: treat attachments and inline files the same
32
+ if content_disposition == "attachment" || ((content_disposition == "inline") && filename)
33
+ part.set_content_type(content_type || defaults.content_type, nil,
34
+ squish("charset" => nil, "name" => filename))
35
+ else
36
+ part.set_content_type(content_type || defaults.content_type, nil,
37
+ "charset" => (charset || defaults.charset))
38
+ end
39
+
40
+ part.set_content_disposition(content_disposition, squish("filename" => filename)) unless content_disposition.blank?
41
+ headers.each {|k,v| part[k] = v }
42
+ # END CHANGE
43
+
44
+ else
45
+ if String === body
46
+ part = TMail::Mail.new
47
+ part.body = body
48
+ part.set_content_type content_type, nil, { "charset" => charset }
49
+ part.set_content_disposition "inline"
50
+ m.parts << part
51
+ end
52
+
53
+ @parts.each do |p|
54
+ prt = (TMail::Mail === p ? p : p.to_mail(defaults))
55
+ part.parts << prt
56
+ end
57
+
58
+ part.set_content_type(content_type, nil, { "charset" => charset }) if content_type =~ /multipart/
59
+ end
60
+
61
+ part
62
+ end
63
+ end
64
+ end
65
+
66
+ module ActionView
67
+ module Helpers #:nodoc:
68
+ module AssetTagHelper
69
+
70
+ # Brisk-Bills Adjustment
71
+ # This is a weird hack that fixes issues in produiction mode with inlineattachment - seems to work, so whatever?
72
+ alias image_path_without_inline_attachment image_path
73
+ def image_path(source)
74
+ @part_container ||= @controller
75
+ if @part_container.is_a?(ActionMailer::Base) or @part_container.is_a?(ActionMailer::Part)
76
+ '/images/%s' % source
77
+ else
78
+ image_path_without_inline_attachment(source)
79
+ end
80
+ end
81
+ # /Brisk-Bills
82
+
83
+ def image_tag(source, options = {})
84
+ options.symbolize_keys!
85
+
86
+ @part_container ||= @controller
87
+
88
+ if @part_container.is_a?(ActionMailer::Base) or @part_container.is_a?(ActionMailer::Part)
89
+ file_path, basename, ext =/^.+?([^\/]+)\.([^\.]+)$/.match("#{RAILS_ROOT}/public#{image_path(source).split('?').first}").to_a
90
+
91
+ cid = Time.now.to_f.to_s + "#{basename}@inline_attachment"
92
+
93
+ @part_container.inline_attachment(:content_type => "image/#{ext}",
94
+ :body => File.open(file_path, 'rb').read,
95
+ :cid => "<#{cid}>",
96
+ :disposition => "inline")
97
+
98
+ options[:src] = "cid:#{cid}"
99
+ options[:alt] ||= basename.capitalize
100
+ else
101
+ options[:src] = image_path(source)
102
+ options[:alt] ||= File.basename(options[:src], '.*').split('.').first.capitalize
103
+ end
104
+
105
+ if options[:size]
106
+ options[:width], options[:height] = options[:size].split("x") if options[:size] =~ %r{^\d+x\d+$}
107
+ options.delete(:size)
108
+ end
109
+
110
+ tag("img", options)
111
+ end
112
+ end
113
+ end
114
+ end
115
+
116
+ class DummyClass
117
+ def relative_url_root
118
+ ""
119
+ end
120
+
121
+ def protocol
122
+ "http"
123
+ end
124
+
125
+ def relative_url_root
126
+ ""
127
+ end
128
+ end
129
+
130
+ module ActionMailer #:nodoc:
131
+ class Base
132
+ def request
133
+ DummyClass.new
134
+ end
135
+ end
136
+ end