aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2018-04-25 16:00:17 +0200
committerJohan Van Ryseghem2018-04-26 15:35:54 +0200
commit86eb5008e14dfc2d4471aaf409de813f5840e7ac (patch)
treeb576ffdd188c819256941e8aa45406c4c9fc0173
parent1aeb36eb62d6cae25c40f3a99ff442fa9fe965fb (diff)
downloadchouette-core-86eb5008e14dfc2d4471aaf409de813f5840e7ac.tar.bz2
StopAreas#index: Filter by registration number
The input that filters by name and objectid now also needs to filter by registration number. Refs #6681
-rw-r--r--app/views/stop_areas/_filters.html.slim4
-rw-r--r--spec/controllers/stop_areas_controller_spec.rb25
2 files changed, 28 insertions, 1 deletions
diff --git a/app/views/stop_areas/_filters.html.slim b/app/views/stop_areas/_filters.html.slim
index caa264d5e..cca48bb17 100644
--- a/app/views/stop_areas/_filters.html.slim
+++ b/app/views/stop_areas/_filters.html.slim
@@ -1,7 +1,9 @@
= search_form_for @q, url: stop_area_referential_stop_areas_path(@stop_area_referential), html: {method: :get}, class: 'form form-filter' do |f|
.ffg-row
.input-group.search_bar class=filter_item_class(params[:q], :name_or_objectid_cont)
- = f.search_field :name_or_objectid_cont, placeholder: t('.name_or_objectid'), class: 'form-control'
+ = f.search_field :name_or_objectid_or_registration_number_cont,
+ placeholder: t('.name_or_objectid'),
+ class: 'form-control'
span.input-group-btn
button.btn.btn-default#search-btn type='submit'
span.fa.fa-search
diff --git a/spec/controllers/stop_areas_controller_spec.rb b/spec/controllers/stop_areas_controller_spec.rb
index f39ac5776..a67b0e2e6 100644
--- a/spec/controllers/stop_areas_controller_spec.rb
+++ b/spec/controllers/stop_areas_controller_spec.rb
@@ -4,6 +4,31 @@ 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
+ end
+
describe 'PUT deactivate' do
let(:request){ put :deactivate, id: stop_area.id, stop_area_referential_id: stop_area_referential.id }