OSDN Git Service

t#32046:add sheet
[pettanr/pettanr.git] / spec / models / story_sheet_spec.rb
index b00d8a9..c708a7e 100644 (file)
@@ -23,7 +23,7 @@ describe StorySheet do
   describe '検証に於いて' do
     before do
       @comic = FactoryGirl.create :comic, :author_id => @author.id
-      @story = FactoryGirl.create :story, :comic_id => @comic.id, :author_id => @author.id, :visible => 1
+      @story = FactoryGirl.create :story, :comic_id => @comic.id, :visible => 1
       @sheet = FactoryGirl.create :sheet, :author_id => @author.id
       @story_sheet = FactoryGirl.build :story_sheet, :author_id => @author.id, :story_id => @story.id, :sheet_id => @sheet.id
     end
@@ -105,7 +105,7 @@ describe StorySheet do
   describe 'デフォルト値補充に於いて' do
     before do
       @comic = FactoryGirl.create :comic, :author_id => @author.id
-      @story = FactoryGirl.create :story, :comic_id => @comic.id, :author_id => @author.id, :visible => 1
+      @story = FactoryGirl.create :story, :comic_id => @comic.id, :visible => 1
       @sheet = FactoryGirl.create :sheet, :author_id => @author.id
     end
     
@@ -121,7 +121,7 @@ describe StorySheet do
   describe '上書き補充に於いて' do
     before do
       @comic = FactoryGirl.create :comic, :author_id => @author.id
-      @story = FactoryGirl.create :story, :comic_id => @comic.id, :author_id => @author.id, :visible => 1
+      @story = FactoryGirl.create :story, :comic_id => @comic.id, :visible => 1
       @sheet = FactoryGirl.create :sheet, :author_id => @author.id
     end
     
@@ -139,11 +139,11 @@ describe StorySheet do
   describe '所持判定に於いて' do
     before do
       @comic = FactoryGirl.create :comic, :author_id => @author.id
-      @story = FactoryGirl.create :story, :comic_id => @comic.id, :author_id => @author.id, :visible => 1
+      @story = FactoryGirl.create :story, :comic_id => @comic.id, :visible => 1
       @sheet = FactoryGirl.create :sheet, :author_id => @author.id
       @story_sheet = FactoryGirl.create :story_sheet, :author_id => @author.id, :story_id => @story.id, :sheet_id => @sheet.id
       @comico = FactoryGirl.create :comic, :author_id => @other_author.id
-      @storyo = FactoryGirl.create :story, :comic_id => @comico.id, :author_id => @other_author.id
+      @storyo = FactoryGirl.create :story, :comic_id => @comico.id
       @sheeto = FactoryGirl.create :sheet, :author_id => @other_author.id
       @story_sheeto = FactoryGirl.create :story_sheet, :author_id => @other_author.id, :story_id => @storyo.id, :sheet_id => @sheeto.id
     end
@@ -180,7 +180,7 @@ describe StorySheet do
   describe '閲覧許可に於いて' do
     before do
       @comic = FactoryGirl.create :comic, :author_id => @author.id
-      @story = FactoryGirl.create :story, :comic_id => @comic.id, :author_id => @author.id, :visible => 1
+      @story = FactoryGirl.create :story, :comic_id => @comic.id, :visible => 1
       @sheet = FactoryGirl.create :sheet, :author_id => @author.id
       @story_sheet = FactoryGirl.create :story_sheet, :author_id => @author.id, :story_id => @story.id, :sheet_id => @sheet.id
     end
@@ -260,90 +260,47 @@ describe StorySheet do
   describe 'プレイリスト取得に於いて' do
     before do
       @comic = FactoryGirl.create :comic, :author_id => @author.id
-      @story = FactoryGirl.create :story, :comic_id => @comic.id, :author_id => @author.id, :visible => 1
+      @story = FactoryGirl.create :story, :comic_id => @comic.id, :visible => 1
       @sheet = FactoryGirl.create :sheet, :author_id => @author.id
-      @sheet2 = FactoryGirl.create :sheet, :author_id => @author.id, :visible => 0
       @story_sheet = FactoryGirl.create :story_sheet, :author_id => @author.id, :story_id => @story.id, :sheet_id => @sheet.id
-      @other_comic = FactoryGirl.create :comic, :author_id => @other_author.id
-      @other_story = FactoryGirl.create :story, :comic_id => @other_comic.id, :author_id => @other_author.id, :visible => 1
-      @other_sheet = FactoryGirl.create :sheet, :author_id => @other_author.id, :visible => 1
     end
-    context 'offset補正について' do
-      it '文字列から数値に変換される' do
-        StorySheet.offset(100, '8').should eq 8
-      end
-      it 'nilの場合は0になる' do
-        StorySheet.offset(100).should eq 0
-      end
-      #投稿された用紙数以上の値が指定されたときは、最後の用紙だけになる
-      #最後の用紙とは、用紙数‐1.
-      it '1件のときオフセット1なら0になる' do
-        StorySheet.offset(1, '1').should eq 0
-      end
-      it '5件のときオフセット5なら4になる' do
-        StorySheet.offset(5, '5').should eq 4
-      end
-      # 負の値が指定されたときは、最後の用紙から数えて用紙を飛ばして表示する。
-      #-4のときは、最後から4つの用紙を表示する。 
-      it '2件のときオフセット-1なら1になる' do
-        StorySheet.offset(2, '-1').should eq 1
-      end
-      it '5件のときオフセット-2なら3になる' do
-        StorySheet.offset(5, '-2').should eq 3
-      end
-      # 最終的なが負になるなど、不正な値が入ったときは0となる。 
-      it '2件のときオフセット-5なら0になる' do
-        StorySheet.offset(2, '-5').should eq 0
-      end
-    end
-    context 'sheet_count補正について' do
-      it '文字列から数値に変換される' do
-        StorySheet.sheet_count(100, '7').should eq 7
-      end
-      it 'nilの場合はStorySheet.default_sheet_sizeになる' do
-        StorySheet.sheet_count(100).should eq StorySheet.default_sheet_size
+    context 'つつがなく終わるとき' do
+      it '用紙に単体取得を問い合わせている' do
+        Sheet.stub(:show).with(any_args).and_return(@sheet)
+        Sheet.should_receive(:show).with(any_args).exactly(1)
+        r = StorySheet.play_sheet @story, @author
       end
-      it '0以下の場合はStorySheet.default_sheet_sizeになる' do
-        StorySheet.sheet_count(100, '0').should eq StorySheet.default_sheet_size
+      it '用紙を返す' do
+        c = StorySheet.play_sheet @story, @author
+        c.should eq @sheet
       end
-      it 'StorySheet.max_sheet_sizeを超えた場合はStorySheet.max_sheet_sizeになる' do
-        StorySheet.sheet_count(100, '1000').should eq StorySheet.max_sheet_size
+      it '削除された用紙は含んでいない' do
+        @sheet2 = FactoryGirl.create :sheet, :author_id => @author.id
+        h = FactoryGirl.create :story_sheet, :author_id => @author.id, :story_id => @story.id, :sheet_id => @sheet2.id, :t => 1
+        @sheet2.destroy
+        c = StorySheet.play_sheet @story, @author, 2
+        c.should eq nil
       end
     end
-    it 'リストを返す' do
-      c = StorySheet.play_list @story, @author
-      c.should eq [@story_sheet]
-    end
-    it 't順で並んでいる' do
-      #公開ストーリーの公開用紙は(他人のストーリーであっても)含んでいる
-      v = FactoryGirl.create :story_sheet, :author_id => @author.id, :story_id => @story.id, :sheet_id => @sheet.id, :t => 1
-      c = StorySheet.play_list @story, @author
-      c.should eq [ @story_sheet, v]
-    end
-    it '非公開の用紙は含んでいる' do
-      h = FactoryGirl.create :story_sheet, :author_id => @author.id, :story_id => @story.id, :sheet_id => @sheet2.id, :t => 1
-      c = StorySheet.play_list @story, @author
-      c.should eq [ @story_sheet, h]
-    end
-    context 'DBに5件あって1ページの件数を2件に変えたとして' do
+    context 'DBに5件あったとして' do
       before do
-        @story_sheet2 = FactoryGirl.create :story_sheet, :author_id => @author.id, :story_id => @story.id, :sheet_id => @sheet.id, :t => 1
-        @story_sheet3 = FactoryGirl.create :story_sheet, :author_id => @author.id, :story_id => @story.id, :sheet_id => @sheet.id, :t => 2
-        @story_sheet4 = FactoryGirl.create :story_sheet, :author_id => @author.id, :story_id => @story.id, :sheet_id => @sheet.id, :t => 3
-        @story_sheet5 = FactoryGirl.create :story_sheet, :author_id => @author.id, :story_id => @story.id, :sheet_id => @sheet.id, :t => 4
-      end
-      it 'offset=0なら末尾2件を返す' do
+        @sheet2 = FactoryGirl.create :sheet, :author_id => @author.id
+        @story_sheet2 = FactoryGirl.create :story_sheet, :author_id => @author.id, :story_id => @story.id, :sheet_id => @sheet2.id, :t => 1
+        @sheet3 = FactoryGirl.create :sheet, :author_id => @author.id
+        @story_sheet3 = FactoryGirl.create :story_sheet, :author_id => @author.id, :story_id => @story.id, :sheet_id => @sheet3.id, :t => 2
+        @sheet4 = FactoryGirl.create :sheet, :author_id => @author.id
+        @story_sheet4 = FactoryGirl.create :story_sheet, :author_id => @author.id, :story_id => @story.id, :sheet_id => @sheet4.id, :t => 3
+        @sheet5 = FactoryGirl.create :sheet, :author_id => @author.id
+        @story_sheet5 = FactoryGirl.create :story_sheet, :author_id => @author.id, :story_id => @story.id, :sheet_id => @sheet5.id, :t => 4
+      end
+      it 'page=1なら先頭を返す' do
         #時系列で並んでいる
-        c = StorySheet.play_list( @story, @author, 0, 2)
-        c.should eq [@story_sheet, @story_sheet2]
+        c = StorySheet.play_sheet( @story, @author, 1)
+        c.should eq @sheet
       end
-      it 'offset=2なら中間2件を返す' do
-        c = StorySheet.play_list(@story, @author, 2, 2)
-        c.should eq [@story_sheet3, @story_sheet4]
-      end
-      it 'offset=4なら先頭1件を返す' do
-        c = StorySheet.play_list(@story, @author, 4, 2)
-        c.should eq [@story_sheet5]
+      it 'page=5なら末尾を返す' do
+        c = StorySheet.play_sheet(@story, @author, 5)
+        c.should eq @sheet5
       end
     end
   end
@@ -351,14 +308,14 @@ describe StorySheet do
   describe '一覧取得に於いて' do
     before do
       @comic = FactoryGirl.create :comic, :author_id => @author.id
-      @story = FactoryGirl.create :story, :comic_id => @comic.id, :author_id => @author.id, :visible => 1
+      @story = FactoryGirl.create :story, :comic_id => @comic.id, :visible => 1
       @sheet = FactoryGirl.create :sheet, :author_id => @author.id
       @story_sheet = FactoryGirl.create :story_sheet, :author_id => @author.id, :story_id => @story.id, :sheet_id => @sheet.id
       @other_comic = FactoryGirl.create :comic, :author_id => @other_author.id
-      @other_story = FactoryGirl.create :story, :comic_id => @other_comic.id, :author_id => @other_author.id, :visible => 1
+      @other_story = FactoryGirl.create :story, :comic_id => @other_comic.id, :visible => 1
       @other_sheet = FactoryGirl.create :sheet, :author_id => @other_author.id
       @hidden_comic = FactoryGirl.create :comic, :author_id => @author.id
-      @hidden_story = FactoryGirl.create :story, :author_id => @author.id, :visible => 0
+      @hidden_story = FactoryGirl.create :story, :visible => 0
     end
     context 'page補正について' do
       it '文字列から数値に変換される' do
@@ -430,14 +387,14 @@ describe StorySheet do
   describe '自分のスト紙一覧取得に於いて' do
     before do
       @comic = FactoryGirl.create :comic, :author_id => @author.id
-      @story = FactoryGirl.create :story, :comic_id => @comic.id, :author_id => @author.id, :visible => 1
+      @story = FactoryGirl.create :story, :comic_id => @comic.id, :visible => 1
       @sheet = FactoryGirl.create :sheet, :author_id => @author.id
       @story_sheet = FactoryGirl.create :story_sheet, :author_id => @author.id, :story_id => @story.id, :sheet_id => @sheet.id
       @other_comic = FactoryGirl.create :comic, :author_id => @other_author.id
-      @other_story = FactoryGirl.create :story, :comic_id => @other_comic.id, :author_id => @other_author.id, :visible => 1
+      @other_story = FactoryGirl.create :story, :comic_id => @other_comic.id, :visible => 1
       @other_sheet = FactoryGirl.create :sheet, :author_id => @other_author.id, :visible => 1
       @hcomic = FactoryGirl.create :comic, :author_id => @author.id
-      @hstory = FactoryGirl.create :story, :comic_id => @comic.id, :author_id => @author.id, :visible => 0
+      @hstory = FactoryGirl.create :story, :comic_id => @comic.id, :visible => 0
       @hsheet = FactoryGirl.create :sheet, :author_id => @author.id, :visible => 0
     end
     context 'つつがなく終わるとき' do
@@ -497,11 +454,11 @@ describe StorySheet do
   describe '他作家のスト紙一覧取得に於いて' do
     before do
       @comic = FactoryGirl.create :comic, :author_id => @author.id
-      @story = FactoryGirl.create :story, :comic_id => @comic.id, :author_id => @author.id, :visible => 1
+      @story = FactoryGirl.create :story, :comic_id => @comic.id, :visible => 1
       @sheet = FactoryGirl.create :sheet, :author_id => @author.id
       @story_sheet = FactoryGirl.create :story_sheet, :author_id => @author.id, :story_id => @story.id, :sheet_id => @sheet.id
       @other_comic = FactoryGirl.create :comic, :author_id => @other_author.id
-      @other_story = FactoryGirl.create :story, :comic_id => @other_comic.id, :author_id => @other_author.id, :visible => 1
+      @other_story = FactoryGirl.create :story, :comic_id => @other_comic.id, :visible => 1
       @other_sheet = FactoryGirl.create :sheet, :author_id => @other_author.id, :visible => 1
       @other_story_sheet = FactoryGirl.create :story_sheet, :author_id => @other_author.id, :story_id => @other_story.id, :sheet_id => @other_sheet.id
     end
@@ -515,7 +472,7 @@ describe StorySheet do
       r.should eq [ns, @other_story_sheet]
     end
     it '公開ストーリーのスト紙' do
-      @hstory = FactoryGirl.create :story, :author_id => @other_author.id, :visible => 0
+      @hstory = FactoryGirl.create :story, :comic_id => @comic.id, :visible => 0
       ns = FactoryGirl.create :story_sheet, :author_id => @other_author.id, :story_id => @hstory.id, :sheet_id => @other_sheet.id, :t => 1, :updated_at => Time.now + 100
       r = StorySheet.himlist @other_author
       r.should eq [@other_story_sheet]
@@ -617,10 +574,6 @@ describe StorySheet do
       r = StorySheet.list_opt
       r.has_key?(:story).should be_true
     end
-      it 'ストーリーは作家を含んでいる' do
-        r = StorySheet.list_opt
-        r[:story].has_key?(:author).should be_true
-      end
     it '作家を含んでいる' do
       r = StorySheet.list_opt
       r.has_key?(:author).should be_true
@@ -637,7 +590,7 @@ describe StorySheet do
   describe 'json一覧出力オプションに於いて' do
     before do
       @comic = FactoryGirl.create :comic, :author_id => @author.id
-      @story = FactoryGirl.create :story, :comic_id => @comic.id, :author_id => @author.id, :visible => 1
+      @story = FactoryGirl.create :story, :comic_id => @comic.id, :visible => 1
       @sheet = FactoryGirl.create :sheet, :author_id => @author.id
       @story_sheet = FactoryGirl.create :story_sheet, :author_id => @author.id, :story_id => @story.id, :sheet_id => @sheet.id
     end
@@ -647,13 +600,6 @@ describe StorySheet do
       i = j.first
       i.has_key?('story').should be_true
     end
-      it 'ストーリーは作家を含んでいる' do
-        r = StorySheet.list.to_json StorySheet.list_json_opt
-        j = JSON.parse r
-        i = j.first
-        s = i['story']
-        s.has_key?('author').should be_true
-      end
     it '用紙を含んでいる' do
       r = StorySheet.list.to_json StorySheet.list_json_opt
       j = JSON.parse r
@@ -678,7 +624,7 @@ describe StorySheet do
   describe '単体取得に於いて' do
     before do
       @comic = FactoryGirl.create :comic, :author_id => @author.id
-      @story = FactoryGirl.create :story, :comic_id => @comic.id, :author_id => @author.id, :visible => 1
+      @story = FactoryGirl.create :story, :comic_id => @comic.id, :visible => 1
       @sheet = FactoryGirl.create :sheet, :author_id => @author.id
       @story_sheet = FactoryGirl.create :story_sheet, :author_id => @author.id, :story_id => @story.id, :sheet_id => @sheet.id
     end
@@ -718,7 +664,7 @@ describe StorySheet do
   describe '編集取得に於いて' do
     before do
       @comic = FactoryGirl.create :comic, :author_id => @author.id
-      @story = FactoryGirl.create :story, :comic_id => @comic.id, :author_id => @author.id, :visible => 1
+      @story = FactoryGirl.create :story, :comic_id => @comic.id, :visible => 1
       @sheet = FactoryGirl.create :sheet, :author_id => @author.id
       @story_sheet = FactoryGirl.create :story_sheet, :author_id => @author.id, :story_id => @story.id, :sheet_id => @sheet.id
     end
@@ -768,10 +714,6 @@ describe StorySheet do
       r = StorySheet.show_opt[:include]
       r.has_key?(:story).should be_true
     end
-      it 'ストーリーは作家を含んでいる' do
-        r = StorySheet.show_opt[:include]
-        r[:story].has_key?(:author).should be_true
-      end
     it '作家を含んでいる' do
       r = StorySheet.show_opt[:include]
       r.has_key?(:author).should be_true
@@ -788,7 +730,7 @@ describe StorySheet do
   describe 'json単体取得オプションに於いて' do
     before do
       @comic = FactoryGirl.create :comic, :author_id => @author.id
-      @story = FactoryGirl.create :story, :comic_id => @comic.id, :author_id => @author.id, :visible => 1
+      @story = FactoryGirl.create :story, :comic_id => @comic.id, :visible => 1
       @sheet = FactoryGirl.create :sheet, :author_id => @author.id
       @story_sheet = FactoryGirl.create :story_sheet, :author_id => @author.id, :story_id => @story.id, :sheet_id => @sheet.id
     end
@@ -798,13 +740,6 @@ describe StorySheet do
       i = j
       i.has_key?('story').should be_true
     end
-      it 'ストーリーは作家を含んでいる' do
-        r = StorySheet.show(@story_sheet.id, @author).to_json StorySheet.show_json_opt
-        j = JSON.parse r
-        i = j
-        s = i['story']
-        s.has_key?('author').should be_true
-      end
     it '用紙を含んでいる' do
       r = StorySheet.show(@story_sheet.id, @author).to_json StorySheet.show_json_opt
       j = JSON.parse r
@@ -826,10 +761,102 @@ describe StorySheet do
     end
   end
   
+  describe 'スクコマのjson出力に於いて' do
+    before do
+      #コマを作成しておく。
+      @panel = FactoryGirl.create :panel, :author_id => @author.id
+      @pp = FactoryGirl.create :panel_picture, :panel_id => @panel.id, :t => 1, :width => @p.width, :height => @p.height
+      @sb = FactoryGirl.build :speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @speech_balloon_template.id
+      @speech = @sb.build_speech(
+        FactoryGirl.attributes_for(:speech, :writing_format_id => @writing_format.id)
+      )
+      @balloon = @sb.build_balloon(
+        FactoryGirl.attributes_for(:balloon, :system_picture_id => @sp.id)
+      )
+      @sb.boost
+      @sb.save!
+      @gc = @panel.ground_colors.create(
+        FactoryGirl.attributes_for(:ground_color, :panel_id => @panel.id)
+      )
+      @gp = @panel.ground_pictures.create(
+        FactoryGirl.attributes_for(:ground_picture, :panel_id => @panel.id, :picture_id => @p.id)
+      )
+      @panel.reload
+      @scroll = FactoryGirl.create :scroll, :author_id => @author.id
+      @scroll_panel = FactoryGirl.create :scroll_panel, :author_id => @author.id, :scroll_id => @scroll.id, :panel_id => @panel.id
+    end
+    context '事前チェックする' do
+      before do
+        Panel.any_instance.stub(:elements).and_return('{}')
+      end
+      it 'コマ要素のjson出力を依頼している' do
+        Panel.any_instance.stub(:visible?).with(any_args).and_return(true)
+        Panel.any_instance.should_receive(:elements).with(any_args).exactly(1)
+        r = @scroll_panel.scroll_panel_as_json @author
+      end
+    end
+    it 'json textを返している' do
+      r = JSON.parse @scroll_panel.scroll_panel_as_json(@author)
+      r.is_a?(Hash).should be_true
+    end
+    it 'scroll,author,panel,コマ要素を含んでいる' do
+      r = JSON.parse @scroll_panel.scroll_panel_as_json(@author)
+      r.has_key?('scroll').should be_true
+      r['scroll'].has_key?('author').should be_true
+      r.has_key?('author').should be_true
+      r.has_key?('panel').should be_true
+      r['panel'].has_key?('author').should be_true
+    end
+    context 'コマ閲覧許可のとき' do
+      before do
+        Panel.any_instance.stub(:visible?).with(any_args).and_return(true)
+      end
+      it 'コマ要素にコマ要素を追加している' do
+        r = JSON.parse @scroll_panel.scroll_panel_as_json(@author)
+        r['panel'].has_key?('elements').should be_true
+        r['panel']['elements'].should_not be_empty
+      end
+    end
+    context 'コマ閲覧不許可のとき' do
+      before do
+        Panel.any_instance.stub(:visible?).with(any_args).and_return(false)
+      end
+      it 'コマ要素にデータを含ませない' do
+        r = JSON.parse @scroll_panel.scroll_panel_as_json(@author)
+        r['panel'].has_key?('elements').should be_false
+      end
+    end
+  end
+  
+  describe 'スクコマリストのjson出力に於いて' do
+    before do
+      @panel = FactoryGirl.create :panel, :author_id => @author.id
+      @scroll = FactoryGirl.create :scroll, :author_id => @author.id
+      @scroll_panel = FactoryGirl.create :scroll_panel, :author_id => @author.id, :scroll_id => @scroll.id, :panel_id => @panel.id
+      ScrollPanel.any_instance.stub(:scroll_panel_as_json).with(@author).and_return('{"s": 5}')
+    end
+    context 'つつがなく終わるとき' do
+      it 'スクコマのjson出力を依頼している' do
+        ScrollPanel.any_instance.should_receive(:scroll_panel_as_json).with(@author).exactly(1)
+        r = ScrollPanel.list_as_json_text [@scroll_panel], @author
+      end
+    end
+    it 'json textを返している' do
+      r = ScrollPanel.list_as_json_text [@scroll_panel], @author
+      j = JSON.parse r
+      j.is_a?(Array).should be_true
+    end
+    it 'スクコマを含んでいる' do
+      r = ScrollPanel.list_as_json_text [@scroll_panel], @author
+      j = JSON.parse r
+      j.first.has_key?('s').should be_true
+    end
+  end
+  
   describe 't補充値に於いて' do
     before do
       @comic = FactoryGirl.create :comic, :author_id => @author.id
-      @story = FactoryGirl.create :story, :comic_id => @comic.id, :author_id => @author.id, :visible => 1
+      @story = FactoryGirl.create :story, :comic_id => @comic.id, :visible => 1
       @sheet = FactoryGirl.create :sheet, :author_id => @author.id
     end
     
@@ -894,10 +921,10 @@ describe StorySheet do
   describe 't収集に於いて' do
     before do
       @comic = FactoryGirl.create :comic, :author_id => @author.id
-      @story = FactoryGirl.create :story, :comic_id => @comic.id, :author_id => @author.id, :visible => 1
+      @story = FactoryGirl.create :story, :comic_id => @comic.id, :visible => 1
       @sheet = FactoryGirl.create :sheet, :author_id => @author.id
       @story_sheet = FactoryGirl.create :story_sheet, :author_id => @author.id, :story_id => @story.id, :sheet_id => @sheet.id
-      @story2 = FactoryGirl.create :story, :author_id => @author.id
+      @story2 = FactoryGirl.create :story
       @c2story_sheet = FactoryGirl.create :story_sheet, :t => 0, :story_id => @story2.id, :sheet_id => @sheet.id, :author_id => @author.id
     end
     context 'つつがなく終わるとき' do
@@ -924,7 +951,7 @@ describe StorySheet do
   describe 'tチェックに於いて' do
     before do
       @comic = FactoryGirl.create :comic, :author_id => @author.id
-      @story = FactoryGirl.create :story, :comic_id => @comic.id, :author_id => @author.id, :visible => 1
+      @story = FactoryGirl.create :story, :comic_id => @comic.id, :visible => 1
       @sheet = FactoryGirl.create :sheet, :author_id => @author.id
       @story_sheet = FactoryGirl.build :story_sheet, :t => 1, :story_id => @story.id, :sheet_id => @sheet.id, :author_id => @author.id
     end
@@ -963,7 +990,7 @@ describe StorySheet do
   describe '挿入シフトに於いて' do
     before do
       @comic = FactoryGirl.create :comic, :author_id => @author.id
-      @story = FactoryGirl.create :story, :comic_id => @comic.id, :author_id => @author.id, :visible => 1
+      @story = FactoryGirl.create :story, :comic_id => @comic.id, :visible => 1
       @sheet = FactoryGirl.create :sheet, :author_id => @author.id
     end
     context '依頼チェック' do
@@ -1020,7 +1047,7 @@ describe StorySheet do
     end
     context '先ほどのケース+他のストーリー1件で挿入したとき' do
       before do
-        @story2 = FactoryGirl.create :story, :author_id => @author.id
+        @story2 = FactoryGirl.create :story, :comic_id => @comic.id
         @story_sheetc2 = FactoryGirl.create :story_sheet, :t => 0, :story_id => @story2.id, :sheet_id => @sheet.id, :author_id => @author.id
         @story_sheet = FactoryGirl.create :story_sheet, :t => 0, :story_id => @story.id, :sheet_id => @sheet.id, :author_id => @author.id
         @story_sheet2 = FactoryGirl.create :story_sheet, :t => 1, :story_id => @story.id, :sheet_id => @sheet.id, :author_id => @author.id
@@ -1045,7 +1072,7 @@ describe StorySheet do
   describe '少ない方に移動に於いて' do
     before do
       @comic = FactoryGirl.create :comic, :author_id => @author.id
-      @story = FactoryGirl.create :story, :comic_id => @comic.id, :author_id => @author.id, :visible => 1
+      @story = FactoryGirl.create :story, :comic_id => @comic.id, :visible => 1
       @sheet = FactoryGirl.create :sheet, :author_id => @author.id
     end
     context '依頼チェック' do
@@ -1137,7 +1164,7 @@ describe StorySheet do
     end
     context '先ほどのケース+他のストーリー1件で挿入したとき' do
       before do
-        @story2 = FactoryGirl.create :story, :author_id => @author.id
+        @story2 = FactoryGirl.create :story, :comic_id => @comic.id
         @story_sheetc2 = FactoryGirl.create :story_sheet, :t => 0, :story_id => @story2.id, :sheet_id => @sheet.id, :author_id => @author.id
         @story_sheet = FactoryGirl.create :story_sheet, :t => 0, :story_id => @story.id, :sheet_id => @sheet.id, :author_id => @author.id
         @story_sheet2 = FactoryGirl.create :story_sheet, :t => 1, :story_id => @story.id, :sheet_id => @sheet.id, :author_id => @author.id
@@ -1207,7 +1234,7 @@ describe StorySheet do
   describe '大きい方に移動に於いて' do
     before do
       @comic = FactoryGirl.create :comic, :author_id => @author.id
-      @story = FactoryGirl.create :story, :comic_id => @comic.id, :author_id => @author.id, :visible => 1
+      @story = FactoryGirl.create :story, :comic_id => @comic.id, :visible => 1
       @sheet = FactoryGirl.create :sheet, :author_id => @author.id
     end
     context '依頼チェック' do
@@ -1299,7 +1326,7 @@ describe StorySheet do
     end
     context '先ほどのケース+他のストーリー1件で挿入したとき' do
       before do
-        @story2 = FactoryGirl.create :story, :author_id => @author.id
+        @story2 = FactoryGirl.create :story, :comic_id => @comic.id
         @story_sheetc2 = FactoryGirl.create :story_sheet, :t => 0, :story_id => @story2.id, :sheet_id => @sheet.id, :author_id => @author.id
         @story_sheet = FactoryGirl.create :story_sheet, :t => 0, :story_id => @story.id, :sheet_id => @sheet.id, :author_id => @author.id
         @story_sheet2 = FactoryGirl.create :story_sheet, :t => 1, :story_id => @story.id, :sheet_id => @sheet.id, :author_id => @author.id
@@ -1370,7 +1397,7 @@ describe StorySheet do
   describe '入れ替えに於いて' do
     before do
       @comic = FactoryGirl.create :comic, :author_id => @author.id
-      @story = FactoryGirl.create :story, :comic_id => @comic.id, :author_id => @author.id, :visible => 1
+      @story = FactoryGirl.create :story, :comic_id => @comic.id, :visible => 1
       @sheet = FactoryGirl.create :sheet, :author_id => @author.id
       @story_sheet = FactoryGirl.create :story_sheet, :t => 0, :story_id => @story.id, :sheet_id => @sheet.id, :author_id => @author.id
       @story_sheet2 = FactoryGirl.create :story_sheet, :t => 1, :story_id => @story.id, :sheet_id => @sheet.id, :author_id => @author.id
@@ -1397,7 +1424,7 @@ describe StorySheet do
   describe '順序入れ替えに於いて' do
     before do
       @comic = FactoryGirl.create :comic, :author_id => @author.id
-      @story = FactoryGirl.create :story, :comic_id => @comic.id, :author_id => @author.id, :visible => 1
+      @story = FactoryGirl.create :story, :comic_id => @comic.id, :visible => 1
       @sheet = FactoryGirl.create :sheet, :author_id => @author.id
     end
     context 'オブジェクトが新規でtが空のとき' do
@@ -1437,7 +1464,7 @@ describe StorySheet do
   describe '編集許可に於いて' do
     before do
       @comic = FactoryGirl.create :comic, :author_id => @author.id
-      @story = FactoryGirl.create :story, :comic_id => @comic.id, :author_id => @author.id, :visible => 1
+      @story = FactoryGirl.create :story, :comic_id => @comic.id, :visible => 1
       @sheet = FactoryGirl.create :sheet, :author_id => @author.id
       @story_sheet = FactoryGirl.build :story_sheet, :t => nil, :story_id => @story.id, :sheet_id => @sheet.id, :author_id => @author.id
     end
@@ -1481,7 +1508,7 @@ describe StorySheet do
   describe '保存に於いて' do
     before do
       @comic = FactoryGirl.create :comic, :author_id => @author.id
-      @story = FactoryGirl.create :story, :comic_id => @comic.id, :author_id => @author.id, :visible => 1
+      @story = FactoryGirl.create :story, :comic_id => @comic.id, :visible => 1
       @sheet = FactoryGirl.create :sheet, :author_id => @author.id
       @story_sheet = FactoryGirl.build :story_sheet, :t => nil, :story_id => @story.id, :sheet_id => @sheet.id, :author_id => @author.id
     end
@@ -1516,7 +1543,7 @@ describe StorySheet do
     #入れ替えテストと同じテストを実施。こちらはシフトだけでなく本尊も更新されている
     context 'テーブルに5件(t:0,1,2,3,4)+他のストーリー1件で2に挿入したとき' do
       before do
-        @story2 = FactoryGirl.create :story, :author_id => @author.id
+        @story2 = FactoryGirl.create :story, :comic_id => @comic.id
         @story_sheetc2 = FactoryGirl.create :story_sheet, :t => 0, :story_id => @story2.id, :sheet_id => @sheet.id, :author_id => @author.id
         @story_sheet = FactoryGirl.create :story_sheet, :t => 0, :story_id => @story.id, :sheet_id => @sheet.id, :author_id => @author.id
         @story_sheet2 = FactoryGirl.create :story_sheet, :t => 1, :story_id => @story.id, :sheet_id => @sheet.id, :author_id => @author.id
@@ -1564,7 +1591,7 @@ describe StorySheet do
     end
     context 'テーブルに5件(t:0,1,2,3,4)+他のストーリー1件で3を1に移動したとき' do
       before do
-        @story2 = FactoryGirl.create :story, :author_id => @author.id
+        @story2 = FactoryGirl.create :story, :comic_id => @comic.id
         @story_sheetc2 = FactoryGirl.create :story_sheet, :t => 0, :story_id => @story2.id, :sheet_id => @sheet.id, :author_id => @author.id
         @story_sheet = FactoryGirl.create :story_sheet, :t => 0, :story_id => @story.id, :sheet_id => @sheet.id, :author_id => @author.id
         @story_sheet2 = FactoryGirl.create :story_sheet, :t => 1, :story_id => @story.id, :sheet_id => @sheet.id, :author_id => @author.id
@@ -1607,7 +1634,7 @@ describe StorySheet do
     end
     context 'テーブルに5件(t:0,1,2,3,4)+他のストーリー1件で1を3に移動したとき' do
       before do
-        @story2 = FactoryGirl.create :story, :author_id => @author.id
+        @story2 = FactoryGirl.create :story, :comic_id => @comic.id
         @story_sheetc2 = FactoryGirl.create :story_sheet, :t => 0, :story_id => @story2.id, :sheet_id => @sheet.id, :author_id => @author.id
         @story_sheet = FactoryGirl.create :story_sheet, :t => 0, :story_id => @story.id, :sheet_id => @sheet.id, :author_id => @author.id
         @story_sheet2 = FactoryGirl.create :story_sheet, :t => 1, :story_id => @story.id, :sheet_id => @sheet.id, :author_id => @author.id
@@ -1652,7 +1679,7 @@ describe StorySheet do
     context 'テーブルに5件(t:0,1,2,3,4)+他のストーリー1件で2に挿入したが保存に失敗したとき' do
       before do
         StorySheet.any_instance.stub(:save).with(any_args).and_return(false)
-        @story2 = FactoryGirl.create :story, :author_id => @author.id
+        @story2 = FactoryGirl.create :story, :comic_id => @comic.id
         @story_sheetc2 = FactoryGirl.create :story_sheet, :t => 0, :story_id => @story2.id, :sheet_id => @sheet.id, :author_id => @author.id
         @story_sheet = FactoryGirl.create :story_sheet, :t => 0, :story_id => @story.id, :sheet_id => @sheet.id, :author_id => @author.id
         @story_sheet2 = FactoryGirl.create :story_sheet, :t => 1, :story_id => @story.id, :sheet_id => @sheet.id, :author_id => @author.id
@@ -1684,7 +1711,7 @@ describe StorySheet do
     context 'テーブルに5件(t:0,1,2,3,4)+他のストーリー1件で3を1に移動したがシリアルチェックに失敗したとき' do
       before do
         StorySheet.stub(:validate_t).with(any_args).and_return(false)
-        @story2 = FactoryGirl.create :story, :author_id => @author.id
+        @story2 = FactoryGirl.create :story, :comic_id => @comic.id
         @story_sheetc2 = FactoryGirl.create :story_sheet, :t => 0, :story_id => @story2.id, :sheet_id => @sheet.id, :author_id => @author.id
         @story_sheet = FactoryGirl.create :story_sheet, :t => 0, :story_id => @story.id, :sheet_id => @sheet.id, :author_id => @author.id
         @story_sheet2 = FactoryGirl.create :story_sheet, :t => 1, :story_id => @story.id, :sheet_id => @sheet.id, :author_id => @author.id
@@ -1734,7 +1761,7 @@ describe StorySheet do
   describe '切り詰め処理つき削除に於いて' do
     before do
       @comic = FactoryGirl.create :comic, :author_id => @author.id
-      @story = FactoryGirl.create :story, :comic_id => @comic.id, :author_id => @author.id, :visible => 1
+      @story = FactoryGirl.create :story, :comic_id => @comic.id, :visible => 1
       @sheet = FactoryGirl.create :sheet, :author_id => @author.id
       @story_sheet = FactoryGirl.create :story_sheet, :t => 0, :story_id => @story.id, :sheet_id => @sheet.id, :author_id => @author.id
     end