diff options
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/controllers/workbenches_controller_spec.rb | 31 | ||||
| -rw-r--r-- | spec/controllers/workgroups_controller_spec.rb | 5 | 
2 files changed, 34 insertions, 2 deletions
diff --git a/spec/controllers/workbenches_controller_spec.rb b/spec/controllers/workbenches_controller_spec.rb index bc0843a07..c6a37a8c0 100644 --- a/spec/controllers/workbenches_controller_spec.rb +++ b/spec/controllers/workbenches_controller_spec.rb @@ -1,7 +1,10 @@  require 'spec_helper'  RSpec.describe WorkbenchesController, :type => :controller do -  let(:workbench) { create :workbench } +  login_user + +  let(:workbench) { create :workbench, organisation: @user.organisation } +  let(:compliance_control_set) { create :compliance_control_set, organisation: @user.organisation }    describe "GET show" do      it "returns http success" do @@ -10,4 +13,30 @@ RSpec.describe WorkbenchesController, :type => :controller do      end    end +  describe 'PATCH update' do +    let(:workbench_params){ +      { +        owner_compliance_control_set_ids: { +          import: compliance_control_set.id, +          merge: 2**64/2 - 1 +        } +      } +    } +    let(:request){ patch :update, id: workbench.id, workbench: workbench_params } + +    it 'should respond with 403' do +      expect(request).to have_http_status 403 +    end + +    with_permission "workbenches.update" do +      it 'returns HTTP success' do +        expect(request).to redirect_to [workbench] +        p workbench.reload.owner_compliance_control_set_ids +        expect(workbench.reload.compliance_control_set(:import)).to eq compliance_control_set +        # Let's check we support Bigint +        expect(workbench.reload.owner_compliance_control_set_ids["merge"]).to eq (2**64/2 - 1).to_s +      end +    end +  end +  end diff --git a/spec/controllers/workgroups_controller_spec.rb b/spec/controllers/workgroups_controller_spec.rb index 2f8565088..0841b6081 100644 --- a/spec/controllers/workgroups_controller_spec.rb +++ b/spec/controllers/workgroups_controller_spec.rb @@ -14,7 +14,8 @@ RSpec.describe WorkgroupsController, :type => :controller do              "0" => {                id: workbench.id,                owner_compliance_control_set_ids: { -                import: compliance_control_set.id +                import: compliance_control_set.id, +                merge: 2**64/2 - 1                }              }            } @@ -34,6 +35,8 @@ RSpec.describe WorkgroupsController, :type => :controller do        it 'returns HTTP success' do          expect(request).to be_redirect          expect(workbench.reload.compliance_control_set(:import)).to eq compliance_control_set +        # Let's check we support Bigint +        expect(workbench.reload.owner_compliance_control_set_ids["merge"]).to eq (2**64/2 - 1).to_s        end      end    end  | 
