diff options
| author | Xinhui | 2017-09-26 11:58:17 +0200 |
|---|---|---|
| committer | Xinhui | 2017-09-27 15:39:16 +0200 |
| commit | b8402fc9803db04b029a22c5bd9d33ee756ff4ec (patch) | |
| tree | 7e4ebea32ded3a12fbce1f7eed55dbb08c6dc7ea | |
| parent | 5724f7c02a5238ef727e0c1674f2c69424563527 (diff) | |
| download | chouette-core-b8402fc9803db04b029a22c5bd9d33ee756ff4ec.tar.bz2 | |
Add dependent destroy on associations
| -rw-r--r-- | app/models/compliance_control_set.rb | 4 | ||||
| -rw-r--r-- | spec/models/compliance_control_set_spec.rb | 2 | ||||
| -rw-r--r-- | spec/models/compliance_control_spec.rb | 1 |
3 files changed, 3 insertions, 4 deletions
diff --git a/app/models/compliance_control_set.rb b/app/models/compliance_control_set.rb index 4dafd48c7..f8f491cba 100644 --- a/app/models/compliance_control_set.rb +++ b/app/models/compliance_control_set.rb @@ -1,11 +1,9 @@ class ComplianceControlSet < ActiveRecord::Base belongs_to :organisation - has_many :compliance_controls + has_many :compliance_controls, dependent: :destroy validates :name, presence: true - scope :where_updated_at_between, ->(start_date, end_date) do where('updated_at BETWEEN ? AND ?', start_date, end_date) end - end diff --git a/spec/models/compliance_control_set_spec.rb b/spec/models/compliance_control_set_spec.rb index ededec5e0..edc684bbc 100644 --- a/spec/models/compliance_control_set_spec.rb +++ b/spec/models/compliance_control_set_spec.rb @@ -6,7 +6,7 @@ RSpec.describe ComplianceControlSet, type: :model do end it { should belong_to :organisation } - it { should have_many :compliance_controls } + it { should have_many(:compliance_controls).dependent(:destroy) } it { should validate_presence_of :name } end diff --git a/spec/models/compliance_control_spec.rb b/spec/models/compliance_control_spec.rb index c8797b938..d65e654cc 100644 --- a/spec/models/compliance_control_spec.rb +++ b/spec/models/compliance_control_spec.rb @@ -6,6 +6,7 @@ RSpec.describe ComplianceControl, type: :model do end it { should belong_to :compliance_control_set } + it { should has_one(:compliance_control_block).dependent(:destroy) } } it { should validate_presence_of :criticity } it { should validate_presence_of :name } |
