dorsale 3.1.5 → 3.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/app/assets/javascripts/dorsale/common/forms.coffee +15 -0
- data/app/filters/dorsale/billing_machine/small_data/filter_for_invoices.rb +3 -1
- data/app/filters/dorsale/billing_machine/small_data/filter_for_quotations.rb +3 -1
- data/app/filters/dorsale/small_data/filter_strategy_by_key_value.rb +5 -0
- data/app/filters/dorsale/small_data/filter_strategy_by_time_period.rb +37 -0
- data/app/helpers/dorsale/filters_helper.rb +10 -4
- data/app/models/dorsale/users/avatar.rb +1 -1
- data/app/views/dorsale/billing_machine/invoices/_filters.html.slim +3 -0
- data/app/views/dorsale/billing_machine/quotations/_filters.html.slim +3 -0
- data/config/locales/common.en.yml +11 -5
- data/config/locales/common.fr.yml +11 -5
- data/features/billing_machine_invoices.feature +16 -1
- data/features/step_definitions/billing_machine_invoices_steps.rb +8 -4
- data/features/step_definitions/billing_machine_quotations_steps.rb +1 -1
- data/features/step_definitions/common_steps.rb +11 -0
- data/features/step_definitions/expense_gun_expenses_steps.rb +2 -1
- data/features/step_definitions/flyboy_tasks_steps.rb +5 -8
- data/features/support/ajax.rb +3 -3
- data/features/support/poltergeist.rb +1 -1
- data/features/support/turbolinks.rb +5 -5
- data/lib/dorsale/version.rb +1 -1
- data/spec/controllers/dorsale/billing_machine/invoices_controller_spec.rb +95 -1
- data/spec/models/dorsale/users_spec.rb +7 -0
- metadata +3 -3
- data/app/filters/dorsale/billing_machine/small_data/filter_strategy_by_time_period.rb +0 -15
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f873a20e46bfa3caee9df65c30c74c9a8451a2e8
|
|
4
|
+
data.tar.gz: cc19ee4d7718957697d931b30b654569e86f99c2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 39bfb09fcf7dabbc4e863cc69d62f7901ef668b1e53f215135cf1414b20058319fb14b89c329ffcfb78d8cf507178e681b66e55c17933340486fdcaa19c0a725
|
|
7
|
+
data.tar.gz: 3fbf7ff0e239aed72868926e6829510dc8b565c627c303850fe4fb1320e387cbbe5a3d78f9ddfbffc687722ad9b5034ba023bae18c7282423ebac37ab0f7f7cf
|
data/CHANGELOG.md
CHANGED
|
@@ -52,3 +52,18 @@ $(document).on "ready turbolinks:load page:load", ->
|
|
|
52
52
|
input.name = "form_url"
|
|
53
53
|
input.value = location.href
|
|
54
54
|
$(this).append(input)
|
|
55
|
+
|
|
56
|
+
$("select").map ->
|
|
57
|
+
select = $(this)
|
|
58
|
+
form = select.parents("form")
|
|
59
|
+
|
|
60
|
+
return if select.find("[value=custom_date]").length == 0
|
|
61
|
+
|
|
62
|
+
select.change ->
|
|
63
|
+
if select.val() == "custom_date"
|
|
64
|
+
form.find(".form-group[class*=date_begin], .form-group[class*=date_end]").show()
|
|
65
|
+
else
|
|
66
|
+
form.find("input[id*=date_begin], input[id*=date_end]").val("")
|
|
67
|
+
form.find(".form-group[class*=date_begin], .form-group[class*=date_end]").hide()
|
|
68
|
+
|
|
69
|
+
select.change()
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
class Dorsale::BillingMachine::SmallData::FilterForInvoices < ::Dorsale::SmallData::Filter
|
|
2
2
|
STRATEGIES = {
|
|
3
3
|
"customer_guid" => ::Dorsale::BillingMachine::SmallData::FilterStrategyByCustomer.new,
|
|
4
|
-
"bm_time_period" => ::Dorsale::
|
|
4
|
+
"bm_time_period" => ::Dorsale::SmallData::FilterStrategyByTimePeriod.new(:date),
|
|
5
|
+
"bm_date_begin" => ::Dorsale::SmallData::FilterStrategyByDateBegin.new(:date),
|
|
6
|
+
"bm_date_end" => ::Dorsale::SmallData::FilterStrategyByDateEnd.new(:date),
|
|
5
7
|
"bm_payment_status" => ::Dorsale::BillingMachine::SmallData::FilterStrategyByPaymentStatus.new,
|
|
6
8
|
}
|
|
7
9
|
end
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
class Dorsale::BillingMachine::SmallData::FilterForQuotations < ::Dorsale::SmallData::Filter
|
|
2
2
|
STRATEGIES = {
|
|
3
3
|
"customer_guid" => ::Dorsale::BillingMachine::SmallData::FilterStrategyByCustomer.new,
|
|
4
|
-
"bm_time_period" => ::Dorsale::
|
|
4
|
+
"bm_time_period" => ::Dorsale::SmallData::FilterStrategyByTimePeriod.new(:date),
|
|
5
|
+
"bm_date_begin" => ::Dorsale::SmallData::FilterStrategyByDateBegin.new(:date),
|
|
6
|
+
"bm_date_end" => ::Dorsale::SmallData::FilterStrategyByDateEnd.new(:date),
|
|
5
7
|
"bm_quotation_state" => ::Dorsale::BillingMachine::SmallData::FilterStrategyByState.new,
|
|
6
8
|
}
|
|
7
9
|
end
|
|
@@ -6,6 +6,11 @@ class Dorsale::SmallData::FilterStrategyByKeyValue < ::Dorsale::SmallData::Filte
|
|
|
6
6
|
end
|
|
7
7
|
|
|
8
8
|
def apply(query, value)
|
|
9
|
+
value = true if value == "true"
|
|
10
|
+
value = false if value == "false"
|
|
11
|
+
value = nil if value == "nil"
|
|
12
|
+
value = nil if value == "null"
|
|
13
|
+
|
|
9
14
|
query.where("#{key} = ?", value)
|
|
10
15
|
end
|
|
11
16
|
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
class Dorsale::SmallData::FilterStrategyByTimePeriod < ::Dorsale::SmallData::FilterStrategyByKeyValue
|
|
2
|
+
def apply(query, value)
|
|
3
|
+
if value == "today"
|
|
4
|
+
a = Time.zone.now.beginning_of_day
|
|
5
|
+
b = Time.zone.now.end_of_day
|
|
6
|
+
elsif value == "yesterday"
|
|
7
|
+
a = (Time.zone.now - 1.day).beginning_of_day
|
|
8
|
+
b = (Time.zone.now - 1.day).end_of_day
|
|
9
|
+
elsif value == "this_week"
|
|
10
|
+
a = Time.zone.now.beginning_of_week
|
|
11
|
+
b = Time.zone.now.end_of_week
|
|
12
|
+
elsif value == "this_month"
|
|
13
|
+
a = Time.zone.now.beginning_of_month
|
|
14
|
+
b = Time.zone.now.end_of_month
|
|
15
|
+
elsif value == "this_year"
|
|
16
|
+
a = Time.zone.now.beginning_of_year
|
|
17
|
+
b = Time.zone.now.end_of_year
|
|
18
|
+
elsif value == "last_week"
|
|
19
|
+
a = (Time.zone.now - 1.week).beginning_of_week
|
|
20
|
+
b = (Time.zone.now - 1.week).end_of_week
|
|
21
|
+
elsif value == "last_month"
|
|
22
|
+
a = (Time.zone.now - 1.month).beginning_of_month
|
|
23
|
+
b = (Time.zone.now - 1.month).end_of_month
|
|
24
|
+
elsif value == "last_year"
|
|
25
|
+
a = (Time.zone.now - 1.year).beginning_of_year
|
|
26
|
+
b = (Time.zone.now - 1.year).end_of_year
|
|
27
|
+
else
|
|
28
|
+
return query
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
criteria = "#{query.model.table_name}.#{key}"
|
|
32
|
+
|
|
33
|
+
query
|
|
34
|
+
.where("#{criteria} >= ?", a.to_date)
|
|
35
|
+
.where("#{criteria} <= ?", b.to_date)
|
|
36
|
+
end
|
|
37
|
+
end
|
|
@@ -52,10 +52,16 @@ module Dorsale::FiltersHelper
|
|
|
52
52
|
|
|
53
53
|
def dorsale_time_periods_for_select
|
|
54
54
|
{
|
|
55
|
-
t("time_periods.all_time")
|
|
56
|
-
t("time_periods.today")
|
|
57
|
-
t("time_periods.
|
|
58
|
-
t("time_periods.
|
|
55
|
+
t("time_periods.all_time") => "",
|
|
56
|
+
t("time_periods.today") => "today",
|
|
57
|
+
t("time_periods.yesterday") => "yesterday" ,
|
|
58
|
+
t("time_periods.this_week") => "this_week",
|
|
59
|
+
t("time_periods.last_week") => "last_week",
|
|
60
|
+
t("time_periods.this_month") => "this_month",
|
|
61
|
+
t("time_periods.last_month") => "last_month",
|
|
62
|
+
t("time_periods.this_year") => "this_year",
|
|
63
|
+
t("time_periods.last_year") => "last_year",
|
|
64
|
+
t("time_periods.custom_date") => "custom_date",
|
|
59
65
|
}
|
|
60
66
|
end
|
|
61
67
|
|
|
@@ -12,7 +12,7 @@ module Dorsale::Users::Avatar
|
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
def gravatar_url
|
|
15
|
-
"https://www.gravatar.com/avatar/" + Digest::MD5.hexdigest(email) + "?default=mm&size=200"
|
|
15
|
+
"https://www.gravatar.com/avatar/" + Digest::MD5.hexdigest(email.to_s) + "?default=mm&size=200"
|
|
16
16
|
end
|
|
17
17
|
end
|
|
18
18
|
end
|
|
@@ -9,6 +9,9 @@
|
|
|
9
9
|
:include_blank => false,
|
|
10
10
|
)
|
|
11
11
|
|
|
12
|
+
= f.input :bm_date_begin, input_html: {placeholder: t("filters.date_begin")}
|
|
13
|
+
= f.input :bm_date_end, input_html: {placeholder: t("filters.date_end")}
|
|
14
|
+
|
|
12
15
|
= f.input(:bm_payment_status,
|
|
13
16
|
:collection => billing_machine_payment_status_for_filter_select,
|
|
14
17
|
:include_blank => false,
|
|
@@ -9,6 +9,9 @@
|
|
|
9
9
|
:include_blank => false,
|
|
10
10
|
)
|
|
11
11
|
|
|
12
|
+
= f.input :bm_date_begin, input_html: {placeholder: t("filters.date_begin")}
|
|
13
|
+
= f.input :bm_date_end, input_html: {placeholder: t("filters.date_end")}
|
|
14
|
+
|
|
12
15
|
= f.input(:bm_quotation_state,
|
|
13
16
|
:collection => billing_machine_quotation_states_for_filter_select,
|
|
14
17
|
:include_blank => false,
|
|
@@ -161,18 +161,24 @@ en:
|
|
|
161
161
|
|
|
162
162
|
filters:
|
|
163
163
|
all_customers: "All customers"
|
|
164
|
+
date_begin: "Date begin"
|
|
165
|
+
date_end: "Date end"
|
|
164
166
|
|
|
165
167
|
time_periods:
|
|
166
168
|
all_time: "All time"
|
|
169
|
+
tomorrow: "Tomorrow"
|
|
167
170
|
today: "Today"
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
+
yesterday: "Yesterday"
|
|
172
|
+
this_week: "This semaine"
|
|
173
|
+
this_month: "This mois"
|
|
174
|
+
this_year: "This année"
|
|
175
|
+
last_week: "Last week"
|
|
176
|
+
last_month: "Last month"
|
|
177
|
+
last_year: "Last year"
|
|
171
178
|
delayed: "Delayed"
|
|
172
|
-
this_week: "This week"
|
|
173
179
|
next_week: "Next week"
|
|
174
180
|
next_next_week: "In two weeks"
|
|
175
|
-
|
|
181
|
+
custom_date: "Custom date"
|
|
176
182
|
|
|
177
183
|
labels:
|
|
178
184
|
<<: *attributes
|
|
@@ -181,18 +181,24 @@ fr:
|
|
|
181
181
|
|
|
182
182
|
filters:
|
|
183
183
|
all_customers: "Tous les clients"
|
|
184
|
+
date_begin: "Date début"
|
|
185
|
+
date_end: "Date fin"
|
|
184
186
|
|
|
185
187
|
time_periods:
|
|
186
188
|
all_time: "Depuis toujours"
|
|
187
|
-
today: "Aujourd'hui"
|
|
188
189
|
tomorrow: "Demain"
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
year: "Cette année"
|
|
192
|
-
delayed: "En retard"
|
|
190
|
+
today: "Aujourd'hui"
|
|
191
|
+
yesterday: "Hier"
|
|
193
192
|
this_week: "Cette semaine"
|
|
193
|
+
this_month: "Ce mois"
|
|
194
|
+
this_year: "Cette année"
|
|
195
|
+
last_week: "La semaine dernière"
|
|
196
|
+
last_month: "Le mois dernier"
|
|
197
|
+
last_year: "L'année dernière"
|
|
198
|
+
delayed: "En retard"
|
|
194
199
|
next_week: "La semaine prochaine"
|
|
195
200
|
next_next_week: "Dans deux semaines"
|
|
201
|
+
custom_date: "Choisir une date"
|
|
196
202
|
|
|
197
203
|
labels:
|
|
198
204
|
<<: *attributes
|
|
@@ -179,6 +179,22 @@ Feature: Invoice Management
|
|
|
179
179
|
When he filters by date on today
|
|
180
180
|
Then only the invoices of today do appear
|
|
181
181
|
|
|
182
|
+
Scenario: Filter by custom dates
|
|
183
|
+
Given a bunch of existing invoices
|
|
184
|
+
When the user goes to the invoices page
|
|
185
|
+
Then he do not see the "bm_date_begin" filter
|
|
186
|
+
Then he do not see the "bm_date_end" filter
|
|
187
|
+
When he select custom date filter
|
|
188
|
+
Then he see the "bm_date_begin" filter
|
|
189
|
+
Then he see the "bm_date_end" filter
|
|
190
|
+
When he filters invoices between two date
|
|
191
|
+
Then only the invoices of today do appear
|
|
192
|
+
Then he see the "bm_date_begin" filter
|
|
193
|
+
Then he see the "bm_date_end" filter
|
|
194
|
+
When he reset filters
|
|
195
|
+
Then he do not see the "bm_date_begin" filter
|
|
196
|
+
Then he do not see the "bm_date_end" filter
|
|
197
|
+
|
|
182
198
|
Scenario: Filter by status
|
|
183
199
|
Given a bunch of existing invoices
|
|
184
200
|
When the user goes to the invoices page
|
|
@@ -230,7 +246,6 @@ Feature: Invoice Management
|
|
|
230
246
|
Given an existing customer
|
|
231
247
|
Given an existing invoice
|
|
232
248
|
When the user download the pdf
|
|
233
|
-
Then the PDF should have the filename "Facture_2014-01_SN.pdf"
|
|
234
249
|
|
|
235
250
|
Scenario: Invoices data
|
|
236
251
|
Given existing "100" invoices with "123" amount
|
|
@@ -105,6 +105,8 @@ When(/^wants to copy it$/) do
|
|
|
105
105
|
end
|
|
106
106
|
|
|
107
107
|
When(/^he fills a line with "(.*?)", "(.*?)", "(.*?)", "(.*?)"$/) do |label, quantity, unit, unit_price|
|
|
108
|
+
expect(page).to have_selector(".line")
|
|
109
|
+
|
|
108
110
|
within all('.line').last do
|
|
109
111
|
find(".line-label textarea").set label
|
|
110
112
|
find(".line-quantity input").set quantity
|
|
@@ -334,10 +336,6 @@ Then(/^the invoice status should be "(.*?)"$/) do |color|
|
|
|
334
336
|
expect(find(".invoice")[:class]).to include(color)
|
|
335
337
|
end
|
|
336
338
|
|
|
337
|
-
Then(/^the PDF should have the filename "([^\"]*)"$/) do |filename|
|
|
338
|
-
expect(page.response_headers['Content-Disposition']).to include("filename=\"#{filename}\"")
|
|
339
|
-
end
|
|
340
|
-
|
|
341
339
|
Then(/^data total amount is "(.*?)"$/) do |text|
|
|
342
340
|
expect(page).to have_content text
|
|
343
341
|
end
|
|
@@ -363,3 +361,9 @@ Then(/^an invoice is sent to customer$/) do
|
|
|
363
361
|
expect(email.parts.first.body).to eq "def"
|
|
364
362
|
expect(email.attachments.count).to eq 1
|
|
365
363
|
end
|
|
364
|
+
|
|
365
|
+
When(/^he filters invoices between two date$/) do
|
|
366
|
+
fill_in :filters_bm_date_begin, with: I18n.l(Time.zone.now.to_date)
|
|
367
|
+
fill_in :filters_bm_date_end, with: I18n.l(Time.zone.now.to_date)
|
|
368
|
+
find(".filter-submit").click
|
|
369
|
+
end
|
|
@@ -144,7 +144,7 @@ end
|
|
|
144
144
|
When(/^he create an invoice from the quotation$/) do
|
|
145
145
|
@invoices_count = Dorsale::BillingMachine::Invoice.count
|
|
146
146
|
find("[href$='create_invoice']").click
|
|
147
|
-
find("[type=submit]").click
|
|
147
|
+
find("form#new_invoice [type=submit]").click
|
|
148
148
|
end
|
|
149
149
|
|
|
150
150
|
When(/^he fill the quotation expiry$/) do
|
|
@@ -42,3 +42,14 @@ Then(/^the selected filter is "(.*?)"$/) do |value|
|
|
|
42
42
|
expect(selected_values).to include value
|
|
43
43
|
end
|
|
44
44
|
|
|
45
|
+
Then(/^he do not see the "([^"]*)" filter$/) do |id|
|
|
46
|
+
expect(page).to have_no_selector("#filters_#{id}")
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
When(/^he select custom date filter$/) do
|
|
50
|
+
select "Choisir une date"
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
Then(/^he see the "([^"]*)" filter$/) do |id|
|
|
54
|
+
expect(page).to have_selector("#filters_#{id}")
|
|
55
|
+
end
|
|
@@ -118,6 +118,7 @@ When(/^I copy the expense$/) do
|
|
|
118
118
|
@expenses_count = Dorsale::ExpenseGun::Expense.count
|
|
119
119
|
|
|
120
120
|
find("[href$=copy]").click
|
|
121
|
+
expect(page).to have_selector("form#new_expense [type=submit]")
|
|
121
122
|
|
|
122
123
|
all(".nested-fields").each do |line|
|
|
123
124
|
within line do
|
|
@@ -125,7 +126,7 @@ When(/^I copy the expense$/) do
|
|
|
125
126
|
end
|
|
126
127
|
end
|
|
127
128
|
|
|
128
|
-
find("[type=submit]").click
|
|
129
|
+
find("form#new_expense [type=submit]").click
|
|
129
130
|
end
|
|
130
131
|
|
|
131
132
|
Then(/^an expense copy is created$/) do
|
|
@@ -64,7 +64,7 @@ end
|
|
|
64
64
|
|
|
65
65
|
When(/^I create a task$/) do
|
|
66
66
|
all("a[href*='tasks/new']").first.click
|
|
67
|
-
find("[type=submit]").click # First submit to see errors
|
|
67
|
+
find("form[id*=task] [type=submit]").click # First submit to see errors
|
|
68
68
|
fill_in "task_name", with: "I-am-the-task-title"
|
|
69
69
|
fill_in "task_description", with: "I-am-the-task-description"
|
|
70
70
|
select @user.name
|
|
@@ -116,7 +116,7 @@ When(/^I filter tasks by undone$/) do
|
|
|
116
116
|
find(".filters [type=submit]:last-child").click
|
|
117
117
|
end
|
|
118
118
|
|
|
119
|
-
When(/^I reset filters$/) do
|
|
119
|
+
When(/^(?:I|he|she) reset filters$/) do
|
|
120
120
|
find(".filters .reset").click
|
|
121
121
|
end
|
|
122
122
|
|
|
@@ -164,18 +164,15 @@ Then(/^the task is snoozed$/) do
|
|
|
164
164
|
end
|
|
165
165
|
|
|
166
166
|
Then(/^I download PDF file$/) do
|
|
167
|
-
|
|
168
|
-
expect(page.response_headers['Content-Type']).to match "application/pdf"
|
|
167
|
+
# Nothing to do, Rails raise if any problem
|
|
169
168
|
end
|
|
170
169
|
|
|
171
170
|
Then(/^I download CSV file$/) do
|
|
172
|
-
|
|
173
|
-
expect(page.response_headers['Content-Type']).to match "text/csv"
|
|
171
|
+
# Nothing to do, Rails raise if any problem
|
|
174
172
|
end
|
|
175
173
|
|
|
176
174
|
Then(/^I download XLS file$/) do
|
|
177
|
-
|
|
178
|
-
expect(page.response_headers['Content-Type']).to match "excel"
|
|
175
|
+
# Nothing to do, Rails raise if any problem
|
|
179
176
|
end
|
|
180
177
|
|
|
181
178
|
Then(/^I am on this task$/) do
|
data/features/support/ajax.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
module CucumberWaitAjaxRequests
|
|
2
|
-
def wait_ajax_requests
|
|
3
|
-
Timeout.timeout(
|
|
2
|
+
def wait_ajax_requests(timeout = Capybara.default_max_wait_time)
|
|
3
|
+
Timeout.timeout(timeout) do
|
|
4
4
|
sleep 0.1 until all_ajax_requests_finished?
|
|
5
5
|
end
|
|
6
6
|
end
|
|
@@ -12,7 +12,7 @@ end
|
|
|
12
12
|
|
|
13
13
|
World(CucumberWaitAjaxRequests)
|
|
14
14
|
|
|
15
|
-
# Auto wait ajax
|
|
15
|
+
# Auto wait ajax request between steps
|
|
16
16
|
AfterStep do |scenario|
|
|
17
17
|
if page.evaluate_script('typeof jQuery') != "undefined"
|
|
18
18
|
wait_ajax_requests
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
require "capybara/poltergeist"
|
|
2
2
|
|
|
3
|
-
phantomjs_version = "1.
|
|
3
|
+
phantomjs_version = "2.1.1"
|
|
4
4
|
phantomjs_binary = `which phantomjs-#{phantomjs_version} phantomjs`.split("\n").first
|
|
5
5
|
raise "invalid phantomjs version" unless `#{phantomjs_binary} -v`.strip == phantomjs_version
|
|
6
6
|
# You can download phantomjs here : https://bitbucket.org/ariya/phantomjs/downloads/
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
module CucumberWaitTurbolinksRequests
|
|
2
|
-
def wait_turbolinks_requests
|
|
3
|
-
Timeout.timeout(
|
|
2
|
+
def wait_turbolinks_requests(timeout = Capybara.default_max_wait_time)
|
|
3
|
+
Timeout.timeout(timeout) do
|
|
4
4
|
sleep 0.1 until all_turbolinks_requests_finished?
|
|
5
5
|
end
|
|
6
6
|
end
|
|
7
7
|
|
|
8
8
|
def all_turbolinks_requests_finished?
|
|
9
|
-
|
|
9
|
+
have_no_selector("html.turbolinks-load")
|
|
10
10
|
end
|
|
11
11
|
end
|
|
12
12
|
|
|
@@ -17,11 +17,11 @@ AfterStep do |scenario|
|
|
|
17
17
|
if page.evaluate_script('typeof Turbolinks') != "undefined"
|
|
18
18
|
evaluate_script %(
|
|
19
19
|
$(document).on("turbolinks:before-visit", function(){
|
|
20
|
-
$("
|
|
20
|
+
$("html").addClass("turbolinks-load")
|
|
21
21
|
})
|
|
22
22
|
|
|
23
23
|
$(document).on("turbolinks:load", function(){
|
|
24
|
-
$("
|
|
24
|
+
$("html").removeClass("turbolinks-load")
|
|
25
25
|
})
|
|
26
26
|
)
|
|
27
27
|
|
data/lib/dorsale/version.rb
CHANGED
|
@@ -15,6 +15,100 @@ describe Dorsale::BillingMachine::InvoicesController, type: :controller do
|
|
|
15
15
|
expect(response).to be_ok
|
|
16
16
|
expect(response.body.split("\n").length).to eq 4 # headers + 3 invoices
|
|
17
17
|
end
|
|
18
|
-
end
|
|
18
|
+
end # describe "CSV export"
|
|
19
|
+
|
|
20
|
+
describe "filters" do
|
|
21
|
+
before do
|
|
22
|
+
Timecop.freeze "2016-11-08 12:00:00"
|
|
23
|
+
@today = create(:billing_machine_invoice, date: "2016-11-08")
|
|
24
|
+
@yesterday = create(:billing_machine_invoice, date: "2016-11-07")
|
|
25
|
+
@tomorrow = create(:billing_machine_invoice, date: "2016-11-09")
|
|
26
|
+
@last_week = create(:billing_machine_invoice, date: "2016-11-04")
|
|
27
|
+
@last_month = create(:billing_machine_invoice, date: "2016-10-18")
|
|
28
|
+
@last_year = create(:billing_machine_invoice, date: "2015-10-18")
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def filter(period)
|
|
32
|
+
cookies[:filters] = {"bm_time_period" => period.to_s}.to_json
|
|
33
|
+
get :index
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
it "should filter by all_time" do
|
|
37
|
+
filter :all_time
|
|
38
|
+
expect(assigns :invoices).to contain_exactly(
|
|
39
|
+
@today,
|
|
40
|
+
@yesterday,
|
|
41
|
+
@tomorrow,
|
|
42
|
+
@last_week,
|
|
43
|
+
@last_month,
|
|
44
|
+
@last_year,
|
|
45
|
+
)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
it "should filter by today" do
|
|
49
|
+
filter :today
|
|
50
|
+
expect(assigns :invoices).to contain_exactly(
|
|
51
|
+
@today,
|
|
52
|
+
)
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
it "should filter by yesterday" do
|
|
56
|
+
filter :yesterday
|
|
57
|
+
expect(assigns :invoices).to contain_exactly(
|
|
58
|
+
@yesterday,
|
|
59
|
+
)
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
it "should filter by this_week" do
|
|
63
|
+
filter :this_week
|
|
64
|
+
expect(assigns :invoices).to contain_exactly(
|
|
65
|
+
@today,
|
|
66
|
+
@yesterday,
|
|
67
|
+
@tomorrow,
|
|
68
|
+
)
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
it "should filter by this_month" do
|
|
72
|
+
filter :this_month
|
|
73
|
+
expect(assigns :invoices).to contain_exactly(
|
|
74
|
+
@today,
|
|
75
|
+
@yesterday,
|
|
76
|
+
@tomorrow,
|
|
77
|
+
@last_week,
|
|
78
|
+
)
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
it "should filter by this_year" do
|
|
82
|
+
filter :this_year
|
|
83
|
+
expect(assigns :invoices).to contain_exactly(
|
|
84
|
+
@today,
|
|
85
|
+
@yesterday,
|
|
86
|
+
@tomorrow,
|
|
87
|
+
@last_week,
|
|
88
|
+
@last_month,
|
|
89
|
+
)
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
it "should filter by last_week" do
|
|
93
|
+
filter :last_week
|
|
94
|
+
expect(assigns :invoices).to contain_exactly(
|
|
95
|
+
@last_week,
|
|
96
|
+
)
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
it "should filter by last_month" do
|
|
100
|
+
filter :last_month
|
|
101
|
+
expect(assigns :invoices).to contain_exactly(
|
|
102
|
+
@last_month,
|
|
103
|
+
)
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
it "should filter by last_year" do
|
|
107
|
+
filter :last_year
|
|
108
|
+
expect(assigns :invoices).to contain_exactly(
|
|
109
|
+
@last_year,
|
|
110
|
+
)
|
|
111
|
+
end
|
|
112
|
+
end # describe "filters"
|
|
19
113
|
|
|
20
114
|
end
|
|
@@ -50,11 +50,18 @@ RSpec.describe User, type: :model do
|
|
|
50
50
|
it "avatar_url should return local_avatar_url if present" do
|
|
51
51
|
expect(@user.avatar_url).to include "avatar.png"
|
|
52
52
|
end
|
|
53
|
+
|
|
53
54
|
it "avatar_url should return gravatar_url if no local avatar" do
|
|
54
55
|
@user.remove_avatar!
|
|
55
56
|
@user.save!
|
|
56
57
|
expect(@user.avatar_url).to include "gravatar"
|
|
57
58
|
end
|
|
59
|
+
|
|
60
|
+
it "should work if email is nil" do
|
|
61
|
+
@user.remove_avatar!
|
|
62
|
+
allow(@user).to receive(:email)
|
|
63
|
+
expect(@user.avatar_url).to be_present
|
|
64
|
+
end
|
|
58
65
|
end
|
|
59
66
|
|
|
60
67
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: dorsale
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.1.
|
|
4
|
+
version: 3.1.6
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- agilidée
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2016-
|
|
11
|
+
date: 2016-11-08 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rails
|
|
@@ -530,7 +530,6 @@ files:
|
|
|
530
530
|
- app/filters/dorsale/billing_machine/small_data/filter_strategy_by_customer.rb
|
|
531
531
|
- app/filters/dorsale/billing_machine/small_data/filter_strategy_by_payment_status.rb
|
|
532
532
|
- app/filters/dorsale/billing_machine/small_data/filter_strategy_by_state.rb
|
|
533
|
-
- app/filters/dorsale/billing_machine/small_data/filter_strategy_by_time_period.rb
|
|
534
533
|
- app/filters/dorsale/customer_vault/small_data/filter_for_people.rb
|
|
535
534
|
- app/filters/dorsale/expense_gun/small_data/filter_for_expenses.rb
|
|
536
535
|
- app/filters/dorsale/flyboy/small_data/filter_for_folders.rb
|
|
@@ -544,6 +543,7 @@ files:
|
|
|
544
543
|
- app/filters/dorsale/small_data/filter_strategy_by_date_end.rb
|
|
545
544
|
- app/filters/dorsale/small_data/filter_strategy_by_key_value.rb
|
|
546
545
|
- app/filters/dorsale/small_data/filter_strategy_by_tags.rb
|
|
546
|
+
- app/filters/dorsale/small_data/filter_strategy_by_time_period.rb
|
|
547
547
|
- app/helpers/dh.rb
|
|
548
548
|
- app/helpers/dorsale/alexandrie/attachments_helper.rb
|
|
549
549
|
- app/helpers/dorsale/all_helpers.rb
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
class Dorsale::BillingMachine::SmallData::FilterStrategyByTimePeriod < ::Dorsale::SmallData::FilterStrategyByKeyValue
|
|
2
|
-
def apply(query, value)
|
|
3
|
-
criteria = "#{query.model.table_name}.#{key}"
|
|
4
|
-
|
|
5
|
-
if value == "today"
|
|
6
|
-
return query.where("#{criteria} >= ?", Time.zone.now.to_date)
|
|
7
|
-
elsif value == "week"
|
|
8
|
-
return query.where("#{criteria} >= ?", Time.zone.now.to_date.at_beginning_of_week)
|
|
9
|
-
elsif value == "month"
|
|
10
|
-
return query.where("#{criteria} >= ?", Time.zone.now.to_date.at_beginning_of_month)
|
|
11
|
-
else
|
|
12
|
-
return query
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
end
|