From 89f518891cff138643eaa14977aa20a3ef01930d Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Wed, 8 Nov 2017 18:37:47 +0100 Subject: ComplianceCheckSets#validated: Add response body On successful status update, respond with the `ComplianceCheckSet` object attributes. Otherwise, respond with an error JSON. Refs #4757 --- .../v1/compliance_check_sets_controller_spec.rb | 27 +++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'spec/controllers/api/v1') diff --git a/spec/controllers/api/v1/compliance_check_sets_controller_spec.rb b/spec/controllers/api/v1/compliance_check_sets_controller_spec.rb index e8e24b530..1c3784807 100644 --- a/spec/controllers/api/v1/compliance_check_sets_controller_spec.rb +++ b/spec/controllers/api/v1/compliance_check_sets_controller_spec.rb @@ -2,11 +2,36 @@ RSpec.describe Api::V1::ComplianceCheckSetsController, type: :controller do include_context 'iboo authenticated api user' describe "POST #validate" do + let(:check_set) { create(:compliance_check_set) } + it "calls #update_status on the ComplianceCheckSet" do - check_set = create(:compliance_check_set) expect_any_instance_of(ComplianceCheckSet).to receive(:update_status) patch :validated, id: check_set.id end + + context "responds with" do + render_views + + it "object JSON on #update_status true" do + allow_any_instance_of( + ComplianceCheckSet + ).to receive(:update_status).and_return(true) + + patch :validated, id: check_set.id + + expect(JSON.parse(response.body)['id']).to eq(check_set.id) + end + + it "error JSON on #update_status false" do + allow_any_instance_of( + ComplianceCheckSet + ).to receive(:update_status).and_return(false) + + patch :validated, id: check_set.id + + expect(response.body).to include('error') + end + end end end -- cgit v1.2.3