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,10 @@
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
@@ -0,0 +1,196 @@
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
@@ -0,0 +1,30 @@
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
@@ -0,0 +1,29 @@
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
@@ -0,0 +1,8 @@
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!
@@ -0,0 +1,18 @@
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,3 +1,3 @@
1
1
  module Dorsale
2
- VERSION = "3.14.4"
2
+ VERSION = "3.14.5"
3
3
  end
@@ -0,0 +1,145 @@
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