aboutsummaryrefslogtreecommitdiffstats
path: root/spec/controllers/api/v1
diff options
context:
space:
mode:
authorTeddy Wing2017-11-08 18:37:47 +0100
committercedricnjanga2017-11-13 17:52:54 +0100
commit89f518891cff138643eaa14977aa20a3ef01930d (patch)
tree7eef684875ba54e6853ad5d6b32b9ea89fdafb0e /spec/controllers/api/v1
parent80f932d417744488c7dadc53d7369ca573f1fc61 (diff)
downloadchouette-core-89f518891cff138643eaa14977aa20a3ef01930d.tar.bz2
ComplianceCheckSets#validated: Add response body
On successful status update, respond with the `ComplianceCheckSet` object attributes. Otherwise, respond with an error JSON. Refs #4757
Diffstat (limited to 'spec/controllers/api/v1')
-rw-r--r--spec/controllers/api/v1/compliance_check_sets_controller_spec.rb27
1 files changed, 26 insertions, 1 deletions
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