OSDN Git Service

t#32046:add sheet
[pettanr/pettanr.git] / spec / models / comic_spec.rb
index ce70711..755c7d0 100644 (file)
@@ -46,6 +46,7 @@ describe Comic do
         @comic.should_not be_valid
       end
     end
+    
     context 'visibleを検証するとき' do
       it 'nullなら失敗する' do
         @comic.visible = nil
@@ -60,6 +61,22 @@ describe Comic do
         @comic.should_not be_valid
       end
     end
+    
+    context 'author_idを検証するとき' do
+      it 'nullなら失敗する' do
+        @comic.author_id = nil
+        @comic.should_not be_valid
+      end
+      it '数値でなければ失敗する' do
+        @comic.author_id = 'a'
+        @comic.should_not be_valid
+      end
+      it '存在する作家でなければ失敗する' do
+        @comic.author_id = 0
+        @comic.should_not be_valid
+      end
+    end
+    
   end
   
   describe '文字コード検証に於いて' do
@@ -635,7 +652,7 @@ describe Comic do
       @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id
       @sbt = FactoryGirl.create :speech_balloon_template
       @comic = FactoryGirl.create :comic, :author_id => @author.id, :visible => 1
-      @story = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id
+      @story = FactoryGirl.create :story, :comic_id => @comic.id
     end
     it 'ストーリーを含んでいる' do
       r = Comic.list.to_json Comic.list_json_opt
@@ -750,7 +767,7 @@ describe Comic do
       @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id
       @sbt = FactoryGirl.create :speech_balloon_template
       @comic = FactoryGirl.create :comic, :author_id => @author.id, :visible => 1
-      @story = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id
+      @story = FactoryGirl.create :story, :comic_id => @comic.id
     end
     it 'ストーリーを含んでいる' do
       r = Comic.show(@comic.id, @author).to_json Comic.show_json_opt
@@ -769,9 +786,9 @@ describe Comic do
   describe '削除に於いて' do
     before do
       @comic = FactoryGirl.create :comic, :author_id => @author.id
-      @story = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id
+      @story = FactoryGirl.create :story, :comic_id => @comic.id
       @other_comic = FactoryGirl.create :comic, :author_id => @author.id
-      @other_story = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @other_comic.id
+      @other_story = FactoryGirl.create :story, :comic_id => @other_comic.id
     end
     context 'つつがなく終わるとき' do
       it '自身を削除する' do