Format dates with .strftime('%d/%m/%Y') when filling datepickers

Advanced search scenarios for Budget::Investments, Debates and
Proposals need proper date formatting as they behave unexpectedly
when APIs such as `7.days.ago` are used
This commit is contained in:
Angel Perez
2018-03-09 10:09:04 -04:00
parent 375c43b5f1
commit ea21fe859b
3 changed files with 12 additions and 12 deletions

View File

@@ -1234,16 +1234,16 @@ feature 'Proposals' do
click_link "Advanced search"
select "Customized", from: "js-advanced-search-date-min"
fill_in "advanced_search_date_min", with: 7.days.ago.to_date
fill_in "advanced_search_date_max", with: 1.day.ago.to_date
fill_in "advanced_search_date_min", with: 7.days.ago.strftime('%d/%m/%Y')
fill_in "advanced_search_date_max", with: 1.day.ago.strftime('%d/%m/%Y')
click_button "Filter"
expect(page).to have_content("citizen proposals cannot be found")
within "#js-advanced-search" do
expect(page).to have_select('advanced_search[date_min]', selected: 'Customized')
expect(page).to have_selector("input[name='advanced_search[date_min]'][value*='#{7.days.ago.strftime('%Y-%m-%d')}']")
expect(page).to have_selector("input[name='advanced_search[date_max]'][value*='#{1.day.ago.strftime('%Y-%m-%d')}']")
expect(page).to have_selector("input[name='advanced_search[date_min]'][value*='#{7.days.ago.strftime('%d/%m/%Y')}']")
expect(page).to have_selector("input[name='advanced_search[date_max]'][value*='#{1.day.ago.strftime('%d/%m/%Y')}']")
end
end