OSDN Git Service

t#30220:i18n system error message
[pettanr/pettanr.git] / spec / models / resource_picture_spec.rb
index e39a6ac..f614348 100644 (file)
@@ -824,6 +824,11 @@ describe ResourcePicture do
         r = @rp.store_picture_with_gif @imager\r
         r.should be_false\r
       end\r
+      it '全体エラーメッセージがセットされている' do\r
+        lambda {\r
+          r = @rp.store_picture_with_gif @imager\r
+        }.should change(@rp.errors[:base], :count)\r
+      end\r
       it 'gif変換判定は呼ばれていない' do\r
         ResourcePicture.any_instance.should_not_receive(:to_gif?).with(any_args)\r
         r = @rp.store_picture_with_gif @imager\r
@@ -839,6 +844,11 @@ describe ResourcePicture do
         r = @rp.store_picture_with_gif @imager\r
         r.should be_false\r
       end\r
+      it '全体エラーメッセージがセットされている' do\r
+        lambda {\r
+          r = @rp.store_picture_with_gif @imager\r
+        }.should change(@rp.errors[:base], :count)\r
+      end\r
       it 'gif画像の保存は呼ばれていない' do\r
         #本画像の保存があるので、一度は呼ばれる\r
         ResourcePicture.any_instance.should_receive(:store_picture).with(any_args).exactly(1)\r
@@ -859,6 +869,11 @@ describe ResourcePicture do
         r = @rp.store_picture_with_gif @imager\r
         r.should be_false\r
       end\r
+      it '全体エラーメッセージがセットされている' do\r
+        lambda {\r
+          r = @rp.store_picture_with_gif @imager\r
+        }.should change(@rp.errors[:base], :count)\r
+      end\r
     end\r
   end\r
   \r
@@ -926,7 +941,7 @@ describe ResourcePicture do
         ResourcePicture.any_instance.stub(:flag_thumbnail).with(any_args).and_return(1)\r
         @tmbimager = @imager.to_thumbnail\r
         ImagerTest.any_instance.stub(:to_thumbnail).with(any_args).and_return(@tmbimager)\r
-        PictureIO.resource_picture_io.stub(:put).with(@tmbimager.binary, '1.gif').and_return(false)\r
+        PictureIO.resource_picture_io.stub(:put).with(@tmbimager.binary, '1.gif').and_raise(PictureIO::Error)\r
       end\r
       it 'Falseを返す' do\r
         r = @rp.store_picture(@imager, '1.gif')\r
@@ -943,7 +958,7 @@ describe ResourcePicture do
         @tmbimager = @imager.to_thumbnail\r
         ImagerTest.any_instance.stub(:to_thumbnail).with(any_args).and_return(@tmbimager)\r
         PictureIO.resource_picture_io.stub(:put).with(@tmbimager.binary, '1.gif').and_return(true)\r
-        PictureIO.resource_picture_io.stub(:put).with(@imager.binary, '1.gif', 'full').and_return(false)\r
+        PictureIO.resource_picture_io.stub(:put).with(@imager.binary, '1.gif', 'full').and_raise(PictureIO::Error)\r
       end\r
       it 'Falseを返す' do\r
         r = @rp.store_picture(@imager, '1.gif')\r