aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorZog2017-12-26 11:23:53 +0100
committerZog2017-12-26 11:23:53 +0100
commitd3445d085b607544dc6355956cd228835258d612 (patch)
tree62588979f26e42e1cbbffab91690256281008b1c /spec
parent9fe0ca13d7caba486561f52557c1fa3d2f9f0a52 (diff)
downloadchouette-core-d3445d085b607544dc6355956cd228835258d612.tar.bz2
Refs #5382 @1h; Enable all area types for Stopareas in Routes
Given that the organisation has the matching feature.
Diffstat (limited to 'spec')
-rw-r--r--spec/controllers/autocomplete_stop_areas_controller_spec.rb24
-rw-r--r--spec/support/controller_spec_helper.rb15
2 files changed, 39 insertions, 0 deletions
diff --git a/spec/controllers/autocomplete_stop_areas_controller_spec.rb b/spec/controllers/autocomplete_stop_areas_controller_spec.rb
index 50fc877dd..2af471361 100644
--- a/spec/controllers/autocomplete_stop_areas_controller_spec.rb
+++ b/spec/controllers/autocomplete_stop_areas_controller_spec.rb
@@ -5,6 +5,8 @@ RSpec.describe AutocompleteStopAreasController, type: :controller do
let(:referential) { Referential.first }
let!(:stop_area) { create :stop_area, name: 'écolà militaire' }
+ let!(:zdep_stop_area) { create :stop_area, area_type: "zdep" }
+ let!(:not_zdep_stop_area) { create :stop_area, area_type: "lda" }
describe 'GET #index' do
it 'should be successful' do
@@ -26,4 +28,26 @@ RSpec.describe AutocompleteStopAreasController, type: :controller do
end
end
end
+
+ context "when searching from the route editor" do
+ let(:scope) { :route_editor }
+ let(:request){
+ get :index, referential_id: referential.id, scope: scope
+ }
+ it "should filter stop areas based on type" do
+ request
+ expect(assigns(:stop_areas)).to include(zdep_stop_area)
+ expect(assigns(:stop_areas)).to_not include(not_zdep_stop_area)
+ end
+
+ with_feature :route_stop_areas_all_types do
+ it "should not filter stop areas based on type" do
+ request
+ expect(assigns(:stop_areas)).to include(zdep_stop_area)
+ expect(assigns(:stop_areas)).to include(not_zdep_stop_area)
+ end
+ end
+ end
+
+
end
diff --git a/spec/support/controller_spec_helper.rb b/spec/support/controller_spec_helper.rb
index 1d0288dea..dbc7d582b 100644
--- a/spec/support/controller_spec_helper.rb
+++ b/spec/support/controller_spec_helper.rb
@@ -11,6 +11,21 @@ module ControllerSpecHelper
end
end
+ def with_feature feature, &block
+ context "with feature #{feature}" do
+ login_user
+ before(:each) do
+ organisation = @user.organisation
+ unless organisation.has_feature?(feature)
+ organisation.features << feature
+ organisation.save!
+ end
+ sign_in @user
+ end
+ context('', &block) if block_given?
+ end
+ end
+
end
RSpec.configure do |config|