genki-dm-has-versions 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Rakefile +1 -1
- data/lib/dm-has-versions/has/versions.rb +5 -0
- data/spec/dm-has-versions_spec.rb +23 -0
- data/spec/fixture/app/models/comment.rb +8 -0
- metadata +1 -1
data/Rakefile
CHANGED
@@ -41,6 +41,12 @@ describe "dm-has-versions" do
|
|
41
41
|
@story.versions.should be_empty
|
42
42
|
end
|
43
43
|
|
44
|
+
it "should not generate versions if the story was not modified" do
|
45
|
+
@story.versions.should be_empty
|
46
|
+
@story.save
|
47
|
+
@story.versions.should be_empty
|
48
|
+
end
|
49
|
+
|
44
50
|
describe "destory and revert of versions" do
|
45
51
|
before do
|
46
52
|
@story.update_attributes :title => 'test-2'
|
@@ -86,6 +92,23 @@ describe "dm-has-versions" do
|
|
86
92
|
@story.title.should == "test-2"
|
87
93
|
@story.dirty_attributes[Story.title].should be_nil
|
88
94
|
end
|
95
|
+
|
96
|
+
it "should destroy all versions if the story was dstroyed" do
|
97
|
+
@story.versions.should_not be_empty
|
98
|
+
@story.destroy
|
99
|
+
Story::Version.all(:story_id => @story.id).should be_empty
|
100
|
+
end
|
101
|
+
|
102
|
+
it "should keep child_models while version control" do
|
103
|
+
@story.comments.create :body => "Hey, maiha!"
|
104
|
+
@story.comments.count.should == 1
|
105
|
+
story = Story.get(@story.id)
|
106
|
+
story.version.should == 3
|
107
|
+
story.version = 1
|
108
|
+
story.title.should == 'test-2'
|
109
|
+
story.comments.should_not be_empty
|
110
|
+
story.comments.last.body.should == "Hey, maiha!"
|
111
|
+
end
|
89
112
|
end
|
90
113
|
end
|
91
114
|
end
|