diff options
| author | cedricnjanga | 2018-03-15 00:11:01 -0700 |
|---|---|---|
| committer | Alban Peignier | 2018-03-15 10:01:30 +0100 |
| commit | 01cf341348eaec620a296a3435131798f4f17f6d (patch) | |
| tree | d6de875f01183896da24c862008d2813af283dfb | |
| parent | 5227184b20e720d6643802b187a4c07c692283cb (diff) | |
| download | chouette-core-01cf341348eaec620a296a3435131798f4f17f6d.tar.bz2 | |
Refs #6033 Fix stop areas spec feature
| -rw-r--r-- | app/controllers/stop_areas_controller.rb | 17 | ||||
| -rw-r--r-- | spec/features/stop_areas_spec.rb | 48 |
2 files changed, 33 insertions, 32 deletions
diff --git a/app/controllers/stop_areas_controller.rb b/app/controllers/stop_areas_controller.rb index c3da92265..e94f64e14 100644 --- a/app/controllers/stop_areas_controller.rb +++ b/app/controllers/stop_areas_controller.rb @@ -53,6 +53,7 @@ class StopAreasController < ChouetteController index! do |format| format.html { + # binding.pry if collection.out_of_bounds? redirect_to params.merge(:page => 1) end @@ -215,28 +216,16 @@ class StopAreasController < ChouetteController @status = { in_creation: params[:q][:status]['in_creation'] == 'true', - activated: params[:q][:status]['activated'] == 'true', + confirmed: params[:q][:status]['confirmed'] == 'true', deactivated: params[:q][:status]['deactivated'] == 'true', } scope = Chouette::StopArea.where( - "confirmed_at #{@status[:activated] ? "IS NOT NULL" : "IS NULL"} + "confirmed_at #{@status[:confirmed] ? "IS NOT NULL" : "IS NULL"} AND deleted_at #{@status[:deactivated] ? "IS NOT NULL" : "IS NULL"}" ) params[:q].delete :status scope end - - # Ignore archived_at_not_null/archived_at_null managed by ransack_status scope - # We clone params[:q] so we can delete fake ransack filter arguments before calling search method, - # which will allow us to preserve params[:q] for sorting - def ransack_params - copy_params = params[:q].clone - copy_params.delete('associated_lines_id_eq') - copy_params.delete('archived_at_not_null') - copy_params.delete('archived_at_null') - copy_params - end - end diff --git a/spec/features/stop_areas_spec.rb b/spec/features/stop_areas_spec.rb index 0e1f6f3a9..02e853999 100644 --- a/spec/features/stop_areas_spec.rb +++ b/spec/features/stop_areas_spec.rb @@ -36,26 +36,38 @@ describe "StopAreas", :type => :feature do stop_areas.first.activate! stop_areas.last.deactivate! end - - xit 'should filter stop areas in creation' do - find("#q_status_in_creation").set(true) - click_button 'search-btn' - expect(page).not_to have_content(stop_areas.first.name) - expect(page).not_to have_content(stop_areas.last.name) - end - xit 'should filter confirmed stop areas' do - find("#q_status_confirmed").set(true) - click_button 'search-btn' - expect(page).to have_content(stop_areas.first.name) - expect(page).not_to have_content(stop_areas.last.name) - end + describe 'updated stop areas in before block' do + + it 'supports displaying only stop areas in creation' do + find("#q_status_in_creation").set(true) + click_button 'search-btn' + expect(page).not_to have_content(stop_areas.first.name) + expect(page).not_to have_content(stop_areas.last.name) + end + + it 'supports displaying only confirmed stop areas' do + find("#q_status_confirmed").set(true) + click_button 'search-btn' + expect(page).to have_content(stop_areas.first.name) + expect(page).not_to have_content(stop_areas.last.name) + end + + it 'supports displaying only deactivated stop areas' do + find("#q_status_deactivated").set(true) + click_button 'search-btn' + expect(page).not_to have_content(stop_areas.first.name) + expect(page).to have_content(stop_areas.last.name) + end - xit 'should filter deactivated stop areas' do - find("#q_status_deactivated").set(true) - click_button 'search-btn' - expect(page).not_to have_content(stop_areas.first.name) - expect(page).to have_content(stop_areas.last.name) + it 'should display all stop areas if all filters are checked' do + find("#q_status_in_creation").set(true) + find("#q_status_confirmed").set(true) + find("#q_status_deactivated").set(true) + click_button 'search-btn' + expect(page).to have_content(stop_areas.first.name) + expect(page).to have_content(stop_areas.last.name) + end end end end |
