aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobert2017-10-10 16:05:02 +0200
committerRobert2017-10-12 17:49:51 +0200
commit60c26e2e636ad43ab63208886fdc8c72bdca49c7 (patch)
tree7451b8542c412cdbfd862ec43630fb3a91d3d99f
parenta383a52049de5777db04fbb16db45a1ed2957f7f (diff)
downloadchouette-core-60c26e2e636ad43ab63208886fdc8c72bdca49c7.tar.bz2
Refs: #4709@1h; Preparing tests for correctly copy of data and migration
-rw-r--r--lib/compliance_control_set_copier.rb3
-rw-r--r--spec/lib/compliance_control_set_copier_spec.rb28
2 files changed, 25 insertions, 6 deletions
diff --git a/lib/compliance_control_set_copier.rb b/lib/compliance_control_set_copier.rb
index 0a688c964..a9891ce6d 100644
--- a/lib/compliance_control_set_copier.rb
+++ b/lib/compliance_control_set_copier.rb
@@ -36,7 +36,8 @@ class ComplianceControlSetCopier
# Copy Blocks:
def make_cck_block cc_block
cck_set.compliance_check_blocks.create(
- name: name_with_refid(cc_block.name)).tap do | cck_block |
+ name: name_with_refid(cc_block.name),
+ condition_attributes: cc_block.condition_attributes).tap do | cck_block |
relink_checks_to_block cc_block, cck_block
end
end
diff --git a/spec/lib/compliance_control_set_copier_spec.rb b/spec/lib/compliance_control_set_copier_spec.rb
index b329018aa..bdf2494d0 100644
--- a/spec/lib/compliance_control_set_copier_spec.rb
+++ b/spec/lib/compliance_control_set_copier_spec.rb
@@ -73,12 +73,30 @@ RSpec.describe ComplianceControlSetCopier do
let( :cc_block ){ create :compliance_control_block, compliance_control_set: cc_set }
let!( :control ){ create :compliance_control,
- compliance_control_set: cc_set,
- compliance_control_block: cc_block,
- name: 'control' }
+ compliance_control_set: cc_set,
+ compliance_control_block: cc_block,
+ name: 'control' }
- it 'indeed' do
- require 'pry'; binding.pry
+ let( :cck_set ) { ComplianceCheckSet.last }
+ let( :cck_block ) { ComplianceCheckBlock.last }
+ let( :cck ) { ComplianceCheck.last }
+
+ it 'into the compliance_check nodes' do
+ subject.copy(cc_set.id, ref.id)
+
+ # Set
+ expect( cck_set.name ).to eq(mk_name(cc_set.name))
+
+ # Block
+ expect( cck_block.name ).to eq(mk_name(cc_block.name))
+ expect( cck_block.condition_attributes ).to eq(cc_block.condition_attributes)
+
+ # Control/Check
+ att_names = %w{ type control_attributes code criticity comment origin_code }
+ expected = control.attributes.values_at(*att_names) << mk_name(control.name)
+ actual = cck.attributes.values_at(*(att_names << 'name'))
+
+ expect( actual ).to eq( expected )
end
end