diff options
| author | af83 | 2017-07-04 17:42:10 +0200 |
|---|---|---|
| committer | af83 | 2017-07-04 17:42:10 +0200 |
| commit | ebd292c7a6abaab5aeb90b37e34e21253184979f (patch) | |
| tree | 64d4a24ace793a6f9c4a0760c9cb478ff25be111 /spec | |
| parent | 3b03d3a554731b3afb71ae18ee8a8d03a0ff7a77 (diff) | |
| parent | a4b4c84ea5a1ed8ec7b77c1aebd2ff8252897f63 (diff) | |
| download | chouette-core-ebd292c7a6abaab5aeb90b37e34e21253184979f.tar.bz2 | |
Change typo to RCZ translation
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/features/workbenches_permissions_spec.rb | 8 | ||||
| -rw-r--r-- | spec/features/workbenches_spec.rb | 53 |
2 files changed, 57 insertions, 4 deletions
diff --git a/spec/features/workbenches_permissions_spec.rb b/spec/features/workbenches_permissions_spec.rb index 962ffdedc..d58293538 100644 --- a/spec/features/workbenches_permissions_spec.rb +++ b/spec/features/workbenches_permissions_spec.rb @@ -18,20 +18,20 @@ describe 'Workbenches', type: :feature do context 'on show view' do let( :path ){ workbench_path(workbench) } - context 'if present → ' do + context 'if present → ' do let( :permission ){ true } it 'shows the corresponding button' do expected_href = new_referential_path(workbench_id: workbench) - expect( page ).to have_link('Ajouter', href: expected_href) + expect( page ).to have_link('Créer', href: expected_href) end end - context 'if absent → ' do + context 'if absent → ' do let( :permission ){ false } it 'does not show the corresponding button' do - expect( page ).not_to have_link('Ajouter') + expect( page ).not_to have_link('Créer') end end # let!(:ready_referential) { create :referential, workbench: workbench, metadatas: referential_metadatas, ready: true, organisation: @user.organisation } 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 |
