diff options
| author | Xinhui | 2017-07-04 14:02:48 +0200 | 
|---|---|---|
| committer | Xinhui | 2017-07-04 14:02:48 +0200 | 
| commit | 332bb514e5450dcd4ce6e995189623d316be167a (patch) | |
| tree | 672f20a0b079dc83bb7d3af6099b1b0f881976b0 /spec/features/workbenches_spec.rb | |
| parent | 433c498ac44aac684f0165265e3da437cafa3243 (diff) | |
| download | chouette-core-332bb514e5450dcd4ce6e995189623d316be167a.tar.bz2 | |
Workbench#show filter by validity_period feature spec
Diffstat (limited to 'spec/features/workbenches_spec.rb')
| -rw-r--r-- | spec/features/workbenches_spec.rb | 41 | 
1 files changed, 41 insertions, 0 deletions
diff --git a/spec/features/workbenches_spec.rb b/spec/features/workbenches_spec.rb index 2f453389d..1eb20dd40 100644 --- a/spec/features/workbenches_spec.rb +++ b/spec/features/workbenches_spec.rb @@ -103,6 +103,47 @@ 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 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  | 
