aboutsummaryrefslogtreecommitdiffstats
path: root/spec/features/workbenches_spec.rb
diff options
context:
space:
mode:
authoraf832017-07-04 17:42:10 +0200
committeraf832017-07-04 17:42:10 +0200
commitebd292c7a6abaab5aeb90b37e34e21253184979f (patch)
tree64d4a24ace793a6f9c4a0760c9cb478ff25be111 /spec/features/workbenches_spec.rb
parent3b03d3a554731b3afb71ae18ee8a8d03a0ff7a77 (diff)
parenta4b4c84ea5a1ed8ec7b77c1aebd2ff8252897f63 (diff)
downloadchouette-core-ebd292c7a6abaab5aeb90b37e34e21253184979f.tar.bz2
Change typo to RCZ translation
Diffstat (limited to 'spec/features/workbenches_spec.rb')
-rw-r--r--spec/features/workbenches_spec.rb53
1 files changed, 53 insertions, 0 deletions
diff --git a/spec/features/workbenches_spec.rb b/spec/features/workbenches_spec.rb
index 2f453389d..9a40a8376 100644
--- a/spec/features/workbenches_spec.rb
+++ b/spec/features/workbenches_spec.rb
@@ -103,6 +103,59 @@ describe 'Workbenches', type: :feature do
expect(find("#q_archived_at_null")).to be_checked
end
end
+
+ context 'filter by validity period' do
+ def fill_validity_field date, field
+ select date.year, :from => "q[validity_period][#{field}(1i)]"
+ select I18n.t("date.month_names")[date.month], :from => "q[validity_period][#{field}(2i)]"
+ select date.day, :from => "q[validity_period][#{field}(3i)]"
+ end
+
+ it 'should show results for referential in range' do
+ dates = referential.validity_period.to_a
+ fill_validity_field dates[0], 'begin_gteq'
+ fill_validity_field dates[1], 'end_lteq'
+ click_button 'Filtrer'
+
+ expect(page).to have_content(referential.name)
+ expect(page).to_not have_content(other_referential.name)
+ end
+
+ it 'should keep filtering on sort' do
+ dates = referential.validity_period.to_a
+ fill_validity_field dates[0], 'begin_gteq'
+ fill_validity_field dates[1], 'end_lteq'
+ click_button 'Filtrer'
+
+ find('a[href*="&sort=validity_period"]').click
+
+ expect(page).to have_content(referential.name)
+ expect(page).to_not have_content(other_referential.name)
+ end
+
+ it 'should not show results for out off range' do
+ fill_validity_field(Date.today - 2.year, 'begin_gteq')
+ fill_validity_field(Date.today - 1.year, 'end_lteq')
+ click_button 'Filtrer'
+
+ expect(page).to_not have_content(referential.name)
+ expect(page).to_not have_content(other_referential.name)
+ end
+
+ it 'should keep value on submit' do
+ dates = referential.validity_period.to_a
+ ['begin_gteq', 'end_lteq'].each_with_index do |field, index|
+ fill_validity_field dates[index], field
+ end
+ click_button 'Filtrer'
+
+ ['begin_gteq', 'end_lteq'].each_with_index do |field, index|
+ expect(find("#q_validity_period_#{field}_3i").value).to eq dates[index].day.to_s
+ expect(find("#q_validity_period_#{field}_2i").value).to eq dates[index].month.to_s
+ expect(find("#q_validity_period_#{field}_1i").value).to eq dates[index].year.to_s
+ end
+ end
+ end
end
context 'permissions' do