OSDN Git Service

t#32046:add sheet
[pettanr/pettanr.git] / spec / models / story_spec.rb
index de0452b..5cc830f 100644 (file)
@@ -20,7 +20,7 @@ describe Story do
   describe '検証に於いて' do
     before do
       @comic = FactoryGirl.create :comic, :author_id => @author.id
-      @story = FactoryGirl.build :story, :comic_id => @comic.id, :author_id => @author.id
+      @story = FactoryGirl.build :story, :comic_id => @comic.id
     end
     
     context 'オーソドックスなデータのとき' do
@@ -38,6 +38,21 @@ describe Story do
       end
     end
     
+    context 'comic_idを検証するとき' do
+      it 'nullなら失敗する' do
+        @story.comic_id = nil
+        @story.should_not be_valid
+      end
+      it '数値でなければ失敗する' do
+        @story.comic_id = 'a'
+        @story.should_not be_valid
+      end
+      it '存在するコミックでなければ失敗する' do
+        @story.comic_id = 0
+        @story.should_not be_valid
+      end
+    end
+    
     context 'titleを検証するとき' do
       it 'nullなら失敗する' do
         @story.title = nil
@@ -48,6 +63,7 @@ describe Story do
         @story.should_not be_valid
       end
     end
+    
     context 'visibleを検証するとき' do
       it 'nullなら失敗する' do
         @story.visible = nil
@@ -62,6 +78,7 @@ describe Story do
         @story.should_not be_valid
       end
     end
+    
     context 'tを検証するとき' do
       it 'nullなら失敗する' do
         @story.t = nil
@@ -81,7 +98,7 @@ describe Story do
   describe '文字コード検証に於いて' do
     before do
       @comic = FactoryGirl.create :comic, :author_id => @author.id
-      @story = FactoryGirl.build :story, :comic_id => @comic.id, :author_id => @author.id
+      @story = FactoryGirl.build :story, :comic_id => @comic.id
     end
     
     context 'titleを検証するとき' do
@@ -112,16 +129,12 @@ describe Story do
   end
   
   describe '上書き補充に於いて' do
-    it '作家idが設定されている' do
-      @story = FactoryGirl.build :story, :author_id => nil
-      @story.overwrite @author
-      @story.author_id.should eq @author.id
-    end
   end
   
   describe '所持判定に於いて' do
     before do
-      @story = FactoryGirl.build :story, :author_id => @author.id
+      @comic = FactoryGirl.create :comic, :author_id => @author.id
+      @story = FactoryGirl.build :story, :comic_id => @comic.id
     end
     context '事前チェックする' do
       it '自身にロールリストからの作家取得を依頼している' do
@@ -132,12 +145,12 @@ describe Story do
     context 'ロール内作家が取得できるとき' do
       before do
       end
-      it 'ロール内作家のidが自身の作家idと一致するなら許可する' do
+      it 'ロール内作家のidが自身のコミックの作家idと一致するなら許可する' do
         Story.stub(:get_author_from_roles).with(any_args).and_return(@author)
         r = @story.own?([@author])
         r.should be_true
       end
-      it 'ロール内作家のidが自身の作家idと一致しないならno' do
+      it 'ロール内作家のidが自身のコミックの作家idと一致しないならno' do
         Story.stub(:get_author_from_roles).with(any_args).and_return(@other_author)
         @story.own?(@other_author).should be_false
       end
@@ -155,7 +168,8 @@ describe Story do
   
   describe '閲覧許可に於いて' do
     before do
-      @story = FactoryGirl.build :story, :author_id => @author.id
+      @comic = FactoryGirl.create :comic, :author_id => @author.id
+      @story = FactoryGirl.build :story, :comic_id => @comic.id
     end
     context 'オープンモードのとき' do
       before do
@@ -227,7 +241,7 @@ describe Story 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
+      @story = FactoryGirl.create :story, :comic_id => @comic.id
     end
     context 'page補正について' do
       it '文字列から数値に変換される' do
@@ -266,23 +280,23 @@ describe Story do
       c.should eq [@story]
     end
     it '非公開ストーリーは(自分のストーリーであっても)含んでいない' do
-      FactoryGirl.create :story, :comic_id => @comic.id, :author_id => @author.id, :visible => 0
+      FactoryGirl.create :story, :comic_id => @comic.id, :visible => 0
       c = Story.list
       c.should eq [@story]
     end
     it '時系列で並んでいる' do
       #公開ストーリーは(他人のストーリーであっても)含んでいる
       other_comic = FactoryGirl.create :comic, :author_id => @other_author.id
-      v = FactoryGirl.create :story, :comic_id => other_comic.id, :author_id => @other_author.id, :updated_at => Time.now + 100
+      v = FactoryGirl.create :story, :comic_id => other_comic.id, :updated_at => Time.now + 100
       c = Story.list
       c.should eq [v, @story]
     end
     context 'DBに5件あって1ページの件数を2件に変えたとして' do
       before do
-        @story2 = FactoryGirl.create :story, :comic_id => @comic.id, :author_id => @author.id, :updated_at => Time.now + 100
-        @story3 = FactoryGirl.create :story, :comic_id => @comic.id, :author_id => @author.id, :updated_at => Time.now + 200
-        @story4 = FactoryGirl.create :story, :comic_id => @comic.id, :author_id => @author.id, :updated_at => Time.now + 300
-        @story5 = FactoryGirl.create :story, :comic_id => @comic.id, :author_id => @author.id, :updated_at => Time.now + 400
+        @story2 = FactoryGirl.create :story, :comic_id => @comic.id, :updated_at => Time.now + 100
+        @story3 = FactoryGirl.create :story, :comic_id => @comic.id, :updated_at => Time.now + 200
+        @story4 = FactoryGirl.create :story, :comic_id => @comic.id, :updated_at => Time.now + 300
+        @story5 = FactoryGirl.create :story, :comic_id => @comic.id, :updated_at => Time.now + 400
         Story.stub(:default_page_size).and_return(2)
       end
       it '通常は2件を返す' do
@@ -308,7 +322,7 @@ describe Story 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
+      @story = FactoryGirl.create :story, :comic_id => @comic.id
     end
     context 'つつがなく終わるとき' do
       it '一覧取得オプションを利用している' do
@@ -322,27 +336,27 @@ describe Story do
       c.should eq [@story]
     end
     it '時系列で並んでいる' do
-      nc = FactoryGirl.create :story, :comic_id => @comic.id, :author_id => @author.id, :updated_at => Time.now + 100
+      nc = FactoryGirl.create :story, :comic_id => @comic.id, :updated_at => Time.now + 100
       cl = Story.mylist @author
       cl.should eq [nc, @story]
     end
     it '他人のストーリーは公開でも含まない' do
       other_comic = FactoryGirl.create :comic, :author_id => @other_author.id
-      nc = FactoryGirl.create :story, :comic_id => other_comic.id, :author_id => @other_author.id, :visible => 1
+      nc = FactoryGirl.create :story, :comic_id => other_comic.id, :visible => 1
       cl = Story.mylist @author
       cl.should eq [@story]
     end
     it '自分のストーリーは非公開でも含んでいる' do
-      nc = FactoryGirl.create :story, :comic_id => @comic.id, :author_id => @author.id, :visible => 0, :updated_at => Time.now + 100
+      nc = FactoryGirl.create :story, :comic_id => @comic.id, :visible => 0, :updated_at => Time.now + 100
       cl = Story.mylist @author
       cl.should eq [nc, @story]
     end
     context 'DBに5件あって1ページの件数を2件に変えたとして' do
       before do
-        @story2 = FactoryGirl.create :story, :comic_id => @comic.id, :author_id => @author.id, :updated_at => Time.now + 100
-        @story3 = FactoryGirl.create :story, :comic_id => @comic.id, :author_id => @author.id, :updated_at => Time.now + 200
-        @story4 = FactoryGirl.create :story, :comic_id => @comic.id, :author_id => @author.id, :updated_at => Time.now + 300
-        @story5 = FactoryGirl.create :story, :comic_id => @comic.id, :author_id => @author.id, :updated_at => Time.now + 400
+        @story2 = FactoryGirl.create :story, :comic_id => @comic.id, :updated_at => Time.now + 100
+        @story3 = FactoryGirl.create :story, :comic_id => @comic.id, :updated_at => Time.now + 200
+        @story4 = FactoryGirl.create :story, :comic_id => @comic.id, :updated_at => Time.now + 300
+        @story5 = FactoryGirl.create :story, :comic_id => @comic.id, :updated_at => Time.now + 400
       end
       it '通常は2件を返す' do
         c = Story.mylist @author, 1, 2
@@ -367,9 +381,9 @@ describe Story 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
-      @other_comic = FactoryGirl.create :comic, :author_id => @other_author.id
-      @other_story = FactoryGirl.create :story, :author_id => @other_author.id, :visible => 1
+      @story = FactoryGirl.create :story, :comic_id => @comic.id
+      @other_comic = FactoryGirl.create :comic, :visible => 1, :author_id => @other_author.id
+      @other_story = FactoryGirl.create :story, :visible => 1, :comic_id => @other_comic.id
     end
     context 'つつがなく終わるとき' do
       it '一覧取得オプションを利用している' do
@@ -383,21 +397,21 @@ describe Story do
       r.should eq [@other_story]
     end
     it '時系列で並んでいる' do
-      nc = FactoryGirl.create :story, :comic_id => @other_comic.id, :author_id => @other_author.id, :updated_at => Time.now + 100
+      nc = FactoryGirl.create :story, :comic_id => @other_comic.id, :updated_at => Time.now + 100
       r = Story.himlist @other_author
       r.should eq [nc, @other_story]
     end
     it '公開ストーリーに限る ' do
-      hidden = FactoryGirl.create :story, :comic_id => @other_comic.id, :author_id => @other_author.id, :visible => 0
+      hidden = FactoryGirl.create :story, :comic_id => @other_comic.id, :visible => 0
       r = Story.himlist @other_author
       r.should eq [@other_story]
     end
     context 'DBに5件あって1ページの件数を2件に変えたとして' do
       before do
-        @other_story2 = FactoryGirl.create :story, :comic_id => @other_comic.id, :author_id => @other_author.id, :updated_at => Time.now + 100
-        @other_story3 = FactoryGirl.create :story, :comic_id => @other_comic.id, :author_id => @other_author.id, :updated_at => Time.now + 200
-        @other_story4 = FactoryGirl.create :story, :comic_id => @other_comic.id, :author_id => @other_author.id, :updated_at => Time.now + 300
-        @other_story5 = FactoryGirl.create :story, :comic_id => @other_comic.id, :author_id => @other_author.id, :updated_at => Time.now + 400
+        @other_story2 = FactoryGirl.create :story, :comic_id => @other_comic.id, :updated_at => Time.now + 100
+        @other_story3 = FactoryGirl.create :story, :comic_id => @other_comic.id, :updated_at => Time.now + 200
+        @other_story4 = FactoryGirl.create :story, :comic_id => @other_comic.id, :updated_at => Time.now + 300
+        @other_story5 = FactoryGirl.create :story, :comic_id => @other_comic.id, :updated_at => Time.now + 400
       end
       it '通常は2件を返す' do
         c = Story.himlist @other_author, 1, 2
@@ -480,66 +494,43 @@ describe Story do
   end
   
   describe '一覧取得オプションに於いて' do
-    it '2つの項目を含んでいる' do
+    it '1つの項目を含んでいる' do
       r = Story.list_opt
-      r.should have(2).items
+      r.should have(1).items
     end
-    it 'ã\82¹ã\83\88ç´\99を含んでいる' do
+    it 'ã\82³ã\83\9fã\83\83ã\82¯を含んでいる' do
       r = Story.list_opt
-      r.has_key?(:story_sheets).should be_true
+      r.has_key?(:comic).should be_true
     end
-      it 'スト紙は用紙を含んでいる' do
-        r = Story.list_opt
-        r[:story_sheets].has_key?(:sheet).should be_true
-      end
-      it 'スト紙は作家を含んでいる' do
+      it 'コミックは作家を含んでいる' do
         r = Story.list_opt
-        r[:story_sheets].has_key?(:author).should be_true
+        r[:comic].has_key?(:author).should be_true
       end
-    it '作家を含んでいる' do
-      r = Story.list_opt
-      r.has_key?(:author).should be_true
-    end
   end
   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
-      @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
+      @story = FactoryGirl.create :story, :comic_id => @comic.id, :visible => 1
     end
-    it 'ã\82¹ã\83\88ç´\99を含んでいる' do
+    it 'ã\82³ã\83\9fã\83\83ã\82¯を含んでいる' do
       r = Story.list.to_json Story.list_json_opt
       j = JSON.parse r
       i = j.first
-      i.has_key?('story_sheets').should be_true
+      i.has_key?('comic').should be_true
     end
-      it 'スト紙は用紙を含んでいる' do
-        r = Story.list.to_json Story.list_json_opt
-        j = JSON.parse r
-        i = j.first
-        s = i['story_sheets'].first
-        s.has_key?('sheet').should be_true
-      end
-      it 'スト紙は作家を含んでいる' do
+      it 'コミックは作家を含んでいる' do
         r = Story.list.to_json Story.list_json_opt
         j = JSON.parse r
         i = j.first
-        s = i['story_sheets'].first
+        s = i['comic']
         s.has_key?('author').should be_true
       end
-    it '作家を含んでいる' do
-      r = Story.list.to_json Story.list_json_opt
-      j = JSON.parse r
-      i = j.first
-      i.has_key?('author').should be_true
-    end
   end
   
   describe '単体取得に於いて' do
     before do
       @comic = FactoryGirl.create :comic, :author_id => @author.id
-      @story = FactoryGirl.create :story, :comic_id => @comic.id, :author_id => @author.id
+      @story = FactoryGirl.create :story, :comic_id => @comic.id
     end
     context 'つつがなく終わるとき' do
       it '単体取得オプションを利用している' do
@@ -577,7 +568,7 @@ describe Story 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
+      @story = FactoryGirl.create :story, :comic_id => @comic.id
     end
     context 'つつがなく終わるとき' do
       it '単体取得オプションを利用している' do
@@ -617,60 +608,37 @@ describe Story do
       r = Story.show_opt
       r.has_key?(:include).should be_true
     end
-    it '2つの項目を含んでいる' do
+    it '1つの項目を含んでいる' do
       r = Story.show_opt[:include]
-      r.should have(2).items
+      r.should have(1).items
     end
-    it '作家を含んでいる' do
+    it 'コミックを含んでいる' do
       r = Story.show_opt[:include]
-      r.has_key?(:author).should be_true
+      r.has_key?(:comic).should be_true
     end
-    it 'スト紙を含んでいる' do
-      r = Story.show_opt[:include]
-      r.has_key?(:story_sheets).should be_true
-    end
-      it 'スト紙は用紙を含んでいる' do
-        r = Story.show_opt[:include]
-        r[:story_sheets].has_key?(:sheet).should be_true
-      end
-      it 'スト紙は作家を含んでいる' do
+      it 'コミックは作家を含んでいる' do
         r = Story.show_opt[:include]
-        r[:story_sheets].has_key?(:author).should be_true
+        r[:comic].has_key?(:author).should be_true
       end
   end
   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
-      @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
+      @story = FactoryGirl.create :story, :comic_id => @comic.id, :visible => 1
     end
-    it 'ã\82¹ã\83\88ç´\99を含んでいる' do
+    it 'ã\82³ã\83\9fã\83\83ã\82¯を含んでいる' do
       r = Story.show(@story.id, @author).to_json Story.show_json_opt
       j = JSON.parse r
       i = j
-      i.has_key?('story_sheets').should be_true
+      i.has_key?('comic').should be_true
     end
-      it 'ã\82¹ã\83\88ç´\99ã\81¯ç\94¨ç´\99を含んでいる' do
+      it 'ã\82³ã\83\9fã\83\83ã\82¯ã\81¯ä½\9c家を含んでいる' do
         r = Story.show(@story.id, @author).to_json Story.show_json_opt
         j = JSON.parse r
         i = j
-        s = i['story_sheets'].first
-        s.has_key?('sheet').should be_true
-      end
-      it 'スト紙は作家を含んでいる' do
-        r = Story.show(@story.id, @author).to_json Story.show_json_opt
-        j = JSON.parse r
-        i = j
-        s = i['story_sheets'].first
+        s = i['comic']
         s.has_key?('author').should be_true
       end
-    it '作家を含んでいる' do
-      r = Story.show(@story.id, @author).to_json Story.show_json_opt
-      j = JSON.parse r
-      i = j
-      i.has_key?('author').should be_true
-    end
   end
   
   describe 't補充値に於いて' do
@@ -680,7 +648,7 @@ describe Story do
     
     context 'コミック初のコマなら' do
       it '0を補充値とする' do
-        @story = FactoryGirl.build :story, :author_id => @author.id, :comic_id => @comic.id
+        @story = FactoryGirl.build :story, :comic_id => @comic.id
         @story.t = nil
         r = Story.new_t @story.comic_id
         r.should eq 0
@@ -688,8 +656,8 @@ describe Story do
     end
     context 'コミックに一個コマがあるとき' do
       it '1を補充値とする' do
-        FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :t => 0
-        @story = FactoryGirl.build :story, :author_id => @author.id, :comic_id => @comic.id
+        FactoryGirl.create :story, :comic_id => @comic.id, :t => 0
+        @story = FactoryGirl.build :story, :comic_id => @comic.id
         @story.t = nil
         r = Story.new_t @story.comic_id
         r.should eq 1
@@ -697,9 +665,9 @@ describe Story do
     end
     context 'コミックに2個コマがあるとき' do
       it '2を補充値とする' do
-        FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :t => 0
-        FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :t => 1
-        @story = FactoryGirl.build :story, :author_id => @author.id, :comic_id => @comic.id
+        FactoryGirl.create :story, :comic_id => @comic.id, :t => 0
+        FactoryGirl.create :story, :comic_id => @comic.id, :t => 1
+        @story = FactoryGirl.build :story, :comic_id => @comic.id
         @story.t = nil
         r = Story.new_t @story.comic_id
         r.should eq 2
@@ -739,9 +707,9 @@ describe Story do
   describe 't収集に於いて' do
     before do
       @comic = FactoryGirl.create :comic, :author_id => @author.id
-      @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :author_id => @author.id
+      @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id
       @comic2 = FactoryGirl.create :comic, :author_id => @author.id
-      @c2story = FactoryGirl.create :story, :t => 0, :comic_id => @comic2.id, :author_id => @author.id
+      @c2story = FactoryGirl.create :story, :t => 0, :comic_id => @comic2.id
     end
     context 'つつがなく終わるとき' do
       it 'ストーリーから同一コミックのtだけを収集している' do
@@ -751,14 +719,14 @@ describe Story do
     end
     context '複数コマのとき' do
       it 'ストーリーから同一コミックのtだけを収集している' do
-        @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :author_id => @author.id
+        @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id
         r = Story.collect_t @story
         r.sort.should eq [0, 1]
       end
     end
     context '複数ストーリーでヨソのコミックも混じっているとき' do
       it 'ストーリーから同一コミックのtだけを収集している' do
-        @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :author_id => @author.id
+        @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id
         r = Story.collect_t @story
         r.sort.should eq [0, 1]
       end
@@ -767,7 +735,7 @@ describe Story do
   describe 'tチェックに於いて' do
     before do
       @comic = FactoryGirl.create :comic, :author_id => @author.id
-      @story = FactoryGirl.build :story, :t => 1, :comic_id => @comic.id, :author_id => @author.id
+      @story = FactoryGirl.build :story, :t => 1, :comic_id => @comic.id
     end
     context 'つつがなく終わるとき' do
       it 't収集を依頼している' do
@@ -787,15 +755,15 @@ describe Story do
     #依頼チェックだけでは不安なので最低限のチェックを
     context '新規のとき' do
       it '一件だけで正常通過している' do
-        @story = FactoryGirl.build :story, :comic_id => @comic.id, :author_id => @author.id, :t => 0
+        @story = FactoryGirl.build :story, :comic_id => @comic.id, :t => 0
         r = Story.validate_t @story
         r.should be_true 
       end
     end
     context '既存のとき' do
       it '2件目を作っても正常通過している' do
-        @story = FactoryGirl.create :story, :comic_id => @comic.id, :author_id => @author.id, :t => 0
-        @story2 = FactoryGirl.build :story, :comic_id => @comic.id, :author_id => @author.id, :t => 1
+        @story = FactoryGirl.create :story, :comic_id => @comic.id, :t => 0
+        @story2 = FactoryGirl.build :story, :comic_id => @comic.id, :t => 1
         r = Story.validate_t @story2
         r.should be_true 
       end
@@ -810,14 +778,14 @@ describe Story do
       it 'Updateを依頼している' do
         Story.stub(:update_all).with(any_args)
         Story.should_receive(:update_all).with(any_args).exactly(1)
-        @story = FactoryGirl.build :story, :t => 0, :comic_id => @comic.id, :author_id => @author.id
+        @story = FactoryGirl.build :story, :t => 0, :comic_id => @comic.id
         @story.insert_shift
       end
     end
     context 'テーブルに1件(t:0)で0に挿入したとき' do
       before do
-        @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :author_id => @author.id
-        @story2 = FactoryGirl.build :story, :t => 0, :comic_id => @comic.id, :author_id => @author.id
+        @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id
+        @story2 = FactoryGirl.build :story, :t => 0, :comic_id => @comic.id
       end
       it '既存の行を1にシフトしている' do
         @story2.insert_shift
@@ -832,9 +800,9 @@ describe Story do
     end
     context 'テーブルに2件(t:0,1)で1に挿入したとき' do
       before do
-        @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :author_id => @author.id
-        @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :author_id => @author.id
-        @story3 = FactoryGirl.build :story, :t => 1, :comic_id => @comic.id, :author_id => @author.id
+        @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id
+        @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id
+        @story3 = FactoryGirl.build :story, :t => 1, :comic_id => @comic.id
       end
       it '既存のt1を2にシフトしてこれから挿入するt(1)が欠番になっている' do
         @story3.insert_shift
@@ -844,12 +812,12 @@ describe Story do
     end
     context 'テーブルに5件(t:0,1,2,3,4)で2に挿入したとき' do
       before do
-        @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :author_id => @author.id
-        @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :author_id => @author.id
-        @story3 = FactoryGirl.create :story, :t => 2, :comic_id => @comic.id, :author_id => @author.id
-        @story4 = FactoryGirl.create :story, :t => 3, :comic_id => @comic.id, :author_id => @author.id
-        @story5 = FactoryGirl.create :story, :t => 4, :comic_id => @comic.id, :author_id => @author.id
-        @story6 = FactoryGirl.build :story, :t => 2, :comic_id => @comic.id, :author_id => @author.id
+        @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id
+        @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id
+        @story3 = FactoryGirl.create :story, :t => 2, :comic_id => @comic.id
+        @story4 = FactoryGirl.create :story, :t => 3, :comic_id => @comic.id
+        @story5 = FactoryGirl.create :story, :t => 4, :comic_id => @comic.id
+        @story6 = FactoryGirl.build :story, :t => 2, :comic_id => @comic.id
       end
       it '既存のt1を2にシフトしてこれから挿入するt(1)が欠番になっている' do
         @story6.insert_shift
@@ -860,13 +828,13 @@ describe Story do
     context '先ほどのケース+他のコミック1件で挿入したとき' do
       before do
         @comic2 = FactoryGirl.create :comic, :author_id => @author.id
-        @storyc2 = FactoryGirl.create :story, :t => 0, :comic_id => @comic2.id, :author_id => @author.id
-        @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :author_id => @author.id
-        @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :author_id => @author.id
-        @story3 = FactoryGirl.create :story, :t => 2, :comic_id => @comic.id, :author_id => @author.id
-        @story4 = FactoryGirl.create :story, :t => 3, :comic_id => @comic.id, :author_id => @author.id
-        @story5 = FactoryGirl.create :story, :t => 4, :comic_id => @comic.id, :author_id => @author.id
-        @story6 = FactoryGirl.build :story, :t => 2, :comic_id => @comic.id, :author_id => @author.id
+        @storyc2 = FactoryGirl.create :story, :t => 0, :comic_id => @comic2.id
+        @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id
+        @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id
+        @story3 = FactoryGirl.create :story, :t => 2, :comic_id => @comic.id
+        @story4 = FactoryGirl.create :story, :t => 3, :comic_id => @comic.id
+        @story5 = FactoryGirl.create :story, :t => 4, :comic_id => @comic.id
+        @story6 = FactoryGirl.build :story, :t => 2, :comic_id => @comic.id
       end
       it '既存のt1を2にシフトしてこれから挿入するt(1)が欠番になっている' do
         @story6.insert_shift
@@ -883,12 +851,12 @@ describe Story do
   end
   describe '少ない方に移動に於いて' do
     before do
-      @comic = FactoryGirl.create :comic, :author_id => @author.id
+      @comic = FactoryGirl.create :comic
     end
     context '依頼チェック' do
       it 'Updateを依頼している' do
-        @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :author_id => @author.id
-        @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :author_id => @author.id
+        @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id
+        @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id
         Story.stub(:update_all).with(any_args)
         Story.should_receive(:update_all).with(any_args).exactly(1)
         ot = @story2.t
@@ -898,8 +866,8 @@ describe Story do
     end
     context 'テーブルに2件(t:0,1)で1を0に移動したとき' do
       before do
-        @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :author_id => @author.id
-        @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :author_id => @author.id
+        @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id
+        @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id
         @ot = @story2.t
         @story2.t = 0
       end
@@ -917,9 +885,9 @@ describe Story do
     end
     context 'テーブルに3件(t:0,1,2)で2を1に移動したとき' do
       before do
-        @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :author_id => @author.id
-        @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :author_id => @author.id
-        @story3 = FactoryGirl.create :story, :t => 2, :comic_id => @comic.id, :author_id => @author.id
+        @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id
+        @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id
+        @story3 = FactoryGirl.create :story, :t => 2, :comic_id => @comic.id
         @ot = @story3.t
         @story3.t = 1
       end
@@ -937,11 +905,11 @@ describe Story do
     end
     context 'テーブルに5件(t:0,1,2,3,4)で3を1に移動したとき' do
       before do
-        @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :author_id => @author.id
-        @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :author_id => @author.id
-        @story3 = FactoryGirl.create :story, :t => 2, :comic_id => @comic.id, :author_id => @author.id
-        @story4 = FactoryGirl.create :story, :t => 3, :comic_id => @comic.id, :author_id => @author.id
-        @story5 = FactoryGirl.create :story, :t => 4, :comic_id => @comic.id, :author_id => @author.id
+        @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id
+        @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id
+        @story3 = FactoryGirl.create :story, :t => 2, :comic_id => @comic.id
+        @story4 = FactoryGirl.create :story, :t => 3, :comic_id => @comic.id
+        @story5 = FactoryGirl.create :story, :t => 4, :comic_id => @comic.id
         @ot = @story4.t
         @story4.t = 1
       end
@@ -974,13 +942,13 @@ describe Story do
     end
     context '先ほどのケース+他のコミック1件で挿入したとき' do
       before do
-        @comic2 = FactoryGirl.create :comic, :author_id => @author.id
-        @storyc2 = FactoryGirl.create :story, :t => 0, :comic_id => @comic2.id, :author_id => @author.id
-        @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :author_id => @author.id
-        @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :author_id => @author.id
-        @story3 = FactoryGirl.create :story, :t => 2, :comic_id => @comic.id, :author_id => @author.id
-        @story4 = FactoryGirl.create :story, :t => 3, :comic_id => @comic.id, :author_id => @author.id
-        @story5 = FactoryGirl.create :story, :t => 4, :comic_id => @comic.id, :author_id => @author.id
+        @comic2 = FactoryGirl.create :comic
+        @storyc2 = FactoryGirl.create :story, :t => 0, :comic_id => @comic2.id
+        @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id
+        @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id
+        @story3 = FactoryGirl.create :story, :t => 2, :comic_id => @comic.id
+        @story4 = FactoryGirl.create :story, :t => 3, :comic_id => @comic.id
+        @story5 = FactoryGirl.create :story, :t => 4, :comic_id => @comic.id
         @ot = @story4.t
         @story4.t = 1
       end
@@ -1019,8 +987,8 @@ describe Story do
     #負のときは0として正常扱い
     context 'テーブルに2件(t:0,1)で1を-1に移動したとき' do
       before do
-        @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :author_id => @author.id
-        @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :author_id => @author.id
+        @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id
+        @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id
         @ot = @story2.t
         @story2.t = -1
       end
@@ -1047,8 +1015,8 @@ describe Story do
     end
     context '依頼チェック' do
       it 'Updateを依頼している' do
-        @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :author_id => @author.id
-        @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :author_id => @author.id
+        @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id
+        @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id
         Story.stub(:update_all).with(any_args)
         Story.should_receive(:update_all).with(any_args).exactly(1)
         ot = @story.t
@@ -1058,8 +1026,8 @@ describe Story do
     end
     context 'テーブルに2件(t:0,1)で0を1に移動したとき' do
       before do
-        @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :author_id => @author.id
-        @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :author_id => @author.id
+        @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id
+        @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id
         @ot = @story.t
         @story.t = 1
       end
@@ -1077,9 +1045,9 @@ describe Story do
     end
     context 'テーブルに3件(t:0,1,2)で0を1に移動したとき' do
       before do
-        @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :author_id => @author.id
-        @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :author_id => @author.id
-        @story3 = FactoryGirl.create :story, :t => 2, :comic_id => @comic.id, :author_id => @author.id
+        @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id
+        @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id
+        @story3 = FactoryGirl.create :story, :t => 2, :comic_id => @comic.id
         @ot = @story.t
         @story.t = 1
       end
@@ -1097,11 +1065,11 @@ describe Story do
     end
     context 'テーブルに5件(t:0,1,2,3,4)で1を3に移動したとき' do
       before do
-        @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :author_id => @author.id
-        @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :author_id => @author.id
-        @story3 = FactoryGirl.create :story, :t => 2, :comic_id => @comic.id, :author_id => @author.id
-        @story4 = FactoryGirl.create :story, :t => 3, :comic_id => @comic.id, :author_id => @author.id
-        @story5 = FactoryGirl.create :story, :t => 4, :comic_id => @comic.id, :author_id => @author.id
+        @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id
+        @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id
+        @story3 = FactoryGirl.create :story, :t => 2, :comic_id => @comic.id
+        @story4 = FactoryGirl.create :story, :t => 3, :comic_id => @comic.id
+        @story5 = FactoryGirl.create :story, :t => 4, :comic_id => @comic.id
         @ot = @story2.t
         @story2.t = 3
       end
@@ -1135,12 +1103,12 @@ describe Story do
     context '先ほどのケース+他のコミック1件で挿入したとき' do
       before do
         @comic2 = FactoryGirl.create :comic, :author_id => @author.id
-        @storyc2 = FactoryGirl.create :story, :t => 0, :comic_id => @comic2.id, :author_id => @author.id
-        @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :author_id => @author.id
-        @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :author_id => @author.id
-        @story3 = FactoryGirl.create :story, :t => 2, :comic_id => @comic.id, :author_id => @author.id
-        @story4 = FactoryGirl.create :story, :t => 3, :comic_id => @comic.id, :author_id => @author.id
-        @story5 = FactoryGirl.create :story, :t => 4, :comic_id => @comic.id, :author_id => @author.id
+        @storyc2 = FactoryGirl.create :story, :t => 0, :comic_id => @comic2.id
+        @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id
+        @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id
+        @story3 = FactoryGirl.create :story, :t => 2, :comic_id => @comic.id
+        @story4 = FactoryGirl.create :story, :t => 3, :comic_id => @comic.id
+        @story5 = FactoryGirl.create :story, :t => 4, :comic_id => @comic.id
         @ot = @story2.t
         @story2.t = 3
       end
@@ -1180,8 +1148,8 @@ describe Story do
     #max超えたときはmaxとして正常扱い
     context 'テーブルに2件(t:0,1)で0を2に移動したとき' do
       before do
-        @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :author_id => @author.id
-        @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :author_id => @author.id
+        @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id
+        @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id
         @ot = @story.t
         @story.t = 2
       end
@@ -1205,8 +1173,8 @@ describe Story do
   describe '入れ替えに於いて' do
     before do
       @comic = FactoryGirl.create :comic, :author_id => @author.id
-      @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :author_id => @author.id
-      @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :author_id => @author.id
+      @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id
+      @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id
     end
     context '新tが旧tより小さいとき' do
       it '少ない方に移動を依頼している' do
@@ -1233,7 +1201,7 @@ describe Story do
     end
     context 'オブジェクトが新規でtが空のとき' do
       it '末尾追加としてtを補充依頼している' do
-        @story = FactoryGirl.build :story, :comic_id => @comic.id, :author_id => @author.id
+        @story = FactoryGirl.build :story, :comic_id => @comic.id
         Story.stub(:new_t).with(any_args).and_return(0)
         Story.should_receive(:new_t).with(any_args).exactly(1)
         @story.t = nil
@@ -1242,7 +1210,7 @@ describe Story do
     end
     context 'オブジェクトが新規でtが設定されているとき' do
       it '挿入追加として挿入シフトを依頼している' do
-        @story = FactoryGirl.build :story, :comic_id => @comic.id, :author_id => @author.id
+        @story = FactoryGirl.build :story, :comic_id => @comic.id
         Story.any_instance.stub(:insert_shift).with(any_args)
         Story.any_instance.should_receive(:insert_shift).with(any_args).exactly(1)
         @story.t = 0
@@ -1251,8 +1219,8 @@ describe Story do
     end
     context 'オブジェクトが新規でなくtが設定されているとき' do
       it '移動として入れ替えを依頼している' do
-        @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :author_id => @author.id
-        @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :author_id => @author.id
+        @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id
+        @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id
         Story.any_instance.stub(:update_shift).with(any_args)
         Story.any_instance.should_receive(:update_shift).with(1).exactly(1)
         @story2.t = 0
@@ -1268,20 +1236,18 @@ describe Story do
   describe '編集許可に於いて' do
     before do
       @comic = FactoryGirl.create :comic, :author_id => @author.id
-      @panel = FactoryGirl.create :panel, :author_id => @author.id
-      @story = FactoryGirl.build :story, :t => nil, :comic_id => @comic.id, :author_id => @author.id
+      @story = FactoryGirl.build :story, :t => nil, :comic_id => @comic.id
     end
     context 'つつがなく終わるとき' do
       it 'trueを返す' do
-        r = @story.allow?
+        r = @story.allow? @author
         r.should be_true
       end
     end
     context 'コミックで引っかかるとき' do
       it 'falseを返す' do
-        Panel.any_instance.stub(:usable?).with(any_args).and_return(true)
         Comic.any_instance.stub(:own?).with(any_args).and_return(false)
-        r = @story.allow?
+        r = @story.allow? @other_author
         r.should be_false
       end
     end
@@ -1289,7 +1255,7 @@ describe Story do
       it 'nilを返す' do
         Comic.any_instance.stub(:own?).with(any_args).and_return(true)
         @story.comic_id = nil
-        r = @story.allow?
+        r = @story.allow? @author
         r.should eq nil
       end
     end
@@ -1297,81 +1263,81 @@ describe Story do
   describe '保存に於いて' do
     before do
       @comic = FactoryGirl.create :comic, :author_id => @author.id
-      @story = FactoryGirl.build :story, :t => nil, :comic_id => @comic.id, :author_id => @author.id
+      @story = FactoryGirl.build :story, :t => nil, :comic_id => @comic.id
     end
     context 'つつがなく終わるとき' do
       it '編集許可チェックを依頼している' do
         Story.any_instance.stub(:allow?).with(any_args).and_return(true)
         Story.any_instance.should_receive(:allow?).with(any_args).exactly(1)
-        r = @story.store
+        r = @story.store @author
       end
       it '順序入れ替えを依頼している' do
         Story.any_instance.stub(:rotate).with(any_args).and_return(0)
         Story.any_instance.should_receive(:rotate).with(any_args).exactly(1)
         Story.any_instance.stub(:save).with(any_args).and_return(true)
         Story.stub(:validate_t).with(any_args).and_return(true)
-        r = @story.store 
+        r = @story.store @author
       end
       it '保存を依頼している' do
         Story.stub(:new_t).with(any_args).and_return(0)
         Story.any_instance.stub(:save).with(any_args).and_return(true)
         Story.any_instance.should_receive(:save).with(any_args).exactly(1)
         Story.stub(:validate_t).with(any_args).and_return(true)
-        r = @story.store
+        r = @story.store @author
       end
       it 'tのシリアライズチェックを依頼している' do
         Story.stub(:new_t).with(any_args).and_return(0)
         Story.any_instance.stub(:save).with(any_args).and_return(true)
         Story.stub(:validate_t).with(any_args).and_return(true)
         Story.should_receive(:validate_t).with(any_args).exactly(1)
-        r = @story.store
+        r = @story.store @author
       end
     end
     #入れ替えテストと同じテストを実施。こちらはシフトだけでなく本尊も更新されている
     context 'テーブルに5件(t:0,1,2,3,4)+他のコミック1件で2に挿入したとき' do
       before do
         @comic2 = FactoryGirl.create :comic, :author_id => @author.id
-        @storyc2 = FactoryGirl.create :story, :t => 0, :comic_id => @comic2.id, :author_id => @author.id
-        @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :author_id => @author.id
-        @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :author_id => @author.id
-        @story3 = FactoryGirl.create :story, :t => 2, :comic_id => @comic.id, :author_id => @author.id
-        @story4 = FactoryGirl.create :story, :t => 3, :comic_id => @comic.id, :author_id => @author.id
-        @story5 = FactoryGirl.create :story, :t => 4, :comic_id => @comic.id, :author_id => @author.id
-        @story6 = FactoryGirl.build :story, :t => 2, :comic_id => @comic.id, :author_id => @author.id
+        @storyc2 = FactoryGirl.create :story, :t => 0, :comic_id => @comic2.id
+        @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id
+        @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id
+        @story3 = FactoryGirl.create :story, :t => 2, :comic_id => @comic.id
+        @story4 = FactoryGirl.create :story, :t => 3, :comic_id => @comic.id
+        @story5 = FactoryGirl.create :story, :t => 4, :comic_id => @comic.id
+        @story6 = FactoryGirl.build :story, :t => 2, :comic_id => @comic.id
       end
       it '既存のt0には変化がない' do
-        @story6.store
+        @story6.store @author
         @story.reload
         @story.t.should eq 0
       end
       it '既存のt1には変化がない' do
-        @story6.store
+        @story6.store @author
         @story2.reload
         @story2.t.should eq 1
       end
       it '既存のt2を3にシフトしている' do
-        @story6.store
+        @story6.store @author
         @story3.reload
         @story3.t.should eq 3
       end
       it '既存のt3を4にシフトしている' do
-        @story6.store
+        @story6.store @author
         @story4.reload
         @story4.t.should eq 4
       end
       it '既存のt5を5にシフトしている' do
-        @story6.store
+        @story6.store @author
         @story5.reload
         @story5.t.should eq 5
       end
       it '新規のt2が作成されている' do
-        @story6.store
+        @story6.store @author
         @story6.reload
         @story6.t.should eq 2
       end
       it '他のコミックに影響がない' do
         @ot = @storyc2.t
-        @story6.store
+        @story6.store @author
         @storyc2.reload
         @storyc2.t.should eq @ot
       end
@@ -1379,42 +1345,42 @@ describe Story do
     context 'テーブルに5件(t:0,1,2,3,4)+他のコミック1件で3を1に移動したとき' do
       before do
         @comic2 = FactoryGirl.create :comic, :author_id => @author.id
-        @storyc2 = FactoryGirl.create :story, :t => 0, :comic_id => @comic2.id, :author_id => @author.id
-        @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :author_id => @author.id
-        @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :author_id => @author.id
-        @story3 = FactoryGirl.create :story, :t => 2, :comic_id => @comic.id, :author_id => @author.id
-        @story4 = FactoryGirl.create :story, :t => 3, :comic_id => @comic.id, :author_id => @author.id
-        @story5 = FactoryGirl.create :story, :t => 4, :comic_id => @comic.id, :author_id => @author.id
+        @storyc2 = FactoryGirl.create :story, :t => 0, :comic_id => @comic2.id
+        @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id
+        @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id
+        @story3 = FactoryGirl.create :story, :t => 2, :comic_id => @comic.id
+        @story4 = FactoryGirl.create :story, :t => 3, :comic_id => @comic.id
+        @story5 = FactoryGirl.create :story, :t => 4, :comic_id => @comic.id
         @ot = @story4.t
         @story4.t = 1
       end
       it '既存のt0には変化がない' do
-        @story4.store @ot
+        @story4.store  @author, @ot
         @story.reload
         @story.t.should eq 0
       end
       it '既存のt4には変化がない' do
-        @story4.store @ot
+        @story4.store @author, @ot
         @story5.reload
         @story5.t.should eq 4
       end
       it '既存のt1を2にシフトしている' do
-        @story4.store @ot
+        @story4.store @author, @ot
         @story2.reload
         @story2.t.should eq 2
       end
       it '既存のt2を3にシフトしている' do
-        @story4.store @ot
+        @story4.store @author, @ot
         @story3.reload
         @story3.t.should eq 3
       end
       it '既存のt3を1にシフトしている' do
-        @story4.store @ot
+        @story4.store @author, @ot
         @story4.reload
         @story4.t.should eq 1
       end
       it '他のコミックに影響がない' do
-        @story4.store @ot
+        @story4.store @author, @ot
         @storyc2.reload
         @storyc2.t.should eq 0
       end
@@ -1422,42 +1388,42 @@ describe Story do
     context 'テーブルに5件(t:0,1,2,3,4)+他のコミック1件で1を3に移動したとき' do
       before do
         @comic2 = FactoryGirl.create :comic, :author_id => @author.id
-        @storyc2 = FactoryGirl.create :story, :t => 0, :comic_id => @comic2.id, :author_id => @author.id
-        @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :author_id => @author.id
-        @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :author_id => @author.id
-        @story3 = FactoryGirl.create :story, :t => 2, :comic_id => @comic.id, :author_id => @author.id
-        @story4 = FactoryGirl.create :story, :t => 3, :comic_id => @comic.id, :author_id => @author.id
-        @story5 = FactoryGirl.create :story, :t => 4, :comic_id => @comic.id, :author_id => @author.id
+        @storyc2 = FactoryGirl.create :story, :t => 0, :comic_id => @comic2.id
+        @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id
+        @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id
+        @story3 = FactoryGirl.create :story, :t => 2, :comic_id => @comic.id
+        @story4 = FactoryGirl.create :story, :t => 3, :comic_id => @comic.id
+        @story5 = FactoryGirl.create :story, :t => 4, :comic_id => @comic.id
         @ot = @story2.t
         @story2.t = 3
       end
       it '既存のt0には変化がない' do
-        @story2.store @ot
+        @story2.store @author, @ot
         @story.reload
         @story.t.should eq 0
       end
       it '既存のt4には変化がない' do
-        @story2.store @ot
+        @story2.store @author, @ot
         @story5.reload
         @story5.t.should eq 4
       end
       it '既存のt1を3にシフトしている' do
-        @story2.store @ot
+        @story2.store @author, @ot
         @story2.reload
         @story2.t.should eq 3
       end
       it '既存のt2を1にシフトしている' do
-        @story2.store @ot
+        @story2.store @author, @ot
         @story3.reload
         @story3.t.should eq 1
       end
       it '既存のt3を2にシフトしている' do
-        @story2.store @ot
+        @story2.store @author, @ot
         @story4.reload
         @story4.t.should eq 2
       end
       it '他のコミックに影響がない' do
-        @story2.store @ot
+        @story2.store @author, @ot
         @storyc2.reload
         @storyc2.t.should eq 0
       end
@@ -1467,16 +1433,16 @@ describe Story do
       before do
         Story.any_instance.stub(:save).with(any_args).and_return(false)
         @comic2 = FactoryGirl.create :comic, :author_id => @author.id
-        @storyc2 = FactoryGirl.create :story, :t => 0, :comic_id => @comic2.id, :author_id => @author.id
-        @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :author_id => @author.id
-        @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :author_id => @author.id
-        @story3 = FactoryGirl.create :story, :t => 2, :comic_id => @comic.id, :author_id => @author.id
-        @story4 = FactoryGirl.create :story, :t => 3, :comic_id => @comic.id, :author_id => @author.id
-        @story5 = FactoryGirl.create :story, :t => 4, :comic_id => @comic.id, :author_id => @author.id
-        @story6 = FactoryGirl.build :story, :t => 2, :comic_id => @comic.id, :author_id => @author.id
+        @storyc2 = FactoryGirl.create :story, :t => 0, :comic_id => @comic2.id
+        @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id
+        @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id
+        @story3 = FactoryGirl.create :story, :t => 2, :comic_id => @comic.id
+        @story4 = FactoryGirl.create :story, :t => 3, :comic_id => @comic.id
+        @story5 = FactoryGirl.create :story, :t => 4, :comic_id => @comic.id
+        @story6 = FactoryGirl.build :story, :t => 2, :comic_id => @comic.id
       end
       it '既存のtに変化がない' do
-        @story6.store
+        @story6.store @author
         @story.reload
         @story.t.should eq 0
         @story2.reload
@@ -1491,7 +1457,7 @@ describe Story do
         @storyc2.t.should eq 0
       end
       it 'falseを返す' do
-        r = @story6.store
+        r = @story6.store @author
         r.should be_false
       end
     end
@@ -1499,17 +1465,17 @@ describe Story do
       before do
         Story.stub(:validate_t).with(any_args).and_return(false)
         @comic2 = FactoryGirl.create :comic, :author_id => @author.id
-        @storyc2 = FactoryGirl.create :story, :t => 0, :comic_id => @comic2.id, :author_id => @author.id
-        @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :author_id => @author.id
-        @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :author_id => @author.id
-        @story3 = FactoryGirl.create :story, :t => 2, :comic_id => @comic.id, :author_id => @author.id
-        @story4 = FactoryGirl.create :story, :t => 3, :comic_id => @comic.id, :author_id => @author.id
-        @story5 = FactoryGirl.create :story, :t => 4, :comic_id => @comic.id, :author_id => @author.id
+        @storyc2 = FactoryGirl.create :story, :t => 0, :comic_id => @comic2.id
+        @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id
+        @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id
+        @story3 = FactoryGirl.create :story, :t => 2, :comic_id => @comic.id
+        @story4 = FactoryGirl.create :story, :t => 3, :comic_id => @comic.id
+        @story5 = FactoryGirl.create :story, :t => 4, :comic_id => @comic.id
         @ot = @story4.t
         @story4.t = 1
       end
       it '既存のtに変化がない' do
-        @story4.store @ot
+        @story4.store @author, @ot
         @story.reload
         @story.t.should eq 0
         @story2.reload
@@ -1524,23 +1490,23 @@ describe Story do
         @storyc2.t.should eq 0
       end
       it 'falseを返す' do
-        r = @story4.store @ot
+        r = @story4.store @author, @ot
         r.should be_false
       end
       it 'tにエラーメッセージが入っている' do
-        @story4.store @ot
+        @story4.store @author, @ot
         @story4.errors[:t].should_not be_empty
         @story4.valid?.should be_true
       end
     end
     context '編集不可だったとき' do
       before do
-        @story = FactoryGirl.build :story, :t => 0, :comic_id => @comic.id, :author_id => @author.id
+        @story = FactoryGirl.build :story, :t => 0, :comic_id => @comic.id
         Story.any_instance.stub(:allow?).and_return(false)
       end
       it '403Forbidden例外を返す' do
         lambda{
-          @story.store
+          @story.store @author
         }.should raise_error(ActiveRecord::Forbidden)
       end
     end
@@ -1548,9 +1514,14 @@ describe Story do
   describe '切り詰め処理つき削除に於いて' do
     before do
       @comic = FactoryGirl.create :comic, :author_id => @author.id
-      @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :author_id => @author.id
+      @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id
     end
     context 'つつがなく終わるとき' do
+      it '削除を依頼している' do
+        Story.any_instance.stub(:destroy_with_story_sheet).with(any_args).and_return(true)
+        Story.any_instance.should_receive(:destroy_with_story_sheet).with(any_args).exactly(1)
+        r = @story.destroy_and_shorten
+      end
       it '削除される' do
         lambda{
           @story.destroy_and_shorten
@@ -1563,7 +1534,7 @@ describe Story do
     end
     context '削除に失敗したとき' do
       before do
-        Story.any_instance.stub(:destroy).and_return(false)
+        Story.any_instance.stub(:destroy_with_story_sheet).and_return(false)
       end
       it 'ロールバックされる' do
         lambda{
@@ -1578,7 +1549,7 @@ describe Story do
     #連携テスト。切り詰めが直接DBをいじる
     context '2件で先頭を削除したとき' do
       before do
-        @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :author_id => @author.id
+        @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id
       end
       it '行が削除される' do
         lambda{
@@ -1599,8 +1570,8 @@ describe Story do
     end
     context '3件で先頭を削除したとき' do
       before do
-        @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :author_id => @author.id
-        @story3 = FactoryGirl.create :story, :t => 2, :comic_id => @comic.id, :author_id => @author.id
+        @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id
+        @story3 = FactoryGirl.create :story, :t => 2, :comic_id => @comic.id
       end
       it '行が削除される' do
         lambda{
@@ -1626,10 +1597,10 @@ describe Story do
     end
     context '5件で3件目を削除したとき' do
       before do
-        @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :author_id => @author.id
-        @story3 = FactoryGirl.create :story, :t => 2, :comic_id => @comic.id, :author_id => @author.id
-        @story4 = FactoryGirl.create :story, :t => 3, :comic_id => @comic.id, :author_id => @author.id
-        @story5 = FactoryGirl.create :story, :t => 4, :comic_id => @comic.id, :author_id => @author.id
+        @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id
+        @story3 = FactoryGirl.create :story, :t => 2, :comic_id => @comic.id
+        @story4 = FactoryGirl.create :story, :t => 3, :comic_id => @comic.id
+        @story5 = FactoryGirl.create :story, :t => 4, :comic_id => @comic.id
       end
       it '行が削除される' do
         lambda{
@@ -1668,11 +1639,11 @@ describe Story 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
+      @story = FactoryGirl.create :story, :comic_id => @comic.id
       @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 => @author.id
-      @other_story = FactoryGirl.create :story, :comic_id => @other_comic.id, :author_id => @author.id
+      @other_story = FactoryGirl.create :story, :comic_id => @other_comic.id
       @other_sheet = FactoryGirl.create :sheet, :author_id => @author.id
       @other_story_sheet = FactoryGirl.create :story_sheet, :author_id => @author.id, :story_id => @other_story.id, :sheet_id => @other_sheet.id
     end