diff options
| author | Teddy Wing | 2017-11-09 11:46:42 +0100 |
|---|---|---|
| committer | cedricnjanga | 2017-11-13 17:52:54 +0100 |
| commit | 8602bf7a265f32fc84f609eca790c9a76a723be0 (patch) | |
| tree | 11f38cf4badd0d5d63ca479309dd84fd8c3d0d81 | |
| parent | 406726c7d9f1d98a36e263c57a1fa361003cface (diff) | |
| download | chouette-core-8602bf7a265f32fc84f609eca790c9a76a723be0.tar.bz2 | |
Revert "ComplianceCheckSet#update_status: Should return a boolean"
This reverts commit b7477e28f90c961079c7b12c4992071cbc11b2d6.
This logic isn't right. We should return true/false based on the result
of `update`, as in, whether the value was able to be updated, instead of
on the contents of the status.
| -rw-r--r-- | app/models/compliance_check_set.rb | 10 | ||||
| -rw-r--r-- | spec/models/compliance_check_set_spec.rb | 22 |
2 files changed, 2 insertions, 30 deletions
diff --git a/app/models/compliance_check_set.rb b/app/models/compliance_check_set.rb index 66ef6822e..062c5f4a4 100644 --- a/app/models/compliance_check_set.rb +++ b/app/models/compliance_check_set.rb @@ -23,12 +23,10 @@ class ComplianceCheckSet < ActiveRecord::Base case resource.status when 'ERROR' update(status: 'failed') - - return false + return when 'WARNING' update(status: 'warning') - - return false + return else resource.status end @@ -36,11 +34,7 @@ class ComplianceCheckSet < ActiveRecord::Base if all_statuses_are_ok(statuses) update(status: 'successful') - - return true end - - false end private diff --git a/spec/models/compliance_check_set_spec.rb b/spec/models/compliance_check_set_spec.rb index a77795a86..92b052b53 100644 --- a/spec/models/compliance_check_set_spec.rb +++ b/spec/models/compliance_check_set_spec.rb @@ -63,27 +63,5 @@ RSpec.describe ComplianceCheckSet, type: :model do expect(check_set.status).to eq('warning') end - - it "returns true when setting :status to successful" do - check_set = create(:compliance_check_set) - create( - :compliance_check_resource, - compliance_check_set: check_set, - status: 'OK' - ) - - expect(check_set.update_status).to be true - end - - it "returns false when setting :status to anything except successful" do - check_set = create(:compliance_check_set) - create( - :compliance_check_resource, - compliance_check_set: check_set, - status: 'ERROR' - ) - - expect(check_set.update_status).to be false - end end end |
