OSDN Git Service

t#29400:itr3?
[pettanr/pettanr.git] / spec / models / story_spec.rb
index 34b1987..bdda015 100644 (file)
@@ -3,31 +3,36 @@ require 'spec_helper'
 #ストーリー
 describe Story do
   before do
-    Factory :admin
-    @license = Factory :license
-    @user = Factory( :user_yas)
+    FactoryGirl.create :admin
+    @sp = FactoryGirl.create :system_picture
+    @lg = FactoryGirl.create :license_group
+    @license = FactoryGirl.create :license, :license_group_id => @lg.id, :system_picture_id => @sp.id
+    @user = FactoryGirl.create( :user_yas)
     @author = @user.author
-    @artist = Factory :artist_yas, :author_id => @author.id
-    @other_user = Factory( :user_yas)
+    @artist = FactoryGirl.create :artist_yas, :author_id => @author.id
+    @other_user = FactoryGirl.create( :user_yas)
     @other_author = @other_user.author
   end
   
   describe '検証に於いて' do
     before do
-      @comic = Factory :comic, :author_id => @author.id
-      @panel = Factory :panel, :author_id => @author.id
-      @story = Factory.build :story, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+      @comic = FactoryGirl.create :comic, :author_id => @author.id
+      @panel = FactoryGirl.create :panel, :author_id => @author.id
+      @story = FactoryGirl.build :story, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
     end
     
-    it 'オーソドックスなデータなら通る' do
-      @story.should be_valid
+    context 'オーソドックスなデータのとき' do
+      it '下限データが通る' do
+        @story.t = 0
+        @story.should be_valid
+      end
+      it '上限データが通る' do
+        @story.t = 99999
+        @story.should be_valid
+      end
     end
     
     context 'comic_idを検証するとき' do
-      it 'テストデータの確認' do
-        @story.comic_id = @comic.id
-        @story.should be_valid
-      end
       it 'nullなら失敗する' do
         @story.comic_id = nil
         @story.should_not be_valid
@@ -43,10 +48,6 @@ describe Story do
     end
     
     context 'panel_idを検証するとき' do
-      it 'テストデータの確認' do
-        @story.panel_id = @panel.id
-        @story.should be_valid
-      end
       it 'nullなら失敗する' do
         @story.panel_id = nil
         @story.should_not be_valid
@@ -62,12 +63,6 @@ describe Story do
     end
     
     context 'tを検証するとき' do
-      before do
-      end
-      it 'テストデータの確認' do
-        @story.t = 0
-        @story.should be_valid
-      end
       it 'nullなら失敗する' do
         @story.t = nil
         @story.should_not be_valid
@@ -83,10 +78,6 @@ describe Story do
     end
     
     context 'author_idを検証するとき' do
-      it 'テストデータの確認' do
-        @story.author_id = @author.id
-        @story.should be_valid
-      end
       it 'nullなら失敗する' do
         @story.author_id = nil
         @story.should_not be_valid
@@ -101,37 +92,49 @@ describe Story do
       end
     end
     context '全体を検証するとき' do
-      before do
-        @story = Factory :story, :author_id => @author.id
-      end
     end
   end
   
-  describe 'ã\83\87ã\83¼ã\82¿補充に於いて' do
+  describe 'ã\83\87ã\83\95ã\82©ã\83«ã\83\88å\80¤補充に於いて' do
     before do
-      @comic = Factory :comic, :author_id => @author.id
-      @panel = Factory :panel, :author_id => @author.id
+      @comic = FactoryGirl.create :comic, :author_id => @author.id
+      @panel = FactoryGirl.create :panel, :author_id => @author.id
+    end
+    
+    #dbのデフォルト値が0だから明示的にnilにしないと追加ができない
+    it 'tをnilにする' do
+      @story = FactoryGirl.build :story, :comic_id => @comic.id, :panel_id => @panel.id
+      @story.supply_default
+      @story.t.should be_nil
+    end
+    
+  end
+  
+  describe '上書き補充に於いて' do
+    before do
+      @comic = FactoryGirl.create :comic, :author_id => @author.id
+      @panel = FactoryGirl.create :panel, :author_id => @author.id
     end
     
     context 'author_idを補充' do
       it '問答無用でauthor_idを補充する' do
-        @story = Factory.build :story, :comic_id => @comic.id, :panel_id => @panel.id
+        @story = FactoryGirl.build :story, :comic_id => @comic.id, :panel_id => @panel.id
         @story.author_id = nil
-        @story.supply_default @author
+        @story.overwrite @author
         @story.author_id.should eq @author.id
       end
     end
     
   end
   
-  describe '作者判定に於いて' do
+  describe '所持判定に於いて' do
     before do
-      @comic = Factory :comic, :author_id => @author.id
-      @panel = Factory :panel, :author_id => @author.id
-      @story = Factory :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id
-      @comico = Factory :comic, :author_id => @other_author.id
-      @panelo = Factory :panel, :author_id => @other_author.id
-      @storyo = Factory :story, :author_id => @other_author.id, :comic_id => @comico.id, :panel_id => @panelo.id
+      @comic = FactoryGirl.create :comic, :author_id => @author.id
+      @panel = FactoryGirl.create :panel, :author_id => @author.id
+      @story = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id
+      @comico = FactoryGirl.create :comic, :author_id => @other_author.id
+      @panelo = FactoryGirl.create :panel, :author_id => @other_author.id
+      @storyo = FactoryGirl.create :story, :author_id => @other_author.id, :comic_id => @comico.id, :panel_id => @panelo.id
     end
     it '自分のストーリーならyes' do
       @story.own?(@author).should == true
@@ -139,50 +142,15 @@ describe Story do
     it '他人のストーリーならno' do
       @storyo.own?(@author).should == false
     end
-    it '作家が不明ならno' do
-      @story.own?(nil).should == false
-    end
-  end
-  describe '単体取得に於いて' do
-    before do
-      @comic = Factory :comic, :author_id => @author.id
-      @panel = Factory :panel, :author_id => @author.id
-      @story = Factory :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id
-    end
-    context 'オーナー指定がないとき' do
-      it '指定のストーリーを返す' do
-        l = Story.show @story.id, @author
-        l.should eq @story
-      end
-    end
-    context 'オーナー指定のとき' do
-      it '指定のストーリーが自分のものならそれを返す' do
-        l = Story.show @story.id, @author
-        l.should eq @story
-      end
-      context '他人のストーリーを開こうとしたとき' do
-        it '403Forbidden例外を返す' do
-          Story.any_instance.stub(:own?).and_return(false)
-          lambda{
-            Story.show @story.id, @author
-          }.should raise_error(ActiveRecord::Forbidden)
-        end
-      end
-    end
-    context '存在しないストーリーを開こうとしたとき' do
-      it '404RecordNotFound例外を返す' do
-        lambda{
-          Story.show 110, @author
-        }.should raise_error(ActiveRecord::RecordNotFound)
-      end
-    end
   end
-  
   describe '一覧取得に於いて' do
     before do
-      @comic = Factory :comic, :author_id => @author.id
-      @panel = Factory :panel, :author_id => @author.id
-      @story = Factory :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id
+      @comic = FactoryGirl.create :comic, :author_id => @author.id
+      @panel = FactoryGirl.create :panel, :author_id => @author.id
+      @story = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id
+      @panel2 = FactoryGirl.create :panel, :author_id => @author.id, :publish => 0
+      @other_comic = FactoryGirl.create :comic, :author_id => @other_author.id, :visible => 1
+      @other_panel = FactoryGirl.create :panel, :author_id => @other_author.id, :publish => 1
     end
     context 'offset補正について' do
       it '文字列から数値に変換される' do
@@ -231,16 +199,22 @@ describe Story do
       c.should eq [@story]
     end
     it 't順で並んでいる' do
-      v = Factory :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id, :t => 1
+      #公開コミックの公開コマは(他人のコミックであっても)含んでいる
+      v = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id, :t => 1
       c = Story.list @comic, @author
       c.should eq [ @story, v]
     end
+    it '非公開のコマは含まない' do
+      h = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel2.id, :t => 1
+      c = Story.list @comic, @author
+      c.should eq [ @story]
+    end
     context 'DBに5件あって1ページの件数を2件に変えたとして' do
       before do
-        @story2 = Factory :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id, :t => 1
-        @story3 = Factory :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id, :t => 2
-        @story4 = Factory :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id, :t => 3
-        @story5 = Factory :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id, :t => 4
+        @story2 = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id, :t => 1
+        @story3 = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id, :t => 2
+        @story4 = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id, :t => 3
+        @story5 = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id, :t => 4
       end
       it 'offset=0なら末尾2件を返す' do
         #時系列で並んでいる
@@ -290,10 +264,30 @@ describe Story do
         r = Story.list_opt[:include]
         r[:panel].has_key?(:panel_pictures).should be_true
       end
+        it 'コマ絵は実素材を含んでいる' do
+          r = Story.list_opt[:include]
+          r[:panel][:panel_pictures].has_key?(:picture).should be_true
+        end
+          it '実素材は絵師を含んでいる' do
+            r = Story.list_opt[:include]
+            r[:panel][:panel_pictures][:picture].has_key?(:artist).should be_true
+          end
+          it '実素材はライセンスを含んでいる' do
+            r = Story.list_opt[:include]
+            r[:panel][:panel_pictures][:picture].has_key?(:license).should be_true
+          end
       it 'コマはフキダシを含んでいる' do
         r = Story.list_opt[:include]
         r[:panel].has_key?(:speech_balloons).should be_true
       end
+        it 'フキダシはフキダシ枠を含んでいる' do
+          r = Story.list_opt[:include]
+          r[:panel][:speech_balloons].has_key?(:balloons).should be_true
+        end
+        it 'フキダシはセリフを含んでいる' do
+          r = Story.list_opt[:include]
+          r[:panel][:speech_balloons].has_key?(:speeches).should be_true
+        end
   end
   describe 'json一覧出力オプションに於いて' do
     it 'includeキーを含んでいる' do
@@ -328,20 +322,270 @@ describe Story do
         r = Story.list_json_opt[:include]
         r[:panel].has_key?(:panel_pictures).should be_true
       end
+        it 'コマ絵は実素材を含んでいる' do
+          r = Story.list_json_opt[:include]
+          r[:panel][:panel_pictures].has_key?(:picture).should be_true
+        end
+          it '実素材は絵師を含んでいる' do
+            r = Story.list_json_opt[:include]
+            r[:panel][:panel_pictures][:picture].has_key?(:artist).should be_true
+          end
+          it '実素材はライセンスを含んでいる' do
+            r = Story.list_json_opt[:include]
+            r[:panel][:panel_pictures][:picture].has_key?(:license).should be_true
+          end
       it 'コマはフキダシを含んでいる' do
         r = Story.list_json_opt[:include]
         r[:panel].has_key?(:speech_balloons).should be_true
       end
+        it 'フキダシはフキダシ枠を含んでいる' do
+          r = Story.list_json_opt[:include]
+          r[:panel][:speech_balloons].has_key?(:balloons).should be_true
+        end
+        it 'フキダシはセリフを含んでいる' do
+          r = Story.list_json_opt[:include]
+          r[:panel][:speech_balloons].has_key?(:speeches).should be_true
+        end
+  end
+  
+  describe '自分のストーリー一覧取得に於いて' do
+    before do
+      @comic = FactoryGirl.create :comic, :author_id => @author.id, :visible => 0
+      @panel = FactoryGirl.create :panel, :author_id => @author.id, :publish => 0
+      @story = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id
+      @other_comic = FactoryGirl.create :comic, :author_id => @other_author.id, :visible => 1
+      @other_panel = FactoryGirl.create :panel, :author_id => @other_author.id, :publish => 1
+    end
+    context 'つつがなく終わるとき' do\r
+      it '一覧取得オプションを利用している' do\r
+        Story.stub(:list_opt).with(any_args).and_return({})\r
+        Story.should_receive(:list_opt).with(any_args).exactly(1)\r
+        r = Story.mylist @author
+      end\r
+    end\r
+    it 'リストを返す' do
+      s = Story.mylist @author
+      s.should eq [@story]
+    end
+    it '時系列で並んでいる' do
+      ns = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id, :t => 1, :updated_at => Time.now + 100
+      sl = Story.mylist @author
+      sl.should eq [ns, @story]
+    end
+    it '他人のストーリーはコマコミックともに公開でも含まない' do
+      so = FactoryGirl.create :story, :author_id => @other_author.id, :comic_id => @other_comic.id, :panel_id => @other_panel.id
+      sl = Story.mylist @author
+      sl.should eq [@story]
+    end
+    it '自分のストーリーはコマコミックともには非公開でも含んでいる' do
+      nc = FactoryGirl.create :comic, :author_id => @author.id, :visible => 0, :updated_at => Time.now + 100
+      cl = Comic.mylist @author
+      cl.should eq [nc, @story]
+    end
+    context 'DBに5件あって1ページの件数を2件に変えたとして' do
+      before do
+        @story2 = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id, :t => 1, :updated_at => Time.now + 100
+        @story3 = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id, :t => 2, :updated_at => Time.now + 200
+        @story4 = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id, :t => 3, :updated_at => Time.now + 300
+        @story5 = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id, :t => 4, :updated_at => Time.now + 400
+      end
+      it '通常は2件を返す' do
+        c = Story.mylist @author, 1, 2
+        c.should have(2).items 
+      end
+      it 'page=1なら末尾2件を返す' do
+        #時系列で並んでいる
+        c = Story.mylist(@author, 1, 2)
+        c.should eq [@story5, @story4]
+      end
+      it 'page=2なら中間2件を返す' do
+        c = Story.mylist(@author, 2, 2)
+        c.should eq [@story3, @story2]
+      end
+      it 'page=3なら先頭1件を返す' do
+        c = Story.mylist(@author, 3, 2)
+        c.should eq [@story]
+      end
+    end
+    context 'DBに5件あって1ページの件数を0件に変えたとして' do
+      before do
+        @story2 = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id, :t => 1, :updated_at => Time.now + 100
+        @story3 = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id, :t => 2, :updated_at => Time.now + 200
+        @story4 = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id, :t => 3, :updated_at => Time.now + 300
+        @story5 = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id, :t => 4, :updated_at => Time.now + 400
+      end
+      it '通常は全件(5件)を返す' do
+        r = Story.mylist @author, 5, 0
+        r.should have(5).items 
+      end
+    end
   end
+  
+  describe '編集取得に於いて' do
+    before do
+      @comic = FactoryGirl.create :comic, :author_id => @author.id
+      @panel = FactoryGirl.create :panel, :author_id => @author.id
+      @story = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id
+    end
+    context 'つつがなく終わるとき' do\r
+      it '単体取得オプションを利用している' do\r
+        Story.stub(:show_opt).with(any_args).and_return({})\r
+        Story.should_receive(:show_opt).with(any_args).exactly(1)\r
+        r = Story.edit @story.id, @author
+      end\r
+      it '所持判定を問い合わせている' do\r
+        Story.any_instance.stub(:own?).with(any_args).and_return(true)\r
+        Story.any_instance.should_receive(:own?).with(any_args).exactly(1)\r
+        r = Story.edit @story.id, @author
+      end\r
+    end\r
+    it '指定のストーリーを返す' do
+      l = Story.edit @story.id, @author
+      l.should eq @story
+    end
+    context '他人のストーリーを開こうとしたとき' do
+      it '403Forbidden例外を返す' do
+        Story.any_instance.stub(:own?).and_return(false)
+        lambda{
+          Story.edit @story.id, @author
+        }.should raise_error(ActiveRecord::Forbidden)
+      end
+    end
+    context '存在しないストーリーを開こうとしたとき' do
+      it '404RecordNotFound例外を返す' do
+        lambda{
+          Story.edit 110, @author
+        }.should raise_error(ActiveRecord::RecordNotFound)
+      end
+    end
+  end
+  
+  describe '単体取得オプションに於いて' do
+    it 'includeキーを含んでいる' do
+      r = Story.show_opt
+      r.has_key?(:include).should be_true
+    end
+    it '3つの項目を含んでいる' do
+      r = Story.show_opt[:include]
+      r.should have(3).items
+    end
+    it 'コミックを含んでいる' do
+      r = Story.show_opt[:include]
+      r.has_key?(:comic).should be_true
+    end
+      it 'コミックは作家を含んでいる' do
+        r = Story.show_opt[:include]
+        r[:comic].has_key?(:author).should be_true
+      end
+    it '作家を含んでいる' do
+      r = Story.show_opt[:include]
+      r.has_key?(:author).should be_true
+    end
+    it 'コマを含んでいる' do
+      r = Story.show_opt[:include]
+      r.has_key?(:panel).should be_true
+    end
+      it 'コマは作家を含んでいる' do
+        r = Story.show_opt[:include]
+        r[:panel].has_key?(:author).should be_true
+      end
+      it 'コマはコマ絵を含んでいる' do
+        r = Story.show_opt[:include]
+        r[:panel].has_key?(:panel_pictures).should be_true
+      end
+        it 'コマ絵は実素材を含んでいる' do
+          r = Story.show_opt[:include]
+          r[:panel][:panel_pictures].has_key?(:picture).should be_true
+        end
+          it '実素材は絵師を含んでいる' do
+            r = Story.show_opt[:include]
+            r[:panel][:panel_pictures][:picture].has_key?(:artist).should be_true
+          end
+          it '実素材はライセンスを含んでいる' do
+            r = Story.show_opt[:include]
+            r[:panel][:panel_pictures][:picture].has_key?(:license).should be_true
+          end
+      it 'コマはフキダシを含んでいる' do
+        r = Story.show_opt[:include]
+        r[:panel].has_key?(:speech_balloons).should be_true
+      end
+        it 'フキダシはフキダシ枠を含んでいる' do
+          r = Story.show_opt[:include]
+          r[:panel][:speech_balloons].has_key?(:balloons).should be_true
+        end
+        it 'フキダシはセリフを含んでいる' do
+          r = Story.show_opt[:include]
+          r[:panel][:speech_balloons].has_key?(:speeches).should be_true
+        end
+  end
+  describe 'json単体取得オプションに於いて' do
+    it 'includeキーを含んでいる' do
+      r = Story.show_json_opt
+      r.has_key?(:include).should be_true
+    end
+    it '3つの項目を含んでいる' do
+      r = Story.show_json_opt[:include]
+      r.should have(3).items
+    end
+    it 'コミックを含んでいる' do
+      r = Story.show_json_opt[:include]
+      r.has_key?(:comic).should be_true
+    end
+      it 'コミックは作家を含んでいる' do
+        r = Story.show_json_opt[:include]
+        r[:comic].has_key?(:author).should be_true
+      end
+    it '作家を含んでいる' do
+      r = Story.show_json_opt[:include]
+      r.has_key?(:author).should be_true
+    end
+    it 'コマを含んでいる' do
+      r = Story.show_json_opt[:include]
+      r.has_key?(:panel).should be_true
+    end
+      it 'コマは作家を含んでいる' do
+        r = Story.show_json_opt[:include]
+        r[:panel].has_key?(:author).should be_true
+      end
+      it 'コマはコマ絵を含んでいる' do
+        r = Story.show_json_opt[:include]
+        r[:panel].has_key?(:panel_pictures).should be_true
+      end
+        it 'コマ絵は実素材を含んでいる' do
+          r = Story.show_json_opt[:include]
+          r[:panel][:panel_pictures].has_key?(:picture).should be_true
+        end
+          it '実素材は絵師を含んでいる' do
+            r = Story.show_json_opt[:include]
+            r[:panel][:panel_pictures][:picture].has_key?(:artist).should be_true
+          end
+          it '実素材はライセンスを含んでいる' do
+            r = Story.show_json_opt[:include]
+            r[:panel][:panel_pictures][:picture].has_key?(:license).should be_true
+          end
+      it 'コマはフキダシを含んでいる' do
+        r = Story.show_json_opt[:include]
+        r[:panel].has_key?(:speech_balloons).should be_true
+      end
+        it 'フキダシはフキダシ枠を含んでいる' do
+          r = Story.show_json_opt[:include]
+          r[:panel][:speech_balloons].has_key?(:balloons).should be_true
+        end
+        it 'フキダシはセリフを含んでいる' do
+          r = Story.show_json_opt[:include]
+          r[:panel][:speech_balloons].has_key?(:speeches).should be_true
+        end
+  end
+  
   describe 't補充値に於いて' do
     before do
-      @comic = Factory :comic, :author_id => @author.id
-      @panel = Factory :panel, :author_id => @author.id
+      @comic = FactoryGirl.create :comic, :author_id => @author.id
+      @panel = FactoryGirl.create :panel, :author_id => @author.id
     end
     
     context 'コミック初のコマなら' do
       it '0を補充値とする' do
-        @story = Factory.build :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id
+        @story = FactoryGirl.build :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id
         @story.t = nil
         r = Story.new_t @story.comic_id
         r.should eq 0
@@ -349,8 +593,8 @@ describe Story do
     end
     context 'コミックに一個コマがあるとき' do
       it '1を補充値とする' do
-        Factory :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id, :t => 0
-        @story = Factory.build :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id
+        FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id, :t => 0
+        @story = FactoryGirl.build :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id
         @story.t = nil
         r = Story.new_t @story.comic_id
         r.should eq 1
@@ -358,9 +602,9 @@ describe Story do
     end
     context 'コミックに2個コマがあるとき' do
       it '2を補充値とする' do
-        Factory :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id, :t => 0
-        Factory :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id, :t => 1
-        @story = Factory.build :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id
+        FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id, :t => 0
+        FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id, :t => 1
+        @story = FactoryGirl.build :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id
         @story.t = nil
         r = Story.new_t @story.comic_id
         r.should eq 2
@@ -399,11 +643,11 @@ describe Story do
   end
   describe 't収集に於いて' do
     before do
-      @comic = Factory :comic, :author_id => @author.id
-      @panel = Factory :panel, :author_id => @author.id
-      @story = Factory :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
-      @comic2 = Factory :comic, :author_id => @author.id
-      @c2story = Factory :story, :t => 0, :comic_id => @comic2.id, :panel_id => @panel.id, :author_id => @author.id
+      @comic = FactoryGirl.create :comic, :author_id => @author.id
+      @panel = FactoryGirl.create :panel, :author_id => @author.id
+      @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+      @comic2 = FactoryGirl.create :comic, :author_id => @author.id
+      @c2story = FactoryGirl.create :story, :t => 0, :comic_id => @comic2.id, :panel_id => @panel.id, :author_id => @author.id
     end
     context 'つつがなく終わるとき' do
       it 'ストーリーから同一コミックのtだけを収集している' do
@@ -413,14 +657,14 @@ describe Story do
     end
     context '複数コマのとき' do
       it 'ストーリーから同一コミックのtだけを収集している' do
-        @story2 = Factory :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+        @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
         r = Story.collect_t @story
         r.sort.should eq [0, 1]
       end
     end
     context '複数コマでヨソのコミックも混じっているとき' do
       it 'ストーリーから同一コミックのtだけを収集している' do
-        @story2 = Factory :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+        @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
         r = Story.collect_t @story
         r.sort.should eq [0, 1]
       end
@@ -428,9 +672,9 @@ describe Story do
   end
   describe 'tチェックに於いて' do
     before do
-      @comic = Factory :comic, :author_id => @author.id
-      @panel = Factory :panel, :author_id => @author.id
-      @story = Factory.build :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+      @comic = FactoryGirl.create :comic, :author_id => @author.id
+      @panel = FactoryGirl.create :panel, :author_id => @author.id
+      @story = FactoryGirl.build :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
     end
     context 'つつがなく終わるとき' do
       it 't収集を依頼している' do
@@ -450,15 +694,15 @@ describe Story do
     #依頼チェックだけでは不安なので最低限のチェックを
     context '新規のとき' do
       it '一件だけで正常通過している' do
-        @story = Factory.build :story, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id, :t => 0
+        @story = FactoryGirl.build :story, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id, :t => 0
         r = Story.validate_t @story
         r.should be_true 
       end
     end
     context '既存のとき' do
       it '2件目を作っても正常通過している' do
-        @story = Factory :story, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id, :t => 0
-        @story2 = Factory.build :story, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id, :t => 1
+        @story = FactoryGirl.create :story, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id, :t => 0
+        @story2 = FactoryGirl.build :story, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id, :t => 1
         r = Story.validate_t @story2
         r.should be_true 
       end
@@ -466,22 +710,22 @@ describe Story do
   end
   describe '挿入シフトに於いて' do
     before do
-      @comic = Factory :comic, :author_id => @author.id
-      @panel = Factory :panel, :author_id => @author.id
+      @comic = FactoryGirl.create :comic, :author_id => @author.id
+      @panel = FactoryGirl.create :panel, :author_id => @author.id
     end
     context '依頼チェック' do
       #テーブルが空で0に挿入
       it 'Updateを依頼している' do
         Story.stub(:update_all).with(any_args)
         Story.should_receive(:update_all).with(any_args).exactly(1)
-        @story = Factory.build :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+        @story = FactoryGirl.build :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
         @story.insert_shift
       end
     end
     context 'テーブルに1件(t:0)で0に挿入したとき' do
       before do
-        @story = Factory :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
-        @story2 = Factory.build :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+        @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+        @story2 = FactoryGirl.build :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
       end
       it '既存の行を1にシフトしている' do
         @story2.insert_shift
@@ -496,9 +740,9 @@ describe Story do
     end
     context 'テーブルに2件(t:0,1)で1に挿入したとき' do
       before do
-        @story = Factory :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
-        @story2 = Factory :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
-        @story3 = Factory.build :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+        @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+        @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+        @story3 = FactoryGirl.build :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
       end
       it '既存のt1を2にシフトしてこれから挿入するt(1)が欠番になっている' do
         @story3.insert_shift
@@ -508,12 +752,12 @@ describe Story do
     end
     context 'テーブルに5件(t:0,1,2,3,4)で2に挿入したとき' do
       before do
-        @story = Factory :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
-        @story2 = Factory :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
-        @story3 = Factory :story, :t => 2, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
-        @story4 = Factory :story, :t => 3, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
-        @story5 = Factory :story, :t => 4, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
-        @story6 = Factory.build :story, :t => 2, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+        @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+        @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+        @story3 = FactoryGirl.create :story, :t => 2, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+        @story4 = FactoryGirl.create :story, :t => 3, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+        @story5 = FactoryGirl.create :story, :t => 4, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+        @story6 = FactoryGirl.build :story, :t => 2, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
       end
       it '既存のt1を2にシフトしてこれから挿入するt(1)が欠番になっている' do
         @story6.insert_shift
@@ -523,14 +767,14 @@ describe Story do
     end
     context '先ほどのケース+他のコミック1件で挿入したとき' do
       before do
-        @comic2 = Factory :comic, :author_id => @author.id
-        @storyc2 = Factory :story, :t => 0, :comic_id => @comic2.id, :panel_id => @panel.id, :author_id => @author.id
-        @story = Factory :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
-        @story2 = Factory :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
-        @story3 = Factory :story, :t => 2, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
-        @story4 = Factory :story, :t => 3, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
-        @story5 = Factory :story, :t => 4, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
-        @story6 = Factory.build :story, :t => 2, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+        @comic2 = FactoryGirl.create :comic, :author_id => @author.id
+        @storyc2 = FactoryGirl.create :story, :t => 0, :comic_id => @comic2.id, :panel_id => @panel.id, :author_id => @author.id
+        @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+        @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+        @story3 = FactoryGirl.create :story, :t => 2, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+        @story4 = FactoryGirl.create :story, :t => 3, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+        @story5 = FactoryGirl.create :story, :t => 4, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+        @story6 = FactoryGirl.build :story, :t => 2, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
       end
       it '既存のt1を2にシフトしてこれから挿入するt(1)が欠番になっている' do
         @story6.insert_shift
@@ -547,13 +791,13 @@ describe Story do
   end
   describe '少ない方に移動に於いて' do
     before do
-      @comic = Factory :comic, :author_id => @author.id
-      @panel = Factory :panel, :author_id => @author.id
+      @comic = FactoryGirl.create :comic, :author_id => @author.id
+      @panel = FactoryGirl.create :panel, :author_id => @author.id
     end
     context '依頼チェック' do
       it 'Updateを依頼している' do
-        @story = Factory :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
-        @story2 = Factory :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+        @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+        @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
         Story.stub(:update_all).with(any_args)
         Story.should_receive(:update_all).with(any_args).exactly(1)
         ot = @story2.t
@@ -563,8 +807,8 @@ describe Story do
     end
     context 'テーブルに2件(t:0,1)で1を0に移動したとき' do
       before do
-        @story = Factory :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
-        @story2 = Factory :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+        @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+        @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
         @ot = @story2.t
         @story2.t = 0
       end
@@ -582,9 +826,9 @@ describe Story do
     end
     context 'テーブルに3件(t:0,1,2)で2を1に移動したとき' do
       before do
-        @story = Factory :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
-        @story2 = Factory :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
-        @story3 = Factory :story, :t => 2, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+        @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+        @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+        @story3 = FactoryGirl.create :story, :t => 2, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
         @ot = @story3.t
         @story3.t = 1
       end
@@ -602,11 +846,11 @@ describe Story do
     end
     context 'テーブルに5件(t:0,1,2,3,4)で3を1に移動したとき' do
       before do
-        @story = Factory :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
-        @story2 = Factory :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
-        @story3 = Factory :story, :t => 2, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
-        @story4 = Factory :story, :t => 3, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
-        @story5 = Factory :story, :t => 4, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+        @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+        @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+        @story3 = FactoryGirl.create :story, :t => 2, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+        @story4 = FactoryGirl.create :story, :t => 3, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+        @story5 = FactoryGirl.create :story, :t => 4, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
         @ot = @story4.t
         @story4.t = 1
       end
@@ -639,13 +883,13 @@ describe Story do
     end
     context '先ほどのケース+他のコミック1件で挿入したとき' do
       before do
-        @comic2 = Factory :comic, :author_id => @author.id
-        @storyc2 = Factory :story, :t => 0, :comic_id => @comic2.id, :panel_id => @panel.id, :author_id => @author.id
-        @story = Factory :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
-        @story2 = Factory :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
-        @story3 = Factory :story, :t => 2, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
-        @story4 = Factory :story, :t => 3, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
-        @story5 = Factory :story, :t => 4, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+        @comic2 = FactoryGirl.create :comic, :author_id => @author.id
+        @storyc2 = FactoryGirl.create :story, :t => 0, :comic_id => @comic2.id, :panel_id => @panel.id, :author_id => @author.id
+        @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+        @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+        @story3 = FactoryGirl.create :story, :t => 2, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+        @story4 = FactoryGirl.create :story, :t => 3, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+        @story5 = FactoryGirl.create :story, :t => 4, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
         @ot = @story4.t
         @story4.t = 1
       end
@@ -684,8 +928,8 @@ describe Story do
     #負のときは0として正常扱い
     context 'テーブルに2件(t:0,1)で1を-1に移動したとき' do
       before do
-        @story = Factory :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
-        @story2 = Factory :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+        @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+        @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
         @ot = @story2.t
         @story2.t = -1
       end
@@ -708,13 +952,13 @@ describe Story do
   end
   describe '大きい方に移動に於いて' do
     before do
-      @comic = Factory :comic, :author_id => @author.id
-      @panel = Factory :panel, :author_id => @author.id
+      @comic = FactoryGirl.create :comic, :author_id => @author.id
+      @panel = FactoryGirl.create :panel, :author_id => @author.id
     end
     context '依頼チェック' do
       it 'Updateを依頼している' do
-        @story = Factory :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
-        @story2 = Factory :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+        @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+        @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
         Story.stub(:update_all).with(any_args)
         Story.should_receive(:update_all).with(any_args).exactly(1)
         ot = @story.t
@@ -724,8 +968,8 @@ describe Story do
     end
     context 'テーブルに2件(t:0,1)で0を1に移動したとき' do
       before do
-        @story = Factory :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
-        @story2 = Factory :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+        @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+        @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
         @ot = @story.t
         @story.t = 1
       end
@@ -743,9 +987,9 @@ describe Story do
     end
     context 'テーブルに3件(t:0,1,2)で0を1に移動したとき' do
       before do
-        @story = Factory :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
-        @story2 = Factory :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
-        @story3 = Factory :story, :t => 2, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+        @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+        @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+        @story3 = FactoryGirl.create :story, :t => 2, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
         @ot = @story.t
         @story.t = 1
       end
@@ -763,11 +1007,11 @@ describe Story do
     end
     context 'テーブルに5件(t:0,1,2,3,4)で1を3に移動したとき' do
       before do
-        @story = Factory :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
-        @story2 = Factory :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
-        @story3 = Factory :story, :t => 2, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
-        @story4 = Factory :story, :t => 3, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
-        @story5 = Factory :story, :t => 4, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+        @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+        @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+        @story3 = FactoryGirl.create :story, :t => 2, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+        @story4 = FactoryGirl.create :story, :t => 3, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+        @story5 = FactoryGirl.create :story, :t => 4, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
         @ot = @story2.t
         @story2.t = 3
       end
@@ -800,13 +1044,13 @@ describe Story do
     end
     context '先ほどのケース+他のコミック1件で挿入したとき' do
       before do
-        @comic2 = Factory :comic, :author_id => @author.id
-        @storyc2 = Factory :story, :t => 0, :comic_id => @comic2.id, :panel_id => @panel.id, :author_id => @author.id
-        @story = Factory :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
-        @story2 = Factory :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
-        @story3 = Factory :story, :t => 2, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
-        @story4 = Factory :story, :t => 3, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
-        @story5 = Factory :story, :t => 4, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+        @comic2 = FactoryGirl.create :comic, :author_id => @author.id
+        @storyc2 = FactoryGirl.create :story, :t => 0, :comic_id => @comic2.id, :panel_id => @panel.id, :author_id => @author.id
+        @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+        @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+        @story3 = FactoryGirl.create :story, :t => 2, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+        @story4 = FactoryGirl.create :story, :t => 3, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+        @story5 = FactoryGirl.create :story, :t => 4, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
         @ot = @story2.t
         @story2.t = 3
       end
@@ -846,8 +1090,8 @@ describe Story do
     #max超えたときはmaxとして正常扱い
     context 'テーブルに2件(t:0,1)で0を2に移動したとき' do
       before do
-        @story = Factory :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
-        @story2 = Factory :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+        @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+        @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
         @ot = @story.t
         @story.t = 2
       end
@@ -870,10 +1114,10 @@ describe Story do
   end
   describe '入れ替えに於いて' do
     before do
-      @comic = Factory :comic, :author_id => @author.id
-      @panel = Factory :panel, :author_id => @author.id
-      @story = Factory :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
-      @story2 = Factory :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+      @comic = FactoryGirl.create :comic, :author_id => @author.id
+      @panel = FactoryGirl.create :panel, :author_id => @author.id
+      @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+      @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
     end
     context '新tが旧tより小さいとき' do
       it '少ない方に移動を依頼している' do
@@ -896,12 +1140,12 @@ describe Story do
   end
   describe '順序入れ替えに於いて' do
     before do
-      @comic = Factory :comic, :author_id => @author.id
-      @panel = Factory :panel, :author_id => @author.id
+      @comic = FactoryGirl.create :comic, :author_id => @author.id
+      @panel = FactoryGirl.create :panel, :author_id => @author.id
     end
     context 'オブジェクトが新規でtが空のとき' do
       it '末尾追加としてtを補充依頼している' do
-        @story = Factory.build :story, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+        @story = FactoryGirl.build :story, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
         Story.stub(:new_t).with(any_args).and_return(0)
         Story.should_receive(:new_t).with(any_args).exactly(1)
         @story.t = nil
@@ -910,7 +1154,7 @@ describe Story do
     end
     context 'オブジェクトが新規でtが設定されているとき' do
       it '挿入追加として挿入シフトを依頼している' do
-        @story = Factory.build :story, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+        @story = FactoryGirl.build :story, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.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
@@ -919,8 +1163,8 @@ describe Story do
     end
     context 'オブジェクトが新規でなくtが設定されているとき' do
       it 'コマ移動として入れ替えを依頼している' do
-        @story = Factory :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
-        @story2 = Factory :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+        @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+        @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
         Story.any_instance.stub(:update_shift).with(any_args)
         Story.any_instance.should_receive(:update_shift).with(1).exactly(1)
         @story2.t = 0
@@ -935,9 +1179,9 @@ describe Story do
   end
   describe '編集許可に於いて' do
     before do
-      @comic = Factory :comic, :author_id => @author.id
-      @panel = Factory :panel, :author_id => @author.id
-      @story = Factory.build :story, :t => nil, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+      @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, :panel_id => @panel.id, :author_id => @author.id
     end
     context 'つつがなく終わるとき' do
       it 'trueを返す' do
@@ -972,9 +1216,9 @@ describe Story do
   end
   describe '保存に於いて' do
     before do
-      @comic = Factory :comic, :author_id => @author.id
-      @panel = Factory :panel, :author_id => @author.id
-      @story = Factory.build :story, :t => nil, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+      @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, :panel_id => @panel.id, :author_id => @author.id
     end
     context 'つつがなく終わるとき' do
       it '編集許可チェックを依頼している' do
@@ -1007,14 +1251,14 @@ describe Story do
     #入れ替えテストと同じテストを実施。こちらはシフトだけでなく本尊も更新されている
     context 'テーブルに5件(t:0,1,2,3,4)+他のコミック1件で2に挿入したとき' do
       before do
-        @comic2 = Factory :comic, :author_id => @author.id
-        @storyc2 = Factory :story, :t => 0, :comic_id => @comic2.id, :panel_id => @panel.id, :author_id => @author.id
-        @story = Factory :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
-        @story2 = Factory :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
-        @story3 = Factory :story, :t => 2, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
-        @story4 = Factory :story, :t => 3, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
-        @story5 = Factory :story, :t => 4, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
-        @story6 = Factory.build :story, :t => 2, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+        @comic2 = FactoryGirl.create :comic, :author_id => @author.id
+        @storyc2 = FactoryGirl.create :story, :t => 0, :comic_id => @comic2.id, :panel_id => @panel.id, :author_id => @author.id
+        @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+        @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+        @story3 = FactoryGirl.create :story, :t => 2, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+        @story4 = FactoryGirl.create :story, :t => 3, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+        @story5 = FactoryGirl.create :story, :t => 4, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+        @story6 = FactoryGirl.build :story, :t => 2, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
       end
       it '既存のt0には変化がない' do
         @story6.store
@@ -1055,13 +1299,13 @@ describe Story do
     end
     context 'テーブルに5件(t:0,1,2,3,4)+他のコミック1件で3を1に移動したとき' do
       before do
-        @comic2 = Factory :comic, :author_id => @author.id
-        @storyc2 = Factory :story, :t => 0, :comic_id => @comic2.id, :panel_id => @panel.id, :author_id => @author.id
-        @story = Factory :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
-        @story2 = Factory :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
-        @story3 = Factory :story, :t => 2, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
-        @story4 = Factory :story, :t => 3, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
-        @story5 = Factory :story, :t => 4, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+        @comic2 = FactoryGirl.create :comic, :author_id => @author.id
+        @storyc2 = FactoryGirl.create :story, :t => 0, :comic_id => @comic2.id, :panel_id => @panel.id, :author_id => @author.id
+        @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+        @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+        @story3 = FactoryGirl.create :story, :t => 2, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+        @story4 = FactoryGirl.create :story, :t => 3, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+        @story5 = FactoryGirl.create :story, :t => 4, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
         @ot = @story4.t
         @story4.t = 1
       end
@@ -1098,13 +1342,13 @@ describe Story do
     end
     context 'テーブルに5件(t:0,1,2,3,4)+他のコミック1件で1を3に移動したとき' do
       before do
-        @comic2 = Factory :comic, :author_id => @author.id
-        @storyc2 = Factory :story, :t => 0, :comic_id => @comic2.id, :panel_id => @panel.id, :author_id => @author.id
-        @story = Factory :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
-        @story2 = Factory :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
-        @story3 = Factory :story, :t => 2, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
-        @story4 = Factory :story, :t => 3, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
-        @story5 = Factory :story, :t => 4, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+        @comic2 = FactoryGirl.create :comic, :author_id => @author.id
+        @storyc2 = FactoryGirl.create :story, :t => 0, :comic_id => @comic2.id, :panel_id => @panel.id, :author_id => @author.id
+        @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+        @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+        @story3 = FactoryGirl.create :story, :t => 2, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+        @story4 = FactoryGirl.create :story, :t => 3, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+        @story5 = FactoryGirl.create :story, :t => 4, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
         @ot = @story2.t
         @story2.t = 3
       end
@@ -1143,14 +1387,14 @@ describe Story do
     context 'テーブルに5件(t:0,1,2,3,4)+他のコミック1件で2に挿入したが保存に失敗したとき' do
       before do
         Story.any_instance.stub(:save).with(any_args).and_return(false)
-        @comic2 = Factory :comic, :author_id => @author.id
-        @storyc2 = Factory :story, :t => 0, :comic_id => @comic2.id, :panel_id => @panel.id, :author_id => @author.id
-        @story = Factory :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
-        @story2 = Factory :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
-        @story3 = Factory :story, :t => 2, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
-        @story4 = Factory :story, :t => 3, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
-        @story5 = Factory :story, :t => 4, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
-        @story6 = Factory.build :story, :t => 2, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+        @comic2 = FactoryGirl.create :comic, :author_id => @author.id
+        @storyc2 = FactoryGirl.create :story, :t => 0, :comic_id => @comic2.id, :panel_id => @panel.id, :author_id => @author.id
+        @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+        @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+        @story3 = FactoryGirl.create :story, :t => 2, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+        @story4 = FactoryGirl.create :story, :t => 3, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+        @story5 = FactoryGirl.create :story, :t => 4, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+        @story6 = FactoryGirl.build :story, :t => 2, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
       end
       it '既存のtに変化がない' do
         @story6.store
@@ -1175,13 +1419,13 @@ describe Story do
     context 'テーブルに5件(t:0,1,2,3,4)+他のコミック1件で3を1に移動したがシリアルチェックに失敗したとき' do
       before do
         Story.stub(:validate_t).with(any_args).and_return(false)
-        @comic2 = Factory :comic, :author_id => @author.id
-        @storyc2 = Factory :story, :t => 0, :comic_id => @comic2.id, :panel_id => @panel.id, :author_id => @author.id
-        @story = Factory :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
-        @story2 = Factory :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
-        @story3 = Factory :story, :t => 2, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
-        @story4 = Factory :story, :t => 3, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
-        @story5 = Factory :story, :t => 4, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+        @comic2 = FactoryGirl.create :comic, :author_id => @author.id
+        @storyc2 = FactoryGirl.create :story, :t => 0, :comic_id => @comic2.id, :panel_id => @panel.id, :author_id => @author.id
+        @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+        @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+        @story3 = FactoryGirl.create :story, :t => 2, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+        @story4 = FactoryGirl.create :story, :t => 3, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+        @story5 = FactoryGirl.create :story, :t => 4, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
         @ot = @story4.t
         @story4.t = 1
       end
@@ -1212,7 +1456,7 @@ describe Story do
     end
     context '編集不可だったとき' do
       before do
-        @story = Factory.build :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+        @story = FactoryGirl.build :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
         Story.any_instance.stub(:allow?).and_return(false)
       end
       it '403Forbidden例外を返す' do
@@ -1224,9 +1468,9 @@ describe Story do
   end
   describe '切り詰め処理つき削除に於いて' do
     before do
-      @comic = Factory :comic, :author_id => @author.id
-      @panel = Factory :panel, :author_id => @author.id
-      @story = Factory :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+      @comic = FactoryGirl.create :comic, :author_id => @author.id
+      @panel = FactoryGirl.create :panel, :author_id => @author.id
+      @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
     end
     context 'つつがなく終わるとき' do
       it '削除される' do
@@ -1238,7 +1482,7 @@ describe Story do
     #連携テスト。切り詰めが直接DBをいじる
     context '2件で先頭を削除したとき' do
       before do
-        @story2 = Factory :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+        @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
       end
       it '行が削除される' do
         lambda{
@@ -1259,8 +1503,8 @@ describe Story do
     end
     context '3件で先頭を削除したとき' do
       before do
-        @story2 = Factory :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
-        @story3 = Factory :story, :t => 2, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+        @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+        @story3 = FactoryGirl.create :story, :t => 2, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
       end
       it '行が削除される' do
         lambda{
@@ -1286,10 +1530,10 @@ describe Story do
     end
     context '5件で3件目を削除したとき' do
       before do
-        @story2 = Factory :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
-        @story3 = Factory :story, :t => 2, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
-        @story4 = Factory :story, :t => 3, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
-        @story5 = Factory :story, :t => 4, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+        @story2 = FactoryGirl.create :story, :t => 1, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+        @story3 = FactoryGirl.create :story, :t => 2, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+        @story4 = FactoryGirl.create :story, :t => 3, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
+        @story5 = FactoryGirl.create :story, :t => 4, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id
       end
       it '行が削除される' do
         lambda{