diff options
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/controllers/stop_areas_controller_spec.rb | 35 | ||||
| -rw-r--r-- | spec/features/stop_areas_spec.rb | 6 |
2 files changed, 39 insertions, 2 deletions
diff --git a/spec/controllers/stop_areas_controller_spec.rb b/spec/controllers/stop_areas_controller_spec.rb index f39ac5776..fbad2649c 100644 --- a/spec/controllers/stop_areas_controller_spec.rb +++ b/spec/controllers/stop_areas_controller_spec.rb @@ -4,6 +4,41 @@ RSpec.describe StopAreasController, :type => :controller do let(:stop_area_referential) { create :stop_area_referential, member: @user.organisation } let(:stop_area) { create :stop_area, stop_area_referential: stop_area_referential } + describe "GET index" do + it "filters by registration number" do + registration_number = 'E34' + + matched = create( + :stop_area, + stop_area_referential: stop_area_referential, + registration_number: registration_number + ) + create( + :stop_area, + stop_area_referential: stop_area_referential, + registration_number: "doesn't match" + ) + + get :index, + stop_area_referential_id: stop_area_referential.id, + q: { + name_or_objectid_or_registration_number_cont: registration_number + } + + expect(assigns(:stop_areas)).to eq([matched]) + end + + it "doesn't filter when the name filter is empty" do + get :index, + stop_area_referential_id: stop_area_referential.id, + q: { + name_or_objectid_or_registration_number_cont: '' + } + + expect(assigns(:stop_areas)).to eq([stop_area]) + end + end + describe 'PUT deactivate' do let(:request){ put :deactivate, id: stop_area.id, stop_area_referential_id: stop_area_referential.id } diff --git a/spec/features/stop_areas_spec.rb b/spec/features/stop_areas_spec.rb index 17aee2cc0..52040f070 100644 --- a/spec/features/stop_areas_spec.rb +++ b/spec/features/stop_areas_spec.rb @@ -18,14 +18,16 @@ describe "StopAreas", :type => :feature do context 'filtering' do it 'supports filtering by name' do - fill_in 'q[name_or_objectid_cont]', with: stop_areas.first.name + fill_in 'q[name_or_objectid_or_registration_number_cont]', + with: stop_areas.first.name 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 filtering by objectid' do - fill_in 'q[name_or_objectid_cont]', with: stop_areas.first.objectid + fill_in 'q[name_or_objectid_or_registration_number_cont]', + with: stop_areas.first.objectid click_button 'search-btn' expect(page).to have_content(stop_areas.first.name) expect(page).not_to have_content(stop_areas.last.name) |
