aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorAlban Peignier2017-12-20 22:20:02 +0100
committerGitHub2017-12-20 22:20:02 +0100
commitb012deb3ec8626d2d114dd725cfaeed363e08e25 (patch)
treede17c3b082391b104b868b9f591dbdd3acf2187b /spec
parent6b4b00a57d2c96ea9f2c663dd9892ccdd4fdbd29 (diff)
parentc683f940f274d9f9a9cbfb00e33c6f45a3526960 (diff)
downloadchouette-core-b012deb3ec8626d2d114dd725cfaeed363e08e25.tar.bz2
Merge pull request #163 from af83/5341-create-referential-vehiclejourneys-controller
Create ReferentialVehicleJourneysController. Refs #5341
Diffstat (limited to 'spec')
-rw-r--r--spec/controllers/referential_vehicle_journeys_controller_spec.rb43
1 files changed, 43 insertions, 0 deletions
diff --git a/spec/controllers/referential_vehicle_journeys_controller_spec.rb b/spec/controllers/referential_vehicle_journeys_controller_spec.rb
new file mode 100644
index 000000000..842a6665e
--- /dev/null
+++ b/spec/controllers/referential_vehicle_journeys_controller_spec.rb
@@ -0,0 +1,43 @@
+require "rails_helper"
+
+RSpec.describe ReferentialVehicleJourneysController, type: :controller do
+ login_user
+
+ before do
+ @user.organisation.update features: %w{referential_vehicle_journeys}
+ end
+
+ describe 'GET #index' do
+ it 'should be successful' do
+ get :index, referential_id: referential
+ expect(response).to be_success
+ end
+
+ it "refuse access when organisation does not have the feature 'referential_vehicle_journeys'" do
+ @user.organisation.update features: []
+
+ expect do
+ get :index, referential_id: referential
+ end.to raise_error(FeatureChecker::NotAuthorizedError)
+ end
+
+ it 'define Ransack search (alias @q)' do
+ get :index, referential_id: referential
+ expect(assigns[:q]).to be_an_instance_of(Ransack::Search)
+ end
+
+ it 'define @vehicle_journeys collection' do
+ vehicle_journey = FactoryGirl.create :vehicle_journey
+ get :index, referential_id: referential
+ expect(assigns[:vehicle_journeys]).to include(vehicle_journey)
+ end
+
+ it 'paginage @vehicle_journeys collection' do
+ FactoryGirl.create :vehicle_journey
+
+ get :index, referential_id: referential
+ expect(assigns[:vehicle_journeys].total_entries).to be(1)
+ end
+ end
+
+end