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,19 @@
1
+ Given(/^billing machine in multiple vat mode$/) do
2
+ ::Dorsale::BillingMachine.vat_mode = :multiple
3
+ end
4
+
5
+ When(/^he fills the reference, the date and the payment terms$/) do
6
+ fill_in "invoice_label", with: @label = "My reference"
7
+ fill_in "invoice_date", with: @date = "01/01/2014"
8
+ select @payment_term.label
9
+ end
10
+
11
+ When(/^he fills a multiple vat line with "(.*?)", "(.*?)", "(.*?)", "(.*?)", "(.*?)"$/) do |label, quantity, unit, vat_rate, unit_price|
12
+ within all(".line").last do
13
+ find(".line-label textarea").set label
14
+ find(".line-quantity input").set quantity
15
+ find(".line-unit input").set unit
16
+ find(".line-vat_rate input").set vat_rate
17
+ find(".line-unit_price input").set unit_price
18
+ end
19
+ end
@@ -0,0 +1,42 @@
1
+ Given(/^the user goes on the new payment_term page$/) do
2
+ visit dorsale.billing_machine_payment_terms_path
3
+ find(".link_create").click
4
+ end
5
+
6
+ When(/^he fills the payment_term's information$/) do
7
+ fill_in "billing_machine_payment_term_label", with: "Payment Term Label"
8
+ end
9
+
10
+ When(/^creates a new payment_term$/) do
11
+ find("[type=submit]").click
12
+ end
13
+
14
+ Then(/^he is redirected on the payment_terms page$/) do
15
+ expect(current_path).to eq dorsale.billing_machine_payment_terms_path
16
+ end
17
+
18
+ Then(/^the payment_term is added to the payment_term list$/) do
19
+ expect(page).to have_content "Payment Term Label"
20
+ end
21
+
22
+ Given(/^an existing payment_term$/) do
23
+ @payment_term = create(:billing_machine_payment_term)
24
+ end
25
+
26
+ When(/^the user edits the payment_term$/) do
27
+ visit dorsale.billing_machine_payment_terms_path
28
+ find(".link_update").click
29
+ end
30
+
31
+ Then(/^the current payment_term's label should be pre\-filled$/) do
32
+ expect(page).to have_field("billing_machine_payment_term_label", with: @payment_term.label)
33
+ end
34
+
35
+ When(/^he validates the new payment_term$/) do
36
+ fill_in "billing_machine_payment_term_label", with: "New Payment Term Label"
37
+ find("[type=submit]").click
38
+ end
39
+
40
+ Then(/^the payment_term's label is updated$/) do
41
+ expect(page).to have_content "New Payment Term Label"
42
+ end
@@ -0,0 +1,248 @@
1
+ Given(/^an existing quotation$/) do
2
+ @quotation = create(:billing_machine_quotation, customer: @customer)
3
+ @quotation.lines.create!(quantity: 1, unit_price: 9.99)
4
+ end
5
+
6
+ Given(/^(\d+) existing quotations$/) do |nb|
7
+ create_list(:billing_machine_quotation, nb.to_i)
8
+ end
9
+
10
+ Given(/^an existing emtpy quotation$/) do
11
+ @quotation = create(:billing_machine_quotation, label: nil, customer: nil)
12
+ end
13
+
14
+ Given(/^an existing quotation with a "(.*?)"% VAT rate$/) do |rate|
15
+ @quotation = create(:billing_machine_quotation)
16
+ create(:billing_machine_quotation_line, vat_rate: rate, quotation: @quotation)
17
+ end
18
+
19
+ Given(/^(\d+) associated documents to this quotation$/) do |n|
20
+ n.to_i.times do |i|
21
+ instance_variable_set "@document#{i}", create(:alexandrie_attachment, attachable: @quotation)
22
+ end
23
+ end
24
+
25
+ Given(/^a bunch of existing quotations$/) do
26
+ c1 = create(:customer_vault_corporation, name: "Bidule")
27
+ c2 = create(:customer_vault_corporation, name: "Machin")
28
+ c3 = create(:customer_vault_corporation, name: "Chose")
29
+
30
+ i1 = create(:customer_vault_individual, first_name: "Oh")
31
+ i2 = create(:customer_vault_individual, first_name: "Ah")
32
+ i3 = create(:customer_vault_individual, first_name: "Eh")
33
+
34
+ create(:billing_machine_quotation, customer: c1, date: Date.current)
35
+ create(:billing_machine_quotation, customer: c2, date: Date.current)
36
+ create(:billing_machine_quotation, customer: c3, date: Date.current)
37
+ create(:billing_machine_quotation, customer: c1, date: Date.current - 2.days)
38
+ create(:billing_machine_quotation, customer: i1, date: Date.current - 3.days)
39
+ create(:billing_machine_quotation, customer: i2, date: Date.current - 3.days)
40
+ create(:billing_machine_quotation, customer: i3, date: Date.current - 3.days)
41
+ end
42
+
43
+ Given(/^existing "(.*?)" quotations with "(.*?)" amount$/) do |n, amount|
44
+ n.to_i.times do
45
+ create(:billing_machine_quotation_line, quantity: 1, unit_price: amount)
46
+ end
47
+ end
48
+
49
+ When(/^he changes the quotation VAT rate to "(.*?)"$/) do |arg1|
50
+ fill_in "quotation_vat_rate", with: arg1
51
+ end
52
+
53
+ When(/^the user goes to the quotations page$/) do
54
+ visit dorsale.billing_machine_quotations_path
55
+ end
56
+
57
+ When(/^the quotation line shows the right date$/) do
58
+ expect(page).to have_selector ".date", text: I18n.l(@quotation.date)
59
+ end
60
+
61
+ When(/^the quotation line shows the right traking\-id$/) do
62
+ expect(page).to have_selector ".tracking_id", text: @quotation.tracking_id
63
+ end
64
+
65
+ When(/^the quotation line shows the right customer's name$/) do
66
+ expect(page).to have_selector ".customer_name", text: @customer.name
67
+ end
68
+
69
+ When(/^the quotation line shows the right total excluding taxes value$/) do
70
+ expect(page).to have_selector ".total_excluding_taxes", text: "9,99 €"
71
+ end
72
+
73
+ When(/^the quotation line shows the right total including taxes value$/) do
74
+ expect(page).to have_selector ".total_including_taxes", text: "11,99 €"
75
+ end
76
+
77
+ When(/^the user goes to the quotation details$/) do
78
+ visit dorsale.billing_machine_quotation_path(@quotation)
79
+ end
80
+
81
+ When(/^he creates a new quotation$/) do
82
+ find(".link_create").click
83
+ end
84
+
85
+ When(/^he fills the reference and the date$/) do
86
+ fill_in "quotation_label", with: @label = "My reference"
87
+ fill_in "quotation_date", with: @date = "01/01/2014"
88
+ select @payment_term.label
89
+ fill_in "quotation_comments", with: "I-am-a-comment"
90
+ end
91
+
92
+ When(/^he saves the quotation$/) do
93
+ find("[type=submit]").click
94
+ end
95
+
96
+ When(/^he goes on the edit page of the quotation$/) do
97
+ visit dorsale.edit_billing_machine_quotation_path(@quotation)
98
+ end
99
+
100
+ When(/^changes the quotation label$/) do
101
+ @new_label= @quotation.label + " Edited"
102
+ fill_in "quotation_label", with: @new_label
103
+ end
104
+
105
+ When(/^he copy the quotation$/) do
106
+ @quotations_count = Dorsale::BillingMachine::Quotation.count
107
+ find("[href$=copy]").click
108
+ end
109
+
110
+ When(/^he create an invoice from the quotation$/) do
111
+ @invoices_count = Dorsale::BillingMachine::Invoice.count
112
+ find("[href$='create_invoice']").click
113
+ find("form#new_invoice [type=submit]").click
114
+ end
115
+
116
+ When(/^he fill the quotation expiry$/) do
117
+ fill_in :quotation_expires_at, with: "21/12/2012"
118
+ end
119
+
120
+ Then(/^the document is not in the quotation details$/) do
121
+ visit dorsale.billing_machine_quotation_path(@quotation)
122
+ expect(page).to have_link "pdf.pdf", count: 1
123
+ end
124
+
125
+ Then(/^a message signals the success of the quotation update$/) do
126
+ expect(page).to have_selector ".alert-success"
127
+ end
128
+
129
+ Then(/^he fill the quotation commercial discount with "(.*?)"$/) do |arg1|
130
+ fill_in "quotation_commercial_discount", with: arg1
131
+ end
132
+
133
+ Then(/^the quotation's label has changed$/) do
134
+ visit dorsale.edit_billing_machine_quotation_path(@quotation)
135
+ expect(page).to have_field("quotation_label", with: @new_label)
136
+ end
137
+
138
+ Then(/^I am on the created quotation$/) do
139
+ @quotation = Dorsale::BillingMachine::Quotation.last_created
140
+ expect(current_path).to eq dorsale.billing_machine_quotation_path(@quotation)
141
+ end
142
+
143
+ Then(/^he can see all the quotation informations$/) do
144
+ expect(page).to have_selector ".quotation-label", text: @quotation.label
145
+ end
146
+
147
+ Then(/^the quotation default date is set to today's date\.$/) do
148
+ expect(page).to have_field("quotation_date", with: I18n.l(Date.current))
149
+ end
150
+
151
+ Then(/^he should see (\d+) quotations?$/) do |arg1|
152
+ expect(page).to have_selector ".quotation", count: arg1
153
+ end
154
+
155
+ Then(/^the quotation is displayed correctly$/) do
156
+ expect(page).to have_selector ".tracking_id", text: @quotation.tracking_id
157
+ end
158
+
159
+ Then(/^a message signals the success of the quotation creation$/) do
160
+ expect(page).to have_selector ".alert-success"
161
+ end
162
+
163
+ Then(/^he will see links to the documents$/) do
164
+ expect(page).to have_link "pdf.pdf", count: 2
165
+ end
166
+
167
+ Then(/^the quotation informations are visible on the quotation details$/) do
168
+ @quotation = ::Dorsale::BillingMachine::Quotation.last_created
169
+ visit dorsale.billing_machine_quotation_path(@quotation)
170
+ expect(page).to have_content @payment_term.label
171
+ expect(page).to have_content "I-am-a-comment"
172
+ end
173
+
174
+ Then(/^only the quotations of this customer do appear$/) do
175
+ expect(page).to have_selector(".customer_name", text: "Bidule", count: 2)
176
+ end
177
+
178
+ Then(/^only the quotations of today do appear$/) do
179
+ expect(page).to have_selector(".quotation", count: 3)
180
+ end
181
+
182
+ Then(/^he is on the created quotation edit page$/) do
183
+ expect(Dorsale::BillingMachine::Quotation.count).to eq(@quotations_count+1)
184
+ @quotation = Dorsale::BillingMachine::Quotation.last_created
185
+ expect(current_path).to eq dorsale.edit_billing_machine_quotation_path(@quotation)
186
+ end
187
+
188
+ Then(/^an invoice is created from quotation$/) do
189
+ expect(Dorsale::BillingMachine::Invoice.count).to eq(@invoices_count+1)
190
+ @invoice = Dorsale::BillingMachine::Invoice.last_created
191
+ expect(@invoice.label).to eq @quotation.label
192
+ end
193
+
194
+ Then(/^the document is in the quotation details$/) do
195
+ expect(page).to have_content "pdf.pdf"
196
+ end
197
+
198
+ When(/^he filters by "(.*?)" state$/) do |state|
199
+ select find("option[value=#{state}]").text
200
+ find(".filter-submit").click
201
+ end
202
+
203
+ Then(/^only the "(.*?)" quotations appear$/) do |state|
204
+ state_i18n = find("option[value=#{state}]").text
205
+
206
+ expect(page).to have_selector("tr.quotation", count: 1)
207
+ expect(find("tr.quotation")).to have_content(state_i18n)
208
+ end
209
+
210
+ When(/^he send quotation to customer by email$/) do
211
+ ActionMailer::Base.deliveries.clear
212
+
213
+ Dorsale::BillingMachine::PdfFileGenerator.(@quotation)
214
+ @quotation.customer = create(:customer_vault_corporation, email: "aaa@example.org")
215
+ @quotation.save!
216
+
217
+ find("[href$=email]").click
218
+ fill_in :email_subject, with: "abc"
219
+ fill_in :email_body, with: "def"
220
+ find("[type=submit]").click
221
+ end
222
+
223
+ Then(/^an quotation is sent to customer$/) do
224
+ expect(ActionMailer::Base.deliveries.count).to eq 1
225
+ email = ActionMailer::Base.deliveries.first
226
+
227
+ expect(email.to).to include "aaa@example.org"
228
+ expect(email.subject).to eq "abc"
229
+ expect(email.parts.first.body).to eq "def"
230
+ expect(email.attachments.count).to eq 1
231
+ end
232
+
233
+ When(/^he click on the preview quotation button$/) do
234
+ @invoices_count = Dorsale::BillingMachine::Quotation.count
235
+ controller = Dorsale::BillingMachine::QuotationsController
236
+ expect_any_instance_of(controller).to receive(:preview).and_call_original
237
+ expect_any_instance_of(controller).to_not receive(:create)
238
+ expect_any_instance_of(controller).to_not receive(:update)
239
+ find("#preview-button").click
240
+ end
241
+
242
+ Then(/^he see the quotation preview$/) do
243
+ expect(windows.count).to eq 2
244
+ end
245
+
246
+ Then(/^no quotation is created$/) do
247
+ expect(Dorsale::BillingMachine::Quotation.count).to eq @invoices_count
248
+ end
@@ -0,0 +1,91 @@
1
+ When(/^I search "(.*?)"$/) do |q|
2
+ fill_in "q", with: q
3
+ find(".search-submit").click
4
+ end
5
+
6
+ When(/^an existing customer$/) do
7
+ @customer = create(:customer_vault_corporation)
8
+ end
9
+
10
+ When(/^he goes on the next page$/) do
11
+ find(".next").click
12
+ expect(page).to have_selector ".page.active a[href$='2']"
13
+ end
14
+
15
+ Given(/^an existing payment term$/) do
16
+ @payment_term = create(:billing_machine_payment_term)
17
+ end
18
+
19
+ Given(/^an authenticated user$/) do
20
+ @user = create(:user)
21
+ sign_in @user
22
+ end
23
+
24
+ Given(/^an active user$/) do
25
+ @user = create(:user)
26
+ end
27
+
28
+ Given(/^an inactive user$/) do
29
+ @user = create(:user, is_active: false)
30
+ end
31
+
32
+ Given(/^an existing "(.*?)" having "(.*?)" set to "(.*?)"$/) do |factory, key, value|
33
+ create(factory, key => value)
34
+ end
35
+
36
+ Then(/^the selected filter is "(.*?)"$/) do |value|
37
+ selected_values = all(".filters select").map(&:value)
38
+ expect(selected_values).to include value
39
+ end
40
+
41
+ Then(/^he do not see the "([^"]*)" filter$/) do |id|
42
+ expect(page).to have_no_selector("#filters_#{id}")
43
+ end
44
+
45
+ When(/^he select custom date filter$/) do
46
+ select "Choisir une date"
47
+ end
48
+
49
+ Then(/^he see the "([^"]*)" filter$/) do |id|
50
+ expect(page).to have_selector("#filters_#{id}")
51
+ end
52
+
53
+ When(/^(?:I|he|she) export to XLSX$/) do
54
+ find("a[href$=xlsx]").click
55
+ end
56
+
57
+ When(/^(?:I|he|she) download XLSX file$/) do
58
+ end
59
+
60
+ When(/^I click on show more$/) do
61
+ find("a[class*=show_more]").click
62
+ end
63
+
64
+ When(/^I select "([^"]*)"$/) do |value|
65
+ select value
66
+ end
67
+
68
+ When(/^I submit$/) do
69
+ find("#main [type=submit]").click
70
+ end
71
+
72
+ When(/^I fill "([^"]*)" with "([^"]*)"$/) do |field, value|
73
+ fill_in field, with: value
74
+ end
75
+
76
+ Then(/^"([^"]*)" has value "([^"]*)"$/) do |field, expected_value|
77
+ value = find_field(field).value
78
+ expect(value).to eq expected_value
79
+ end
80
+
81
+ Then(/^I do not see "([^"]*)" element$/) do |element_selector|
82
+ expect(page).to have_no_selector element_selector
83
+ end
84
+
85
+ Then(/^I see "([^"]*)" element$/) do |element_selector|
86
+ expect(page).to have_selector element_selector
87
+ end
88
+
89
+ When("I click on {string}") do |text|
90
+ click_on text
91
+ end
@@ -0,0 +1,42 @@
1
+ Given(/^the user goes on the new activity type page$/) do
2
+ visit dorsale.customer_vault_activity_types_path
3
+ find(".link_create").click
4
+ end
5
+
6
+ When(/^he fills the activity type's information$/) do
7
+ fill_in "activity_type_name", with: "Activity Name"
8
+ end
9
+
10
+ When(/^creates a new activity type$/) do
11
+ find("[type=submit]").click
12
+ end
13
+
14
+ Then(/^he is redirected on the activity types page$/) do
15
+ expect(current_path).to eq dorsale.customer_vault_activity_types_path
16
+ end
17
+
18
+ Then(/^the activity type is added to the activity types list$/) do
19
+ expect(page).to have_content "Activity Name"
20
+ end
21
+
22
+ Given(/^an existing activity type$/) do
23
+ @activity_type = create(:customer_vault_activity_type)
24
+ end
25
+
26
+ When(/^I edit the activity type$/) do
27
+ visit dorsale.customer_vault_activity_types_path
28
+ find(".link_update").click
29
+ end
30
+
31
+ Then(/^the current activity type's name should be pre\-filled$/) do
32
+ expect(page).to have_field("activity_type_name", with: @activity_type.name)
33
+ end
34
+
35
+ When(/^he validates the new activity type$/) do
36
+ fill_in "activity_type_name", with: "New Activity Name"
37
+ find("[type=submit]").click
38
+ end
39
+
40
+ Then(/^the activity type's label is updated$/) do
41
+ expect(page).to have_content "New Activity Name"
42
+ end
@@ -0,0 +1,218 @@
1
+ Given(/^(\d+) existing corporations$/) do |count|
2
+ create_list(:customer_vault_corporation, Integer(count))
3
+ end
4
+
5
+ When(/^I create an new corporation$/) do
6
+ @corporations_count = Dorsale::CustomerVault::Corporation.count
7
+
8
+ visit dorsale.new_customer_vault_corporation_path
9
+ end
10
+
11
+ When(/^I add the corporation's informations$/) do
12
+ fill_in "person_corporation_name", with: "AGILiDEE"
13
+ fill_in "person_email", with: "contact@agilidee.com"
14
+ fill_in "person_www", with: "www.agilidee.com"
15
+ fill_in "person_phone", with: "04 91 00 00 00"
16
+ fill_in "person_fax", with: "09 00 00 00 00"
17
+ end
18
+
19
+ When(/^I fill the corporation capital, immatriculation, legal form$/) do
20
+ fill_in "person_capital", with: "1000"
21
+ fill_in "person_immatriculation_number", with: "RCS 201523658"
22
+ fill_in "person_legal_form", with: "SARL"
23
+ fill_in "person_number_of_employees", with: "45"
24
+ fill_in "person_revenue", with: "450000"
25
+ fill_in "person_context", with: "Le joli contexte"
26
+ fill_in "person_societe_com", with: "societe_com"
27
+ end
28
+
29
+ When(/^I fill the corporation's address$/) do
30
+ fill_in "person_address_attributes_street", with: "3 Rue Marx Dormoy"
31
+ fill_in "person_address_attributes_street_bis", with: ""
32
+ fill_in "person_address_attributes_city", with: "Marseille"
33
+ fill_in "person_address_attributes_zip", with: "13004"
34
+ fill_in "person_address_attributes_country", with: "France"
35
+ end
36
+
37
+ When(/^I validate the new corporation$/) do
38
+ find("[type=submit]").click
39
+ end
40
+
41
+ When(/^I go on the corporate index$/) do
42
+ visit dorsale.customer_vault_people_path
43
+ end
44
+
45
+ Then(/^i see an error message for the missing name$/) do
46
+ expect(page).to have_selector ".person_corporation_name.has-error"
47
+ end
48
+
49
+ Then(/^he can see (\d+) corporate$/) do |count|
50
+ expect(page).to have_selector ".person", count: count
51
+ end
52
+
53
+ Then(/^the corporation is created$/) do
54
+ expect(Dorsale::CustomerVault::Corporation.count).to eq(@corporations_count + 1)
55
+ @corporation = Dorsale::CustomerVault::Corporation.last_created
56
+
57
+ expect(@corporation.corporation_name).to eq "AGILiDEE"
58
+ end
59
+
60
+ When(/^I go on this corporation$/) do
61
+ visit dorsale.customer_vault_corporation_path(@corporation)
62
+ end
63
+
64
+ When(/^I add a comment on the person$/) do
65
+ @events_count = Dorsale::CustomerVault::Event.count
66
+ fill_in "event_text", with: "MyNewComment"
67
+ find("[type=submit]").click
68
+ end
69
+
70
+ Then(/^I see my new comment on the person$/) do
71
+ expect(Dorsale::CustomerVault::Event.count).to eq(@events_count + 1)
72
+
73
+ expect(find("p.comment-text")).to have_content "MyNewComment"
74
+ end
75
+
76
+ Given(/^an existing comment on this corporation$/) do
77
+ @event = create(:customer_vault_event_comment, person: @corporation)
78
+ end
79
+
80
+ When(/^I update the comment on the person$/) do
81
+ find(".comment [href*=edit]").click
82
+ within "form[id*=edit]" do
83
+ fill_in :event_text, with: "MyUpdatedComment"
84
+ find("[type=submit]").click
85
+ end
86
+ end
87
+
88
+ Then(/^I see my updated comment on the person$/) do
89
+ expect(find("p.comment-text")).to have_content "MyUpdatedComment"
90
+ end
91
+
92
+ When(/^I delete the comment on the person$/) do
93
+ @events_count = Dorsale::CustomerVault::Event.count
94
+ find(".comment [data-method*=delete]").click
95
+ end
96
+
97
+ Then(/^I see do not see my comment on the person$/) do
98
+ expect(Dorsale::CustomerVault::Event.count).to eq(@events_count - 1)
99
+ expect(page).to have_no_content @event.text
100
+ end
101
+
102
+ Given(/^an existing individual with recent comments$/) do
103
+ @individual = create(:customer_vault_individual)
104
+ create(:customer_vault_event_comment, person: @individual, text: "individual-comment-1")
105
+ create(:customer_vault_event_comment, person: @individual, text: "individual-comment-2")
106
+ end
107
+
108
+ Given(/^an existing corporation with recent comments$/) do
109
+ @corporation = create(:customer_vault_corporation)
110
+ create(:customer_vault_event_comment, person: @corporation, text: "corporation-comment-1")
111
+ create(:customer_vault_event_comment, person: @corporation, text: "corporation-comment-2")
112
+ end
113
+
114
+ When(/^I go on the people activity$/) do
115
+ visit dorsale.customer_vault_events_path
116
+ end
117
+
118
+ Then(/^I see all these comments$/) do
119
+ expect(page).to have_content "individual-comment-1"
120
+ expect(page).to have_content "individual-comment-2"
121
+ expect(page).to have_content "corporation-comment-1"
122
+ expect(page).to have_content "corporation-comment-2"
123
+ end
124
+
125
+ Given(/^an existing corporation with (\d+) comments$/) do |n|
126
+ step "an existing corporation"
127
+
128
+ n.to_i.times do
129
+ create(:customer_vault_event_comment, person: @corporation)
130
+ end
131
+ end
132
+
133
+ Then(/^I see these comments paginated$/) do
134
+ expect(all(".comment").count).to eq 50
135
+ expect(page).to have_selector ".pagination"
136
+ end
137
+
138
+ When(/^I edit this corporation$/) do
139
+ visit dorsale.edit_customer_vault_corporation_path(@corporation)
140
+ end
141
+
142
+ When(/^I add tags to this corporation$/) do
143
+ page.execute_script %(
144
+ $("#person_tag_list").append("<option value='mytag1'>mytag1</option>")
145
+ $("#person_tag_list").append("<option value='mytag2'>mytag2</option>")
146
+ )
147
+
148
+ select "mytag1"
149
+ select "mytag2"
150
+ end
151
+
152
+ When(/^I submit this corporation$/) do
153
+ find("[type=submit]").click
154
+ end
155
+
156
+ Then(/^tags are added$/) do
157
+ expect(all(".tag").count).to eq 2
158
+ expect(page).to have_content "mytag1"
159
+ expect(page).to have_content "mytag2"
160
+ end
161
+
162
+ Given(/^an existing corporation with tags$/) do
163
+ @corporation = create(:customer_vault_corporation, tag_list: "mytag1, mytag2")
164
+ end
165
+
166
+ When(/^I remove tags to this corporation$/) do
167
+ unselect "mytag1"
168
+ end
169
+
170
+ Then(/^tags are removed$/) do
171
+ expect(all(".tag").count).to eq 1
172
+ expect(page).to have_no_content "mytag1"
173
+ expect(page).to have_content "mytag2"
174
+ end
175
+
176
+ Given(/^an open task to this corporation$/) do
177
+ @open_task = @corporation.tasks.create!(progress: 20, name: "I-am-open")
178
+ end
179
+
180
+ Given(/^a closed task to this corporation$/) do
181
+ @closed_task = @corporation.tasks.create!(progress: 100, done: true, name: "I-am-closed")
182
+ end
183
+
184
+ Given(/^a link between this individual and this corporation$/) do
185
+ @link = ::Dorsale::CustomerVault::Link.create!(
186
+ :alice => @corporation,
187
+ :bob => @individual,
188
+ :title => "I-am-a-link",
189
+ )
190
+ end
191
+
192
+ Then(/^I see only the open task in the context$/) do
193
+ expect(find("#context")).to have_content "I-am-open"
194
+ expect(find("#context")).to have_no_content "I-am-closed"
195
+ end
196
+
197
+ Then(/^I see the link in the context$/) do
198
+ expect(find("#context")).to have_content "I-am-a-link"
199
+ end
200
+
201
+ Then(/^I am on the corporation page$/) do
202
+ wait_for { current_path }.to eq dorsale.customer_vault_corporation_path(@corporation)
203
+ end
204
+
205
+ When(/^I delete this corporation$/) do
206
+ @corporations_count = ::Dorsale::CustomerVault::Corporation.count
207
+
208
+ find(".context [href$=edit]").click
209
+ find(".context [data-method=delete]").click
210
+ end
211
+
212
+ Then(/^the corporation is deleted$/) do
213
+ expect(::Dorsale::CustomerVault::Corporation.count).to eq(@corporations_count - 1)
214
+ end
215
+
216
+ Then(/^I am on the people page$/) do
217
+ expect(current_path).to eq dorsale.customer_vault_people_path
218
+ end