dorsale 3.14.3 → 3.14.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (136) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +3 -0
  3. data/Rakefile +2 -0
  4. data/app/pdfs/dorsale/application_pdf.rb +11 -1
  5. data/app/pdfs/dorsale/expense_gun/expense_pdf.rb +75 -0
  6. data/app/views/dorsale/expense_gun/expenses/_show_actions.html.slim +2 -0
  7. data/app/views/dorsale/expense_gun/expenses/show.pdf.ruby +3 -0
  8. data/lib/dorsale/version.rb +1 -1
  9. metadata +125 -358
  10. data/features/access.feature +0 -17
  11. data/features/billing_machine_invoices.feature +0 -261
  12. data/features/billing_machine_multiple_vat.feature +0 -53
  13. data/features/billing_machine_payment_terms.feature +0 -19
  14. data/features/billing_machine_quotations.feature +0 -193
  15. data/features/customer_vault_activity_types.feature +0 -19
  16. data/features/customer_vault_corporations.feature +0 -95
  17. data/features/customer_vault_filters.feature +0 -14
  18. data/features/customer_vault_individuals.feature +0 -35
  19. data/features/customer_vault_invoices.feature +0 -10
  20. data/features/customer_vault_links.feature +0 -54
  21. data/features/customer_vault_origins.feature +0 -19
  22. data/features/customer_vault_people.feature +0 -25
  23. data/features/customer_vault_search.feature +0 -22
  24. data/features/customer_vault_tasks.feature +0 -35
  25. data/features/expense_gun_categories.feature +0 -19
  26. data/features/expense_gun_expenses.feature +0 -60
  27. data/features/flyboy_task_comments.feature +0 -21
  28. data/features/flyboy_tasks.feature +0 -122
  29. data/features/flyboy_tasks_summary.feature +0 -22
  30. data/features/step_definitions/access_steps.rb +0 -15
  31. data/features/step_definitions/alexandrie_steps.rb +0 -25
  32. data/features/step_definitions/billing_machine_invoices_steps.rb +0 -377
  33. data/features/step_definitions/billing_machine_multiple_vat.rb +0 -19
  34. data/features/step_definitions/billing_machine_payment_terms_steps.rb +0 -42
  35. data/features/step_definitions/billing_machine_quotations_steps.rb +0 -248
  36. data/features/step_definitions/common_steps.rb +0 -91
  37. data/features/step_definitions/customer_vault_activity_types_steps.rb +0 -42
  38. data/features/step_definitions/customer_vault_corporations_steps.rb +0 -218
  39. data/features/step_definitions/customer_vault_filters_steps.rb +0 -37
  40. data/features/step_definitions/customer_vault_individuals_steps.rb +0 -67
  41. data/features/step_definitions/customer_vault_invoices_steps.rb +0 -7
  42. data/features/step_definitions/customer_vault_links_steps.rb +0 -73
  43. data/features/step_definitions/customer_vault_origins_steps.rb +0 -42
  44. data/features/step_definitions/customer_vault_people_steps.rb +0 -26
  45. data/features/step_definitions/customer_vault_search_steps.rb +0 -48
  46. data/features/step_definitions/customer_vault_tasks_steps.rb +0 -34
  47. data/features/step_definitions/expense_gun_categories_steps.rb +0 -50
  48. data/features/step_definitions/expense_gun_expenses_steps.rb +0 -135
  49. data/features/step_definitions/flyboy_task_comments_steps.rb +0 -10
  50. data/features/step_definitions/flyboy_tasks_steps.rb +0 -196
  51. data/features/step_definitions/tasks_summary_steps.rb +0 -30
  52. data/features/step_definitions/users_management_step.rb +0 -29
  53. data/features/support/env.rb +0 -8
  54. data/features/users_management.feature +0 -18
  55. data/spec/controllers/dorsale/alexandrie/attachments_controller_spec.rb +0 -145
  56. data/spec/controllers/dorsale/billing_machine/invoices_controller_spec.rb +0 -153
  57. data/spec/controllers/dorsale/billing_machine/quotations_controller_spec.rb +0 -24
  58. data/spec/controllers/dorsale/comments_controller_spec.rb +0 -50
  59. data/spec/controllers/dorsale/customer_vault/events_controller_spec.rb +0 -42
  60. data/spec/controllers/dorsale/customer_vault/people_controller_spec.rb +0 -129
  61. data/spec/controllers/dorsale/expense_gun/expenses_controller_spec.rb +0 -45
  62. data/spec/controllers/dorsale/flyboy/task_comments_controller_spec.rb +0 -40
  63. data/spec/controllers/dorsale/flyboy/tasks_controller_spec.rb +0 -349
  64. data/spec/factories/alexandrie_attachment_types.rb +0 -5
  65. data/spec/factories/alexandrie_attachments.rb +0 -16
  66. data/spec/factories/billing_machine_invoice_lines.rb +0 -9
  67. data/spec/factories/billing_machine_invoices.rb +0 -9
  68. data/spec/factories/billing_machine_payment_terms.rb +0 -5
  69. data/spec/factories/billing_machine_quotation_lines.rb +0 -9
  70. data/spec/factories/billing_machine_quotations.rb +0 -9
  71. data/spec/factories/customer_vault_activity_types.rb +0 -5
  72. data/spec/factories/customer_vault_corporations.rb +0 -13
  73. data/spec/factories/customer_vault_event.rb +0 -13
  74. data/spec/factories/customer_vault_individuals.rb +0 -17
  75. data/spec/factories/customer_vault_links.rb +0 -7
  76. data/spec/factories/customer_vault_origins.rb +0 -5
  77. data/spec/factories/dorsale_addresses.rb +0 -9
  78. data/spec/factories/dorsale_comments.rb +0 -7
  79. data/spec/factories/expense_gun_categories.rb +0 -7
  80. data/spec/factories/expense_gun_expense_lines.rb +0 -10
  81. data/spec/factories/expense_gun_expenses.rb +0 -13
  82. data/spec/factories/flyboy_task_comments.rb +0 -9
  83. data/spec/factories/flyboy_tasks.rb +0 -8
  84. data/spec/files/avatar.png +0 -0
  85. data/spec/files/pdf.pdf +0 -0
  86. data/spec/mailers/user_mailer_spec.rb +0 -21
  87. data/spec/models/dorsale/address_spec.rb +0 -46
  88. data/spec/models/dorsale/alexandrie/attachment_spec.rb +0 -36
  89. data/spec/models/dorsale/alexandrie/attachment_type_spec.rb +0 -11
  90. data/spec/models/dorsale/billing_machine/invoice_line_spec.rb +0 -52
  91. data/spec/models/dorsale/billing_machine/invoice_spec.rb +0 -258
  92. data/spec/models/dorsale/billing_machine/quotation_line_spec.rb +0 -51
  93. data/spec/models/dorsale/billing_machine/quotation_spec.rb +0 -213
  94. data/spec/models/dorsale/billing_machine_spec.rb +0 -57
  95. data/spec/models/dorsale/comment_spec.rb +0 -24
  96. data/spec/models/dorsale/customer_vault/activity_type_spec.rb +0 -10
  97. data/spec/models/dorsale/customer_vault/corporation_spec.rb +0 -33
  98. data/spec/models/dorsale/customer_vault/event_spec.rb +0 -22
  99. data/spec/models/dorsale/customer_vault/individual_spec.rb +0 -44
  100. data/spec/models/dorsale/customer_vault/link_spec.rb +0 -14
  101. data/spec/models/dorsale/customer_vault/origin_spec.rb +0 -8
  102. data/spec/models/dorsale/customer_vault/person_spec.rb +0 -112
  103. data/spec/models/dorsale/email_spec.rb +0 -39
  104. data/spec/models/dorsale/expense_gun/category_spec.rb +0 -9
  105. data/spec/models/dorsale/expense_gun/expense_line_spec.rb +0 -59
  106. data/spec/models/dorsale/expense_gun/expense_spec.rb +0 -176
  107. data/spec/models/dorsale/flyboy/task_comment_spec.rb +0 -54
  108. data/spec/models/dorsale/flyboy/task_spec.rb +0 -254
  109. data/spec/models/dorsale/i18n_spec.rb +0 -30
  110. data/spec/models/dorsale/users_spec.rb +0 -65
  111. data/spec/pdfs/dorsale/billing_machine/invoice_multiple_vat_pdf_spec.rb +0 -42
  112. data/spec/pdfs/dorsale/billing_machine/invoice_single_vat_pdf_spec.rb +0 -42
  113. data/spec/pdfs/dorsale/billing_machine/quotation_multiple_vat_pdf_spec.rb +0 -42
  114. data/spec/pdfs/dorsale/billing_machine/quotation_single_vat_pdf_spec.rb +0 -55
  115. data/spec/rails_helper.rb +0 -55
  116. data/spec/routing/dorsale/alexandrie/attachments_routing_spec.rb +0 -32
  117. data/spec/routing/dorsale/billing_machine/invoices_routing_spec.rb +0 -67
  118. data/spec/routing/dorsale/billing_machine/quotations_routing_spec.rb +0 -67
  119. data/spec/routing/dorsale/comments_routing_spec.rb +0 -23
  120. data/spec/routing/dorsale/customer_vault/activity_types_routing_spec.rb +0 -40
  121. data/spec/routing/dorsale/customer_vault/events_routing_spec.rb +0 -12
  122. data/spec/routing/dorsale/customer_vault/origins_routing_spec.rb +0 -40
  123. data/spec/routing/dorsale/customer_vault/people_routing_spec.rb +0 -109
  124. data/spec/routing/dorsale/expense_gun/expenses_routing_spec.rb +0 -62
  125. data/spec/routing/dorsale/flyboy/task_comments_routing_spec.rb +0 -11
  126. data/spec/routing/dorsale/flyboy/tasks_routing_spec.rb +0 -51
  127. data/spec/routing/dorsale/users_routing_spec.rb +0 -38
  128. data/spec/services/dorsale/billing_machine/quotation/copy_spec.rb +0 -55
  129. data/spec/services/dorsale/billing_machine/quotation/statistics.rb +0 -23
  130. data/spec/services/dorsale/billing_machine/quotation/to_invoice_spec.rb +0 -46
  131. data/spec/services/dorsale/expense_gun/expense/copy_spec.rb +0 -83
  132. data/spec/services/dorsale/flyboy/task/copy_spec.rb +0 -24
  133. data/spec/services/dorsale/flyboy/task/snoozer_spec.rb +0 -117
  134. data/spec/spec_helper.rb +0 -86
  135. data/spec/support/devise.rb +0 -3
  136. data/spec/support/message_delivery.rb +0 -5
@@ -1,254 +0,0 @@
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
@@ -1,30 +0,0 @@
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
@@ -1,65 +0,0 @@
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
@@ -1,42 +0,0 @@
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
@@ -1,42 +0,0 @@
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
@@ -1,42 +0,0 @@
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