OSDN Git Service

t30350#:fix destroy
[pettanr/pettanr.git] / spec / models / story_spec.rb
index f1a1646..06a8f84 100644 (file)
@@ -1697,6 +1697,24 @@ describe Story do
           @story.destroy_and_shorten
         }.should change(Story, :count ).by(-1)
       end
+      it 'Trueを返す' do
+        r = @story.destroy_and_shorten
+        r.should be_true 
+      end
+    end
+    context '削除に失敗したとき' do
+      before do
+        Story.any_instance.stub(:destroy).and_return(false)
+      end
+      it 'ロールバックされる' do
+        lambda{
+          @story.destroy_and_shorten
+        }.should_not change(Story, :count )
+      end
+      it 'Falseを返す' do
+        r = @story.destroy_and_shorten
+        r.should be_false
+      end
     end
     #連携テスト。切り詰めが直接DBをいじる
     context '2件で先頭を削除したとき' do