diff options
| author | Zog | 2018-05-07 16:57:22 +0200 | 
|---|---|---|
| committer | Zog | 2018-05-07 16:57:22 +0200 | 
| commit | 430550b965035be3d78abad790e6c44fdc69087f (patch) | |
| tree | b5762d5055910c6ff14881c1f9101c0bfdc65ea5 /spec | |
| parent | fb4d1c66cb4c0cd83e183a13ca5f9ea44803631b (diff) | |
| download | chouette-core-430550b965035be3d78abad790e6c44fdc69087f.tar.bz2 | |
Refs #6960; Add a view to set the controls associated to each workbench
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/controllers/workgroups_controller_spec.rb | 40 | 
1 files changed, 40 insertions, 0 deletions
diff --git a/spec/controllers/workgroups_controller_spec.rb b/spec/controllers/workgroups_controller_spec.rb new file mode 100644 index 000000000..2f8565088 --- /dev/null +++ b/spec/controllers/workgroups_controller_spec.rb @@ -0,0 +1,40 @@ +RSpec.describe WorkgroupsController, :type => :controller do +  login_user + +  let(:workgroup) { create :workgroup } +  let(:workbench) { create :workbench, workgroup: workgroup } +  let(:compliance_control_set) { create :compliance_control_set, organisation: @user.organisation } + +  describe 'PATCH update' do +    let(:params){ +      { +        id: workgroup.id, +        workgroup: { +          workbenches_attributes: { +            "0" => { +              id: workbench.id, +              owner_compliance_control_set_ids: { +                import: compliance_control_set.id +              } +            } +          } +        } +      } +    } +    let(:request){ patch :update, params } + +    it 'should respond with 403' do +      expect(request).to have_http_status 403 +    end + +    context "when belonging to the owner" do +      before do +        workgroup.update owner: @user.organisation +      end +      it 'returns HTTP success' do +        expect(request).to be_redirect +        expect(workbench.reload.compliance_control_set(:import)).to eq compliance_control_set +      end +    end +  end +end  | 
