diff options
| author | Zog | 2018-04-13 16:01:27 +0200 |
|---|---|---|
| committer | cedricnjanga | 2018-04-16 06:23:04 -0700 |
| commit | 51125f25847db2bb2c654c1bbfd1fd39295693f6 (patch) | |
| tree | 8168ac5aa9d27c0deb75decf9968e664c0e44768 /spec | |
| parent | 9276a47e2ddccbde5aefca8e33f4c2b36057ef99 (diff) | |
| download | chouette-core-51125f25847db2bb2c654c1bbfd1fd39295693f6.tar.bz2 | |
Refs #6458; Fix Timetables autocompletion
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/controllers/autocomplete_time_tables_controller_spec.rb | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/spec/controllers/autocomplete_time_tables_controller_spec.rb b/spec/controllers/autocomplete_time_tables_controller_spec.rb index 85a8eb714..02bf83b6e 100644 --- a/spec/controllers/autocomplete_time_tables_controller_spec.rb +++ b/spec/controllers/autocomplete_time_tables_controller_spec.rb @@ -8,6 +8,11 @@ RSpec.describe AutocompleteTimeTablesController, type: :controller do let!(:time_table) { create :time_table, comment: 'écolà militaire' } let!(:blargh) { create :time_table, comment: 'écolàë militaire' } let!(:other_time_table) { create :time_table, comment: 'foo bar baz' } + let(:route){ create :route } + + before do + create :vehicle_journey, time_tables: [time_table, blargh, other_time_table], journey_pattern: route.full_journey_pattern + end describe 'GET #index' do it 'should be successful' do @@ -17,7 +22,7 @@ RSpec.describe AutocompleteTimeTablesController, type: :controller do context 'search by name' do it 'should be successful' do - get :index, referential_id: referential.id, q: {unaccented_comment_or_objectid_cont_any: 'écolà'}, :format => :json + get :index, referential_id: referential.id, q: {unaccented_comment_or_objectid_cont_any: 'écolà'}, format: :json expect(response).to be_success expect(assigns(:time_tables)).to include(time_table) expect(assigns(:time_tables)).to include(blargh) @@ -25,13 +30,33 @@ RSpec.describe AutocompleteTimeTablesController, type: :controller do end it 'should be accent insensitive' do - get :index, referential_id: referential.id, q: {unaccented_comment_or_objectid_cont_any: 'ecola'}, :format => :json + get :index, referential_id: referential.id, q: {unaccented_comment_or_objectid_cont_any: 'ecola'}, format: :json expect(response).to be_success expect(assigns(:time_tables)).to include(time_table) expect(assigns(:time_tables)).to include(blargh) expect(assigns(:time_tables)).to_not include(other_time_table) end end + + context "within a route" do + context 'search by name' do + it 'should be successful' do + get :index, referential_id: referential.id, q: {unaccented_comment_or_objectid_cont_any: 'écolà'}, route_id: route.id, format: :json + expect(response).to be_success + expect(assigns(:time_tables)).to include(time_table) + expect(assigns(:time_tables)).to include(blargh) + expect(assigns(:time_tables)).to_not include(other_time_table) + end + + it 'should be accent insensitive' do + get :index, referential_id: referential.id, q: {unaccented_comment_or_objectid_cont_any: 'ecola'}, route_id: route.id, format: :json + expect(response).to be_success + expect(assigns(:time_tables)).to include(time_table) + expect(assigns(:time_tables)).to include(blargh) + expect(assigns(:time_tables)).to_not include(other_time_table) + end + end + end end end |
