Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Implement dependent destroy between lab and default_deadline, with test

  • Loading branch information...
commit 40eebca83006b944d17e24d74288556e4e5f946d 1 parent 7b0607e
@anjonas anjonas authored
Showing with 10 additions and 1 deletion.
  1. +1 −1  app/models/lab.rb
  2. +9 −0 spec/models/lab_spec.rb
View
2  app/models/lab.rb
@@ -5,7 +5,7 @@ class Lab < ActiveRecord::Base
has_many :lab_has_groups
has_many :lab_groups, through: :lab_has_groups
has_many :submissions
- has_many :default_deadlines
+ has_many :default_deadlines, dependent: :destroy
has_one :initial_lab_commit_for_lab
has_one :initial_lab_commit, through: :initial_lab_commit_for_lab
View
9 spec/models/lab_spec.rb
@@ -143,4 +143,13 @@
lab.description.should eq(lab.lab_description.description)
end
end
+
+ describe "Dependent destroy" do
+ it "should not be possible for a lab_default_dealine to exist without a lab" do
+ lab = Factory.create(:lab)
+ ldd = Factory.create(:default_deadline, lab: lab)
+ lab.destroy
+ lambda{ldd.reload}.should raise_error(ActiveRecord::RecordNotFound)
+ end
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.