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,10 +0,0 @@
1
- When(/^I create a new task comment$/) do
2
- fill_in "task_comment_progress", with: "50"
3
- fill_in "task_comment_description", with: "I-am-the-task-comment-description"
4
- find("form[id*=task_comment] [type=submit]").click
5
- end
6
-
7
- Then(/^the task comment is created$/) do
8
- expect(@task.comments.count).to eq 1
9
- expect(page).to have_content "I-am-the-task-comment-description"
10
- end
@@ -1,196 +0,0 @@
1
- Given(/^an existing done task$/) do
2
- @done_task = create(:flyboy_task, done: true)
3
- end
4
-
5
- Given(/^an existing undone task$/) do
6
- @undone_task = create(:flyboy_task, done: false)
7
- end
8
-
9
- Given(/^an existing task named "(.*?)"$/) do |name|
10
- create(:flyboy_task, name: name)
11
- end
12
-
13
- Given(/^an existing task$/) do
14
- @task = create(:flyboy_task)
15
- end
16
-
17
- Given(/^an existing snoozable task$/) do
18
- @task = create(:flyboy_task, term: Date.current)
19
- end
20
-
21
- Given(/^(\d+) existing tasks$/) do |n|
22
- n.to_i.times do
23
- create(:flyboy_task)
24
- end
25
- end
26
-
27
- Given(/^a task with an owner that's the term is today$/) do
28
- @task = create(:flyboy_task,
29
- :term => Date.current,
30
- :reminder_type => "custom",
31
- :reminder_date => Date.yesterday,
32
- :owner => create(:user),
33
- )
34
- end
35
-
36
- Given(/^a task without owner$/) do
37
- @task = create(:flyboy_task,
38
- :term => Date.current,
39
- :reminder_type => "custom",
40
- :reminder_date => Date.yesterday,
41
- :owner => nil,
42
- )
43
- end
44
-
45
- Given(/^a closed task with an owner$/) do
46
- @task = create(:flyboy_task,
47
- :term => Date.current,
48
- :reminder_type => "custom",
49
- :reminder_date => Date.yesterday,
50
- :owner => create(:user),
51
- :progress => 100,
52
- :done => true,
53
- )
54
- end
55
-
56
- When(/^the flyboy daily crons run$/) do
57
- ActionMailer::Base.deliveries.clear
58
- Dorsale::Flyboy::TaskCrons.send_daily_term_emails!
59
- end
60
-
61
- When(/^I create a task$/) do
62
- find("a[href*='tasks/new']").click
63
- find("form[id*=task] [type=submit]").click # First submit to see errors
64
- fill_in "task_name", with: "I-am-the-task-title"
65
- fill_in "task_description", with: "I-am-the-task-description"
66
- select @user.name
67
- find("form[id*=task] [type=submit]").click
68
- end
69
-
70
- When(/^I go to the tasks section$/) do
71
- visit dorsale.flyboy_tasks_path
72
- end
73
-
74
- When(/^I consult this task$/) do
75
- click_link @task.name
76
- end
77
-
78
- When(/^I update this task$/) do
79
- visit dorsale.flyboy_task_path(@task)
80
- find("a[href$='tasks/#{@task.id}/edit']").click
81
- fill_in "task_name", with: "New-task-title"
82
- find("form[id*=task] [type=submit]").click
83
- end
84
-
85
- When(/^I complete this task$/) do
86
- find("a[href$=complete]").click
87
- end
88
-
89
- When(/^I snooze this task$/) do
90
- find("a[href*=snooze]").click
91
- end
92
-
93
- When(/^I filter tasks by done$/) do
94
- select "Terminée"
95
- find(".filters [type=submit]:last-child").click
96
- end
97
-
98
- When(/^I filter tasks by undone$/) do
99
- select "Non terminé"
100
- find(".filters [type=submit]:last-child").click
101
- end
102
-
103
- When(/^(?:I|he|she) reset filters$/) do
104
- find(".filters .reset").click
105
- end
106
-
107
- When(/^I delete this task$/) do
108
- visit dorsale.flyboy_task_path(@task)
109
- find("a[href$='tasks/#{@task.id}/edit']").click
110
- find(".context a[data-method=delete]").click
111
- end
112
-
113
- Then(/^I am on the created task$/) do
114
- @task = Dorsale::Flyboy::Task.last_created
115
- expect(current_path).to eq dorsale.flyboy_task_path(@task)
116
- end
117
-
118
- Then(/^the task is created$/) do
119
- expect(page).to have_content "I-am-the-task-title"
120
- end
121
-
122
- Then(/^I see this task$/) do
123
- expect(current_path).to eq dorsale.flyboy_task_path(@task)
124
- end
125
-
126
- Then(/^I am on the updated task$/) do
127
- expect(current_path).to eq dorsale.flyboy_task_path(@task)
128
- end
129
-
130
- Then(/^the task is updated$/) do
131
- expect(page).to have_content "New-task-title"
132
- end
133
-
134
- Then(/^I am on the tasks section$/) do
135
- expect(current_path).to eq dorsale.flyboy_tasks_path
136
- end
137
-
138
- Then(/^the task is deleted$/) do
139
- expect(page).to have_no_content @task.name
140
- end
141
-
142
- Then(/^the task is completed$/) do
143
- expect(page).to have_content "100%"
144
- end
145
-
146
- Then(/^the task is snoozed$/) do
147
- expect(page).to have_no_selector "a[href*=snooze]"
148
- end
149
-
150
- Then(/^I am on this task$/) do
151
- expect(current_path).to eq dorsale.flyboy_task_path(@task)
152
- end
153
-
154
- Then(/^only done tasks appear$/) do
155
- expect(page).to have_content @done_task.name
156
- expect(page).to have_no_content @undone_task.name
157
- end
158
-
159
- Then(/^only undone tasks appear$/) do
160
- expect(page).to have_no_content @done_task.name
161
- expect(page).to have_content @undone_task.name
162
- end
163
-
164
- Then(/^all tasks appear$/) do
165
- expect(page).to have_content @done_task.name
166
- expect(page).to have_content @undone_task.name
167
- end
168
-
169
- Then(/^only the "Hello" task appear$/) do
170
- expect(page).to have_content "Hello"
171
- expect(page).to have_no_content "World"
172
- end
173
-
174
- Then(/^tasks are paginated$/) do
175
- expect(all("tr.task").count).to eq 50
176
- expect(page).to have_selector ".pagination"
177
- end
178
-
179
- Then(/^no email is sent$/) do
180
- expect(ActionMailer::Base.deliveries.count).to eq 0
181
- end
182
-
183
- Then(/^the owner receive an email$/) do
184
- expect(ActionMailer::Base.deliveries.count).to eq 1
185
- email = ActionMailer::Base.deliveries.last
186
- expect(email.to).to include @task.owner.email
187
- end
188
-
189
- When(/^I go on the new task page$/) do
190
- visit dorsale.new_flyboy_task_path
191
- end
192
-
193
- Then(/^selected task term is "([^"]*)"$/) do |expected_value|
194
- value = find("#task_term option[selected]").text
195
- expect(value).to eq expected_value
196
- end
@@ -1,30 +0,0 @@
1
- Given(/^an expired tasks$/) do
2
- @task = create(:flyboy_task, owner: @user, term: Date.current-1)
3
- end
4
-
5
- Given(/^a task that expire tommorow$/) do
6
- @task = create(:flyboy_task, owner: @user, term: Date.current+1)
7
- end
8
-
9
- Given(/^a task that expire today$/) do
10
- @task = create(:flyboy_task, owner: @user, term: Date.current)
11
- end
12
-
13
- When(/^he go to the tasks summary page$/) do
14
- visit dorsale.summary_flyboy_tasks_path
15
- end
16
-
17
- Then(/^the task is classed as 'expired'$/) do
18
- expect(page).to have_content("En retard")
19
- expect(page).to have_content(@task.name)
20
- end
21
-
22
- Then(/^the task is classed as 'Expire Today'$/) do
23
- expect(page).to have_content("Aujourd'hui")
24
- expect(page).to have_content(@task.name)
25
- end
26
-
27
- Then(/^the task is classed as 'Expire tommorow'$/) do
28
- expect(page).to have_content("Demain")
29
- expect(page).to have_content(@task.name)
30
- end
@@ -1,29 +0,0 @@
1
- When(/^he goes to the users section$/) do
2
- visit dorsale.users_path
3
- end
4
-
5
- When(/^he creates a new user$/) do
6
- find("[href$='users/new']").click
7
- fill_in "user_email", with: "toto@toto.fr"
8
- find("[type=submit]").click
9
- end
10
-
11
- Then(/^the user is visible in the user list$/) do
12
- expect(page).to have_content I18n.t("messages.users.create_ok")
13
- expect(page).to have_content "toto@toto.fr"
14
- end
15
-
16
- When(/^he click on update user button$/) do
17
- expect(page).to have_content @user.email
18
- find("#main [href$=edit]").click
19
- end
20
-
21
- When(/^he update the user$/) do
22
- fill_in "user_email", with: "toto@toto.fr"
23
- find("[type=submit]").click
24
- end
25
-
26
- Then(/^the user's new informations are visible in the users list$/) do
27
- expect(page).to have_content I18n.t("messages.users.update_ok")
28
- expect(page).to have_content "toto@toto.fr"
29
- end
@@ -1,8 +0,0 @@
1
- ENV["RAILS_ROOT"] ||= File.expand_path("../../spec/dummy", __dir__)
2
- require "cucumber/rails"
3
- require "agilibox/cucumber_config"
4
- def Zonebie.set_random_timezone
5
- # https://github.com/agilidee/dorsale/issues/273
6
- end
7
- Agilibox::CucumberConfig.require_all_helpers!
8
- Agilibox::CucumberConfig.require_cuprite!
@@ -1,18 +0,0 @@
1
- @javascript
2
- Feature: Manage users
3
- As an user
4
- I can manage users
5
- In order to provide them an access
6
-
7
- Background:
8
- Given an authenticated user
9
- When he goes to the users section
10
-
11
- Scenario: Create a User
12
- And he creates a new user
13
- Then the user is visible in the user list
14
-
15
- Scenario: Update a User
16
- And he click on update user button
17
- And he update the user
18
- Then the user's new informations are visible in the users list
@@ -1,145 +0,0 @@
1
- require "rails_helper"
2
-
3
- describe Dorsale::Alexandrie::AttachmentsController, type: :controller do
4
- routes { Dorsale::Engine.routes }
5
-
6
- let(:uploaded_file) {
7
- path = Rails.root.join("..", "..", "spec", "files", "pdf.pdf").to_s
8
- Rack::Test::UploadedFile.new(path, "application/pdf")
9
- }
10
-
11
- let(:valid_attributes) {
12
- attachable = DummyModel.create!(name: "A")
13
-
14
- {
15
- :attachable_id => attachable.id,
16
- :attachable_type => attachable.class.to_s,
17
- :file => uploaded_file,
18
- }
19
- }
20
-
21
- let(:user) { create(:user) }
22
-
23
- before(:each) { sign_in(user) }
24
-
25
- let(:attachment) { create(:alexandrie_attachment) }
26
-
27
- describe "sorting" do
28
- let!(:attachable) { create(:billing_machine_quotation) }
29
-
30
- let!(:attachment1) {
31
- create(:alexandrie_attachment,
32
- :attachable => attachable,
33
- :name => "AAA",
34
- :created_at => "2010-01-01",
35
- :updated_at => "2010-01-01",
36
- :attachment_type => create(:alexandrie_attachment_type, name: "AAA"),
37
- )
38
- }
39
-
40
- let!(:attachment2) {
41
- create(:alexandrie_attachment,
42
- :attachable => attachable,
43
- :name => "ZZZ",
44
- :created_at => "2020-01-01",
45
- :updated_at => "2020-01-01",
46
- :attachment_type => create(:alexandrie_attachment_type, name: "ZZZ"),
47
- )
48
- }
49
-
50
- before do
51
- allow_any_instance_of(described_class).to \
52
- receive(:find_attachable_from_params).and_return(attachable)
53
- end
54
-
55
- it "should sort by name" do
56
- get :index, params: {sort: "name"}
57
- expect(assigns :attachments).to eq [attachment1, attachment2]
58
- end
59
-
60
- it "should sort by -name" do
61
- get :index, params: {sort: "-name"}
62
- expect(assigns :attachments).to eq [attachment2, attachment1]
63
- end
64
-
65
- it "should sort by created_at" do
66
- get :index, params: {sort: "created_at"}
67
- expect(assigns :attachments).to eq [attachment1, attachment2]
68
- end
69
-
70
- it "should sort by -created_at" do
71
- get :index, params: {sort: "-created_at"}
72
- expect(assigns :attachments).to eq [attachment2, attachment1]
73
- end
74
-
75
- it "should sort by updated_at" do
76
- get :index, params: {sort: "updated_at"}
77
- expect(assigns :attachments).to eq [attachment1, attachment2]
78
- end
79
-
80
- it "should sort by -updated_at" do
81
- get :index, params: {sort: "-updated_at"}
82
- expect(assigns :attachments).to eq [attachment2, attachment1]
83
- end
84
-
85
- it "should sort by attachment_type_name" do
86
- get :index, params: {sort: "attachment_type_name"}
87
- expect(assigns :attachments).to eq [attachment1, attachment2]
88
- end
89
-
90
- it "should sort by -attachment_type_name" do
91
- get :index, params: {sort: "-attachment_type_name"}
92
- expect(assigns :attachments).to eq [attachment2, attachment1]
93
- end
94
- end # describe "sorting"
95
-
96
- describe "create" do
97
- it "should create attachment" do
98
- post :create, params: {attachment: valid_attributes}
99
- expect(assigns(:attachment)).to be_persisted
100
- end
101
-
102
- it "should render list" do
103
- post :create, params: {attachment: valid_attributes}
104
- expect(response).to be_ok
105
- expect(response).to render_template :index
106
- end
107
- end
108
-
109
- describe "edit" do
110
- it "should render list" do
111
- get :edit, params: {id: attachment}
112
- expect(response).to be_ok
113
- expect(response).to render_template :index
114
- end
115
- end
116
-
117
- describe "update" do
118
- it "should update attachment" do
119
- patch :update, params: {id: attachment, attachment: {name: "new_name"}}
120
- expect(attachment.reload.name).to eq "new_name"
121
- end
122
-
123
- it "should render list" do
124
- patch :update, params: {id: attachment}
125
- expect(response).to be_ok
126
- expect(response).to render_template :index
127
- end
128
- end
129
-
130
- describe "destroy" do
131
- let!(:attachment) { create(:alexandrie_attachment) }
132
-
133
- it "should delete attachment" do
134
- expect {
135
- delete :destroy, params: {id: attachment}
136
- }.to change(::Dorsale::Alexandrie::Attachment, :count).by(-1)
137
- end
138
-
139
- it "should render list" do
140
- delete :destroy, params: {id: attachment}
141
- expect(response).to be_ok
142
- expect(response).to render_template :index
143
- end
144
- end
145
- end
@@ -1,153 +0,0 @@
1
- require "rails_helper"
2
-
3
- describe Dorsale::BillingMachine::InvoicesController, type: :controller do
4
- routes { Dorsale::Engine.routes }
5
-
6
- let(:user) { create(:user) }
7
- before(:each) { sign_in(user) }
8
-
9
- describe "#preview" do
10
- render_views
11
-
12
- it "should render show" do
13
- post :preview
14
- expect(response).to render_template(:show)
15
- end
16
-
17
- it "should not save" do
18
- post :preview
19
- @invoice = assigns(:invoice)
20
- expect(@invoice).to be_valid
21
- expect(@invoice).to_not be_persisted
22
- end
23
- end # describe "#preview" do
24
-
25
- describe "XLSX export" do
26
- render_views
27
-
28
- it "should be ok" do
29
- 3.times { create(:billing_machine_invoice_line) }
30
- get :index, params: {format: :xlsx}
31
- expect(response).to be_ok
32
- end
33
- end # describe "XLSX export"
34
-
35
- describe "PDF export" do
36
- render_views
37
-
38
- it "should be ok" do
39
- 3.times {
40
- invoice = create(:billing_machine_invoice)
41
- Dorsale::BillingMachine::PdfFileGenerator.(invoice)
42
- }
43
- get :index, params: {format: :pdf}
44
- expect(response).to be_ok
45
- end
46
- end # describe "PDF export"
47
-
48
- describe "filters" do
49
- describe "filter by date" do
50
- before do
51
- Timecop.freeze "2016-11-08 12:00:00"
52
- @today = create(:billing_machine_invoice, date: "2016-11-08")
53
- @yesterday = create(:billing_machine_invoice, date: "2016-11-07")
54
- @tomorrow = create(:billing_machine_invoice, date: "2016-11-09")
55
- @last_week = create(:billing_machine_invoice, date: "2016-11-04")
56
- @last_month = create(:billing_machine_invoice, date: "2016-10-18")
57
- @last_year = create(:billing_machine_invoice, date: "2015-10-18")
58
- end
59
-
60
- def filter(period)
61
- cookies[:filters] = {"bm_time_period" => period.to_s}.to_json
62
- get :index
63
- end
64
-
65
- it "should filter by all_time" do
66
- filter :all_time
67
- expect(assigns :invoices).to contain_exactly(
68
- @today,
69
- @yesterday,
70
- @tomorrow,
71
- @last_week,
72
- @last_month,
73
- @last_year,
74
- )
75
- end
76
-
77
- it "should filter by today" do
78
- filter :today
79
- expect(assigns :invoices).to contain_exactly(@today)
80
- end
81
-
82
- it "should filter by yesterday" do
83
- filter :yesterday
84
- expect(assigns :invoices).to contain_exactly(@yesterday)
85
- end
86
-
87
- it "should filter by this_week" do
88
- filter :this_week
89
- expect(assigns :invoices).to contain_exactly(@today, @yesterday, @tomorrow)
90
- end
91
-
92
- it "should filter by this_month" do
93
- filter :this_month
94
- expect(assigns :invoices).to contain_exactly(@today, @yesterday, @tomorrow, @last_week)
95
- end
96
-
97
- it "should filter by this_year" do
98
- filter :this_year
99
- expect(assigns :invoices).to \
100
- contain_exactly(@today, @yesterday, @tomorrow, @last_week, @last_month)
101
- end
102
-
103
- it "should filter by last_week" do
104
- filter :last_week
105
- expect(assigns :invoices).to contain_exactly(@last_week)
106
- end
107
-
108
- it "should filter by last_month" do
109
- filter :last_month
110
- expect(assigns :invoices).to contain_exactly(@last_month)
111
- end
112
-
113
- it "should filter by last_year" do
114
- filter :last_year
115
- expect(assigns :invoices).to contain_exactly(@last_year)
116
- end
117
- end # describe "filter by date"
118
-
119
- describe "filter by payment status" do
120
- before do
121
- Timecop.freeze "2016-11-08 12:00:00"
122
- @paid = create(:billing_machine_invoice, paid: true, due_date: "2016-01-08")
123
- @pending = create(:billing_machine_invoice, paid: false, due_date: "2016-11-10")
124
- @late = create(:billing_machine_invoice, paid: false, due_date: "2016-06-05")
125
- end
126
-
127
- def filter(value)
128
- cookies[:filters] = {"bm_payment_status" => value.to_s}.to_json
129
- get :index
130
- end
131
-
132
- it "should filter by paid" do
133
- filter :paid
134
- expect(assigns :invoices).to contain_exactly(@paid)
135
- end
136
-
137
- it "should filter by unpaid" do
138
- filter :unpaid
139
- expect(assigns :invoices).to contain_exactly(@pending, @late)
140
- end
141
-
142
- it "should filter by pending" do
143
- filter :pending
144
- expect(assigns :invoices).to contain_exactly(@pending)
145
- end
146
-
147
- it "should filter by late" do
148
- filter :late
149
- expect(assigns :invoices).to contain_exactly(@late)
150
- end
151
- end # describe "filter by payment status"
152
- end # describe "filters"
153
- end