diff options
| -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 | 
