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,14 +0,0 @@
1
- require "rails_helper"
2
-
3
- RSpec.describe ::Dorsale::CustomerVault::Link, type: :model do
4
- it "should have a valid factory" do
5
- link = build(:customer_vault_link)
6
- expect(link).to be_valid
7
- end
8
-
9
- it { should belong_to :alice }
10
- it { should belong_to :bob }
11
-
12
- it { should validate_presence_of :alice }
13
- it { should validate_presence_of :bob }
14
- end
@@ -1,8 +0,0 @@
1
- RSpec.describe ::Dorsale::CustomerVault::Origin, type: :model do
2
- it { is_expected.to validate_presence_of :name }
3
-
4
- it "should have a valid factory" do
5
- origin = create(:customer_vault_origin)
6
- expect(origin).to be_valid
7
- end
8
- end
@@ -1,112 +0,0 @@
1
- require "rails_helper"
2
-
3
- RSpec.describe ::Dorsale::CustomerVault::Person, type: :model do
4
- describe "#links" do
5
- let!(:c) { create(:customer_vault_corporation) }
6
- let!(:i) { create(:customer_vault_individual) }
7
- let!(:link) { create(:customer_vault_link, alice: c, bob: i, title: "a") }
8
-
9
- it "should return links" do
10
- expect(c.links).to eq [link]
11
- link = c.links.first
12
- expect(link.person).to eq c
13
- expect(link.other_person).to eq i
14
-
15
- expect(i.links).to eq [link]
16
- link = i.links.first
17
- expect(link.person).to eq i
18
- expect(link.other_person).to eq c
19
- end
20
-
21
- describe "#destroy" do
22
- it "should destroy links" do
23
- c.destroy!
24
- expect { link.reload }.to raise_error(ActiveRecord::RecordNotFound)
25
- end
26
- end
27
- end # describe '#links'
28
-
29
- it "should return self_and_related_events" do
30
- corporation = create(:customer_vault_corporation)
31
- individual = create(:customer_vault_individual, corporation: corporation)
32
- corporation_event = create(:customer_vault_event, person: corporation)
33
- individual_event = create(:customer_vault_event, person: individual)
34
-
35
- expect(corporation.self_and_related_events).to \
36
- contain_exactly(corporation_event, individual_event)
37
- expect(individual.self_and_related_events).to contain_exactly(individual_event)
38
- end
39
-
40
- describe "address" do
41
- let(:person_without_address) {
42
- corporation = Dorsale::CustomerVault::Corporation.create!(name: "agilidée")
43
- corporation.address.destroy!
44
- corporation
45
- }
46
-
47
- it "should auto create address on build" do
48
- corporation = Dorsale::CustomerVault::Corporation.new
49
- expect(corporation.address).to be_present
50
- end
51
-
52
- it "should NOT auto create address on find" do
53
- corporation = Dorsale::CustomerVault::Corporation.find(person_without_address.id)
54
- expect(corporation.address).to be_nil
55
- end
56
-
57
- it "should auto create address before validation" do
58
- corporation = Dorsale::CustomerVault::Corporation.find(person_without_address.id)
59
- expect(corporation.address).to be_nil
60
-
61
- corporation.save!
62
- expect(corporation.address).to be_present
63
- end
64
- end # describe "address"
65
-
66
- describe "emails" do
67
- it "should strip email" do
68
- individual = create(:customer_vault_individual, email: " myemail@example.org ")
69
- expect(individual.email).to eq "myemail@example.org"
70
- end
71
-
72
- it "should create an array of strings without blank characters" do
73
- test_individual = create(:customer_vault_individual, email: "primary@example.org")
74
- test_individual.secondary_emails_str = " first@example.org \n second@example.org "
75
- expect(test_individual.secondary_emails).to eq ["first@example.org", "second@example.org"]
76
- end
77
-
78
- it "should return one object in the scope" do
79
- individual = create(:customer_vault_individual,
80
- :email => "primary@example.org",
81
- :secondary_emails => ["first@example.org"],
82
- )
83
-
84
- individual2 = Dorsale::CustomerVault::Person.having_email("primary@example.org")
85
- expect(individual2).to eq [individual]
86
-
87
- individual3 = Dorsale::CustomerVault::Person.having_email("first@example.org")
88
- expect(individual3).to eq [individual]
89
- end
90
-
91
- it "should check whether a new email address already is in the database" do
92
- individual = create(:customer_vault_individual,
93
- :email => "primary@example.org",
94
- :secondary_emails => ["first@example.org", "second@example.org"],
95
- )
96
-
97
- individual2 = create(:customer_vault_individual)
98
- individual2.email = "primary@example.org"
99
- expect(individual2).to be_invalid
100
- expect(individual2.errors).to have_key :email
101
- expect(individual2.errors).to_not have_key :secondary_emails
102
- expect(individual2.errors).to_not have_key :secondary_emails_str
103
-
104
- individual3 = create(:customer_vault_individual)
105
- individual3.secondary_emails << "first@example.org"
106
- expect(individual3).to be_invalid
107
- expect(individual3.errors).to have_key :secondary_emails
108
- expect(individual3.errors).to have_key :secondary_emails_str
109
- expect(individual3.errors).to_not have_key :email
110
- end
111
- end # describe "emails"
112
- end
@@ -1,39 +0,0 @@
1
- require "rails_helper"
2
-
3
- describe Dorsale::Email do
4
- describe "validations" do
5
- it "should validate :to format" do
6
- email = described_class.new
7
-
8
- expect(email).to allow_value("user@example.org").for(:to)
9
- expect(email).to allow_value("user1@example.org,user2@example.org").for(:to)
10
- expect(email).to allow_value("user1@example.org;user2@example.org").for(:to)
11
- expect(email).to allow_value("User <user@example.com>").for(:to)
12
- expect(email).to allow_value("<user@example.com>").for(:to)
13
- expect(email).to allow_value("User <user@example.com>;user2@example.org").for(:to)
14
-
15
- expect(email).to_not allow_value("user").for(:to)
16
- expect(email).to_not allow_value("user@example.com>").for(:to)
17
- expect(email).to_not allow_value("<user@example.com").for(:to)
18
- expect(email).to_not allow_value("valid@example.com;invalid").for(:to)
19
- end
20
-
21
- it "should validate :cc format" do
22
- email = described_class.new
23
-
24
- expect(email).to allow_value("").for(:cc)
25
-
26
- expect(email).to allow_value("user@example.org").for(:cc)
27
- expect(email).to allow_value("user1@example.org,user2@example.org").for(:cc)
28
- expect(email).to allow_value("user1@example.org;user2@example.org").for(:cc)
29
- expect(email).to allow_value("User <user@example.com>").for(:cc)
30
- expect(email).to allow_value("<user@example.com>").for(:cc)
31
- expect(email).to allow_value("User <user@example.com>;user2@example.org").for(:cc)
32
-
33
- expect(email).to_not allow_value("user").for(:cc)
34
- expect(email).to_not allow_value("user@example.com>").for(:cc)
35
- expect(email).to_not allow_value("<user@example.com").for(:cc)
36
- expect(email).to_not allow_value("valid@example.com;invalid").for(:to)
37
- end
38
- end # describe "validations" do
39
- end
@@ -1,9 +0,0 @@
1
- require "rails_helper"
2
-
3
- RSpec.describe ::Dorsale::ExpenseGun::Category, type: :model do
4
- it { is_expected.to validate_presence_of :name }
5
-
6
- it "category factory should be valid?" do
7
- expect(build(:expense_gun_category)).to be_valid
8
- end
9
- end
@@ -1,59 +0,0 @@
1
- require "rails_helper"
2
-
3
- RSpec.describe ::Dorsale::ExpenseGun::ExpenseLine, type: :model do
4
- it { is_expected.to belong_to :expense }
5
- it { is_expected.to validate_presence_of :expense }
6
- it { is_expected.to validate_presence_of :category }
7
- it { is_expected.to validate_presence_of :name }
8
- it { is_expected.to validate_presence_of :date }
9
- it { is_expected.to validate_presence_of :total_all_taxes }
10
- it { is_expected.to validate_presence_of :vat }
11
- it { is_expected.to validate_presence_of :company_part }
12
- it { is_expected.to validate_numericality_of(:total_all_taxes).is_greater_than_or_equal_to(0) }
13
- it { is_expected.to validate_numericality_of(:company_part).is_greater_than_or_equal_to(0) }
14
- it { is_expected.to validate_numericality_of(:company_part).is_less_than_or_equal_to(100) }
15
-
16
- it "expense line factory should be valid?" do
17
- expense_line = build :expense_gun_expense_line, expense: build(:expense_gun_expense)
18
- expect(expense_line).to be_valid
19
- end
20
-
21
- it "#vat should be decimal" do
22
- expense_line = build(:expense_gun_expense_line, vat: 123)
23
- expect(expense_line.valid?).to be false
24
- expect(expense_line.vat).to eq 123.0
25
- end
26
-
27
- it "#company_part should be 100 as default" do
28
- expense_line = described_class.new
29
- expect(expense_line.company_part).to eq 100.0
30
- end
31
-
32
- it "#employee_payback should be correct" do
33
- expense_line = described_class.new(total_all_taxes: 100, company_part: 100)
34
- expect(expense_line.employee_payback).to eq 100.0
35
-
36
- expense_line = described_class.new(total_all_taxes: 250, company_part: 50)
37
- expect(expense_line.employee_payback).to eq 125.0
38
-
39
- expense_line = described_class.new(total_all_taxes: 200, company_part: 80)
40
- expect(expense_line.employee_payback).to eq 160.0
41
- end
42
-
43
- it "#total_vat_deductible should be proportional to #company_part}" do
44
- category = build(:expense_gun_category, vat_deductible: true)
45
- expense_line = build(:expense_gun_expense_line,
46
- :category => category,
47
- :total_all_taxes => 200,
48
- :vat => 40,
49
- :company_part => 50,
50
- )
51
- expect(expense_line.total_vat_deductible).to eq 20.0
52
- end
53
-
54
- it "#total_vat_deductible should be 0 if categorie is non vat_decuctible" do
55
- category = build(:expense_gun_category, vat_deductible: false)
56
- expense_line = build(:expense_gun_expense_line, category: category)
57
- expect(expense_line.total_vat_deductible).to eq 0.0
58
- end
59
- end
@@ -1,176 +0,0 @@
1
- require "rails_helper"
2
-
3
- RSpec.describe Dorsale::ExpenseGun::Expense, type: :model do
4
- it { is_expected.to have_many(:expense_lines).dependent(:destroy) }
5
- it { is_expected.to validate_presence_of :name }
6
- it { is_expected.to validate_presence_of :date }
7
-
8
- it "expense factory should be valid?" do
9
- expect(build(:expense_gun_expense)).to be_valid
10
- end
11
-
12
- it "default #date should be tody" do
13
- expect(described_class.new.date).to eq Date.current
14
- end
15
-
16
- it "new expense should have new state" do
17
- expect(described_class.new.current_state).to be :draft
18
- end
19
-
20
- describe "new state" do
21
- before :each do
22
- @expense = build(:expense_gun_expense)
23
- end
24
-
25
- it "new expense can be submitted" do
26
- expect(@expense.go_to_submitted).to be true
27
- expect(@expense.current_state).to be :submitted
28
- end
29
-
30
- it "new expense can't be accepted" do
31
- expect(@expense.go_to_accepted).to be false
32
- expect(@expense.current_state).to be :draft
33
- end
34
-
35
- it "new expense can't be refused" do
36
- expect(@expense.go_to_refused).to be false
37
- expect(@expense.current_state).to be :draft
38
- end
39
-
40
- it "new expense can be canceled" do
41
- expect(@expense.go_to_canceled).to be true
42
- expect(@expense.current_state).to be :canceled
43
- end
44
- end
45
-
46
- describe "submitted state" do
47
- before :each do
48
- @expense = build(:expense_gun_expense)
49
- @expense.go_to_submitted
50
- end
51
-
52
- it "submitted expense can be accepted" do
53
- expect(@expense.go_to_accepted).to be true
54
- expect(@expense.current_state).to be :accepted
55
- end
56
-
57
- it "submitted expense can be refused" do
58
- expect(@expense.go_to_refused).to be true
59
- expect(@expense.current_state).to be :refused
60
- end
61
-
62
- it "submitted expense can be canceled" do
63
- expect(@expense.go_to_canceled).to be true
64
- expect(@expense.current_state).to be :canceled
65
- end
66
- end
67
-
68
- describe "acceped state" do
69
- before :each do
70
- @expense = build(:expense_gun_expense)
71
- @expense.go_to_submitted
72
- @expense.go_to_accepted
73
- end
74
-
75
- it "acceped expense can't be submitted" do
76
- expect(@expense.go_to_submitted).to be false
77
- expect(@expense.current_state).to be :accepted
78
- end
79
-
80
- it "acceped expense can't be refused" do
81
- expect(@expense.go_to_refused).to be false
82
- expect(@expense.current_state).to be :accepted
83
- end
84
-
85
- it "acceped expense can be canceled" do
86
- expect(@expense.go_to_canceled).to be true
87
- expect(@expense.current_state).to be :canceled
88
- end
89
- end
90
-
91
- describe "refused state" do
92
- before :each do
93
- @expense = build(:expense_gun_expense)
94
- @expense.go_to_submitted
95
- @expense.go_to_refused
96
- end
97
-
98
- it "refused expense can't be submitted" do
99
- expect(@expense.go_to_submitted).to be false
100
- expect(@expense.current_state).to be :refused
101
- end
102
-
103
- it "refused expense can't be acceped" do
104
- expect(@expense.go_to_accepted).to be false
105
- expect(@expense.current_state).to be :refused
106
- end
107
-
108
- it "refused expense can't be canceled" do
109
- expect(@expense.go_to_canceled).to be false
110
- expect(@expense.current_state).to be :refused
111
- end
112
- end
113
-
114
- describe "canceled state" do
115
- before :each do
116
- @expense = build(:expense_gun_expense)
117
- @expense.go_to_canceled
118
- end
119
-
120
- it "canceled expense can't be submitted" do
121
- expect(@expense.go_to_submitted).to be false
122
- expect(@expense.current_state).to be :canceled
123
- end
124
-
125
- it "canceled expense can't be acceped" do
126
- expect(@expense.go_to_accepted).to be false
127
- expect(@expense.current_state).to be :canceled
128
- end
129
-
130
- it "canceled expense can't be refused" do
131
- expect(@expense.go_to_refused).to be false
132
- expect(@expense.current_state).to be :canceled
133
- end
134
- end
135
-
136
- it "#total_all_taxes should return sum of lines" do
137
- expense = build(:expense_gun_expense, expense_lines: [])
138
- expense.expense_lines << build(:expense_gun_expense_line, total_all_taxes: 10)
139
- expense.expense_lines << build(:expense_gun_expense_line, total_all_taxes: 10)
140
- expect(expense.total_all_taxes).to eq 20.0
141
- end
142
-
143
- it "#total_employee_payback should return sum of lines" do
144
- expense = build(:expense_gun_expense, expense_lines: [])
145
-
146
- line1 = build(:expense_gun_expense_line, total_all_taxes: 10, company_part: 100)
147
- expense.expense_lines << line1
148
-
149
- line2 = build(:expense_gun_expense_line, total_all_taxes: 10, company_part: 50)
150
- expense.expense_lines << line2
151
-
152
- expect(expense.total_employee_payback).to eq 15.0
153
- end
154
-
155
- it "#total_vat_deductible should return sum of lines" do
156
- expense = build(:expense_gun_expense, expense_lines: [])
157
-
158
- category1 = build(:expense_gun_category, vat_deductible: true)
159
- line1 = build(:expense_gun_expense_line, vat: 10, category: category1, company_part: 50)
160
- expense.expense_lines << line1
161
-
162
- category2 = build(:expense_gun_category, vat_deductible: false)
163
- line2 = build(:expense_gun_expense_line, vat: 10, category: category2, company_part: 50)
164
- expense.expense_lines << line2
165
-
166
- expect(expense.total_vat_deductible).to eq 5.0
167
- end
168
-
169
- it "#may_edit? should return false unless expense is not submitted" do
170
- expect(described_class.new(state: :draft).may_edit?).to be true
171
- expect(described_class.new(state: :submitted).may_edit?).to be false
172
- expect(described_class.new(state: :acceped).may_edit?).to be false
173
- expect(described_class.new(state: :refused).may_edit?).to be false
174
- expect(described_class.new(state: :canceled).may_edit?).to be false
175
- end
176
- end
@@ -1,54 +0,0 @@
1
- require "rails_helper"
2
-
3
- describe Dorsale::Flyboy::TaskComment do
4
- it { is_expected.to belong_to(:task) }
5
-
6
- it { is_expected.to validate_presence_of :task }
7
- it { is_expected.to validate_presence_of :date }
8
- it { is_expected.to validate_presence_of :description }
9
-
10
- it { is_expected.to belong_to :author }
11
- it { is_expected.to validate_presence_of :author }
12
-
13
- it "should have a valid factory" do
14
- expect(build(:flyboy_task_comment)).to be_valid
15
- end
16
-
17
- it "should update the task progress upon creation" do
18
- task = create(:flyboy_task, progress: 10)
19
- comment = create(:flyboy_task_comment, progress: 20, task: task)
20
- expect(task.reload.progress).to eq(20)
21
- end
22
-
23
- it "should mark task as complete when progress == 100" do
24
- task = create(:flyboy_task, progress: 10, done: false)
25
- comment = create(:flyboy_task_comment, progress: 100, task: task)
26
- expect(task.reload.done).to be true
27
- end
28
-
29
- it "should mark task as un complete when progress < 100" do
30
- task = create(:flyboy_task, progress: 100, done: true)
31
- comment = create(:flyboy_task_comment, progress: 90, task: task)
32
- expect(task.reload.done).to be false
33
- end
34
-
35
- describe "default values" do
36
- it "#new progress should be 0 if no task" do
37
- expect(Dorsale::Flyboy::TaskComment.new.progress).to eq 0
38
- end
39
-
40
- it "#new progress should be task progress if task specified" do
41
- task = create(:flyboy_task, progress: 50)
42
- expect(task.comments.new.progress).to eq 50
43
- end
44
-
45
- it "#new progress should not override exisring progress" do
46
- task = create(:flyboy_task)
47
- comment1 = create(:flyboy_task_comment, task: task, progress: 30)
48
- comment2 = create(:flyboy_task_comment, task: task, progress: 50)
49
- expect(task.reload.progress).to eq 50
50
- expect(comment1.reload.progress).to eq 30
51
- expect(comment2.reload.progress).to eq 50
52
- end
53
- end
54
- end