From 430550b965035be3d78abad790e6c44fdc69087f Mon Sep 17 00:00:00 2001 From: Zog Date: Mon, 7 May 2018 16:57:22 +0200 Subject: Refs #6960; Add a view to set the controls associated to each workbench --- spec/controllers/workgroups_controller_spec.rb | 40 ++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 spec/controllers/workgroups_controller_spec.rb (limited to 'spec') 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 -- cgit v1.2.3