diff options
| author | Alban Peignier | 2018-05-10 20:54:52 +0200 |
|---|---|---|
| committer | Alban Peignier | 2018-05-10 20:54:52 +0200 |
| commit | 6f624a7ca68600e93aae71f98182dfeb8c082674 (patch) | |
| tree | 769a07779cb6f58727c2fb8ac7497ce11042a7fe | |
| parent | 65afd2cfe722e57241d27cf8a1069ca67aafc3e0 (diff) | |
| download | chouette-core-6f624a7ca68600e93aae71f98182dfeb8c082674.tar.bz2 | |
Test WorkbenchesController without workbenches.update permission. Refs #69606960-workgroup-edition
| -rw-r--r-- | spec/controllers/workbenches_controller_spec.rb | 6 | ||||
| -rw-r--r-- | spec/support/controller_spec_helper.rb | 12 |
2 files changed, 16 insertions, 2 deletions
diff --git a/spec/controllers/workbenches_controller_spec.rb b/spec/controllers/workbenches_controller_spec.rb index d9403d7b0..8478b0a7b 100644 --- a/spec/controllers/workbenches_controller_spec.rb +++ b/spec/controllers/workbenches_controller_spec.rb @@ -25,8 +25,10 @@ RSpec.describe WorkbenchesController, :type => :controller do } let(:request){ patch :update, id: workbench.id, workbench: workbench_params } - it 'should respond with 403' do - expect(request).to have_http_status 403 + without_permission "workbenches.update" do + it 'should respond with 403' do + expect(request).to have_http_status 403 + end end with_permission "workbenches.update" do diff --git a/spec/support/controller_spec_helper.rb b/spec/support/controller_spec_helper.rb index dbc7d582b..ac4bfe06c 100644 --- a/spec/support/controller_spec_helper.rb +++ b/spec/support/controller_spec_helper.rb @@ -11,6 +11,18 @@ module ControllerSpecHelper end end + def without_permission permission, &block + context "without permission #{permission}" do + login_user + before(:each) do + @user.permissions.delete permission + @user.save! + sign_in @user + end + context('', &block) if block_given? + end + end + def with_feature feature, &block context "with feature #{feature}" do login_user |
