Skip to content
This repository was archived by the owner on Jan 30, 2018. It is now read-only.

Commit 8cc45b6

Browse files
committed
Fix bug when destroying pages. Also spec the Activity targets to track any future occurrence of this issue.
1 parent 64200bb commit 8cc45b6

File tree

2 files changed

+38
-3
lines changed

2 files changed

+38
-3
lines changed

app/models/page.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
class Page < RoleRecord
2-
has_many :notes, :dependent => :delete_all
3-
has_many :dividers, :dependent => :delete_all
4-
has_many :uploads, :dependent => :delete_all
2+
has_many :notes, :dependent => :destroy
3+
has_many :dividers, :dependent => :destroy
4+
has_many :uploads, :dependent => :destroy
55

66
has_many :slots, :class_name => 'PageSlot', :order => 'position ASC', :dependent => :delete_all
77

spec/models/activity_spec.rb

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
require 'spec_helper'
2+
3+
describe Activity do
4+
describe "target when deleting objects" do
5+
it "should still be valid when deleting core project objects" do
6+
7+
project = Factory.create(:project)
8+
Factory.create(:comment, :project => project)
9+
Factory.create(:conversation, :project => project)
10+
Factory.create(:task_list, :project => project)
11+
Factory.create(:upload, :project => project)
12+
page = Factory.create(:page, :project => project)
13+
14+
note = page.build_note({:name => 'Office Ettiquete'}).tap do |n|
15+
n.updated_by = project.user
16+
n.save
17+
end
18+
divider = page.build_note({:name => 'Office Ettiquete'}).tap do |n|
19+
n.updated_by = project.user
20+
n.save
21+
end
22+
23+
Activity.count.should_not == 0
24+
Activity.all.map{|a|a.target.nil?}.include?(true).should == false
25+
26+
Person.destroy_all
27+
Comment.destroy_all
28+
Conversation.destroy_all
29+
TaskList.destroy_all
30+
Page.destroy_all
31+
32+
Activity.all.map{|a|a.target.nil?}.include?(true).should == false
33+
end
34+
end
35+
end

0 commit comments

Comments
 (0)