dorsale 1.2.6 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (267) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/accounting.js +413 -0
  3. data/app/assets/javascripts/dorsale/billing_machine/all.coffee +20 -0
  4. data/app/assets/javascripts/dorsale/billing_machine/invoices.coffee +39 -0
  5. data/app/assets/javascripts/dorsale/billing_machine/quotations.coffee +38 -0
  6. data/app/assets/javascripts/dorsale/comments.coffee +4 -0
  7. data/app/assets/javascripts/dorsale/customer_vault/all.coffee +9 -0
  8. data/app/assets/javascripts/dorsale/datepicker.coffee +1 -1
  9. data/app/assets/javascripts/dorsale/flyboy/all.coffee +0 -0
  10. data/app/assets/javascripts/dorsale/forms.coffee +20 -6
  11. data/app/assets/stylesheets/dorsale/billing_machine/all.sass +15 -0
  12. data/app/assets/stylesheets/dorsale/bootstrap_nav_left.sass +34 -0
  13. data/app/assets/stylesheets/dorsale/comments.sass +25 -3
  14. data/app/assets/stylesheets/dorsale/customer_vault/all.sass +89 -0
  15. data/app/assets/stylesheets/dorsale/filters.sass +4 -1
  16. data/app/assets/stylesheets/dorsale/flyboy/all.sass +52 -0
  17. data/app/assets/stylesheets/dorsale/forms.sass +19 -0
  18. data/app/controllers/dorsale/alexandrie/attachments_controller.rb +52 -0
  19. data/app/controllers/dorsale/billing_machine/application_controller.rb +15 -0
  20. data/app/controllers/dorsale/billing_machine/invoices_controller.rb +180 -0
  21. data/app/controllers/dorsale/billing_machine/quotations_controller.rb +151 -0
  22. data/app/controllers/dorsale/comments_controller.rb +64 -17
  23. data/app/controllers/dorsale/customer_vault/application_controller.rb +26 -0
  24. data/app/controllers/dorsale/customer_vault/corporations_controller.rb +100 -0
  25. data/app/controllers/dorsale/customer_vault/individuals_controller.rb +104 -0
  26. data/app/controllers/dorsale/customer_vault/links_controller.rb +92 -0
  27. data/app/controllers/dorsale/customer_vault/people_controller.rb +42 -0
  28. data/app/controllers/dorsale/flyboy/application_controller.rb +9 -0
  29. data/app/controllers/dorsale/flyboy/folders_controller.rb +124 -0
  30. data/app/controllers/dorsale/flyboy/task_comments_controller.rb +29 -0
  31. data/app/controllers/dorsale/flyboy/tasks_controller.rb +171 -0
  32. data/app/controllers/dorsale/small_data/filters_controller.rb +7 -0
  33. data/app/helpers/dorsale/alexandrie/attachments_helper.rb +17 -0
  34. data/app/helpers/dorsale/all_helpers.rb +12 -9
  35. data/app/helpers/dorsale/button_helper.rb +23 -3
  36. data/app/helpers/dorsale/comments_helper.rb +4 -0
  37. data/app/helpers/dorsale/customer_vault/application_helper.rb +98 -0
  38. data/app/helpers/dorsale/flyboy/application_helper.rb +44 -0
  39. data/app/helpers/dorsale/form_helper.rb +7 -0
  40. data/app/helpers/dorsale/link_helper.rb +3 -2
  41. data/app/helpers/dorsale/routes_helper.rb +5 -3
  42. data/app/helpers/dorsale/text_helper.rb +28 -1
  43. data/app/models/dorsale/ability_helper.rb +7 -0
  44. data/app/models/dorsale/alexandrie/ability_helper.rb +9 -0
  45. data/app/models/dorsale/alexandrie/attachment.rb +18 -0
  46. data/app/models/dorsale/billing_machine/ability_helper.rb +10 -0
  47. data/app/models/dorsale/billing_machine/id_card.rb +18 -0
  48. data/app/models/dorsale/billing_machine/invoice.rb +126 -0
  49. data/app/models/dorsale/billing_machine/invoice_line.rb +27 -0
  50. data/app/models/dorsale/billing_machine/payment_term.rb +12 -0
  51. data/app/models/dorsale/billing_machine/quotation.rb +66 -0
  52. data/app/models/dorsale/billing_machine/quotation_line.rb +25 -0
  53. data/app/models/dorsale/billing_machine/small_data/filter_for_invoices.rb +21 -0
  54. data/app/models/dorsale/billing_machine/small_data/filter_for_quotations.rb +20 -0
  55. data/app/models/dorsale/billing_machine/small_data/filter_strategy_by_customer.rb +12 -0
  56. data/app/models/dorsale/billing_machine/small_data/filter_strategy_by_payment_status.rb +23 -0
  57. data/app/models/dorsale/billing_machine/small_data/filter_strategy_by_time_period.rb +27 -0
  58. data/app/models/dorsale/comment.rb +6 -2
  59. data/app/models/dorsale/customer_vault/ability_helper.rb +9 -0
  60. data/app/models/dorsale/customer_vault/corporation.rb +12 -0
  61. data/app/models/dorsale/customer_vault/individual.rb +17 -0
  62. data/app/models/dorsale/customer_vault/link.rb +10 -0
  63. data/app/models/dorsale/customer_vault/person.rb +35 -0
  64. data/app/models/dorsale/customer_vault/small_data/filter_for_people.rb +19 -0
  65. data/app/models/dorsale/customer_vault/small_data/filter_strategy_by_tags.rb +18 -0
  66. data/app/models/dorsale/flyboy/ability_helper.rb +41 -0
  67. data/app/models/dorsale/flyboy/folder.rb +77 -0
  68. data/app/models/dorsale/flyboy/small_data/filter_for_folders.rb +19 -0
  69. data/app/models/dorsale/flyboy/small_data/filter_for_tasks.rb +19 -0
  70. data/app/models/dorsale/flyboy/small_data/filter_strategy_by_done.rb +12 -0
  71. data/app/models/dorsale/flyboy/small_data/filter_strategy_by_nothing.rb +11 -0
  72. data/app/models/dorsale/flyboy/small_data/filter_strategy_by_status.rb +15 -0
  73. data/app/models/dorsale/flyboy/task.rb +97 -0
  74. data/app/models/dorsale/flyboy/task_comment.rb +35 -0
  75. data/app/pdfs/dorsale/billing_machine/invoice_pdf.rb +209 -0
  76. data/app/pdfs/dorsale/billing_machine/quotation_pdf.rb +53 -0
  77. data/app/pdfs/dorsale/flyboy/roadmap.rb +51 -0
  78. data/app/uploaders/dorsale/alexandrie/file_uploader.rb +6 -0
  79. data/app/uploaders/dorsale/file_uploader.rb +9 -0
  80. data/app/uploaders/dorsale/image_uploader.rb +7 -0
  81. data/app/views/dorsale/_contextual.html.slim +3 -0
  82. data/app/views/dorsale/alexandrie/attachments/_form.html.slim +13 -0
  83. data/app/views/dorsale/alexandrie/attachments/_form_and_list.html.slim +2 -0
  84. data/app/views/dorsale/alexandrie/attachments/_list.html.slim +7 -0
  85. data/app/views/dorsale/billing_machine/invoices/_data_context.html.slim +10 -0
  86. data/app/views/dorsale/billing_machine/invoices/_filters.html.slim +16 -0
  87. data/app/views/dorsale/billing_machine/invoices/_form.html.slim +62 -0
  88. data/app/views/dorsale/billing_machine/invoices/_line_fields.html.slim +23 -0
  89. data/app/views/dorsale/billing_machine/invoices/_list.html.slim +30 -0
  90. data/app/views/dorsale/billing_machine/invoices/edit.html.slim +2 -0
  91. data/app/views/dorsale/billing_machine/invoices/index.html.slim +15 -0
  92. data/app/views/dorsale/billing_machine/invoices/new.html.slim +2 -0
  93. data/app/views/dorsale/billing_machine/invoices/show.html.slim +53 -0
  94. data/app/views/dorsale/billing_machine/quotations/_data_context.html.slim +10 -0
  95. data/app/views/dorsale/billing_machine/quotations/_filters.html.slim +13 -0
  96. data/app/views/dorsale/billing_machine/quotations/_form.html.slim +55 -0
  97. data/app/views/dorsale/billing_machine/quotations/_line_fields.html.slim +23 -0
  98. data/app/views/dorsale/billing_machine/quotations/_list.html.slim +30 -0
  99. data/app/views/dorsale/billing_machine/quotations/edit.html.slim +2 -0
  100. data/app/views/dorsale/billing_machine/quotations/index.html.slim +14 -0
  101. data/app/views/dorsale/billing_machine/quotations/new.html.slim +2 -0
  102. data/app/views/dorsale/billing_machine/quotations/show.html.slim +61 -0
  103. data/app/views/dorsale/comments/_comment.html.slim +23 -9
  104. data/app/views/dorsale/comments/_comments.html.slim +2 -2
  105. data/app/views/dorsale/comments/_form.html.slim +1 -1
  106. data/app/views/dorsale/comments/_list.html.slim +2 -0
  107. data/app/views/dorsale/comments/edit.html.slim +5 -0
  108. data/app/views/dorsale/customer_vault/_breadcrumb.html.slim +4 -0
  109. data/app/views/dorsale/customer_vault/corporations/_context.html.slim +20 -0
  110. data/app/views/dorsale/customer_vault/corporations/_form.html.slim +21 -0
  111. data/app/views/dorsale/customer_vault/corporations/_list_details.html.slim +20 -0
  112. data/app/views/dorsale/customer_vault/corporations/edit.html.slim +14 -0
  113. data/app/views/dorsale/customer_vault/corporations/new.html.slim +14 -0
  114. data/app/views/dorsale/customer_vault/corporations/show.html.slim +1 -0
  115. data/app/views/dorsale/customer_vault/individuals/_context.html.slim +15 -0
  116. data/app/views/dorsale/customer_vault/individuals/_form.html.slim +22 -0
  117. data/app/views/dorsale/customer_vault/individuals/_list_details.html.slim +20 -0
  118. data/app/views/dorsale/customer_vault/individuals/edit.html.slim +14 -0
  119. data/app/views/dorsale/customer_vault/individuals/new.html.slim +14 -0
  120. data/app/views/dorsale/customer_vault/individuals/show.html.slim +1 -0
  121. data/app/views/dorsale/customer_vault/links/_title.html.slim +7 -0
  122. data/app/views/dorsale/customer_vault/links/edit.html.slim +19 -0
  123. data/app/views/dorsale/customer_vault/links/new.html.slim +15 -0
  124. data/app/views/dorsale/customer_vault/people/_activity_tab.html.slim +5 -0
  125. data/app/views/dorsale/customer_vault/people/_comment.html.slim +1 -0
  126. data/app/views/dorsale/customer_vault/people/_context.html.slim +4 -0
  127. data/app/views/dorsale/customer_vault/people/_data_context.html.slim +32 -0
  128. data/app/views/dorsale/customer_vault/people/_filters.html.slim +15 -0
  129. data/app/views/dorsale/customer_vault/people/_index_tabs.html.slim +7 -0
  130. data/app/views/dorsale/customer_vault/people/_links_tab.html.slim +16 -0
  131. data/app/views/dorsale/customer_vault/people/_new_people_contexts.html.slim +7 -0
  132. data/app/views/dorsale/customer_vault/people/_show.html.slim +31 -0
  133. data/app/views/dorsale/customer_vault/people/_tasks_tab.html.slim +1 -0
  134. data/app/views/dorsale/customer_vault/people/activity.slim +20 -0
  135. data/app/views/dorsale/customer_vault/people/list.html.slim +27 -0
  136. data/app/views/dorsale/flyboy/_filters.html.slim +12 -0
  137. data/app/views/dorsale/flyboy/folders/_actions.html.slim +15 -0
  138. data/app/views/dorsale/flyboy/folders/_context.html.slim +18 -0
  139. data/app/views/dorsale/flyboy/folders/_form.html.slim +22 -0
  140. data/app/views/dorsale/flyboy/folders/_list.html.slim +30 -0
  141. data/app/views/dorsale/flyboy/folders/edit.html.slim +2 -0
  142. data/app/views/dorsale/flyboy/folders/index.html.slim +8 -0
  143. data/app/views/dorsale/flyboy/folders/new.html.slim +2 -0
  144. data/app/views/dorsale/flyboy/folders/show.html.slim +9 -0
  145. data/app/views/dorsale/flyboy/task_comments/_list.html.slim +31 -0
  146. data/app/views/dorsale/flyboy/tasks/_actions.html.slim +9 -0
  147. data/app/views/dorsale/flyboy/tasks/_context.html.slim +15 -0
  148. data/app/views/dorsale/flyboy/tasks/_form.html.slim +29 -0
  149. data/app/views/dorsale/flyboy/tasks/_list.html.slim +43 -0
  150. data/app/views/dorsale/flyboy/tasks/_tasks_for_taskable.html.slim +6 -0
  151. data/app/views/dorsale/flyboy/tasks/edit.html.slim +2 -0
  152. data/app/views/dorsale/flyboy/tasks/index.html.slim +10 -0
  153. data/app/views/dorsale/flyboy/tasks/index.xls.erb +29 -0
  154. data/app/views/dorsale/flyboy/tasks/new.html.slim +2 -0
  155. data/app/views/dorsale/flyboy/tasks/show.html.slim +14 -0
  156. data/app/views/dorsale/search/_form.html.slim +6 -0
  157. data/config/locales/alexandrie.fr.yml +8 -0
  158. data/config/locales/billing_machine.fr.yml +50 -0
  159. data/config/locales/common.fr.yml +142 -0
  160. data/config/locales/customer_vault.fr.yml +69 -0
  161. data/config/locales/flyboy.fr.yml +66 -0
  162. data/config/locales/fr.yml +8 -87
  163. data/config/routes.rb +50 -1
  164. data/db/migrate/20141010140200_create_dorsale_addresses.rb +1 -1
  165. data/db/migrate/20150312083147_create_dorsale_comments.rb +3 -3
  166. data/db/migrate/20150616074852_create_dorsale_alexandrie_attachments.rb +9 -0
  167. data/db/migrate/20150622075000_create_flyboy.rb +50 -0
  168. data/db/migrate/20150622075038_create_billing_machine.rb +121 -0
  169. data/db/migrate/20150622105217_create_customer_vault.rb +49 -0
  170. data/db/migrate/20150623093218_dorsale_v2_changes.rb +68 -0
  171. data/db/migrate/20150625093326_billing_machine_quotations_add_expires_at.rb +5 -0
  172. data/db/migrate/20150625131155_billing_machine_add_tracking_ids.rb +6 -0
  173. data/lib/active_record_comma_type_cast.rb +12 -0
  174. data/lib/dorsale/alexandrie/prawn.rb +17 -0
  175. data/lib/dorsale/engine.rb +19 -0
  176. data/lib/dorsale/file_loader.rb +10 -0
  177. data/lib/dorsale/model_i18n.rb +21 -0
  178. data/lib/dorsale/model_to_s.rb +13 -0
  179. data/lib/dorsale/polymorphic_id.rb +2 -0
  180. data/lib/dorsale/version.rb +1 -1
  181. data/spec/controllers/dorsale/alexandrie/attachments_controller_spec.rb +47 -0
  182. data/spec/controllers/dorsale/comments_controller_spec.rb +45 -0
  183. data/spec/controllers/dorsale/customer_vault/corporations_controller_spec.rb +132 -0
  184. data/spec/controllers/dorsale/customer_vault/individuals_controller_spec.rb +130 -0
  185. data/spec/controllers/dorsale/customer_vault/people_controller_spec.rb +59 -0
  186. data/spec/controllers/dorsale/flyboy/folders_controller_spec.rb +111 -0
  187. data/spec/controllers/dorsale/flyboy/task_comments_controller_spec.rb +16 -0
  188. data/spec/controllers/dorsale/flyboy/tasks_controller_spec.rb +234 -0
  189. data/spec/dummy/app/assets/javascripts/application.coffee +10 -0
  190. data/spec/dummy/app/assets/stylesheets/application.sass +9 -0
  191. data/spec/dummy/app/controllers/application_controller.rb +4 -0
  192. data/spec/dummy/app/models/ability.rb +16 -0
  193. data/spec/dummy/app/models/dummy_model.rb +2 -0
  194. data/spec/dummy/app/views/layouts/application.html.erb +10 -3
  195. data/spec/dummy/config/application.rb +4 -2
  196. data/spec/dummy/db/development.sqlite3 +0 -0
  197. data/spec/dummy/db/migrate/20150616082916_create_dorsale_dummy_models.rb +8 -0
  198. data/spec/dummy/db/migrate/20150624081204_acts_as_taggable_on_migration.acts_as_taggable_on_engine.rb +31 -0
  199. data/spec/dummy/db/migrate/20150624081205_add_missing_unique_indices.acts_as_taggable_on_engine.rb +20 -0
  200. data/spec/dummy/db/migrate/20150624081206_add_taggings_counter_cache_to_tags.acts_as_taggable_on_engine.rb +15 -0
  201. data/spec/dummy/db/migrate/20150624081207_add_missing_taggable_index.acts_as_taggable_on_engine.rb +10 -0
  202. data/spec/dummy/db/migrate/20150624081208_change_collation_for_tag_names.acts_as_taggable_on_engine.rb +10 -0
  203. data/spec/dummy/db/schema.rb +243 -5
  204. data/spec/dummy/db/seed.rb +1 -0
  205. data/spec/dummy/db/test.sqlite3 +0 -0
  206. data/spec/dummy/log/development.log +227 -0
  207. data/spec/dummy/log/test.log +2740 -25
  208. data/spec/dummy/{app/assets/stylesheets/application.css → tmp/cache/assets/development/sprockets/13fe41fee1fe35b49d145bcc06610705} +0 -0
  209. data/spec/dummy/tmp/cache/assets/development/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
  210. data/spec/dummy/tmp/cache/assets/development/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
  211. data/spec/dummy/tmp/cache/assets/development/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
  212. data/spec/dummy/tmp/cache/assets/development/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
  213. data/spec/dummy/tmp/cache/assets/development/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
  214. data/spec/factories/alexandrie_attachments.rb +12 -0
  215. data/spec/factories/billing_machine_id_cards.rb +26 -0
  216. data/spec/factories/billing_machine_invoice_lines.rb +11 -0
  217. data/spec/factories/billing_machine_invoices.rb +12 -0
  218. data/spec/factories/billing_machine_payment_terms.rb +5 -0
  219. data/spec/factories/billing_machine_quotation_lines.rb +12 -0
  220. data/spec/factories/billing_machine_quotations.rb +12 -0
  221. data/spec/factories/customer_vault_corporations.rb +14 -0
  222. data/spec/factories/customer_vault_individuals.rb +19 -0
  223. data/spec/factories/customer_vault_links.rb +7 -0
  224. data/spec/factories/dorsale_addresses.rb +6 -8
  225. data/spec/factories/dorsale_comments.rb +8 -0
  226. data/spec/factories/flyboy_folders.rb +7 -0
  227. data/spec/factories/flyboy_task_comments.rb +8 -0
  228. data/spec/factories/flyboy_tasks.rb +12 -0
  229. data/spec/files/pdf.pdf +0 -0
  230. data/spec/helpers/dorsale/flyboy/application_helper_spec.rb +91 -0
  231. data/spec/helpers/dorsale/link_helper_spec.rb +1 -0
  232. data/spec/helpers/dorsale/text_helper_spec.rb +33 -9
  233. data/spec/models/dorsale/ability_helper_spec.rb +11 -0
  234. data/spec/models/dorsale/alexandrie/ability_helper_spec.rb +10 -0
  235. data/spec/models/dorsale/alexandrie/attachment_spec.rb +12 -0
  236. data/spec/models/dorsale/billing_machine/id_card_spec.rb +12 -0
  237. data/spec/models/dorsale/billing_machine/invoice_line_spec.rb +50 -0
  238. data/spec/models/dorsale/billing_machine/invoice_spec.rb +156 -0
  239. data/spec/models/dorsale/billing_machine/quotation_line_spec.rb +36 -0
  240. data/spec/models/dorsale/billing_machine/quotation_spec.rb +91 -0
  241. data/spec/models/dorsale/comment_spec.rb +11 -0
  242. data/spec/models/dorsale/customer_vault/corporation_spec.rb +17 -0
  243. data/spec/models/dorsale/customer_vault/individual_spec.rb +17 -0
  244. data/spec/models/dorsale/customer_vault/link_spec.rb +12 -0
  245. data/spec/models/dorsale/customer_vault/person_spec.rb +44 -0
  246. data/spec/models/dorsale/flyboy/ability_spec.rb +148 -0
  247. data/spec/models/dorsale/flyboy/folder_spec.rb +103 -0
  248. data/spec/models/dorsale/flyboy/task_comment_spec.rb +52 -0
  249. data/spec/models/dorsale/flyboy/task_spec.rb +83 -0
  250. data/spec/pdfs/dorsale/billing_machine/invoice_pdf_spec.rb +252 -0
  251. data/spec/pdfs/dorsale/billing_machine/quotation_pdf_spec.rb +255 -0
  252. data/spec/rails_helper.rb +11 -11
  253. data/spec/routing/dorsale/alexandrie/attachments_routing_spec.rb +19 -0
  254. data/spec/routing/dorsale/billing_machine/invoices_routing_spec.rb +53 -0
  255. data/spec/routing/dorsale/billing_machine/quotations_routing_spec.rb +43 -0
  256. data/spec/routing/dorsale/comments_routing_spec.rb +25 -0
  257. data/spec/routing/dorsale/customer_vault/corporations_routing_spec.rb +66 -0
  258. data/spec/routing/dorsale/customer_vault/individual_routing_spec.rb +66 -0
  259. data/spec/routing/dorsale/customer_vault/people_routing_spec.rb +22 -0
  260. data/spec/routing/dorsale/flyboy/folders_routing_spec.rb +44 -0
  261. data/spec/routing/dorsale/flyboy/task_comments_routing_spec.rb +12 -0
  262. data/spec/routing/dorsale/flyboy/tasks_routing_spec.rb +44 -0
  263. data/spec/spec_helper.rb +0 -6
  264. metadata +439 -10
  265. data/MIT-LICENSE +0 -20
  266. data/README.rdoc +0 -3
  267. data/spec/dummy/app/assets/javascripts/application.js +0 -13
@@ -0,0 +1,255 @@
1
+ require "rails_helper"
2
+
3
+ describe ::Dorsale::BillingMachine::InvoicePdf, pdfs: true do
4
+
5
+ def self.it_should_write(string)
6
+ it "should write '#{string}'" do
7
+ text.strings.should include string
8
+ end
9
+ end
10
+
11
+ def self.it_should_not_write(string)
12
+ it "should write '#{string}'" do
13
+ text.strings.should_not include string
14
+ end
15
+ end
16
+
17
+ let(:customer) {
18
+ create(:customer_vault_corporation)
19
+ }
20
+
21
+ let(:id_card) { create(:billing_machine_id_card,
22
+ entity_name: "HEYHO",
23
+ registration_city: 'RCS MARSEILLE',
24
+ registration_number: '000 000 000',
25
+ siret: '000 000 000 00000',
26
+ ape_naf: '0000A',
27
+ legal_form: 'SARL',
28
+ capital: 1_000_000_000,
29
+ intracommunity_vat: 'FR 00 000 000 000 000 00',
30
+ address1: '42 Avenue de Ruby', zip: '13004',
31
+ city: 'Marseille',
32
+ contact_full_name: 'Jane Doe',
33
+ contact_phone: '+33.6.00.00.00.00',
34
+ contact_fax: '+33.9.00.00.00.00',
35
+ contact_email: 'email@example.org',
36
+ iban: 'FR76 0000 0000 0000 0000 0000 000',
37
+ bic_swift: 'PSSTTHEGAME',
38
+ custom_info_1: "Mention légale" + "\n" + "Tout retard de règlement donnera lieu de plein droit et sans qu’aucune mise en demeure ne soit nécessaire au paiement de " +
39
+ 'pénalités de retard sur la base du taux BCE majoré de dix (10) points et au paiement d’une indemnité forfaitaire pour frais de ' +
40
+ 'recouvrement d’un montant de 999999€'
41
+ ) }
42
+
43
+ let(:quotation) { create(:billing_machine_quotation,
44
+ date: '16/04/2014',
45
+ expires_at: '10/06/2014',
46
+ id_card: id_card,
47
+ customer: customer,
48
+ total_duty: 1812.53,
49
+ vat_amount: 355.26,
50
+ total_all_taxes: 2167.79,
51
+ vat_rate: 19.6,
52
+ comments: 'this is the quotation comment') }
53
+
54
+ let(:quotation_line) { create(:billing_machine_quotation_line,
55
+ quotation_id: quotation.id,
56
+ quantity: 3.14,
57
+ unit: 'heures',
58
+ unit_price: 2.54,
59
+ total: 7.98) }
60
+
61
+ let(:quotation_line_2) { create(:billing_machine_quotation_line,
62
+ quotation_id: quotation.id,
63
+ label: 'Truc',
64
+ quantity: 42.42,
65
+ unit: 'nuts',
66
+ unit_price: 42.54,
67
+ total: 1804.55) }
68
+
69
+ let(:pdf) { quotation.pdf }
70
+
71
+ describe "#initialize" do
72
+ it 'inherits from Prawn::Document' do
73
+ pdf.should be_kind_of(Prawn::Document)
74
+ end
75
+
76
+ it 'inherits from CommonQuotation' do
77
+ pdf.should be_kind_of(::Dorsale::BillingMachine::QuotationPdf)
78
+ end
79
+
80
+ it 'should assign @main_document' do
81
+ pdf.main_document.should eq(quotation)
82
+ end
83
+ end
84
+
85
+ describe "#build" do
86
+ let(:text) { PDF::Inspector::Text.analyze(pdf.render) }
87
+
88
+ context 'when the id card is empty' do
89
+ let(:id_card) { ::Dorsale::BillingMachine::IdCard.create(id_card_name: 'default')}
90
+ it 'should not crash' do
91
+ pdf.build
92
+ end
93
+ end
94
+
95
+ before do
96
+ quotation.lines << quotation_line
97
+ quotation.lines << quotation_line_2
98
+ pdf.build
99
+ end
100
+ context 'in Mentions légales - Coin supérieur droit' do
101
+ it_should_write 'HEYHO'
102
+ it_should_write 'SIRET 000 000 000 00000 APE 0000A'
103
+ it_should_write 'SARL au capital de 1.000.000.000 euros'
104
+ it_should_write 'RCS MARSEILLE 000 000 000'
105
+ it_should_write 'N° TVA FR 00 000 000 000 000 00'
106
+ it_should_write '42 Avenue de Ruby'
107
+ it_should_write '13004 Marseille'
108
+ end
109
+
110
+ context 'in Entete de facturation' do
111
+
112
+ it_should_write 'Devis'
113
+
114
+ it "should write invoice tracking id" do
115
+ text.strings.should include ' N°' + quotation.tracking_id
116
+ end
117
+ it "should write 'Marseille le ' and invoice date" do
118
+ text.strings.should include 'Marseille le ' + '16 avril 2014'
119
+ end
120
+
121
+ context 'in Informations contact' do
122
+ it_should_write 'Contact :'
123
+ it_should_write ' Jane Doe'
124
+ it_should_write 'Tél :'
125
+ it_should_write ' +33.6.00.00.00.00'
126
+ it_should_write 'Fax:'
127
+ it_should_write ' +33.9.00.00.00.00'
128
+ it_should_write 'Email:'
129
+ it_should_write ' email@example.org'
130
+ end
131
+
132
+ context 'in Informations client' do
133
+ it_should_write 'A l’attention de :'
134
+
135
+ it "should write customer name" do
136
+ text.strings.should include quotation.customer.name
137
+ end
138
+
139
+ it "should write customer address" do
140
+ text.strings.should include quotation.customer.address.street
141
+ text.strings.should include quotation.customer.address.street_bis
142
+ end
143
+
144
+ it "should write customer zip and city" do
145
+ text.strings.should include quotation.customer.address.zip.to_s +
146
+ ' ' + quotation.customer.address.city.to_s
147
+ end
148
+
149
+ it "should write customer country" do
150
+ text.strings.should include quotation.customer.address.country
151
+ end
152
+ end # context in Informations client
153
+ end # context in Entete de facturation
154
+
155
+ it "shoud write 'Objet :' and invoice label" do
156
+ text.strings.should include 'Objet :'
157
+ text.strings.should include ' ' + quotation.label
158
+ end
159
+
160
+ context "in Tableau" do
161
+ it_should_write 'Prestation'
162
+ it_should_write 'Prix'
163
+ it_should_write 'unitaire'
164
+ it_should_write 'Quantité'
165
+ it_should_write 'Total HT'
166
+
167
+
168
+ context "in Lignes de facturation" do
169
+ it 'should write invoice line label of each invoice line' do
170
+ quotation.lines.each do |line|
171
+ text.strings.should include line.label
172
+ end
173
+ end
174
+
175
+ it 'should write invoice line quantity of each line' do
176
+ text.strings.should include '3,14'
177
+ text.strings.should include '42,42'
178
+ end
179
+
180
+ it 'should write invoice line unit_price of each line' do
181
+ text.strings.should include '2,54 €'
182
+ text.strings.should include '42,54 €'
183
+ end
184
+
185
+ it 'should write invoice line total of each line' do
186
+ text.strings.should include '7,98 €'
187
+ text.strings.should include '1.804,55 €'
188
+ end
189
+ end # context in Lignes de facturation
190
+
191
+ context 'in Synthèse' do
192
+ it_should_write 'Total HT'
193
+ it_should_write '1.812,52 €'
194
+
195
+ it_should_write 'TVA 19,6 %'
196
+ it_should_write '355,25 €'
197
+
198
+ it_should_write 'Total TTC'
199
+ it_should_write '2.167,78 €'
200
+
201
+ it_should_not_write 'Acompte reçu sur commande'
202
+ it_should_not_write '1,79 €'
203
+
204
+ it_should_not_write 'Solde à payer'
205
+ it 'should write balance calculated using total_all_taxes - advance' do
206
+ text.strings.should_not include '2.165,99 €'
207
+ end
208
+
209
+ end
210
+ end # context in Tableau
211
+ it_should_write "Date d'expiration : 10/06/2014"
212
+
213
+ it_should_write 'Conditions de paiement :'
214
+
215
+ it 'should write invoice payment term' do
216
+ text.strings.should include quotation.payment_term.label
217
+ end
218
+
219
+ it_should_not_write 'Coordonnées bancaires :'
220
+ it_should_not_write 'IBAN : FR76 0000 0000 0000 0000 0000 000'
221
+ it_should_not_write 'BIC / SWIFT : PSSTTHEGAME'
222
+
223
+ context 'in Comments - Bas de page' do
224
+ it_should_write 'this is the quotation comment'
225
+ end
226
+
227
+ context 'in Mentions légales - Bas de page' do
228
+ it_should_write 'Mention légale'
229
+ it_should_write 'Tout retard de règlement donnera lieu de plein droit et sans qu’aucune mise en demeure ne soit nécessaire au paiement de'
230
+ it_should_write 'pénalités de retard sur la base du taux BCE majoré de dix (10) points et au paiement d’une indemnité forfaitaire pour frais de'
231
+ it_should_write 'recouvrement d’un montant de 999999€'
232
+ end
233
+ end # describe #build
234
+
235
+ describe "missing data" do
236
+ it "missing payment_term should be OK" do
237
+ quotation = create(:billing_machine_quotation, payment_term: nil)
238
+ pdf = ::Dorsale::BillingMachine::QuotationPdf.new(quotation)
239
+ pdf.build
240
+ PDF::Inspector::Text.analyze(pdf.render)
241
+ end
242
+ end
243
+
244
+ it "should build attachments" do
245
+ quotation = create(:billing_machine_quotation)
246
+ attachment = create(:alexandrie_attachment, attachable: quotation)
247
+ pdf = quotation.pdf
248
+ pdf.build
249
+
250
+ text = Yomu.read(:text, pdf.render_with_attachments).split("\n")
251
+ expect(text).to include "page 1"
252
+ expect(text).to include "page 2"
253
+ end
254
+
255
+ end
data/spec/rails_helper.rb CHANGED
@@ -1,18 +1,16 @@
1
1
  # This file is copied to spec/ when you run 'rails generate rspec:install'
2
- ENV["RAILS_ENV"] ||= 'test'
2
+ ENV["RAILS_ENV"] = 'test'
3
3
  require 'spec_helper'
4
4
  require File.expand_path("../dummy/config/environment", __FILE__)
5
5
  require 'rspec/rails'
6
-
7
- require 'factory_girl_rails'
8
- require 'slim'
9
- Rails.backtrace_cleaner.remove_silencers!
10
- # Load support files
11
- Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
12
-
13
-
6
+ require 'cancan/matchers'
7
+ require "yomu"
14
8
  # Add additional requires below this line. Rails is not loaded until this point!
15
9
 
10
+ require "factory_girl_rails"
11
+ FactoryGirl.definition_file_paths = [File.expand_path('../factories', __FILE__)]
12
+ FactoryGirl.find_definitions
13
+
16
14
  # Requires supporting ruby files with custom matchers and macros, etc, in
17
15
  # spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
18
16
  # run as spec files by default. This means that files in spec/support that end
@@ -30,11 +28,11 @@ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
30
28
 
31
29
  # Checks for pending migrations before tests are run.
32
30
  # If you are not using ActiveRecord, you can remove this line.
33
- ActiveRecord::Migration.check_pending!
31
+ ActiveRecord::Migration.maintain_test_schema!
34
32
 
35
33
  RSpec.configure do |config|
36
34
  # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
37
- # config.fixture_path = "#{::Rails.root}/spec/fixtures"
35
+ config.fixture_path = "#{::Rails.root}/spec/fixtures"
38
36
 
39
37
  # If you're not using ActiveRecord, or you'd prefer not to run each of your
40
38
  # examples within a transaction, remove the following line or assign false
@@ -55,4 +53,6 @@ RSpec.configure do |config|
55
53
  # The different available types are documented in the features, such as in
56
54
  # https://relishapp.com/rspec/rspec-rails/docs
57
55
  config.infer_spec_type_from_file_location!
56
+
57
+ config.include FactoryGirl::Syntax::Methods
58
58
  end
@@ -0,0 +1,19 @@
1
+ require "rails_helper"
2
+
3
+ RSpec.describe Dorsale::Alexandrie::AttachmentsController, type: :routing do
4
+ routes { Dorsale::Engine.routes }
5
+
6
+ describe "routing" do
7
+
8
+ it "#create" do
9
+ expect(post "/alexandrie/attachments").to \
10
+ route_to("dorsale/alexandrie/attachments#create")
11
+ end
12
+
13
+ it "#destroy" do
14
+ expect(delete "/alexandrie/attachments/3").to \
15
+ route_to("dorsale/alexandrie/attachments#destroy", id: "3")
16
+ end
17
+
18
+ end
19
+ end
@@ -0,0 +1,53 @@
1
+ require "rails_helper"
2
+
3
+ describe ::Dorsale::BillingMachine::InvoicesController, type: :routing do
4
+ routes { ::Dorsale::Engine.routes }
5
+
6
+ describe "routing" do
7
+ it "#index" do
8
+ expect(get "/billing_machine/invoices").to \
9
+ route_to("dorsale/billing_machine/invoices#index")
10
+ end
11
+
12
+ it "#new" do
13
+ expect(get "/billing_machine/invoices/new").to \
14
+ route_to("dorsale/billing_machine/invoices#new")
15
+ end
16
+
17
+ it "#create" do
18
+ expect(post "/billing_machine/invoices").to \
19
+ route_to("dorsale/billing_machine/invoices#create")
20
+ end
21
+
22
+ it "#show" do
23
+ expect(get "/billing_machine/invoices/1").to \
24
+ route_to("dorsale/billing_machine/invoices#show", id: "1")
25
+ end
26
+
27
+ it "#show pdf" do
28
+ expect(get "/billing_machine/invoices/1.pdf").to \
29
+ route_to("dorsale/billing_machine/invoices#show", id: "1", format: "pdf")
30
+ end
31
+
32
+ it "#pay" do
33
+ expect(patch "/billing_machine/invoices/1/pay").to \
34
+ route_to("dorsale/billing_machine/invoices#pay", id: "1")
35
+ end
36
+
37
+ it "#copy" do
38
+ expect(get "/billing_machine/invoices/1/copy").to \
39
+ route_to("dorsale/billing_machine/invoices#copy", id: "1")
40
+ end
41
+
42
+ it "#edit" do
43
+ expect(get "/billing_machine/invoices/1/edit").to \
44
+ route_to("dorsale/billing_machine/invoices#edit", id: "1")
45
+ end
46
+
47
+ it "#update" do
48
+ expect(patch "/billing_machine/invoices/1").to \
49
+ route_to("dorsale/billing_machine/invoices#update", id: "1")
50
+ end
51
+
52
+ end
53
+ end
@@ -0,0 +1,43 @@
1
+ require "rails_helper"
2
+
3
+ describe ::Dorsale::BillingMachine::QuotationsController do
4
+ describe "routing" do
5
+ routes { ::Dorsale::Engine.routes }
6
+
7
+ it "#index" do
8
+ expect(get "/billing_machine/quotations").to \
9
+ route_to("dorsale/billing_machine/quotations#index")
10
+ end
11
+
12
+ it "#new" do
13
+ expect(get "/billing_machine/quotations/new").to \
14
+ route_to("dorsale/billing_machine/quotations#new")
15
+ end
16
+
17
+ it "#show" do
18
+ expect(get "/billing_machine/quotations/1").to \
19
+ route_to("dorsale/billing_machine/quotations#show", id: "1")
20
+ end
21
+
22
+ it "#edit" do
23
+ expect(get "/billing_machine/quotations/1/edit").to \
24
+ route_to("dorsale/billing_machine/quotations#edit", id: "1")
25
+ end
26
+
27
+ it "#create" do
28
+ expect(post "/billing_machine/quotations").to \
29
+ route_to("dorsale/billing_machine/quotations#create")
30
+ end
31
+
32
+ it "#update" do
33
+ expect(patch "/billing_machine/quotations/1").to \
34
+ route_to("dorsale/billing_machine/quotations#update", id: "1")
35
+ end
36
+
37
+ it "#destroy" do
38
+ expect(delete "/billing_machine/quotations/1").to \
39
+ route_to("dorsale/billing_machine/quotations#destroy", id: "1")
40
+ end
41
+
42
+ end
43
+ end
@@ -0,0 +1,25 @@
1
+ require "rails_helper"
2
+
3
+ RSpec.describe Dorsale::CommentsController, type: :routing do
4
+ routes { Dorsale::Engine.routes }
5
+
6
+ describe "routing" do
7
+
8
+ it "routes to #create" do
9
+ expect(post: "/comments").to route_to("dorsale/comments#create")
10
+ end
11
+
12
+ it "routes to #edit" do
13
+ expect(get: "/comments/3/edit").to route_to("dorsale/comments#edit", id: "3")
14
+ end
15
+
16
+ it "routes to #update" do
17
+ expect(patch: "/comments/3").to route_to("dorsale/comments#update", id: "3")
18
+ end
19
+
20
+ it "routes to #destroy" do
21
+ expect(delete: "/comments/3").to route_to("dorsale/comments#destroy", id: "3")
22
+ end
23
+
24
+ end
25
+ end