dorsale 3.14.4 → 3.14.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (132) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +3 -0
  3. data/features/access.feature +17 -0
  4. data/features/billing_machine_invoices.feature +261 -0
  5. data/features/billing_machine_multiple_vat.feature +53 -0
  6. data/features/billing_machine_payment_terms.feature +19 -0
  7. data/features/billing_machine_quotations.feature +193 -0
  8. data/features/customer_vault_activity_types.feature +19 -0
  9. data/features/customer_vault_corporations.feature +95 -0
  10. data/features/customer_vault_filters.feature +14 -0
  11. data/features/customer_vault_individuals.feature +35 -0
  12. data/features/customer_vault_invoices.feature +10 -0
  13. data/features/customer_vault_links.feature +54 -0
  14. data/features/customer_vault_origins.feature +19 -0
  15. data/features/customer_vault_people.feature +25 -0
  16. data/features/customer_vault_search.feature +22 -0
  17. data/features/customer_vault_tasks.feature +35 -0
  18. data/features/expense_gun_categories.feature +19 -0
  19. data/features/expense_gun_expenses.feature +60 -0
  20. data/features/flyboy_task_comments.feature +21 -0
  21. data/features/flyboy_tasks.feature +122 -0
  22. data/features/flyboy_tasks_summary.feature +22 -0
  23. data/features/step_definitions/access_steps.rb +15 -0
  24. data/features/step_definitions/alexandrie_steps.rb +25 -0
  25. data/features/step_definitions/billing_machine_invoices_steps.rb +377 -0
  26. data/features/step_definitions/billing_machine_multiple_vat.rb +19 -0
  27. data/features/step_definitions/billing_machine_payment_terms_steps.rb +42 -0
  28. data/features/step_definitions/billing_machine_quotations_steps.rb +248 -0
  29. data/features/step_definitions/common_steps.rb +91 -0
  30. data/features/step_definitions/customer_vault_activity_types_steps.rb +42 -0
  31. data/features/step_definitions/customer_vault_corporations_steps.rb +218 -0
  32. data/features/step_definitions/customer_vault_filters_steps.rb +37 -0
  33. data/features/step_definitions/customer_vault_individuals_steps.rb +67 -0
  34. data/features/step_definitions/customer_vault_invoices_steps.rb +7 -0
  35. data/features/step_definitions/customer_vault_links_steps.rb +73 -0
  36. data/features/step_definitions/customer_vault_origins_steps.rb +42 -0
  37. data/features/step_definitions/customer_vault_people_steps.rb +26 -0
  38. data/features/step_definitions/customer_vault_search_steps.rb +48 -0
  39. data/features/step_definitions/customer_vault_tasks_steps.rb +34 -0
  40. data/features/step_definitions/expense_gun_categories_steps.rb +50 -0
  41. data/features/step_definitions/expense_gun_expenses_steps.rb +135 -0
  42. data/features/step_definitions/flyboy_task_comments_steps.rb +10 -0
  43. data/features/step_definitions/flyboy_tasks_steps.rb +196 -0
  44. data/features/step_definitions/tasks_summary_steps.rb +30 -0
  45. data/features/step_definitions/users_management_step.rb +29 -0
  46. data/features/support/env.rb +8 -0
  47. data/features/users_management.feature +18 -0
  48. data/lib/dorsale/version.rb +1 -1
  49. data/spec/controllers/dorsale/alexandrie/attachments_controller_spec.rb +145 -0
  50. data/spec/controllers/dorsale/billing_machine/invoices_controller_spec.rb +153 -0
  51. data/spec/controllers/dorsale/billing_machine/quotations_controller_spec.rb +24 -0
  52. data/spec/controllers/dorsale/comments_controller_spec.rb +50 -0
  53. data/spec/controllers/dorsale/customer_vault/events_controller_spec.rb +42 -0
  54. data/spec/controllers/dorsale/customer_vault/people_controller_spec.rb +129 -0
  55. data/spec/controllers/dorsale/expense_gun/expenses_controller_spec.rb +55 -0
  56. data/spec/controllers/dorsale/flyboy/task_comments_controller_spec.rb +40 -0
  57. data/spec/controllers/dorsale/flyboy/tasks_controller_spec.rb +349 -0
  58. data/spec/factories/alexandrie_attachment_types.rb +5 -0
  59. data/spec/factories/alexandrie_attachments.rb +16 -0
  60. data/spec/factories/billing_machine_invoice_lines.rb +9 -0
  61. data/spec/factories/billing_machine_invoices.rb +9 -0
  62. data/spec/factories/billing_machine_payment_terms.rb +5 -0
  63. data/spec/factories/billing_machine_quotation_lines.rb +9 -0
  64. data/spec/factories/billing_machine_quotations.rb +9 -0
  65. data/spec/factories/customer_vault_activity_types.rb +5 -0
  66. data/spec/factories/customer_vault_corporations.rb +13 -0
  67. data/spec/factories/customer_vault_event.rb +13 -0
  68. data/spec/factories/customer_vault_individuals.rb +17 -0
  69. data/spec/factories/customer_vault_links.rb +7 -0
  70. data/spec/factories/customer_vault_origins.rb +5 -0
  71. data/spec/factories/dorsale_addresses.rb +9 -0
  72. data/spec/factories/dorsale_comments.rb +7 -0
  73. data/spec/factories/expense_gun_categories.rb +7 -0
  74. data/spec/factories/expense_gun_expense_lines.rb +11 -0
  75. data/spec/factories/expense_gun_expenses.rb +13 -0
  76. data/spec/factories/flyboy_task_comments.rb +9 -0
  77. data/spec/factories/flyboy_tasks.rb +8 -0
  78. data/spec/files/avatar.png +0 -0
  79. data/spec/files/pdf.pdf +0 -0
  80. data/spec/mailers/user_mailer_spec.rb +21 -0
  81. data/spec/models/dorsale/address_spec.rb +46 -0
  82. data/spec/models/dorsale/alexandrie/attachment_spec.rb +36 -0
  83. data/spec/models/dorsale/alexandrie/attachment_type_spec.rb +11 -0
  84. data/spec/models/dorsale/billing_machine/invoice_line_spec.rb +52 -0
  85. data/spec/models/dorsale/billing_machine/invoice_spec.rb +258 -0
  86. data/spec/models/dorsale/billing_machine/quotation_line_spec.rb +51 -0
  87. data/spec/models/dorsale/billing_machine/quotation_spec.rb +213 -0
  88. data/spec/models/dorsale/billing_machine_spec.rb +57 -0
  89. data/spec/models/dorsale/comment_spec.rb +24 -0
  90. data/spec/models/dorsale/customer_vault/activity_type_spec.rb +10 -0
  91. data/spec/models/dorsale/customer_vault/corporation_spec.rb +33 -0
  92. data/spec/models/dorsale/customer_vault/event_spec.rb +22 -0
  93. data/spec/models/dorsale/customer_vault/individual_spec.rb +44 -0
  94. data/spec/models/dorsale/customer_vault/link_spec.rb +14 -0
  95. data/spec/models/dorsale/customer_vault/origin_spec.rb +8 -0
  96. data/spec/models/dorsale/customer_vault/person_spec.rb +112 -0
  97. data/spec/models/dorsale/email_spec.rb +39 -0
  98. data/spec/models/dorsale/expense_gun/category_spec.rb +9 -0
  99. data/spec/models/dorsale/expense_gun/expense_line_spec.rb +53 -0
  100. data/spec/models/dorsale/expense_gun/expense_spec.rb +176 -0
  101. data/spec/models/dorsale/flyboy/task_comment_spec.rb +54 -0
  102. data/spec/models/dorsale/flyboy/task_spec.rb +254 -0
  103. data/spec/models/dorsale/i18n_spec.rb +30 -0
  104. data/spec/models/dorsale/users_spec.rb +65 -0
  105. data/spec/pdfs/dorsale/billing_machine/invoice_multiple_vat_pdf_spec.rb +42 -0
  106. data/spec/pdfs/dorsale/billing_machine/invoice_single_vat_pdf_spec.rb +42 -0
  107. data/spec/pdfs/dorsale/billing_machine/quotation_multiple_vat_pdf_spec.rb +42 -0
  108. data/spec/pdfs/dorsale/billing_machine/quotation_single_vat_pdf_spec.rb +55 -0
  109. data/spec/pdfs/dorsale/expense_gun/expense_pdf_spec.rb +11 -0
  110. data/spec/rails_helper.rb +57 -0
  111. data/spec/routing/dorsale/alexandrie/attachments_routing_spec.rb +32 -0
  112. data/spec/routing/dorsale/billing_machine/invoices_routing_spec.rb +67 -0
  113. data/spec/routing/dorsale/billing_machine/quotations_routing_spec.rb +67 -0
  114. data/spec/routing/dorsale/comments_routing_spec.rb +23 -0
  115. data/spec/routing/dorsale/customer_vault/activity_types_routing_spec.rb +40 -0
  116. data/spec/routing/dorsale/customer_vault/events_routing_spec.rb +12 -0
  117. data/spec/routing/dorsale/customer_vault/origins_routing_spec.rb +40 -0
  118. data/spec/routing/dorsale/customer_vault/people_routing_spec.rb +109 -0
  119. data/spec/routing/dorsale/expense_gun/expenses_routing_spec.rb +62 -0
  120. data/spec/routing/dorsale/flyboy/task_comments_routing_spec.rb +11 -0
  121. data/spec/routing/dorsale/flyboy/tasks_routing_spec.rb +51 -0
  122. data/spec/routing/dorsale/users_routing_spec.rb +38 -0
  123. data/spec/services/dorsale/billing_machine/quotation/copy_spec.rb +55 -0
  124. data/spec/services/dorsale/billing_machine/quotation/statistics.rb +23 -0
  125. data/spec/services/dorsale/billing_machine/quotation/to_invoice_spec.rb +46 -0
  126. data/spec/services/dorsale/expense_gun/expense/copy_spec.rb +83 -0
  127. data/spec/services/dorsale/flyboy/task/copy_spec.rb +24 -0
  128. data/spec/services/dorsale/flyboy/task/snoozer_spec.rb +117 -0
  129. data/spec/spec_helper.rb +86 -0
  130. data/spec/support/devise.rb +3 -0
  131. data/spec/support/message_delivery.rb +5 -0
  132. metadata +258 -2
@@ -0,0 +1,254 @@
1
+ require "rails_helper"
2
+
3
+ describe Dorsale::Flyboy::Task do
4
+ it { is_expected.to belong_to(:taskable) }
5
+ it { is_expected.to belong_to :owner }
6
+ it { is_expected.to have_many(:comments).dependent(:destroy) }
7
+
8
+ it { is_expected.to validate_presence_of :name }
9
+ it { is_expected.to validate_presence_of :term }
10
+ it { is_expected.to_not validate_presence_of :reminder_type }
11
+
12
+ it { is_expected.to_not validate_presence_of :taskable }
13
+
14
+ describe "default values" do
15
+ before do
16
+ @task = Dorsale::Flyboy::Task.new
17
+ end
18
+
19
+ it "#done should be false" do
20
+ expect(@task.done).to be false
21
+ end
22
+
23
+ it "#term should be present" do
24
+ expect(@task.term).to be_present
25
+ end
26
+
27
+ it "#reminter should be nil" do
28
+ expect(@task.reminder_type).to be nil
29
+ expect(@task.reminder_date).to be nil
30
+ expect(@task.reminder_duration).to be nil
31
+ expect(@task.reminder_unit).to be nil
32
+ end
33
+
34
+ it "#progress should be 0" do
35
+ expect(@task.progress).to eq 0
36
+ end
37
+ end
38
+
39
+ describe "#validation" do
40
+ it "factory should be #valid?" do
41
+ expect(create(:flyboy_task)).to be_valid
42
+ end
43
+ end # describe '#validation'
44
+
45
+ describe "reminders" do
46
+ before do
47
+ Timecop.freeze "2017-04-12"
48
+ end
49
+
50
+ it "should not validate reminder_date if reminder_type is nil" do
51
+ task = described_class.new(reminder_type: nil)
52
+ task.valid?
53
+ expect(task.errors).to_not have_key :reminder_date
54
+ end
55
+
56
+ it "should validate reminder_date if reminder_type is present" do
57
+ task = described_class.new(reminder_type: "custom")
58
+ task.valid?
59
+ expect(task.errors).to have_key :reminder_date
60
+ end
61
+
62
+ it "should auto reset reminder_date" do
63
+ task = described_class.new(
64
+ :term => "2017-04-12",
65
+ :reminder_type => "custom",
66
+ :reminder_date => "2017-04-11",
67
+ )
68
+ task.reminder_type = nil
69
+ expect(task.reminder_date).to eq nil
70
+ end
71
+
72
+ it "should auto set reminder_date by with days" do
73
+ task = described_class.new(
74
+ :term => "2017-04-12",
75
+ :reminder_type => "duration",
76
+ :reminder_duration => 1,
77
+ :reminder_unit => "days",
78
+ )
79
+ expect(task.reminder_date).to eq Date.parse("2017-04-11")
80
+ end
81
+
82
+ it "should auto set reminder_date by with weeks" do
83
+ task = described_class.new(
84
+ :term => "2017-04-12",
85
+ :reminder_type => "duration",
86
+ :reminder_duration => 2,
87
+ :reminder_unit => "weeks",
88
+ )
89
+ expect(task.reminder_date).to eq Date.parse("2017-03-29")
90
+ end
91
+
92
+ it "should auto set reminder_date by with months" do
93
+ task = described_class.new(
94
+ :term => "2017-04-12",
95
+ :reminder_type => "duration",
96
+ :reminder_duration => 1,
97
+ :reminder_unit => "months",
98
+ )
99
+ expect(task.reminder_date).to eq Date.parse("2017-03-12")
100
+ end
101
+
102
+ it "update term should update reminder_date" do
103
+ task = described_class.new(
104
+ :term => "2017-04-12",
105
+ :reminder_type => "duration",
106
+ :reminder_duration => 1,
107
+ :reminder_unit => "days",
108
+ )
109
+ expect(task.reminder_date).to eq Date.parse("2017-04-11")
110
+ task.term = "2017-04-25"
111
+ expect(task.reminder_date).to eq Date.parse("2017-04-24")
112
+ end
113
+ end # describe "reminders"
114
+
115
+ describe "scopes" do
116
+ it "should return delayed undone tasks" do
117
+ task = create(:flyboy_task, owner: @user1, term: Date.current+1)
118
+ task1 = create(:flyboy_task, owner: @user1, term: Date.current-1, done: true)
119
+ task2 = create(:flyboy_task, owner: @user1, term: Date.current-1, done: false)
120
+ task3 = create(:flyboy_task, owner: @user1, term: Date.current-2, done: true)
121
+ task4 = create(:flyboy_task, owner: @user1, term: Date.current-2, done: false)
122
+ tasks = ::Dorsale::Flyboy::Task.delayed
123
+ expect(tasks).to contain_exactly(task2, task4)
124
+ end
125
+
126
+ it "should return today undone tasks" do
127
+ task = create(:flyboy_task, owner: @user1, term: Date.current+1)
128
+ task1 = create(:flyboy_task, owner: @user1, term: Date.current, done: true)
129
+ task2 = create(:flyboy_task, owner: @user1, term: Date.current, done: false)
130
+ tasks = ::Dorsale::Flyboy::Task.today
131
+ expect(tasks).to contain_exactly(task2)
132
+ end
133
+
134
+ it "should return tomorrow undone tasks" do
135
+ task = create(:flyboy_task, owner: @user1, term: Date.current)
136
+ task1 = create(:flyboy_task, owner: @user1, term: Date.tomorrow, done: true)
137
+ task2 = create(:flyboy_task, owner: @user1, term: Date.tomorrow, done: false)
138
+ tasks = ::Dorsale::Flyboy::Task.tomorrow
139
+ expect(tasks).to contain_exactly(task2)
140
+ end
141
+
142
+ it "should return this week undone tasks" do
143
+ Timecop.freeze(2015, 5, 21, 12, 0, 0)
144
+ task = create(:flyboy_task, owner: @user1, term: Date.current-7, done: false)
145
+ task1 = create(:flyboy_task, owner: @user1, term: Date.current+2, done: true)
146
+ task2 = create(:flyboy_task, owner: @user1, term: Date.current+2, done: false)
147
+ task3 = create(:flyboy_task, owner: @user1, term: Date.current+3, done: false)
148
+ task4 = create(:flyboy_task, owner: @user1, term: Date.current+5, done: false)
149
+ tasks = ::Dorsale::Flyboy::Task.this_week
150
+ expect(tasks).to contain_exactly(task2, task3)
151
+ end
152
+
153
+ it "should return next week undone tasks" do
154
+ Timecop.freeze(2015, 5, 21)
155
+ task = create(:flyboy_task, owner: @user1, term: Date.current, done: false)
156
+ task1 = create(:flyboy_task, owner: @user1, term: Date.current+7, done: true)
157
+ task2 = create(:flyboy_task, owner: @user1, term: Date.current+7, done: false)
158
+ task3 = create(:flyboy_task, owner: @user1, term: Date.current+9, done: false)
159
+ task4 = create(:flyboy_task, owner: @user1, term: Date.current+12, done: false)
160
+ tasks = ::Dorsale::Flyboy::Task.next_week
161
+ expect(tasks).to contain_exactly(task2, task3)
162
+ end
163
+ end # describe "scopes"
164
+
165
+ describe "states" do
166
+ # L’affichage de la couleur de la tâche dépend de son achèvement:
167
+ # Si date jour < date relance alors noir
168
+ let(:task_ontime) {
169
+ create(:flyboy_task,
170
+ :reminder_type => "custom",
171
+ :reminder_date => Date.current + 1.day,
172
+ :term => Date.current + 3.days,
173
+ :done => false,
174
+ )
175
+ }
176
+
177
+ it "should return :ontime" do
178
+ expect(task_ontime.state).to eq "ontime"
179
+ expect(described_class.ontime).to eq [task_ontime]
180
+ end
181
+
182
+ # Si date relance <= date jour
183
+ let(:task_onwarning) {
184
+ create(:flyboy_task,
185
+ :reminder_type => "custom",
186
+ :reminder_date => Date.current,
187
+ :term => Date.current + 3.days,
188
+ :done => false,
189
+ )
190
+ }
191
+
192
+ it "should return :onwarning" do
193
+ expect(task_onwarning.state).to eq "onwarning"
194
+ expect(described_class.onwarning).to eq [task_onwarning]
195
+ end
196
+
197
+ # Si date butoir <= date jour alors rouge
198
+ let(:task_onalert) {
199
+ create(:flyboy_task,
200
+ :reminder_type => "custom",
201
+ :reminder_date => Date.current - 3.days,
202
+ :term => Date.current,
203
+ :done => false,
204
+ )
205
+ }
206
+
207
+ it "should return :onalert" do
208
+ expect(task_onalert.state).to eq "onalert"
209
+ expect(described_class.onalert).to eq [task_onalert]
210
+ end
211
+
212
+ # Si action faite alors vert
213
+ let(:task_done) {
214
+ create(:flyboy_task,
215
+ :reminder_type => "custom",
216
+ :reminder_date => Date.current - 3.days,
217
+ :term => Date.current - 1.day,
218
+ :done => true,
219
+ )
220
+ }
221
+
222
+ it "should return on_warning_or_alert" do
223
+ expect(described_class.on_warning_or_alert).to contain_exactly(task_onwarning, task_onalert)
224
+ end
225
+
226
+ it "should return :done" do
227
+ expect(task_done.state).to eq "done"
228
+ expect(described_class.done).to eq [task_done]
229
+ end
230
+ end # describe "states"
231
+
232
+ describe "#create_term_changed_comment!" do
233
+ let!(:task) { create(:flyboy_task, term: "2019-10-02") }
234
+ let!(:author) { create(:user) }
235
+
236
+ it "should create comment" do
237
+ expect {
238
+ task.create_term_changed_comment!(previous: Date.new(2019, 10, 1), author: author)
239
+ }.to change(Dorsale::Flyboy::TaskComment, :count).by(1)
240
+
241
+ task_comment = task.comments.last_created
242
+ expect(task_comment.task).to eq task
243
+ expect(task_comment.author).to eq author
244
+ expect(task_comment.description).to eq \
245
+ "L'échéance de la tâche a été modifiée de 01/10/2019 à 02/10/2019."
246
+ end
247
+
248
+ it "should not create comment if date not changed" do
249
+ expect {
250
+ task.create_term_changed_comment!(previous: Date.new(2019, 10, 2), author: author)
251
+ }.to_not change(Dorsale::Flyboy::TaskComment, :count)
252
+ end
253
+ end # describe "#create_term_changed_comment!"
254
+ end
@@ -0,0 +1,30 @@
1
+ require "rails_helper"
2
+
3
+ # TODO : test FR + EN
4
+
5
+ RSpec.describe "i18n" do
6
+ Rails.application.eager_load!
7
+
8
+ ::Dorsale::ApplicationRecord.descendants.each do |model|
9
+ next unless model.to_s.start_with?("Dorsale")
10
+
11
+ it "should i18n #{model} model name" do
12
+ i18n = model.model_name.human(default: "")
13
+ expect(i18n).to be_present
14
+ end
15
+
16
+ model.column_names.each do |column_name|
17
+ next if column_name.end_with?("_type")
18
+ next if column_name.end_with?("_bak")
19
+ next if column_name.start_with?("old_")
20
+
21
+ # user_id => user
22
+ column_name = column_name[0..-4] if column_name.end_with?("_id")
23
+
24
+ it "should i18n #{model}##{column_name}" do
25
+ i18n = model.human_attribute_name(column_name, default: "")
26
+ expect(i18n).to be_present
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,65 @@
1
+ require "rails_helper"
2
+
3
+ RSpec.describe User, type: :model do
4
+ it "should have a valid factores" do
5
+ expect(create(:user)).to be_valid
6
+ end
7
+
8
+ it { is_expected.to respond_to :is_active }
9
+
10
+ describe "default values" do
11
+ it "default active value should be true" do
12
+ @user = create(:user)
13
+ expect(@user.is_active).to eq true
14
+ end
15
+
16
+ it "should create a valid password upon creation" do
17
+ user = create(:user, password: nil, password_confirmation: nil)
18
+ expect(user).to be_persisted
19
+ end
20
+
21
+ it "should not override choosen password" do
22
+ user = create(:user, password: "totototo", password_confirmation: nil)
23
+ expect(user.password).to eq "totototo"
24
+ end
25
+
26
+ it "should send a welcome message upon creation" do
27
+ expect {
28
+ create(:user)
29
+ }.to change(ActionMailer::Base.deliveries, :count).by(1)
30
+ end
31
+ end
32
+
33
+ describe "avatar" do
34
+ before do
35
+ @user = create(:user,
36
+ :email => "user@example.org",
37
+ :avatar => Dorsale::Engine.root.join("spec/files/avatar.png").open,
38
+ )
39
+ end
40
+
41
+ it "gravatar_url" do
42
+ expect(@user.gravatar_url).to include "gravatar"
43
+ end
44
+
45
+ it "local_avatar_url" do
46
+ expect(@user.local_avatar_url).to include "avatar.png"
47
+ end
48
+
49
+ it "avatar_url should return local_avatar_url if present" do
50
+ expect(@user.avatar_url).to include "avatar.png"
51
+ end
52
+
53
+ it "avatar_url should return gravatar_url if no local avatar" do
54
+ @user.remove_avatar!
55
+ @user.save!
56
+ expect(@user.avatar_url).to include "gravatar"
57
+ end
58
+
59
+ it "should work if email is nil" do
60
+ @user.remove_avatar!
61
+ allow(@user).to receive(:email)
62
+ expect(@user.avatar_url).to be_present
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,42 @@
1
+ require "rails_helper"
2
+
3
+ describe ::Dorsale::BillingMachine::InvoiceMultipleVatPdf, pdfs: true do
4
+ before :each do
5
+ ::Dorsale::BillingMachine.vat_mode = :multiple
6
+ end
7
+
8
+ let(:invoice) {
9
+ i = create(:billing_machine_invoice)
10
+
11
+ create(:billing_machine_invoice_line,
12
+ :invoice => i,
13
+ :vat_rate => 19.6,
14
+ )
15
+
16
+ i
17
+ }
18
+
19
+ let(:generate!) {
20
+ Dorsale::BillingMachine::PdfFileGenerator.(invoice)
21
+ invoice.reload
22
+ }
23
+
24
+ let(:content) {
25
+ generate!
26
+ Yomu.new(invoice.pdf_file.path).text
27
+ }
28
+
29
+ it "should not display global vat rate" do
30
+ expect(content).to_not include "TVA 19,60 %"
31
+ expect(content).to include "MONTANT TVA"
32
+ expect(content).to include "TVA %"
33
+ end
34
+
35
+ it "should work with empty invoice" do
36
+ invoice = ::Dorsale::BillingMachine::Invoice.new
37
+
38
+ expect {
39
+ described_class.new(invoice).tap(&:build).render_with_attachments
40
+ }.to_not raise_error
41
+ end
42
+ end
@@ -0,0 +1,42 @@
1
+ require "rails_helper"
2
+
3
+ describe ::Dorsale::BillingMachine::InvoiceSingleVatPdf, pdfs: true do
4
+ before :each do
5
+ ::Dorsale::BillingMachine.vat_mode = :single
6
+ end
7
+
8
+ let(:invoice) {
9
+ i = create(:billing_machine_invoice)
10
+
11
+ create(:billing_machine_invoice_line,
12
+ :invoice => i,
13
+ :vat_rate => 19.6,
14
+ )
15
+
16
+ i
17
+ }
18
+
19
+ let(:generate!) {
20
+ Dorsale::BillingMachine::PdfFileGenerator.(invoice)
21
+ invoice.reload
22
+ }
23
+
24
+ let(:content) {
25
+ generate!
26
+ Yomu.new(invoice.pdf_file.path).text
27
+ }
28
+
29
+ it "should display global vat rate" do
30
+ expect(content).to include "TVA 19,60"
31
+ expect(content).to_not include "MONTANT TVA"
32
+ expect(content).to_not include "TVA %"
33
+ end
34
+
35
+ it "should work with empty invoice" do
36
+ invoice = ::Dorsale::BillingMachine::Invoice.new
37
+
38
+ expect {
39
+ described_class.new(invoice).tap(&:build).render_with_attachments
40
+ }.to_not raise_error
41
+ end
42
+ end
@@ -0,0 +1,42 @@
1
+ require "rails_helper"
2
+
3
+ describe ::Dorsale::BillingMachine::QuotationMultipleVatPdf, pdfs: true do
4
+ before :each do
5
+ ::Dorsale::BillingMachine.vat_mode = :multiple
6
+ end
7
+
8
+ let(:quotation) {
9
+ q = create(:billing_machine_quotation)
10
+
11
+ create(:billing_machine_quotation_line,
12
+ :quotation => q,
13
+ :vat_rate => 19.6,
14
+ )
15
+
16
+ q
17
+ }
18
+
19
+ let(:generate!) {
20
+ Dorsale::BillingMachine::PdfFileGenerator.(quotation)
21
+ quotation.reload
22
+ }
23
+
24
+ let(:content) {
25
+ generate!
26
+ Yomu.new(quotation.pdf_file.path).text
27
+ }
28
+
29
+ it "should not display global vat rate" do
30
+ expect(content).to_not include "TVA 19,60 %"
31
+ expect(content).to include "MONTANT TVA"
32
+ expect(content).to include "TVA %"
33
+ end
34
+
35
+ it "should work with empty quotation" do
36
+ quotation = ::Dorsale::BillingMachine::Quotation.new
37
+
38
+ expect {
39
+ described_class.new(quotation).tap(&:build).render_with_attachments
40
+ }.to_not raise_error
41
+ end
42
+ end