OSDN Git Service

fix peta test
authoryasushiito <yas@pen-chan.jp>
Thu, 24 Jul 2014 23:47:47 +0000 (08:47 +0900)
committeryasushiito <yas@pen-chan.jp>
Thu, 24 Jul 2014 23:47:47 +0000 (08:47 +0900)
16 files changed:
app/models/comic_story.rb
app/models/sheet_panel.rb
app/models/story_sheet.rb
app/views/sheet_panels/_summary.html.erb
db/migrate/20140723225955_rm_leaf_owner.rb [new file with mode: 0644]
spec/factories/comic.rb
spec/factories/comic_story.rb
spec/factories/panel.rb
spec/factories/scroll.rb
spec/factories/sheet.rb
spec/factories/sheet_panel.rb
spec/factories/story.rb
spec/factories/story_sheet.rb
spec/models/sheet_panel_spec.rb
spec/peta/binder_spec.rb
spec/peta/owner_spec.rb

index ddf6d74..66c2acc 100644 (file)
@@ -6,7 +6,6 @@ class ComicStory < Peta::Leaf
   
   validates :comic_id, :presence => true, :numericality => true, :existence => {:both => false}
   validates :story_id, :presence => true, :numericality => true, :existence => {:both => false}
-  validates :author_id, :presence => true, :numericality => true, :existence => {:both => false}
   validates :t, :presence => true, :numericality => {:greater_than_or_equal_to => 0}
   
   def supply_default
@@ -17,7 +16,6 @@ class ComicStory < Peta::Leaf
   
   def overwrite operators
     return false unless operators.author
-    self.author_id = operators.author.id
   end
   
   def disp_t
index 15b0798..591b259 100644 (file)
@@ -1,19 +1,18 @@
 class SheetPanel < Peta::Element
   load_manifest
-  belongs_to :author
   belongs_to :panel
   belongs_to :sheet
   accepts_nested_attributes_for :panel, :allow_destroy => true
+  #alias_attribute :attr_y, :y
   
   validates :sheet_id, :numericality => {:allow_blank => true}
   validates :panel_id, :numericality => {:allow_blank => true}
-  validates :author_id, :presence => true, :numericality => true, :existence => {:both => false}
   validates :x, :presence => true, :numericality => true
   validates :y, :presence => true, :numericality => true
   validates :z, :presence => true, :numericality => {:greater_than => 0}
   validates :t, :presence => true, :numericality => {:greater_than_or_equal_to => 0}
   
-  def attr_y
+  def y
     self.attributes['y']
   end
   
@@ -31,11 +30,6 @@ class SheetPanel < Peta::Element
     end
   end
   
-  def overwrite operators
-    return false unless operators.author
-    self.author_id = operators.author.id
-  end
-  
   def self.by_author_list_includes
     {
       :sheet => {
@@ -46,7 +40,6 @@ class SheetPanel < Peta::Element
   
   def self.show_opt
     {:include => {
-      :author => {}, 
       :sheet => {
         :author => {}
       }, 
@@ -64,11 +57,11 @@ class SheetPanel < Peta::Element
   
   def sheet_panel_as_json au
     panel_include = if self.panel and self.panel.visible?(au)
-      {:include => {:author => {}}, :methods => :elements}
+      {:include => {}, :methods => :elements}
     else
-      {:include => {:author => {}}}
+      {:include => {}}
     end
-    self.to_json({:include => {:sheet => {:include => {:author => {}}}, :author => {}, :panel => panel_include}})
+    self.to_json({:include => {:sheet => {:include => {:author => {}}}, :panel => panel_include}})
   end
   
   def self.list_as_json_text ary, au
index b290a30..7d32735 100644 (file)
@@ -1,12 +1,10 @@
 class StorySheet < Peta::Leaf
   load_manifest
-  belongs_to :author
   belongs_to :story
   belongs_to :sheet
   
   validates :story_id, :presence => true, :numericality => true, :existence => {:both => false}
   validates :sheet_id, :presence => true, :numericality => true, :existence => {:both => false}
-  validates :author_id, :presence => true, :numericality => true, :existence => {:both => false}
   validates :t, :presence => true, :numericality => {:greater_than_or_equal_to => 0}
   
   def supply_default
@@ -15,11 +13,6 @@ class StorySheet < Peta::Leaf
     self.t = nil
   end
   
-  def overwrite operators
-    return false unless operators.author
-    self.author_id = operators.author.id
-  end
-  
   def self.public_list_where
     'stories.visible > 0'
   end
@@ -34,7 +27,6 @@ class StorySheet < Peta::Leaf
   
   def self.show_opt
     {:include => {
-      :author => {}, 
       :story => {}, 
       :sheet => {
         :author => {} 
index c8e9a25..300cc51 100644 (file)
@@ -5,5 +5,5 @@
   <% end %>
 </div>
 <div>
-  <%= link_to h(truncate(item.author.name, :length => 12)), author_path(item.author) %>
+  <%= link_to h(truncate(item.sheet.author.name, :length => 12)), author_path(item.sheet.author) %>
 </div>
diff --git a/db/migrate/20140723225955_rm_leaf_owner.rb b/db/migrate/20140723225955_rm_leaf_owner.rb
new file mode 100644 (file)
index 0000000..915f993
--- /dev/null
@@ -0,0 +1,10 @@
+class RmLeafOwner < ActiveRecord::Migration
+  def up
+    remove_column :sheet_panels, :author_id
+    remove_column :story_sheets, :author_id
+    remove_column :scroll_panels, :author_id
+  end
+
+  def down
+  end
+end
index 4eea085..bdfec3f 100644 (file)
@@ -1,10 +1,16 @@
 # -*- encoding: utf-8 -*-\r
 FactoryGirl.define do\r
-  factory :comic001, :class => Comic do |i|\r
-    i.title 'ã\82¢ã\82¢ã\82¢ã\83\83'\r
-    i.description ''\r
+  factory :comic_doc, :class => Comic do |i|\r
+    i.title 'ã\81ºã\81£ã\81\9fã\82\93\81®ã\83\89ã\82­ã\83¥ã\83¡ã\83³ã\83\88'\r
+    i.description '分かりやすく漫画にしました。'\r
     i.visible 1\r
-    i.author_id 1\r
+    trait :with_comic_stories do\r
+      after(:create) do |comic, evaluator|\r
+        create(:comic_story_plain, t: 0, comic: comic, story: create(:story_install, author: comic.author))\r
+        create(:comic_story_plain, t: 1, comic: comic, story: create(:story_setup, author: comic.author))\r
+      end\r
+    end\r
+    factory :comic_doc_with_comic_stories, traits: [:with_comic_stories]\r
   end\r
   factory :comic002, :class => Comic do |i|\r
     i.title '双子?'\r
index a2ae568..8b2121e 100644 (file)
@@ -1,10 +1,6 @@
 # -*- encoding: utf-8 -*-\r
 FactoryGirl.define do\r
-  factory :comic_story001, :class => ComicStory do |i|\r
-    i.comic_id 1\r
-    i.story_id 1\r
-    i.t 0\r
-    i.author_id 1\r
+  factory :comic_story_plain, :class => ComicStory do |i|\r
   end\r
   factory :comic_story002, :class => ComicStory do |i|\r
     i.comic_id 2\r
index 39d1f10..ebe99ab 100644 (file)
@@ -1,12 +1,11 @@
 # -*- encoding: utf-8 -*-\r
 FactoryGirl.define do\r
-  factory :panel001, :class => Panel do |i|\r
+  factory :panel, :class => Panel do |i|\r
     i.width 470\r
     i.height 247\r
     i.border 2\r
-    i.caption ''\r
-    i.publish 0\r
-    i.author_id 1\r
+    i.caption 'test'\r
+    i.publish 1\r
   end\r
   factory :panel_hello, :class => Panel do |i|\r
     i.width 514\r
@@ -45,7 +44,7 @@ FactoryGirl.define do
     i.caption 'enjoy!'\r
     i.publish 1\r
   end\r
-  factory :panel003, :class => Panel do |i|\r
+  factory :panel_install_install, :class => Panel do |i|\r
     i.width 200\r
     i.height 80\r
     i.border 2\r
index 0efb1c2..c80f5e0 100644 (file)
@@ -2,7 +2,7 @@
 FactoryGirl.define do\r
   factory :scroll_hello, :class => Scroll do |i|\r
     i.title 'おめざめ2'\r
-    i.description ''\r
+    i.description 'とうとうあいつが目覚めたぞ。その勇姿をご覧あれ。'\r
     i.visible 1\r
     #association :author, factory: :author_yas\r
     trait :with_scroll_panels do\r
index 64486b5..02c1955 100644 (file)
@@ -1,39 +1,41 @@
 # -*- encoding: utf-8 -*-\r
 FactoryGirl.define do\r
-  factory :sheet001, :class => Sheet do |i|\r
-    i.caption '選択肢のリスト'\r
+  factory :sheet_install_a, :class => Sheet do |i|\r
+    i.caption 'ダウンロード方法'\r
     i.width 839\r
     i.height 1191\r
     i.visible 1\r
-    i.author_id 1\r
+    trait :with_sheet_panels do\r
+      after(:create) do |sheet, evaluator|\r
+        create(:sheet_panel_plain, z: 1, t: 0, sheet: sheet, panel: create(:panel_install_install, author: sheet.author))\r
+        create(:sheet_panel_plain, z: 2, t: 1, sheet: sheet, panel: create(:panel_install_install, author: sheet.author))\r
+      end\r
+    end\r
+    factory :sheet_install_a_with_sheet_panels, traits: [:with_sheet_panels]\r
   end\r
-  factory :sheet002, :class => Sheet do |i|\r
-    i.caption '画像を投稿'\r
+  factory :sheet_install_b, :class => Sheet do |i|\r
+    i.caption '展開してインストール'\r
     i.width 839\r
     i.height 1191\r
     i.visible 1\r
-    i.author_id 1\r
   end\r
-  factory :sheet003, :class => Sheet do |i|\r
-    i.caption '選択肢のリスト'\r
+  factory :sheet_setup_a, :class => Sheet do |i|\r
+    i.caption '設定ファイルの編集'\r
     i.width 839\r
     i.height 1191\r
     i.visible 1\r
-    i.author_id 1\r
   end\r
-  factory :sheet004, :class => Sheet do |i|\r
-    i.caption 'ぎょっとする'\r
+  factory :sheet_setup_b, :class => Sheet do |i|\r
+    i.caption '管理者アカウントの作成'\r
     i.width 839\r
     i.height 1191\r
     i.visible 1\r
-    i.author_id 1\r
   end\r
-  factory :sheet005, :class => Sheet do |i|\r
-    i.caption 'そんな馬鹿な'\r
+  factory :sheet, :class => Sheet do |i|\r
+    i.caption 'test'\r
     i.width 839\r
     i.height 1191\r
     i.visible 1\r
-    i.author_id 1\r
   end\r
   factory :sheet006, :class => Sheet do |i|\r
     i.caption '社会でうまくいかず'\r
index 548af19..652ada0 100644 (file)
 # -*- encoding: utf-8 -*-\r
 FactoryGirl.define do\r
-  factory :sheet_panel001, :class => SheetPanel do |i|\r
-    i.sheet_id 1\r
-    i.panel_id 6\r
-    i.x 4\r
-    i.y 610\r
+  factory :sheet_panel_plain, :class => SheetPanel do |i|\r
+    i.x 10\r
+    i.y 10\r
     i.z 1\r
     i.t 0\r
-    i.author_id 1\r
   end\r
-  factory :sheet_panel002, :class => SheetPanel do |i|\r
-    i.sheet_id 1\r
-    i.panel_id 9\r
-    i.x 28\r
-    i.y 11\r
-    i.z 3\r
-    i.t 1\r
-    i.author_id 1\r
-  end\r
-  factory :sheet_panel003, :class => SheetPanel do |i|\r
-    i.sheet_id 1\r
-    i.panel_id 8\r
-    i.x 7\r
-    i.y 293\r
-    i.z 2\r
-    i.t 2\r
-    i.author_id 1\r
-  end\r
-  factory :sheet_panel004, :class => SheetPanel do |i|\r
-    i.sheet_id 2\r
-    i.panel_id 7\r
-    i.x 15\r
-    i.y 15\r
-    i.z 1\r
-    i.t 0\r
-    i.author_id 1\r
-  end\r
-  factory :sheet_panel005, :class => SheetPanel do |i|\r
-    i.sheet_id 1\r
-    i.panel_id 10\r
-    i.x 279\r
-    i.y 11\r
-    i.z 4\r
-    i.t 3\r
-    i.author_id 1\r
-  end\r
-  factory :sheet_panel006, :class => SheetPanel do |i|\r
-    i.sheet_id 3\r
-    i.panel_id 6\r
-    i.x 4\r
-    i.y 610\r
-    i.z 1\r
-    i.t 0\r
-    i.author_id 1\r
-  end\r
-  factory :sheet_panel007, :class => SheetPanel do |i|\r
-    i.sheet_id 3\r
-    i.panel_id 9\r
-    i.x 533\r
-    i.y 289\r
-    i.z 3\r
-    i.t 1\r
-    i.author_id 1\r
-  end\r
-  factory :sheet_panel008, :class => SheetPanel do |i|\r
-    i.sheet_id 3\r
-    i.panel_id 8\r
-    i.x 7\r
-    i.y 293\r
-    i.z 2\r
-    i.t 2\r
-    i.author_id 1\r
-  end\r
-  factory :sheet_panel009, :class => SheetPanel do |i|\r
-    i.sheet_id 3\r
-    i.panel_id 10\r
-    i.x 279\r
-    i.y 11\r
-    i.z 4\r
-    i.t 3\r
-    i.author_id 1\r
-  end\r
-  factory :sheet_panel010, :class => SheetPanel do |i|\r
-    i.sheet_id 3\r
-    i.panel_id 11\r
-    i.x 15\r
-    i.y 15\r
-    i.z 5\r
-    i.t 4\r
-    i.author_id 1\r
-  end\r
-  factory :sheet_panel011, :class => SheetPanel do |i|\r
-    i.sheet_id 4\r
-    i.panel_id 9\r
-    i.x 15\r
-    i.y 15\r
-    i.z 1\r
-    i.t 0\r
-    i.author_id 1\r
-  end\r
-  factory :sheet_panel012, :class => SheetPanel do |i|\r
-    i.sheet_id 5\r
-    i.panel_id 12\r
-    i.x 15\r
-    i.y 15\r
-    i.z 1\r
-    i.t 0\r
-    i.author_id 1\r
+  factory :sheet_panel, :class => SheetPanel do |i|\r
   end\r
 end\r
index fe2e5bd..57f1313 100644 (file)
@@ -1,18 +1,29 @@
 # -*- encoding: utf-8 -*-\r
 FactoryGirl.define do\r
-  factory :story001, :class => Story do |i|\r
-    i.title '区別がつかな'\r
-    i.description ''\r
-    i.t \r
+  factory :story_install, :class => Story do |i|\r
+    i.title 'インストール'\r
+    i.description 'ダウンロードからHello worldまで。'\r
     i.visible 1\r
-    i.author_id 1\r
+    trait :with_story_sheets do\r
+      after(:create) do |story, evaluator|\r
+      create(:sheet_install_a, author: story.author)\r
+        create(:story_sheet_plain, t: 0, story: story, sheet: create(:sheet_install_a_with_sheet_panels, author: story.author))\r
+        create(:story_sheet_plain, t: 1, story: story, sheet: create(:sheet_install_b, author: story.author))\r
+      end\r
+    end\r
+    factory :story_install_with_story_sheets, traits: [:with_story_sheets]\r
   end\r
-  factory :story002, :class => Story do |i|\r
-    i.title '絵師ã\81®é\83½å\90\88'\r
+  factory :story_setup, :class => Story do |i|\r
+    i.title '管ç\90\86è\80\85ã\82¢ã\82«ã\82¦ã\83³ã\83\88ã\82\92æº\96å\82\99ã\81\99ã\82\8b'\r
     i.description ''\r
-    i.t \r
     i.visible 1\r
-    i.author_id 1\r
+    trait :with_story_sheets do\r
+      after(:create) do |story, evaluator|\r
+        create(:story_sheet_plain, t: 0, story: story, sheet: create(:sheet_setup_a, author: story.author))\r
+        create(:story_sheet_plain, t: 1, story: story, sheet: create(:sheet_setup_b, author: story.author))\r
+      end\r
+    end\r
+    factory :story_setup_with_story_sheets, traits: [:with_story_sheets]\r
   end\r
   factory :story003, :class => Story do |i|\r
     i.title 'キツネが憑いている'\r
index b067195..0973a4d 100644 (file)
@@ -1,93 +1,5 @@
 # -*- encoding: utf-8 -*-\r
 FactoryGirl.define do\r
-  factory :story_sheet001, :class => StorySheet do |i|\r
-    i.story_id 1\r
-    i.sheet_id 1\r
-    i.t 1\r
-    i.author_id 1\r
-  end\r
-  factory :story_sheet002, :class => StorySheet do |i|\r
-    i.story_id 1\r
-    i.sheet_id 3\r
-    i.t 0\r
-    i.author_id 1\r
-  end\r
-  factory :story_sheet003, :class => StorySheet do |i|\r
-    i.story_id 2\r
-    i.sheet_id 4\r
-    i.t 1\r
-    i.author_id 1\r
-  end\r
-  factory :story_sheet004, :class => StorySheet do |i|\r
-    i.story_id 2\r
-    i.sheet_id 5\r
-    i.t 0\r
-    i.author_id 1\r
-  end\r
-  factory :story_sheet005, :class => StorySheet do |i|\r
-    i.story_id 4\r
-    i.sheet_id 4\r
-    i.t 0\r
-    i.author_id 1\r
-  end\r
-  factory :story_sheet006, :class => StorySheet do |i|\r
-    i.story_id 4\r
-    i.sheet_id 6\r
-    i.t 1\r
-    i.author_id 1\r
-  end\r
-  factory :story_sheet007, :class => StorySheet do |i|\r
-    i.story_id 5\r
-    i.sheet_id 6\r
-    i.t 0\r
-    i.author_id 1\r
-  end\r
-  factory :story_sheet008, :class => StorySheet do |i|\r
-    i.story_id 5\r
-    i.sheet_id 5\r
-    i.t 1\r
-    i.author_id 1\r
-  end\r
-  factory :story_sheet009, :class => StorySheet do |i|\r
-    i.story_id 8\r
-    i.sheet_id 7\r
-    i.t 0\r
-    i.author_id 1\r
-  end\r
-  factory :story_sheet010, :class => StorySheet do |i|\r
-    i.story_id 8\r
-    i.sheet_id 7\r
-    i.t 1\r
-    i.author_id 1\r
-  end\r
-  factory :story_sheet011, :class => StorySheet do |i|\r
-    i.story_id 8\r
-    i.sheet_id 7\r
-    i.t 2\r
-    i.author_id 1\r
-  end\r
-  factory :story_sheet012, :class => StorySheet do |i|\r
-    i.story_id 8\r
-    i.sheet_id 7\r
-    i.t 3\r
-    i.author_id 1\r
-  end\r
-  factory :story_sheet013, :class => StorySheet do |i|\r
-    i.story_id 9\r
-    i.sheet_id 3\r
-    i.t 1\r
-    i.author_id 1\r
-  end\r
-  factory :story_sheet014, :class => StorySheet do |i|\r
-    i.story_id 9\r
-    i.sheet_id 4\r
-    i.t 0\r
-    i.author_id 1\r
-  end\r
-  factory :story_sheet015, :class => StorySheet do |i|\r
-    i.story_id 9\r
-    i.sheet_id 5\r
-    i.t 2\r
-    i.author_id 1\r
+  factory :story_sheet_plain, :class => StorySheet do |i|\r
   end\r
 end\r
index 863d9c1..4f4c893 100644 (file)
@@ -3,145 +3,111 @@ require 'spec_helper'
 #紙コマ
 describe SheetPanel do
   before do
-    SpeechBalloonTemplate.delete_all
-    @admin = 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
-    SpeechBalloonTemplate.delete_all
-    @speech_balloon_template = FactoryGirl.create(:speech_balloon_template, "name" => "circle@pettan.com", "classname" => "CircleSpeechBalloon", "caption" => "cc",  "system_picture_id" => @sp.id, "settings" => '{}')
-    @writing_format = FactoryGirl.create :writing_format
-    @user = FactoryGirl.create( :user_yas)
-    @author = FactoryGirl.create :author, :user_id => @user.id
-    @artist = FactoryGirl.create :artist_yas, :author_id => @author.id
-    @other_user = FactoryGirl.create( :user_yas)
-    @other_author = FactoryGirl.create :author, :user_id => @other_user.id
-    @op = FactoryGirl.create :original_picture, :artist_id => @artist.id
-    @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id
-    @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id
+    @admin =FactoryGirl.create :admin
+    @user_yas = FactoryGirl.create :user_yas_with_owner
+    @user_rom = FactoryGirl.create :user_rom
+    @author_yas =  @user_yas.author
   end
   
   describe '検証に於いて' do
     before do
-      @sheet = FactoryGirl.create :sheet, :author_id => @author.id
-      @panel = FactoryGirl.create :panel, :author_id => @author.id
-      @sheet_panel = FactoryGirl.build :sheet_panel, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+      @sheet = FactoryGirl.create :sheet, author_id: @author_yas.id
+      @panel = FactoryGirl.create :panel, author_id: @author_yas.id
+      @item = FactoryGirl.build :sheet_panel_plain, sheet: @sheet, panel: @panel
     end
     
     context 'オーソドックスなデータのとき' do
       it '下限データが通る' do
-        @sheet_panel.x = -99999
-        @sheet_panel.y = -99999
-        @sheet_panel.z = 1
-        @sheet_panel.t = 0
-        @sheet_panel.should be_valid
+        @item.x = -99999
+        @item.y = -99999
+        @item.z = 1
+        @item.t = 0
+        expect(@item).to be_valid
       end
       it '上限データが通る' do
-        @sheet_panel.x = 99999
-        @sheet_panel.y = 99999
-        @sheet_panel.z = 99999
-        @sheet_panel.t = 99999
-        @sheet_panel.should be_valid
+        @item.x = 99999
+        @item.y = 99999
+        @item.z = 99999
+        @item.t = 99999
+        expect(@item).to be_valid
       end
     end
     
     context 'sheet_idを検証するとき' do
-      it '数値でなければ失敗する' do
-        @sheet_panel.sheet_id = 'a'
-        @sheet_panel.should_not be_valid
+      it '他人のコマや用紙を引用しているケースで、オーナーが削除することもあるので、空白でも通る' do
+        @item.sheet_id = nil
+        expect(@item).to be_valid
       end
     end
     
     context 'panel_idを検証するとき' do
-      it '数値でなければ失敗する' do
-        @sheet_panel.panel_id = 'a'
-        @sheet_panel.should_not be_valid
+      it '他人のコマや用紙を引用しているケースで、オーナーが削除することもあるので、空白でも通る' do
+        @item.panel_id = nil
+        expect(@item).to be_valid
       end
     end
     
     context 'xを検証するとき' do
       it 'nullなら失敗する' do
-        @sheet_panel.x = nil
-        @sheet_panel.should_not be_valid
-      end
-      it '数値でなければ失敗する' do
-        @sheet_panel.x = 'a'
-        @sheet_panel.should_not be_valid
+        @item.x = nil
+        expect(@item).to_not be_valid
       end
       it '0なら通る' do
-        @sheet_panel.x = '0'
-        @sheet_panel.should be_valid
+        @item.x = 0
+        expect(@item).to be_valid
       end
       it '負でも通る' do
-        @sheet_panel.x = -1
-        @sheet_panel.should be_valid
+        @item.x = -1
+        expect(@item).to be_valid
       end
     end
     context 'yを検証するとき' do
       it 'nullなら失敗する' do
-        @sheet_panel.y = nil
-        @sheet_panel.should_not be_valid
-      end
-      it '数値でなければ失敗する' do
-        @sheet_panel.y = 'a'
-        @sheet_panel.should_not be_valid
+        @item.y = nil
+        expect(@item).to_not be_valid
       end
       it '0なら通る' do
-        @sheet_panel.y = '0'
-        @sheet_panel.should be_valid
+        @item.y = 0
+        expect(@item).to be_valid
       end
       it '負でも通る' do
-        @sheet_panel.y = -1
-        @sheet_panel.should be_valid
+        @item.y = -1
+        expect(@item).to be_valid
       end
     end
     context 'zを検証するとき' do
       it 'nullなら失敗する' do
-        @sheet_panel.z = nil
-        @sheet_panel.should_not be_valid
-      end
-      it '数値でなければ失敗する' do
-        @sheet_panel.z = 'a'
-        @sheet_panel.should_not be_valid
+        @item.z = nil
+        expect(@item).to_not be_valid
       end
       it '負なら失敗する' do
-        @sheet_panel.z = -1
-        @sheet_panel.should_not be_valid
+        @item.z = -1
+        expect(@item).to_not be_valid
       end
       it '0なら失敗する' do
-        @sheet_panel.z = 0
-        @sheet_panel.should_not be_valid
+        @item.z = 0
+        expect(@item).to_not be_valid
+      end
+      it '1なら通る' do
+        @item.z = 1
+        expect(@item).to be_valid
       end
     end
     context 'tを検証するとき' do
       it 'nullなら失敗する' do
-        @sheet_panel.t = nil
-        @sheet_panel.should_not be_valid
-      end
-      it '数値でなければ失敗する' do
-        @sheet_panel.t = 'a'
-        @sheet_panel.should_not be_valid
+        @item.t = nil
+        expect(@item).to_not be_valid
       end
       it '負なら失敗する' do
-        @sheet_panel.t = -1
-        @sheet_panel.should_not be_valid
+        @item.t = -1
+        expect(@item).to_not be_valid
       end
-    end
-    
-    context 'author_idを検証するとき' do
-      it 'nullなら失敗する' do
-        @sheet_panel.author_id = nil
-        @sheet_panel.should_not be_valid
-      end
-      it '数値でなければ失敗する' do
-        @sheet_panel.author_id = 'a'
-        @sheet_panel.should_not be_valid
-      end
-      it '存在する作家でなければ失敗する' do
-        @sheet_panel.author_id = 0
-        @sheet_panel.should_not be_valid
+      it '0なら通る' do
+        @item.t = 0
+        expect(@item).to be_valid
       end
     end
+    
     context '全体を検証するとき' do
     end
   end
@@ -154,21 +120,21 @@ describe SheetPanel do
     
     #dbのデフォルト値が0だから明示的にnilにしないと追加ができない
     it 'tをnilにする' do
-      @sheet_panel = FactoryGirl.build :sheet_panel, :sheet_id => nil, :panel_id => @panel.id
-      @sheet_panel.supply_default
-      @sheet_panel.t.should be_nil
+      @item = FactoryGirl.build :sheet_panel, :sheet_id => nil, :panel_id => @panel.id
+      @item.supply_default
+      @item.t.should be_nil
     end
     
     it '自身の用紙に最大t取得を依頼している' do
-      @sheet_panel = FactoryGirl.build :sheet_panel, :sheet_id => @sheet.id, :panel_id => @panel.id
+      @item = FactoryGirl.build :sheet_panel, :sheet_id => @sheet.id, :panel_id => @panel.id
       Sheet.any_instance.should_receive(:new_t).with(any_args).exactly(1)
-      @sheet_panel.supply_default
+      @item.supply_default
     end
     it 'tをnilにする' do
-      @sheet_panel = FactoryGirl.build :sheet_panel, :sheet_id => @sheet.id, :panel_id => @panel.id
+      @item = FactoryGirl.build :sheet_panel, :sheet_id => @sheet.id, :panel_id => @panel.id
       Sheet.any_instance.stub(:new_t).with(any_args).and_return(4)
-      @sheet_panel.supply_default
-      @sheet_panel.t.should eq 4
+      @item.supply_default
+      @item.t.should eq 4
     end
     
   end
@@ -181,10 +147,10 @@ describe SheetPanel do
     
     context 'author_idを補充' do
       it '問答無用でauthor_idを補充する' do
-        @sheet_panel = FactoryGirl.build :sheet_panel, :sheet_id => @sheet.id, :panel_id => @panel.id
-        @sheet_panel.author_id = nil
-        @sheet_panel.overwrite @author
-        @sheet_panel.author_id.should eq @author.id
+        @item = FactoryGirl.build :sheet_panel, :sheet_id => @sheet.id, :panel_id => @panel.id
+        @item.author_id = nil
+        @item.overwrite @author
+        @item.author_id.should eq @author.id
       end
     end
     
@@ -194,15 +160,15 @@ describe SheetPanel do
     before do
       @sheet = FactoryGirl.create :sheet, :author_id => @author.id
       @panel = FactoryGirl.create :panel, :author_id => @author.id
-      @sheet_panel = FactoryGirl.create :sheet_panel, :author_id => @author.id, :sheet_id => @sheet.id, :panel_id => @panel.id
+      @item = FactoryGirl.create :sheet_panel, :author_id => @author.id, :sheet_id => @sheet.id, :panel_id => @panel.id
       @sheeto = FactoryGirl.create :sheet, :author_id => @other_author.id
       @panelo = FactoryGirl.create :panel, :author_id => @other_author.id
-      @sheet_panelo = FactoryGirl.create :sheet_panel, :author_id => @other_author.id, :sheet_id => @sheeto.id, :panel_id => @panelo.id
+      @itemo = FactoryGirl.create :sheet_panel, :author_id => @other_author.id, :sheet_id => @sheeto.id, :panel_id => @panelo.id
     end
     context '事前チェックする' do
       it '自身にロールリストからの作家取得を依頼している' do
         SheetPanel.should_receive(:get_author_from_roles).with(any_args).exactly(1)
-        r = @sheet_panel.own?([@author])
+        r = @item.own?([@author])
       end
     end
     context 'ロール内作家が取得できるとき' do
@@ -210,12 +176,12 @@ describe SheetPanel do
       end
       it 'ロール内作家のidが自身の作家idと一致するなら許可する' do
         SheetPanel.stub(:get_author_from_roles).with(any_args).and_return(@author)
-        r = @sheet_panel.own?([@author])
+        r = @item.own?([@author])
         r.should be_true
       end
       it 'ロール内作家のidが自身の作家idと一致しないならno' do
         SheetPanel.stub(:get_author_from_roles).with(any_args).and_return(@other_author)
-        @sheet_panel.own?(@other_author).should be_false
+        @item.own?(@other_author).should be_false
       end
     end
     context 'ロール内作家が取得できないとき' do
@@ -223,7 +189,7 @@ describe SheetPanel do
         SheetPanel.stub(:get_author_from_roles).with(any_args).and_return(nil)
       end
       it 'Falseを返す' do
-        r = @sheet_panel.own?([@author])
+        r = @item.own?([@author])
         r.should be_false
       end
     end
@@ -233,7 +199,7 @@ describe SheetPanel do
     before do
       @sheet = FactoryGirl.create :sheet, :author_id => @author.id
       @panel = FactoryGirl.create :panel, :author_id => @author.id
-      @sheet_panel = FactoryGirl.create :sheet_panel, :author_id => @author.id, :sheet_id => @sheet.id, :panel_id => @panel.id
+      @item = FactoryGirl.create :sheet_panel, :author_id => @author.id, :sheet_id => @sheet.id, :panel_id => @panel.id
     end
     context 'オープンモードのとき' do
       before do
@@ -242,11 +208,11 @@ describe SheetPanel do
       it '自身にゲスト用ロールチェックを問い合わせしている' do
         SheetPanel.any_instance.stub(:guest_role_check).and_return(true)
         SheetPanel.any_instance.should_receive(:guest_role_check).with(any_args).exactly(1)
-        r = @sheet_panel.visible?([@author])
+        r = @item.visible?([@author])
       end
       it 'ゲスト用ロールチェックが失敗したとき、falseを返す' do
         SheetPanel.any_instance.stub(:guest_role_check).and_return(false)
-        r = @sheet_panel.visible?([@author])
+        r = @item.visible?([@author])
         r.should be_false
       end
     end
@@ -257,11 +223,11 @@ describe SheetPanel do
       it '自身に読者用ロールチェックを問い合わせしている' do
         SheetPanel.any_instance.stub(:reader_role_check).and_return(true)
         SheetPanel.any_instance.should_receive(:reader_role_check).with(any_args).exactly(1)
-        r = @sheet_panel.visible?([@author])
+        r = @item.visible?([@author])
       end
       it '読者用ロールチェックが失敗したとき、falseを返す' do
         SheetPanel.any_instance.stub(:reader_role_check).and_return(false)
-        r = @sheet_panel.visible?([@author])
+        r = @item.visible?([@author])
         r.should be_false
       end
     end
@@ -273,13 +239,13 @@ describe SheetPanel do
       it '自身の用紙に所持判定を問い合わせしている' do
         Sheet.any_instance.stub(:own?).and_return(true)
         Sheet.any_instance.should_receive(:own?).with(any_args).exactly(1)
-        r = @sheet_panel.visible?([@author])
+        r = @item.visible?([@author])
       end
       it '自身の用紙に閲覧許可を問い合わせしている' do
         Sheet.any_instance.stub(:own?).and_return(false)
         Sheet.any_instance.stub(:visible?).and_return(true)
         Sheet.any_instance.should_receive(:visible?).with(any_args).exactly(1)
-        r = @sheet_panel.visible?([@author])
+        r = @item.visible?([@author])
       end
     end
     context 'つつがなく終わるとき' do
@@ -290,386 +256,52 @@ describe SheetPanel do
       it '自分の用紙の紙コマなら許可する' do
         Sheet.any_instance.stub(:own?).and_return(true)
         Sheet.any_instance.stub(:visible).and_return(0)
-        r = @sheet_panel.visible?([@author])
+        r = @item.visible?([@author])
         r.should be_true
       end
       it '他人の非公開用紙の紙コマなら許可しない' do
         Sheet.any_instance.stub(:own?).and_return(false)
         Sheet.any_instance.stub(:visible).and_return(0)
-        r = @sheet_panel.visible?([@author])
+        r = @item.visible?([@author])
         r.should be_false
       end
       it '他人の用紙の紙コマでも公開なら許可する' do
         Sheet.any_instance.stub(:own?).and_return(false)
         Sheet.any_instance.stub(:visible).and_return(1)
-        r = @sheet_panel.visible?([@author])
+        r = @item.visible?([@author])
         r.should be_true
       end
     end
   end
   
-  describe 'プレイリスト取得に於いて' do
-    before do
-      @sheet = FactoryGirl.create :sheet, :author_id => @author.id
-      @panel = FactoryGirl.create :panel, :author_id => @author.id
-      @sheet_panel = FactoryGirl.create :sheet_panel, :author_id => @author.id, :sheet_id => @sheet.id, :panel_id => @panel.id
-      @panel2 = FactoryGirl.create :panel, :author_id => @author.id, :publish => 0
-      @other_sheet = FactoryGirl.create :sheet, :author_id => @other_author.id, :visible => 1
-      @other_panel = FactoryGirl.create :panel, :author_id => @other_author.id, :publish => 1
-    end
-    it 'リストを返す' do
-      c = SheetPanel.play_list @sheet, @author
-      c.should eq [@sheet_panel]
-    end
-    it 't順で並んでいる' do
-      #公開用紙の公開コマは(他人の用紙であっても)含んでいる
-      v = FactoryGirl.create :sheet_panel, :author_id => @author.id, :sheet_id => @sheet.id, :panel_id => @panel.id, :t => 1
-      c = SheetPanel.play_list @sheet, @author
-      c.should eq [ @sheet_panel, v]
-    end
-    it '非公開のコマは含んでいる' do
-      h = FactoryGirl.create :sheet_panel, :author_id => @author.id, :sheet_id => @sheet.id, :panel_id => @panel2.id, :t => 1
-      c = SheetPanel.play_list @sheet, @author
-      c.should eq [ @sheet_panel, h]
-    end
-  end
-  
-  describe '一覧取得に於いて' do
-    before do
-      @sheet = FactoryGirl.create :sheet, :author_id => @author.id, :visible => 1
-      @panel = FactoryGirl.create :panel, :author_id => @author.id
-      @sheet_panel = FactoryGirl.create :sheet_panel, :author_id => @author.id, :sheet_id => @sheet.id, :panel_id => @panel.id
-      @other_sheet = FactoryGirl.create :sheet, :author_id => @other_author.id, :visible => 1
-      @other_panel = FactoryGirl.create :panel, :author_id => @other_author.id, :publish => 1
-      @hidden_sheet = FactoryGirl.create :sheet, :author_id => @author.id, :visible => 0
-    end
-    context 'page補正について' do
-      it '文字列から数値に変換される' do
-        SheetPanel.page('8').should eq 8
-      end
-      it 'nilの場合は1になる' do
-        SheetPanel.page().should eq 1
-      end
-      it '0以下の場合は1になる' do
-        SheetPanel.page('0').should eq 1
-      end
-    end
-    context 'page_size補正について' do
-      it '文字列から数値に変換される' do
-        SheetPanel.page_size('7').should eq 7
-      end
-      it 'nilの場合はSheetPanel.default_page_sizeになる' do
-        SheetPanel.page_size().should eq SheetPanel.default_page_size
-      end
-      it '0以下の場合はSheetPanel.default_page_sizeになる' do
-        SheetPanel.page_size('0').should eq SheetPanel.default_page_size
-      end
-      it 'SheetPanel.max_page_sizeを超えた場合はSheetPanel.max_page_sizeになる' do
-        SheetPanel.page_size('1000').should eq SheetPanel.max_page_size
-      end
-    end
-    it 'リストを返す' do
-      c = SheetPanel.list
-      c.should eq [@sheet_panel]
-    end
-    it '時系列で並んでいる' do
-      #公開用紙のSheetPanelは(他人のSheetPanelであっても)含んでいる
-      v = FactoryGirl.create :sheet_panel, :author_id => @other_author.id, :sheet_id => @other_sheet.id, :panel_id => @other_panel.id, :t => 0, :updated_at => Time.now + 100
-      c = SheetPanel.list 
-      c.should eq [ v, @sheet_panel]
-    end
-    it '非公開の紙コマは(自分の紙コマであっても)含まない' do
-      h = FactoryGirl.create :sheet_panel, :author_id => @author.id, :sheet_id => @hidden_sheet.id, :panel_id => @panel.id, :t => 0
-      c = SheetPanel.list 
-      c.should eq [ @sheet_panel]
-    end
-    context 'DBに5件あって1ページの件数を2件に変えたとして' do
-      before do
-        @sheet_panel2 = FactoryGirl.create :sheet_panel, :author_id => @author.id, :sheet_id => @sheet.id, :panel_id => @panel.id, :t => 1, :updated_at => Time.now + 100
-        @sheet_panel3 = FactoryGirl.create :sheet_panel, :author_id => @author.id, :sheet_id => @sheet.id, :panel_id => @panel.id, :t => 2, :updated_at => Time.now + 200
-        @sheet_panel4 = FactoryGirl.create :sheet_panel, :author_id => @author.id, :sheet_id => @sheet.id, :panel_id => @panel.id, :t => 3, :updated_at => Time.now + 300
-        @sheet_panel5 = FactoryGirl.create :sheet_panel, :author_id => @author.id, :sheet_id => @sheet.id, :panel_id => @panel.id, :t => 4, :updated_at => Time.now + 400
-      end
-      it '通常は2件を返す' do
-        l = SheetPanel.list 1, 2
-        l.should have(2).items 
-      end
-      it 'page=1なら末尾2件を返す' do
-        #時系列で並んでいる
-        l = SheetPanel.list 1, 2
-        l.should eq [@sheet_panel5, @sheet_panel4]
-      end
-      it 'page=2なら中間2件を返す' do
-        l = SheetPanel.list 2, 2
-        l.should eq [@sheet_panel3, @sheet_panel2]
-      end
-      it 'page=3なら先頭1件を返す' do
-        l = SheetPanel.list 3, 2
-        l.should eq [@sheet_panel]
-      end
-    end
-  end
-  
-  describe '自分の紙コマ一覧取得に於いて' do
-    before do
-      @sheet = FactoryGirl.create :sheet, :author_id => @author.id, :visible => 1
-      @panel = FactoryGirl.create :panel, :author_id => @author.id, :publish => 1
-      @sheet_panel = FactoryGirl.create :sheet_panel, :author_id => @author.id, :sheet_id => @sheet.id, :panel_id => @panel.id
-      @other_sheet = FactoryGirl.create :sheet, :author_id => @other_author.id, :visible => 1
-      @other_panel = FactoryGirl.create :panel, :author_id => @other_author.id, :publish => 1
-      @hsheet = FactoryGirl.create :sheet, :author_id => @author.id, :visible => 0
-      @hpanel = FactoryGirl.create :panel, :author_id => @author.id, :publish => 0
-    end
-    context 'つつがなく終わるとき' do
-      it '一覧取得オプションを利用している' do
-        SheetPanel.stub(:list_opt).with(any_args).and_return({})
-        SheetPanel.should_receive(:list_opt).with(any_args).exactly(1)
-        r = SheetPanel.mylist @author
-      end
-    end
-    it 'リストを返す' do
-      s = SheetPanel.mylist @author
-      s.should eq [@sheet_panel]
-    end
-    it '時系列で並んでいる' do
-      ns = FactoryGirl.create :sheet_panel, :author_id => @author.id, :sheet_id => @sheet.id, :panel_id => @panel.id, :t => 1, :updated_at => Time.now + 100
-      sl = SheetPanel.mylist @author
-      sl.should eq [ns, @sheet_panel]
-    end
-    it '他人の紙コマはコマ用紙ともに公開でも含まない' do
-      so = FactoryGirl.create :sheet_panel, :author_id => @other_author.id, :sheet_id => @other_sheet.id, :panel_id => @other_panel.id
-      sl = SheetPanel.mylist @author
-      sl.should eq [@sheet_panel]
-    end
-    it '自分の紙コマはコマ用紙ともに非公開でも含んでいる' do
-      hs = FactoryGirl.create :sheet_panel, :author_id => @author.id, :sheet_id => @hsheet.id, :panel_id => @hpanel.id, :updated_at => Time.now + 100
-      sl = SheetPanel.mylist @author
-      sl.should eq [hs, @sheet_panel]
-    end
-    context 'DBに5件あって1ページの件数を2件に変えたとして' do
-      before do
-        @sheet_panel2 = FactoryGirl.create :sheet_panel, :author_id => @author.id, :sheet_id => @sheet.id, :panel_id => @panel.id, :t => 1, :updated_at => Time.now + 100
-        @sheet_panel3 = FactoryGirl.create :sheet_panel, :author_id => @author.id, :sheet_id => @sheet.id, :panel_id => @panel.id, :t => 2, :updated_at => Time.now + 200
-        @sheet_panel4 = FactoryGirl.create :sheet_panel, :author_id => @author.id, :sheet_id => @sheet.id, :panel_id => @panel.id, :t => 3, :updated_at => Time.now + 300
-        @sheet_panel5 = FactoryGirl.create :sheet_panel, :author_id => @author.id, :sheet_id => @sheet.id, :panel_id => @panel.id, :t => 4, :updated_at => Time.now + 400
-        SheetPanel.stub(:default_page_size).and_return(2)
-      end
-      it '通常は2件を返す' do
-        l = SheetPanel.mylist @author, 1, 2
-        l.should have(2).items 
-      end
-      it 'page=1なら末尾2件を返す' do
-        #時系列で並んでいる
-        l = SheetPanel.mylist @author, 1, 2
-        l.should eq [@sheet_panel5, @sheet_panel4]
-      end
-      it 'page=2なら中間2件を返す' do
-        l = SheetPanel.mylist @author, 2, 2
-        l.should eq [@sheet_panel3, @sheet_panel2]
-      end
-      it 'page=3なら先頭1件を返す' do
-        l = SheetPanel.mylist @author, 3, 2
-        l.should eq [@sheet_panel]
-      end
-    end
-  end
-  
-  describe '他作家の紙コマ一覧取得に於いて' do
-    before do
-      @sheet = FactoryGirl.create :sheet, :author_id => @author.id, :visible => 1
-      @panel = FactoryGirl.create :panel, :author_id => @author.id, :publish => 1
-      @sheet_panel = FactoryGirl.create :sheet_panel, :author_id => @author.id, :sheet_id => @sheet.id, :panel_id => @panel.id
-      @other_sheet = FactoryGirl.create :sheet, :author_id => @other_author.id, :visible => 1
-      @other_panel = FactoryGirl.create :panel, :author_id => @other_author.id, :publish => 1
-      @other_sheet_panel = FactoryGirl.create :sheet_panel, :author_id => @other_author.id, :sheet_id => @other_sheet.id, :panel_id => @other_panel.id
-    end
-    it 'リストを返す' do
-      r = SheetPanel.himlist @other_author
-      r.should eq [@other_sheet_panel]
-    end
-    it '時系列で並んでいる' do
-      ns = FactoryGirl.create :sheet_panel, :author_id => @other_author.id, :sheet_id => @other_sheet.id, :panel_id => @other_panel.id, :t => 1, :updated_at => Time.now + 100
-      r = SheetPanel.himlist @other_author
-      r.should eq [ns, @other_sheet_panel]
-    end
-    it '公開用紙の紙コマ' do
-      @hsheet = FactoryGirl.create :sheet, :author_id => @other_author.id, :visible => 0
-      ns = FactoryGirl.create :sheet_panel, :author_id => @other_author.id, :sheet_id => @hsheet.id, :panel_id => @other_panel.id, :t => 1, :updated_at => Time.now + 100
-      r = SheetPanel.himlist @other_author
-      r.should eq [@other_sheet_panel]
-    end
-    context 'DBに5件あって1ページの件数を2件に変えたとして' do
-      before do
-        @other_sheet_panel2 = FactoryGirl.create :sheet_panel, :author_id => @other_author.id, :sheet_id => @other_sheet.id, :panel_id => @other_panel.id, :t => 1, :updated_at => Time.now + 100
-        @other_sheet_panel3 = FactoryGirl.create :sheet_panel, :author_id => @other_author.id, :sheet_id => @other_sheet.id, :panel_id => @other_panel.id, :t => 2, :updated_at => Time.now + 200
-        @other_sheet_panel4 = FactoryGirl.create :sheet_panel, :author_id => @other_author.id, :sheet_id => @other_sheet.id, :panel_id => @other_panel.id, :t => 3, :updated_at => Time.now + 300
-        @other_sheet_panel5 = FactoryGirl.create :sheet_panel, :author_id => @other_author.id, :sheet_id => @other_sheet.id, :panel_id => @other_panel.id, :t => 4, :updated_at => Time.now + 400
-        SheetPanel.stub(:default_page_size).and_return(2)
-      end
-      it '通常は2件を返す' do
-        l = SheetPanel.himlist @other_author, 1, 2
-        l.should have(2).items 
-      end
-      it 'page=1なら末尾2件を返す' do
-        #時系列で並んでいる
-        l = SheetPanel.himlist @other_author, 1, 2
-        l.should eq [@other_sheet_panel5, @other_sheet_panel4]
-      end
-      it 'page=2なら中間2件を返す' do
-        l = SheetPanel.himlist @other_author, 2, 2
-        l.should eq [@other_sheet_panel3, @other_sheet_panel2]
-      end
-      it 'page=3なら先頭1件を返す' do
-        l = SheetPanel.himlist @other_author, 3, 2
-        l.should eq [@other_sheet_panel]
-      end
-    end
-  end
-  
-  describe '紙コマ一覧ページ制御に於いて' do
-    before do
-      SheetPanel.stub(:count).with(any_args).and_return(100)
-    end
-    it 'ページ制御を返す' do
-      r = SheetPanel.list_paginate 
-      r.is_a?(Kaminari::PaginatableArray).should be_true
-    end
-    it '紙コマ一覧の取得条件を利用している' do
-      SheetPanel.stub(:list_where).with(any_args).and_return('')
-      SheetPanel.should_receive(:list_where).with(any_args).exactly(1)
-      r = SheetPanel.list_paginate 
-    end
-    it 'ページ件数10のとき、3ページ目のオフセットは20から始まる' do
-      r = SheetPanel.list_paginate 3, 10
-      r.limit_value.should eq 10
-      r.offset_value.should eq 20
-    end
-  end
-  
-  describe '自分の紙コマ一覧ページ制御に於いて' do
-    before do
-      SheetPanel.stub(:count).with(any_args).and_return(100)
-    end
-    it 'ページ制御を返す' do
-      r = SheetPanel.mylist_paginate @author
-      r.is_a?(Kaminari::PaginatableArray).should be_true
-    end
-    it '自分の紙コマ一覧の取得条件を利用している' do
-      SheetPanel.stub(:mylist_where).with(any_args).and_return('')
-      SheetPanel.should_receive(:mylist_where).with(any_args).exactly(1)
-      r = SheetPanel.mylist_paginate @author
-    end
-    it 'ページ件数10のとき、3ページ目のオフセットは20から始まる' do
-      r = SheetPanel.mylist_paginate @author, 3, 10
-      r.limit_value.should eq 10
-      r.offset_value.should eq 20
-    end
-  end
-  
-  describe '他作家の紙コマ一覧ページ制御に於いて' do
-    before do
-      SheetPanel.stub(:count).with(any_args).and_return(100)
-    end
-    it 'ページ制御を返す' do
-      r = SheetPanel.himlist_paginate @other_author
-      r.is_a?(Kaminari::PaginatableArray).should be_true
-    end
-    it '他作家の紙コマ一覧の取得条件を利用している' do
-      SheetPanel.stub(:himlist_where).with(any_args).and_return('')
-      SheetPanel.should_receive(:himlist_where).with(any_args).exactly(1)
-      r = SheetPanel.himlist_paginate @other_author
-    end
-    it 'ページ件数10のとき、3ページ目のオフセットは20から始まる' do
-      r = SheetPanel.himlist_paginate @other_author, 3, 10
-      r.limit_value.should eq 10
-      r.offset_value.should eq 20
-    end
-  end
-  
-  describe 'list関連テーブルプションに於いて' do
-    it '3つの項目を含んでいる' do
-      r = SheetPanel.list_opt
-      r.should have(3).items
-    end
-    it '用紙を含んでいる' do
-      r = SheetPanel.list_opt
-      r.has_key?(:sheet).should be_true
-    end
-      it '用紙は作家を含んでいる' do
-        r = SheetPanel.list_opt
-        r[:sheet].has_key?(:author).should be_true
-      end
-    it '作家を含んでいる' do
-      r = SheetPanel.list_opt
-      r.has_key?(:author).should be_true
-    end
-    it 'コマを含んでいる' do
-      r = SheetPanel.list_opt
-      r.has_key?(:panel).should be_true
-    end
-      it 'コマは作家を含んでいる' do
-        r = SheetPanel.list_opt
-        r[:panel].has_key?(:author).should be_true
-      end
-      it 'コマはコマ絵を含んでいる' do
-        r = SheetPanel.list_opt
-        r[:panel].has_key?(:panel_pictures).should be_true
-      end
-        it 'コマ絵は実素材を含んでいる' do
-          r = SheetPanel.list_opt
-          r[:panel][:panel_pictures].has_key?(:picture).should be_true
-        end
-          it '実素材は絵師を含んでいる' do
-            r = SheetPanel.list_opt
-            r[:panel][:panel_pictures][:picture].has_key?(:artist).should be_true
-          end
-          it '実素材はライセンスを含んでいる' do
-            r = SheetPanel.list_opt
-            r[:panel][:panel_pictures][:picture].has_key?(:license).should be_true
-          end
-      it 'コマはフキダシを含んでいる' do
-        r = SheetPanel.list_opt
-        r[:panel].has_key?(:speech_balloons).should be_true
-      end
-        it 'フキダシはフキダシ枠を含んでいる' do
-          r = SheetPanel.list_opt
-          r[:panel][:speech_balloons].has_key?(:balloon).should be_true
-        end
-        it 'フキダシはセリフを含んでいる' do
-          r = SheetPanel.list_opt
-          r[:panel][:speech_balloons].has_key?(:speech).should be_true
-        end
-  end
-  describe 'json一覧出力オプションに於いて' do
-  end
   
   describe '単体取得に於いて' do
     before do
       @sheet = FactoryGirl.create :sheet, :author_id => @author.id
       @panel = FactoryGirl.create :panel, :author_id => @author.id
-      @sheet_panel = FactoryGirl.create :sheet_panel, :author_id => @author.id, :sheet_id => @sheet.id, :panel_id => @panel.id
+      @item = FactoryGirl.create :sheet_panel, :author_id => @author.id, :sheet_id => @sheet.id, :panel_id => @panel.id
     end
     context 'つつがなく終わるとき' do
       it '単体取得オプションを利用している' do
         SheetPanel.stub(:show_opt).with(any_args).and_return({})
         SheetPanel.should_receive(:show_opt).with(any_args).exactly(1)
-        r = SheetPanel.show @sheet_panel.id, @author
+        r = SheetPanel.show @item.id, @author
       end
       it '閲覧許可を問い合わせている' do
         SheetPanel.any_instance.stub(:visible?).with(@author).and_return(true)
         SheetPanel.any_instance.should_receive(:visible?).with(@author).exactly(1)
-        r = SheetPanel.show @sheet_panel.id, @author
+        r = SheetPanel.show @item.id, @author
       end
     end
     it '指定の紙コマを返す' do
-      l = SheetPanel.show @sheet_panel.id, @author
-      l.should eq @sheet_panel
+      l = SheetPanel.show @item.id, @author
+      l.should eq @item
     end
     context '他人の紙コマを開こうとしたとき' do
       it '403Forbidden例外を返す' do
         SheetPanel.any_instance.stub(:visible?).with(@other_author).and_return(false)
         lambda{
-          SheetPanel.show @sheet_panel.id, @other_author
+          SheetPanel.show @item.id, @other_author
         }.should raise_error(ActiveRecord::Forbidden)
       end
     end
@@ -686,29 +318,29 @@ describe SheetPanel do
     before do
       @sheet = FactoryGirl.create :sheet, :author_id => @author.id
       @panel = FactoryGirl.create :panel, :author_id => @author.id
-      @sheet_panel = FactoryGirl.create :sheet_panel, :author_id => @author.id, :sheet_id => @sheet.id, :panel_id => @panel.id
+      @item = FactoryGirl.create :sheet_panel, :author_id => @author.id, :sheet_id => @sheet.id, :panel_id => @panel.id
     end
     context 'つつがなく終わるとき' do
       it '単体取得オプションを利用している' do
         SheetPanel.stub(:show_opt).with(any_args).and_return({})
         SheetPanel.should_receive(:show_opt).with(any_args).exactly(1)
-        r = SheetPanel.edit @sheet_panel.id, @author
+        r = SheetPanel.edit @item.id, @author
       end
       it '所持判定を問い合わせている' do
         SheetPanel.any_instance.stub(:own?).with(any_args).and_return(true)
         SheetPanel.any_instance.should_receive(:own?).with(any_args).exactly(1)
-        r = SheetPanel.edit @sheet_panel.id, @author
+        r = SheetPanel.edit @item.id, @author
       end
     end
     it '指定の紙コマを返す' do
-      l = SheetPanel.edit @sheet_panel.id, @author
-      l.should eq @sheet_panel
+      l = SheetPanel.edit @item.id, @author
+      l.should eq @item
     end
     context '他人の紙コマを開こうとしたとき' do
       it '403Forbidden例外を返す' do
         SheetPanel.any_instance.stub(:own?).and_return(false)
         lambda{
-          SheetPanel.edit @sheet_panel.id, @author
+          SheetPanel.edit @item.id, @author
         }.should raise_error(ActiveRecord::Forbidden)
       end
     end
@@ -804,7 +436,7 @@ describe SheetPanel do
       )
       @panel.reload
       @sheet = FactoryGirl.create :sheet, :author_id => @author.id
-      @sheet_panel = FactoryGirl.create :sheet_panel, :author_id => @author.id, :sheet_id => @sheet.id, :panel_id => @panel.id
+      @item = FactoryGirl.create :sheet_panel, :author_id => @author.id, :sheet_id => @sheet.id, :panel_id => @panel.id
     end
     context '事前チェックする' do
       before do
@@ -813,15 +445,15 @@ describe SheetPanel do
       it 'コマ要素のjson出力を依頼している' do
         Panel.any_instance.stub(:visible?).with(any_args).and_return(true)
         Panel.any_instance.should_receive(:elements).with(any_args).exactly(1)
-        r = @sheet_panel.sheet_panel_as_json @author
+        r = @item.sheet_panel_as_json @author
       end
     end
     it 'json textを返している' do
-      r = JSON.parse @sheet_panel.sheet_panel_as_json(@author)
+      r = JSON.parse @item.sheet_panel_as_json(@author)
       r.is_a?(Hash).should be_true
     end
     it 'sheet,author,panel,コマ要素を含んでいる' do
-      r = JSON.parse @sheet_panel.sheet_panel_as_json(@author)
+      r = JSON.parse @item.sheet_panel_as_json(@author)
       r.has_key?('sheet').should be_true
       r['sheet'].has_key?('author').should be_true
       r.has_key?('author').should be_true
@@ -833,7 +465,7 @@ describe SheetPanel do
         Panel.any_instance.stub(:visible?).with(any_args).and_return(true)
       end
       it 'コマ要素にコマ要素を追加している' do
-        r = JSON.parse @sheet_panel.sheet_panel_as_json(@author)
+        r = JSON.parse @item.sheet_panel_as_json(@author)
         r['panel'].has_key?('elements').should be_true
         r['panel']['elements'].should_not be_empty
       end
@@ -843,7 +475,7 @@ describe SheetPanel do
         Panel.any_instance.stub(:visible?).with(any_args).and_return(false)
       end
       it 'コマ要素にデータを含ませない' do
-        r = JSON.parse @sheet_panel.sheet_panel_as_json(@author)
+        r = JSON.parse @item.sheet_panel_as_json(@author)
         r['panel'].has_key?('elements').should be_false
       end
     end
@@ -853,22 +485,22 @@ describe SheetPanel do
     before do
       @panel = FactoryGirl.create :panel, :author_id => @author.id
       @sheet = FactoryGirl.create :sheet, :author_id => @author.id
-      @sheet_panel = FactoryGirl.create :sheet_panel, :author_id => @author.id, :sheet_id => @sheet.id, :panel_id => @panel.id
+      @item = FactoryGirl.create :sheet_panel, :author_id => @author.id, :sheet_id => @sheet.id, :panel_id => @panel.id
       SheetPanel.any_instance.stub(:sheet_panel_as_json).with(@author).and_return('{"s": 5}')
     end
     context 'つつがなく終わるとき' do
       it '紙コマのjson出力を依頼している' do
         SheetPanel.any_instance.should_receive(:sheet_panel_as_json).with(@author).exactly(1)
-        r = SheetPanel.list_as_json_text [@sheet_panel], @author
+        r = SheetPanel.list_as_json_text [@item], @author
       end
     end
     it 'json textを返している' do
-      r = SheetPanel.list_as_json_text [@sheet_panel], @author
+      r = SheetPanel.list_as_json_text [@item], @author
       j = JSON.parse r
       j.is_a?(Array).should be_true
     end
     it '紙コマを含んでいる' do
-      r = SheetPanel.list_as_json_text [@sheet_panel], @author
+      r = SheetPanel.list_as_json_text [@item], @author
       j = JSON.parse r
       j.first.has_key?('s').should be_true
     end
@@ -882,18 +514,18 @@ describe SheetPanel do
     
     context '用紙初のコマなら' do
       it '0を補充値とする' do
-        @sheet_panel = FactoryGirl.build :sheet_panel, :author_id => @author.id, :sheet_id => @sheet.id, :panel_id => @panel.id
-        @sheet_panel.t = nil
-        r = SheetPanel.new_t @sheet_panel.sheet_id
+        @item = FactoryGirl.build :sheet_panel, :author_id => @author.id, :sheet_id => @sheet.id, :panel_id => @panel.id
+        @item.t = nil
+        r = SheetPanel.new_t @item.sheet_id
         r.should eq 0
       end
     end
     context '用紙に一個コマがあるとき' do
       it '1を補充値とする' do
         FactoryGirl.create :sheet_panel, :author_id => @author.id, :sheet_id => @sheet.id, :panel_id => @panel.id, :t => 0
-        @sheet_panel = FactoryGirl.build :sheet_panel, :author_id => @author.id, :sheet_id => @sheet.id, :panel_id => @panel.id
-        @sheet_panel.t = nil
-        r = SheetPanel.new_t @sheet_panel.sheet_id
+        @item = FactoryGirl.build :sheet_panel, :author_id => @author.id, :sheet_id => @sheet.id, :panel_id => @panel.id
+        @item.t = nil
+        r = SheetPanel.new_t @item.sheet_id
         r.should eq 1
       end
     end
@@ -901,9 +533,9 @@ describe SheetPanel do
       it '2を補充値とする' do
         FactoryGirl.create :sheet_panel, :author_id => @author.id, :sheet_id => @sheet.id, :panel_id => @panel.id, :t => 0
         FactoryGirl.create :sheet_panel, :author_id => @author.id, :sheet_id => @sheet.id, :panel_id => @panel.id, :t => 1
-        @sheet_panel = FactoryGirl.build :sheet_panel, :author_id => @author.id, :sheet_id => @sheet.id, :panel_id => @panel.id
-        @sheet_panel.t = nil
-        r = SheetPanel.new_t @sheet_panel.sheet_id
+        @item = FactoryGirl.build :sheet_panel, :author_id => @author.id, :sheet_id => @sheet.id, :panel_id => @panel.id
+        @item.t = nil
+        r = SheetPanel.new_t @item.sheet_id
         r.should eq 2
       end
     end
@@ -942,27 +574,27 @@ describe SheetPanel do
     before do
       @sheet = FactoryGirl.create :sheet, :author_id => @author.id
       @panel = FactoryGirl.create :panel, :author_id => @author.id
-      @sheet_panel = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+      @item = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
       @sheet2 = FactoryGirl.create :sheet, :author_id => @author.id
       @c2sheet_panel = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet2.id, :panel_id => @panel.id, :author_id => @author.id
     end
     context 'つつがなく終わるとき' do
       it '紙コマから同一用紙のtだけを収集している' do
-        r = SheetPanel.collect_t @sheet_panel
+        r = SheetPanel.collect_t @item
         r.should eq [0]
       end
     end
     context '複数コマのとき' do
       it '紙コマから同一用紙のtだけを収集している' do
-        @sheet_panel2 = FactoryGirl.create :sheet_panel, :t => 1, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
-        r = SheetPanel.collect_t @sheet_panel
+        @item2 = FactoryGirl.create :sheet_panel, :t => 1, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        r = SheetPanel.collect_t @item
         r.sort.should eq [0, 1]
       end
     end
     context '複数コマでヨソの用紙も混じっているとき' do
       it '紙コマから同一用紙のtだけを収集している' do
-        @sheet_panel2 = FactoryGirl.create :sheet_panel, :t => 1, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
-        r = SheetPanel.collect_t @sheet_panel
+        @item2 = FactoryGirl.create :sheet_panel, :t => 1, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        r = SheetPanel.collect_t @item
         r.sort.should eq [0, 1]
       end
     end
@@ -971,36 +603,36 @@ describe SheetPanel do
     before do
       @sheet = FactoryGirl.create :sheet, :author_id => @author.id
       @panel = FactoryGirl.create :panel, :author_id => @author.id
-      @sheet_panel = FactoryGirl.build :sheet_panel, :t => 1, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+      @item = FactoryGirl.build :sheet_panel, :t => 1, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
     end
     context 'つつがなく終わるとき' do
       it 't収集を依頼している' do
         SheetPanel.should_receive(:collect_t).with(any_args).exactly(1)
         SheetPanel.stub(:collect_t).with(any_args).and_return([])
         SheetPanel.stub(:serial?).with(any_args).and_return(true)
-        r = SheetPanel.validate_t @sheet_panel
+        r = SheetPanel.validate_t @item
       end
       it '収集したtをシリアライズチェック依頼している' do
         SheetPanel.stub(:collect_t).with(any_args).and_return([])
         SheetPanel.should_receive(:serial?).with(any_args).exactly(1)
         SheetPanel.stub(:serial?).with(any_args).and_return(true)
-        r = SheetPanel.validate_t @sheet_panel
+        r = SheetPanel.validate_t @item
       end
     end
     #実データでチェック
     #依頼チェックだけでは不安なので最低限のチェックを
     context '新規のとき' do
       it '一件だけで正常通過している' do
-        @sheet_panel = FactoryGirl.build :sheet_panel, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id, :t => 0
-        r = SheetPanel.validate_t @sheet_panel
+        @item = FactoryGirl.build :sheet_panel, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id, :t => 0
+        r = SheetPanel.validate_t @item
         r.should be_true 
       end
     end
     context '既存のとき' do
       it '2件目を作っても正常通過している' do
-        @sheet_panel = FactoryGirl.create :sheet_panel, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id, :t => 0
-        @sheet_panel2 = FactoryGirl.build :sheet_panel, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id, :t => 1
-        r = SheetPanel.validate_t @sheet_panel2
+        @item = FactoryGirl.create :sheet_panel, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id, :t => 0
+        @item2 = FactoryGirl.build :sheet_panel, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id, :t => 1
+        r = SheetPanel.validate_t @item2
         r.should be_true 
       end
     end
@@ -1015,49 +647,49 @@ describe SheetPanel do
       it 'Updateを依頼している' do
         SheetPanel.stub(:update_all).with(any_args)
         SheetPanel.should_receive(:update_all).with(any_args).exactly(1)
-        @sheet_panel = FactoryGirl.build :sheet_panel, :t => 0, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
-        @sheet_panel.insert_shift
+        @item = FactoryGirl.build :sheet_panel, :t => 0, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item.insert_shift
       end
     end
     context 'テーブルに1件(t:0)で0に挿入したとき' do
       before do
-        @sheet_panel = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
-        @sheet_panel2 = FactoryGirl.build :sheet_panel, :t => 0, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item2 = FactoryGirl.build :sheet_panel, :t => 0, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
       end
       it '既存の行を1にシフトしている' do
-        @sheet_panel2.insert_shift
+        @item2.insert_shift
         l = SheetPanel.find :all
         l.first.t.should eq 1
       end
       it 'これから挿入するt(0)が欠番になっている' do
-        @sheet_panel2.insert_shift
+        @item2.insert_shift
         l = SheetPanel.find(:all).map {|s| s.t }
         l.include?(0).should_not be_true
       end
     end
     context 'テーブルに2件(t:0,1)で1に挿入したとき' do
       before do
-        @sheet_panel = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
-        @sheet_panel2 = FactoryGirl.create :sheet_panel, :t => 1, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
-        @sheet_panel3 = FactoryGirl.build :sheet_panel, :t => 1, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item2 = FactoryGirl.create :sheet_panel, :t => 1, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item3 = FactoryGirl.build :sheet_panel, :t => 1, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
       end
       it '既存のt1を2にシフトしてこれから挿入するt(1)が欠番になっている' do
-        @sheet_panel3.insert_shift
+        @item3.insert_shift
         l = SheetPanel.find(:all).map {|s| s.t }
         l.sort.should eq [0, 2]
       end
     end
     context 'テーブルに5件(t:0,1,2,3,4)で2に挿入したとき' do
       before do
-        @sheet_panel = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
-        @sheet_panel2 = FactoryGirl.create :sheet_panel, :t => 1, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
-        @sheet_panel3 = FactoryGirl.create :sheet_panel, :t => 2, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
-        @sheet_panel4 = FactoryGirl.create :sheet_panel, :t => 3, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
-        @sheet_panel5 = FactoryGirl.create :sheet_panel, :t => 4, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
-        @sheet_panel6 = FactoryGirl.build :sheet_panel, :t => 2, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item2 = FactoryGirl.create :sheet_panel, :t => 1, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item3 = FactoryGirl.create :sheet_panel, :t => 2, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item4 = FactoryGirl.create :sheet_panel, :t => 3, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item5 = FactoryGirl.create :sheet_panel, :t => 4, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item6 = FactoryGirl.build :sheet_panel, :t => 2, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
       end
       it '既存のt1を2にシフトしてこれから挿入するt(1)が欠番になっている' do
-        @sheet_panel6.insert_shift
+        @item6.insert_shift
         l = SheetPanel.find(:all).map {|s| s.t }
         l.sort.should eq [0, 1, 3, 4, 5]
       end
@@ -1065,24 +697,24 @@ describe SheetPanel do
     context '先ほどのケース+他の用紙1件で挿入したとき' do
       before do
         @sheet2 = FactoryGirl.create :sheet, :author_id => @author.id
-        @sheet_panelc2 = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet2.id, :panel_id => @panel.id, :author_id => @author.id
-        @sheet_panel = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
-        @sheet_panel2 = FactoryGirl.create :sheet_panel, :t => 1, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
-        @sheet_panel3 = FactoryGirl.create :sheet_panel, :t => 2, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
-        @sheet_panel4 = FactoryGirl.create :sheet_panel, :t => 3, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
-        @sheet_panel5 = FactoryGirl.create :sheet_panel, :t => 4, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
-        @sheet_panel6 = FactoryGirl.build :sheet_panel, :t => 2, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @itemc2 = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet2.id, :panel_id => @panel.id, :author_id => @author.id
+        @item = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item2 = FactoryGirl.create :sheet_panel, :t => 1, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item3 = FactoryGirl.create :sheet_panel, :t => 2, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item4 = FactoryGirl.create :sheet_panel, :t => 3, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item5 = FactoryGirl.create :sheet_panel, :t => 4, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item6 = FactoryGirl.build :sheet_panel, :t => 2, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
       end
       it '既存のt1を2にシフトしてこれから挿入するt(1)が欠番になっている' do
-        @sheet_panel6.insert_shift
+        @item6.insert_shift
         l = SheetPanel.find(:all, :conditions => ['sheet_id = ?', @sheet.id]).map {|s| s.t }
         l.sort.should eq [0, 1, 3, 4, 5]
       end
       it '他の用紙に影響がない' do
-        ot = @sheet_panelc2.t
-        @sheet_panel6.insert_shift
-        @sheet_panelc2.reload
-        @sheet_panelc2.t.should eq ot
+        ot = @itemc2.t
+        @item6.insert_shift
+        @itemc2.reload
+        @itemc2.t.should eq ot
       end
     end
   end
@@ -1093,157 +725,157 @@ describe SheetPanel do
     end
     context '依頼チェック' do
       it 'Updateを依頼している' do
-        @sheet_panel = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
-        @sheet_panel2 = FactoryGirl.create :sheet_panel, :t => 1, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item2 = FactoryGirl.create :sheet_panel, :t => 1, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
         SheetPanel.stub(:update_all).with(any_args)
         SheetPanel.should_receive(:update_all).with(any_args).exactly(1)
-        ot = @sheet_panel2.t
-        @sheet_panel2.t = 0
-        @sheet_panel2.lesser_shift ot
+        ot = @item2.t
+        @item2.t = 0
+        @item2.lesser_shift ot
       end
     end
     context 'テーブルに2件(t:0,1)で1を0に移動したとき' do
       before do
-        @sheet_panel = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
-        @sheet_panel2 = FactoryGirl.create :sheet_panel, :t => 1, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
-        @ot = @sheet_panel2.t
-        @sheet_panel2.t = 0
+        @item = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item2 = FactoryGirl.create :sheet_panel, :t => 1, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @ot = @item2.t
+        @item2.t = 0
       end
       it '既存のt0を1にシフトしてこれから挿入するt(0)が欠番になっている' do
         #移動させたい行はそのまま残る
-        @sheet_panel2.lesser_shift @ot
+        @item2.lesser_shift @ot
         l = SheetPanel.find(:all).map {|s| s.t }
         l.sort.should eq [1, 1]
       end
       it '既存のt0を1にシフトしている' do
-        @sheet_panel2.lesser_shift @ot
-        @sheet_panel.reload
-        @sheet_panel.t.should eq 1
+        @item2.lesser_shift @ot
+        @item.reload
+        @item.t.should eq 1
       end
     end
     context 'テーブルに3件(t:0,1,2)で2を1に移動したとき' do
       before do
-        @sheet_panel = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
-        @sheet_panel2 = FactoryGirl.create :sheet_panel, :t => 1, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
-        @sheet_panel3 = FactoryGirl.create :sheet_panel, :t => 2, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
-        @ot = @sheet_panel3.t
-        @sheet_panel3.t = 1
+        @item = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item2 = FactoryGirl.create :sheet_panel, :t => 1, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item3 = FactoryGirl.create :sheet_panel, :t => 2, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @ot = @item3.t
+        @item3.t = 1
       end
       it '既存のt1を2にシフトしてこれから挿入するt(1)が欠番になっている' do
         #移動させたい行はそのまま残る
-        @sheet_panel3.lesser_shift @ot
+        @item3.lesser_shift @ot
         l = SheetPanel.find(:all).map {|s| s.t }
         l.sort.should eq [0, 2, 2]
       end
       it '既存のt1を2にシフトしている' do
-        @sheet_panel3.lesser_shift @ot
-        @sheet_panel2.reload
-        @sheet_panel2.t.should eq 2
+        @item3.lesser_shift @ot
+        @item2.reload
+        @item2.t.should eq 2
       end
     end
     context 'テーブルに5件(t:0,1,2,3,4)で3を1に移動したとき' do
       before do
-        @sheet_panel = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
-        @sheet_panel2 = FactoryGirl.create :sheet_panel, :t => 1, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
-        @sheet_panel3 = FactoryGirl.create :sheet_panel, :t => 2, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
-        @sheet_panel4 = FactoryGirl.create :sheet_panel, :t => 3, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
-        @sheet_panel5 = FactoryGirl.create :sheet_panel, :t => 4, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
-        @ot = @sheet_panel4.t
-        @sheet_panel4.t = 1
+        @item = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item2 = FactoryGirl.create :sheet_panel, :t => 1, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item3 = FactoryGirl.create :sheet_panel, :t => 2, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item4 = FactoryGirl.create :sheet_panel, :t => 3, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item5 = FactoryGirl.create :sheet_panel, :t => 4, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @ot = @item4.t
+        @item4.t = 1
       end
       it 'これから挿入するt(1)が欠番になっている' do
         #移動させたい行はそのまま残る
-        @sheet_panel4.lesser_shift @ot
+        @item4.lesser_shift @ot
         l = SheetPanel.find(:all).map {|s| s.t }
         l.sort.should eq [0, 2, 3, 3, 4]
       end
       it '既存のt0には変化がない' do
-        @sheet_panel4.lesser_shift @ot
-        @sheet_panel.reload
-        @sheet_panel.t.should eq 0
+        @item4.lesser_shift @ot
+        @item.reload
+        @item.t.should eq 0
       end
       it '既存のt4には変化がない' do
-        @sheet_panel4.lesser_shift @ot
-        @sheet_panel5.reload
-        @sheet_panel5.t.should eq 4
+        @item4.lesser_shift @ot
+        @item5.reload
+        @item5.t.should eq 4
       end
       it '既存のt1を2にシフトしている' do
-        @sheet_panel4.lesser_shift @ot
-        @sheet_panel2.reload
-        @sheet_panel2.t.should eq 2
+        @item4.lesser_shift @ot
+        @item2.reload
+        @item2.t.should eq 2
       end
       it '既存のt2を3にシフトしている' do
-        @sheet_panel4.lesser_shift @ot
-        @sheet_panel3.reload
-        @sheet_panel3.t.should eq 3
+        @item4.lesser_shift @ot
+        @item3.reload
+        @item3.t.should eq 3
       end
     end
     context '先ほどのケース+他の用紙1件で挿入したとき' do
       before do
         @sheet2 = FactoryGirl.create :sheet, :author_id => @author.id
-        @sheet_panelc2 = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet2.id, :panel_id => @panel.id, :author_id => @author.id
-        @sheet_panel = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
-        @sheet_panel2 = FactoryGirl.create :sheet_panel, :t => 1, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
-        @sheet_panel3 = FactoryGirl.create :sheet_panel, :t => 2, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
-        @sheet_panel4 = FactoryGirl.create :sheet_panel, :t => 3, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
-        @sheet_panel5 = FactoryGirl.create :sheet_panel, :t => 4, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
-        @ot = @sheet_panel4.t
-        @sheet_panel4.t = 1
+        @itemc2 = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet2.id, :panel_id => @panel.id, :author_id => @author.id
+        @item = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item2 = FactoryGirl.create :sheet_panel, :t => 1, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item3 = FactoryGirl.create :sheet_panel, :t => 2, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item4 = FactoryGirl.create :sheet_panel, :t => 3, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item5 = FactoryGirl.create :sheet_panel, :t => 4, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @ot = @item4.t
+        @item4.t = 1
       end
       it 'これから挿入するt(1)が欠番になっている' do
-        @sheet_panel4.lesser_shift @ot
+        @item4.lesser_shift @ot
         l = SheetPanel.find(:all).map {|s| s.t }
         l.sort.should eq [0, 0, 2, 3, 3, 4]
       end
       it '既存のt0には変化がない' do
-        @sheet_panel4.lesser_shift @ot
-        @sheet_panel.reload
-        @sheet_panel.t.should eq 0
+        @item4.lesser_shift @ot
+        @item.reload
+        @item.t.should eq 0
       end
       it '既存のt4には変化がない' do
-        @sheet_panel4.lesser_shift @ot
-        @sheet_panel5.reload
-        @sheet_panel5.t.should eq 4
+        @item4.lesser_shift @ot
+        @item5.reload
+        @item5.t.should eq 4
       end
       it '既存のt1を2にシフトしている' do
-        @sheet_panel4.lesser_shift @ot
-        @sheet_panel2.reload
-        @sheet_panel2.t.should eq 2
+        @item4.lesser_shift @ot
+        @item2.reload
+        @item2.t.should eq 2
       end
       it '既存のt2を3にシフトしている' do
-        @sheet_panel4.lesser_shift @ot
-        @sheet_panel3.reload
-        @sheet_panel3.t.should eq 3
+        @item4.lesser_shift @ot
+        @item3.reload
+        @item3.t.should eq 3
       end
       it '他の用紙に影響がない' do
-        @sheet_panel4.lesser_shift @ot
-        @sheet_panelc2.reload
-        @sheet_panelc2.t.should eq 0
+        @item4.lesser_shift @ot
+        @itemc2.reload
+        @itemc2.t.should eq 0
       end
     end
     #例外ケース。
     #負のときは0として正常扱い
     context 'テーブルに2件(t:0,1)で1を-1に移動したとき' do
       before do
-        @sheet_panel = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
-        @sheet_panel2 = FactoryGirl.create :sheet_panel, :t => 1, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
-        @ot = @sheet_panel2.t
-        @sheet_panel2.t = -1
+        @item = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item2 = FactoryGirl.create :sheet_panel, :t => 1, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @ot = @item2.t
+        @item2.t = -1
       end
       it '既存のt0を1にシフトしてこれから挿入するt(0)が欠番になっている' do
         #移動させたい行はそのまま残る
-        @sheet_panel2.lesser_shift @ot
+        @item2.lesser_shift @ot
         l = SheetPanel.find(:all).map {|s| s.t }
         l.sort.should eq [1, 1]
       end
       it '既存のt0を1にシフトしている' do
-        @sheet_panel2.lesser_shift @ot
-        @sheet_panel.reload
-        @sheet_panel.t.should eq 1
+        @item2.lesser_shift @ot
+        @item.reload
+        @item.t.should eq 1
       end
       it '既存のt1は0に補正されている' do
-        @sheet_panel2.lesser_shift @ot
-        @sheet_panel2.t.should eq 0
+        @item2.lesser_shift @ot
+        @item2.t.should eq 0
       end
     end
   end
@@ -1254,158 +886,158 @@ describe SheetPanel do
     end
     context '依頼チェック' do
       it 'Updateを依頼している' do
-        @sheet_panel = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
-        @sheet_panel2 = FactoryGirl.create :sheet_panel, :t => 1, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item2 = FactoryGirl.create :sheet_panel, :t => 1, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
         SheetPanel.stub(:update_all).with(any_args)
         SheetPanel.should_receive(:update_all).with(any_args).exactly(1)
-        ot = @sheet_panel.t
-        @sheet_panel.t = 1
-        @sheet_panel.higher_shift ot
+        ot = @item.t
+        @item.t = 1
+        @item.higher_shift ot
       end
     end
     context 'テーブルに2件(t:0,1)で0を1に移動したとき' do
       before do
-        @sheet_panel = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
-        @sheet_panel2 = FactoryGirl.create :sheet_panel, :t => 1, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
-        @ot = @sheet_panel.t
-        @sheet_panel.t = 1
+        @item = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item2 = FactoryGirl.create :sheet_panel, :t => 1, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @ot = @item.t
+        @item.t = 1
       end
       it '既存のt1を0にシフトしてこれから挿入するt(1)が欠番になっている' do
         #移動させたい行はそのまま残る
-        @sheet_panel.higher_shift @ot
+        @item.higher_shift @ot
         l = SheetPanel.find(:all).map {|s| s.t }
         l.sort.should eq [0, 0]
       end
       it '既存のt1を0にシフトしている' do
-        @sheet_panel.higher_shift @ot
-        @sheet_panel2.reload
-        @sheet_panel2.t.should eq 0
+        @item.higher_shift @ot
+        @item2.reload
+        @item2.t.should eq 0
       end
     end
     context 'テーブルに3件(t:0,1,2)で0を1に移動したとき' do
       before do
-        @sheet_panel = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
-        @sheet_panel2 = FactoryGirl.create :sheet_panel, :t => 1, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
-        @sheet_panel3 = FactoryGirl.create :sheet_panel, :t => 2, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
-        @ot = @sheet_panel.t
-        @sheet_panel.t = 1
+        @item = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item2 = FactoryGirl.create :sheet_panel, :t => 1, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item3 = FactoryGirl.create :sheet_panel, :t => 2, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @ot = @item.t
+        @item.t = 1
       end
       it '既存のt1を0にシフトしてこれから挿入するt(1)が欠番になっている' do
         #移動させたい行はそのまま残る
-        @sheet_panel.higher_shift @ot
+        @item.higher_shift @ot
         l = SheetPanel.find(:all).map {|s| s.t }
         l.sort.should eq [0, 0, 2]
       end
       it '既存のt1を0にシフトしている' do
-        @sheet_panel.higher_shift @ot
-        @sheet_panel2.reload
-        @sheet_panel2.t.should eq 0
+        @item.higher_shift @ot
+        @item2.reload
+        @item2.t.should eq 0
       end
     end
     context 'テーブルに5件(t:0,1,2,3,4)で1を3に移動したとき' do
       before do
-        @sheet_panel = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
-        @sheet_panel2 = FactoryGirl.create :sheet_panel, :t => 1, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
-        @sheet_panel3 = FactoryGirl.create :sheet_panel, :t => 2, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
-        @sheet_panel4 = FactoryGirl.create :sheet_panel, :t => 3, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
-        @sheet_panel5 = FactoryGirl.create :sheet_panel, :t => 4, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
-        @ot = @sheet_panel2.t
-        @sheet_panel2.t = 3
+        @item = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item2 = FactoryGirl.create :sheet_panel, :t => 1, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item3 = FactoryGirl.create :sheet_panel, :t => 2, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item4 = FactoryGirl.create :sheet_panel, :t => 3, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item5 = FactoryGirl.create :sheet_panel, :t => 4, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @ot = @item2.t
+        @item2.t = 3
       end
       it 'これから挿入するt(3)が欠番になっている' do
         #移動させたい行はそのまま残る
-        @sheet_panel2.higher_shift @ot
+        @item2.higher_shift @ot
         l = SheetPanel.find(:all).map {|s| s.t }
         l.sort.should eq [0, 1, 1, 2, 4]
       end
       it '既存のt0には変化がない' do
-        @sheet_panel2.higher_shift @ot
-        @sheet_panel.reload
-        @sheet_panel.t.should eq 0
+        @item2.higher_shift @ot
+        @item.reload
+        @item.t.should eq 0
       end
       it '既存のt4には変化がない' do
-        @sheet_panel2.higher_shift @ot
-        @sheet_panel5.reload
-        @sheet_panel5.t.should eq 4
+        @item2.higher_shift @ot
+        @item5.reload
+        @item5.t.should eq 4
       end
       it '既存のt2を1にシフトしている' do
-        @sheet_panel2.higher_shift @ot
-        @sheet_panel3.reload
-        @sheet_panel3.t.should eq 1
+        @item2.higher_shift @ot
+        @item3.reload
+        @item3.t.should eq 1
       end
       it '既存のt3を2にシフトしている' do
-        @sheet_panel2.higher_shift @ot
-        @sheet_panel4.reload
-        @sheet_panel4.t.should eq 2
+        @item2.higher_shift @ot
+        @item4.reload
+        @item4.t.should eq 2
       end
     end
     context '先ほどのケース+他の用紙1件で挿入したとき' do
       before do
         @sheet2 = FactoryGirl.create :sheet, :author_id => @author.id
-        @sheet_panelc2 = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet2.id, :panel_id => @panel.id, :author_id => @author.id
-        @sheet_panel = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
-        @sheet_panel2 = FactoryGirl.create :sheet_panel, :t => 1, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
-        @sheet_panel3 = FactoryGirl.create :sheet_panel, :t => 2, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
-        @sheet_panel4 = FactoryGirl.create :sheet_panel, :t => 3, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
-        @sheet_panel5 = FactoryGirl.create :sheet_panel, :t => 4, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
-        @ot = @sheet_panel2.t
-        @sheet_panel2.t = 3
+        @itemc2 = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet2.id, :panel_id => @panel.id, :author_id => @author.id
+        @item = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item2 = FactoryGirl.create :sheet_panel, :t => 1, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item3 = FactoryGirl.create :sheet_panel, :t => 2, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item4 = FactoryGirl.create :sheet_panel, :t => 3, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item5 = FactoryGirl.create :sheet_panel, :t => 4, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @ot = @item2.t
+        @item2.t = 3
       end
       it 'これから挿入するt(3)が欠番になっている' do
         #移動させたい行はそのまま残る
-        @sheet_panel2.higher_shift @ot
+        @item2.higher_shift @ot
         l = SheetPanel.find(:all).map {|s| s.t }
         l.sort.should eq [0, 0, 1, 1, 2, 4]
       end
       it '既存のt0には変化がない' do
-        @sheet_panel2.higher_shift @ot
-        @sheet_panel.reload
-        @sheet_panel.t.should eq 0
+        @item2.higher_shift @ot
+        @item.reload
+        @item.t.should eq 0
       end
       it '既存のt4には変化がない' do
-        @sheet_panel2.higher_shift @ot
-        @sheet_panel5.reload
-        @sheet_panel5.t.should eq 4
+        @item2.higher_shift @ot
+        @item5.reload
+        @item5.t.should eq 4
       end
       it '既存のt2を1にシフトしている' do
-        @sheet_panel2.higher_shift @ot
-        @sheet_panel3.reload
-        @sheet_panel3.t.should eq 1
+        @item2.higher_shift @ot
+        @item3.reload
+        @item3.t.should eq 1
       end
       it '既存のt3を2にシフトしている' do
-        @sheet_panel2.higher_shift @ot
-        @sheet_panel4.reload
-        @sheet_panel4.t.should eq 2
+        @item2.higher_shift @ot
+        @item4.reload
+        @item4.t.should eq 2
       end
       it '他の用紙に影響がない' do
-        @sheet_panel2.higher_shift @ot
-        @sheet_panelc2.reload
-        @sheet_panelc2.t.should eq 0
+        @item2.higher_shift @ot
+        @itemc2.reload
+        @itemc2.t.should eq 0
       end
     end
     #例外ケース。
     #max超えたときはmaxとして正常扱い
     context 'テーブルに2件(t:0,1)で0を2に移動したとき' do
       before do
-        @sheet_panel = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
-        @sheet_panel2 = FactoryGirl.create :sheet_panel, :t => 1, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
-        @ot = @sheet_panel.t
-        @sheet_panel.t = 2
+        @item = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item2 = FactoryGirl.create :sheet_panel, :t => 1, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @ot = @item.t
+        @item.t = 2
       end
       it '既存のt1を0にシフトしてこれから挿入するt(1)が欠番になっている' do
         #移動させたい行はそのまま残る
-        @sheet_panel.higher_shift @ot
+        @item.higher_shift @ot
         l = SheetPanel.find(:all).map {|s| s.t }
         l.sort.should eq [0, 0]
       end
       it '既存のt1を0にシフトしている' do
-        @sheet_panel.higher_shift @ot
-        @sheet_panel2.reload
-        @sheet_panel2.t.should eq 0
+        @item.higher_shift @ot
+        @item2.reload
+        @item2.t.should eq 0
       end
       it '既存のt0は1に補正されている' do
-        @sheet_panel.higher_shift @ot
-        @sheet_panel.t.should eq 1
+        @item.higher_shift @ot
+        @item.t.should eq 1
       end
     end
   end
@@ -1413,25 +1045,25 @@ describe SheetPanel do
     before do
       @sheet = FactoryGirl.create :sheet, :author_id => @author.id
       @panel = FactoryGirl.create :panel, :author_id => @author.id
-      @sheet_panel = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
-      @sheet_panel2 = FactoryGirl.create :sheet_panel, :t => 1, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+      @item = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+      @item2 = FactoryGirl.create :sheet_panel, :t => 1, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
     end
     context '新tが旧tより小さいとき' do
       it '少ない方に移動を依頼している' do
         SheetPanel.any_instance.stub(:lesser_shift).with(any_args)
         SheetPanel.any_instance.should_receive(:lesser_shift).with(any_args).exactly(1)
-        ot = @sheet_panel2.t
-        @sheet_panel2.t = 0
-        @sheet_panel2.update_shift ot
+        ot = @item2.t
+        @item2.t = 0
+        @item2.update_shift ot
       end
     end
     context '新tが旧tより大きいとき' do
       it '大きい方に移動を依頼している' do
         SheetPanel.any_instance.stub(:higher_shift).with(any_args)
         SheetPanel.any_instance.should_receive(:higher_shift).with(any_args).exactly(1)
-        ot = @sheet_panel.t
-        @sheet_panel.t = 1
-        @sheet_panel.update_shift ot
+        ot = @item.t
+        @item.t = 1
+        @item.update_shift ot
       end
     end
   end
@@ -1442,30 +1074,30 @@ describe SheetPanel do
     end
     context 'オブジェクトが新規でtが空のとき' do
       it '末尾追加としてtを補充依頼している' do
-        @sheet_panel = FactoryGirl.build :sheet_panel, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item = FactoryGirl.build :sheet_panel, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
         SheetPanel.stub(:new_t).with(any_args).and_return(0)
         SheetPanel.should_receive(:new_t).with(any_args).exactly(1)
-        @sheet_panel.t = nil
-        r = @sheet_panel.rotate
+        @item.t = nil
+        r = @item.rotate
       end
     end
     context 'オブジェクトが新規でtが設定されているとき' do
       it '挿入追加として挿入シフトを依頼している' do
-        @sheet_panel = FactoryGirl.build :sheet_panel, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item = FactoryGirl.build :sheet_panel, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
         SheetPanel.any_instance.stub(:insert_shift).with(any_args)
         SheetPanel.any_instance.should_receive(:insert_shift).with(any_args).exactly(1)
-        @sheet_panel.t = 0
-        r = @sheet_panel.rotate
+        @item.t = 0
+        r = @item.rotate
       end
     end
     context 'オブジェクトが新規でなくtが設定されているとき' do
       it 'コマ移動として入れ替えを依頼している' do
-        @sheet_panel = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
-        @sheet_panel2 = FactoryGirl.create :sheet_panel, :t => 1, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item2 = FactoryGirl.create :sheet_panel, :t => 1, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
         SheetPanel.any_instance.stub(:update_shift).with(any_args)
         SheetPanel.any_instance.should_receive(:update_shift).with(1).exactly(1)
-        @sheet_panel2.t = 0
-        r = @sheet_panel.rotate 1
+        @item2.t = 0
+        r = @item.rotate 1
       end
     end
     context 'オブジェクトが新規でなくtが空のとき' do
@@ -1478,11 +1110,11 @@ describe SheetPanel do
     before do
       @sheet = FactoryGirl.create :sheet, :author_id => @author.id
       @panel = FactoryGirl.create :panel, :author_id => @author.id
-      @sheet_panel = FactoryGirl.build :sheet_panel, :t => nil, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+      @item = FactoryGirl.build :sheet_panel, :t => nil, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
     end
     context 'つつがなく終わるとき' do
       it 'trueを返す' do
-        r = @sheet_panel.allow?
+        r = @item.allow?
         r.should be_true
       end
     end
@@ -1490,7 +1122,7 @@ describe SheetPanel do
       it 'falseを返す' do
         Panel.any_instance.stub(:usable?).with(any_args).and_return(true)
         Sheet.any_instance.stub(:own?).with(any_args).and_return(false)
-        r = @sheet_panel.allow?
+        r = @item.allow?
         r.should be_false
       end
     end
@@ -1498,21 +1130,21 @@ describe SheetPanel do
       it 'falseを返す' do
         Sheet.any_instance.stub(:own?).with(any_args).and_return(true)
         Panel.any_instance.stub(:usable?).with(any_args).and_return(false)
-        r = @sheet_panel.allow?
+        r = @item.allow?
         r.should be_false
       end
     end
     context '用紙またはコマが指定されていなかったとき' do
       it 'nilを返す' do
         Sheet.any_instance.stub(:own?).with(any_args).and_return(true)
-        @sheet_panel.panel_id = nil
-        r = @sheet_panel.allow?
+        @item.panel_id = nil
+        r = @item.allow?
         r.should eq nil
       end
       it 'nilを返す' do
         Panel.any_instance.stub(:usable?).with(any_args).and_return(true)
-        @sheet_panel.sheet_id = nil
-        r = @sheet_panel.allow?
+        @item.sheet_id = nil
+        r = @item.allow?
         r.should eq nil
       end
     end
@@ -1521,169 +1153,169 @@ describe SheetPanel do
     before do
       @sheet = FactoryGirl.create :sheet, :author_id => @author.id
       @panel = FactoryGirl.create :panel, :author_id => @author.id
-      @sheet_panel = FactoryGirl.build :sheet_panel, :t => nil, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+      @item = FactoryGirl.build :sheet_panel, :t => nil, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
     end
     context 'つつがなく終わるとき' do
       it '編集許可チェックを依頼している' do
         SheetPanel.any_instance.stub(:allow?).with(any_args).and_return(true)
         SheetPanel.any_instance.should_receive(:allow?).with(any_args).exactly(1)
-        r = @sheet_panel.store
+        r = @item.store
       end
       it '順序入れ替えを依頼している' do
         SheetPanel.any_instance.stub(:rotate).with(any_args).and_return(0)
         SheetPanel.any_instance.should_receive(:rotate).with(any_args).exactly(1)
         SheetPanel.any_instance.stub(:save).with(any_args).and_return(true)
         SheetPanel.stub(:validate_t).with(any_args).and_return(true)
-        r = @sheet_panel.store 
+        r = @item.store 
       end
       it '保存を依頼している' do
         SheetPanel.stub(:new_t).with(any_args).and_return(0)
         SheetPanel.any_instance.stub(:save).with(any_args).and_return(true)
         SheetPanel.any_instance.should_receive(:save).with(any_args).exactly(1)
         SheetPanel.stub(:validate_t).with(any_args).and_return(true)
-        r = @sheet_panel.store
+        r = @item.store
       end
       it 'tのシリアライズチェックを依頼している' do
         SheetPanel.stub(:new_t).with(any_args).and_return(0)
         SheetPanel.any_instance.stub(:save).with(any_args).and_return(true)
         SheetPanel.stub(:validate_t).with(any_args).and_return(true)
         SheetPanel.should_receive(:validate_t).with(any_args).exactly(1)
-        r = @sheet_panel.store
+        r = @item.store
       end
     end
     #入れ替えテストと同じテストを実施。こちらはシフトだけでなく本尊も更新されている
     context 'テーブルに5件(t:0,1,2,3,4)+他の用紙1件で2に挿入したとき' do
       before do
         @sheet2 = FactoryGirl.create :sheet, :author_id => @author.id
-        @sheet_panelc2 = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet2.id, :panel_id => @panel.id, :author_id => @author.id
-        @sheet_panel = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
-        @sheet_panel2 = FactoryGirl.create :sheet_panel, :t => 1, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
-        @sheet_panel3 = FactoryGirl.create :sheet_panel, :t => 2, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
-        @sheet_panel4 = FactoryGirl.create :sheet_panel, :t => 3, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
-        @sheet_panel5 = FactoryGirl.create :sheet_panel, :t => 4, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
-        @sheet_panel6 = FactoryGirl.build :sheet_panel, :t => 2, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @itemc2 = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet2.id, :panel_id => @panel.id, :author_id => @author.id
+        @item = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item2 = FactoryGirl.create :sheet_panel, :t => 1, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item3 = FactoryGirl.create :sheet_panel, :t => 2, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item4 = FactoryGirl.create :sheet_panel, :t => 3, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item5 = FactoryGirl.create :sheet_panel, :t => 4, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item6 = FactoryGirl.build :sheet_panel, :t => 2, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
       end
       it '既存のt0には変化がない' do
-        @sheet_panel6.store
-        @sheet_panel.reload
-        @sheet_panel.t.should eq 0
+        @item6.store
+        @item.reload
+        @item.t.should eq 0
       end
       it '既存のt1には変化がない' do
-        @sheet_panel6.store
-        @sheet_panel2.reload
-        @sheet_panel2.t.should eq 1
+        @item6.store
+        @item2.reload
+        @item2.t.should eq 1
       end
       it '既存のt2を3にシフトしている' do
-        @sheet_panel6.store
-        @sheet_panel3.reload
-        @sheet_panel3.t.should eq 3
+        @item6.store
+        @item3.reload
+        @item3.t.should eq 3
       end
       it '既存のt3を4にシフトしている' do
-        @sheet_panel6.store
-        @sheet_panel4.reload
-        @sheet_panel4.t.should eq 4
+        @item6.store
+        @item4.reload
+        @item4.t.should eq 4
       end
       it '既存のt5を5にシフトしている' do
-        @sheet_panel6.store
-        @sheet_panel5.reload
-        @sheet_panel5.t.should eq 5
+        @item6.store
+        @item5.reload
+        @item5.t.should eq 5
       end
       it '新規のt2が作成されている' do
-        @sheet_panel6.store
-        @sheet_panel6.reload
-        @sheet_panel6.t.should eq 2
+        @item6.store
+        @item6.reload
+        @item6.t.should eq 2
       end
       it '他の用紙に影響がない' do
-        @ot = @sheet_panelc2.t
-        @sheet_panel6.store
-        @sheet_panelc2.reload
-        @sheet_panelc2.t.should eq @ot
+        @ot = @itemc2.t
+        @item6.store
+        @itemc2.reload
+        @itemc2.t.should eq @ot
       end
     end
     context 'テーブルに5件(t:0,1,2,3,4)+他の用紙1件で3を1に移動したとき' do
       before do
         @sheet2 = FactoryGirl.create :sheet, :author_id => @author.id
-        @sheet_panelc2 = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet2.id, :panel_id => @panel.id, :author_id => @author.id
-        @sheet_panel = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
-        @sheet_panel2 = FactoryGirl.create :sheet_panel, :t => 1, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
-        @sheet_panel3 = FactoryGirl.create :sheet_panel, :t => 2, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
-        @sheet_panel4 = FactoryGirl.create :sheet_panel, :t => 3, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
-        @sheet_panel5 = FactoryGirl.create :sheet_panel, :t => 4, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
-        @ot = @sheet_panel4.t
-        @sheet_panel4.t = 1
+        @itemc2 = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet2.id, :panel_id => @panel.id, :author_id => @author.id
+        @item = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item2 = FactoryGirl.create :sheet_panel, :t => 1, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item3 = FactoryGirl.create :sheet_panel, :t => 2, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item4 = FactoryGirl.create :sheet_panel, :t => 3, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item5 = FactoryGirl.create :sheet_panel, :t => 4, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @ot = @item4.t
+        @item4.t = 1
       end
       it '既存のt0には変化がない' do
-        @sheet_panel4.store @ot
-        @sheet_panel.reload
-        @sheet_panel.t.should eq 0
+        @item4.store @ot
+        @item.reload
+        @item.t.should eq 0
       end
       it '既存のt4には変化がない' do
-        @sheet_panel4.store @ot
-        @sheet_panel5.reload
-        @sheet_panel5.t.should eq 4
+        @item4.store @ot
+        @item5.reload
+        @item5.t.should eq 4
       end
       it '既存のt1を2にシフトしている' do
-        @sheet_panel4.store @ot
-        @sheet_panel2.reload
-        @sheet_panel2.t.should eq 2
+        @item4.store @ot
+        @item2.reload
+        @item2.t.should eq 2
       end
       it '既存のt2を3にシフトしている' do
-        @sheet_panel4.store @ot
-        @sheet_panel3.reload
-        @sheet_panel3.t.should eq 3
+        @item4.store @ot
+        @item3.reload
+        @item3.t.should eq 3
       end
       it '既存のt3を1にシフトしている' do
-        @sheet_panel4.store @ot
-        @sheet_panel4.reload
-        @sheet_panel4.t.should eq 1
+        @item4.store @ot
+        @item4.reload
+        @item4.t.should eq 1
       end
       it '他の用紙に影響がない' do
-        @sheet_panel4.store @ot
-        @sheet_panelc2.reload
-        @sheet_panelc2.t.should eq 0
+        @item4.store @ot
+        @itemc2.reload
+        @itemc2.t.should eq 0
       end
     end
     context 'テーブルに5件(t:0,1,2,3,4)+他の用紙1件で1を3に移動したとき' do
       before do
         @sheet2 = FactoryGirl.create :sheet, :author_id => @author.id
-        @sheet_panelc2 = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet2.id, :panel_id => @panel.id, :author_id => @author.id
-        @sheet_panel = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
-        @sheet_panel2 = FactoryGirl.create :sheet_panel, :t => 1, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
-        @sheet_panel3 = FactoryGirl.create :sheet_panel, :t => 2, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
-        @sheet_panel4 = FactoryGirl.create :sheet_panel, :t => 3, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
-        @sheet_panel5 = FactoryGirl.create :sheet_panel, :t => 4, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
-        @ot = @sheet_panel2.t
-        @sheet_panel2.t = 3
+        @itemc2 = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet2.id, :panel_id => @panel.id, :author_id => @author.id
+        @item = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item2 = FactoryGirl.create :sheet_panel, :t => 1, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item3 = FactoryGirl.create :sheet_panel, :t => 2, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item4 = FactoryGirl.create :sheet_panel, :t => 3, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item5 = FactoryGirl.create :sheet_panel, :t => 4, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @ot = @item2.t
+        @item2.t = 3
       end
       it '既存のt0には変化がない' do
-        @sheet_panel2.store @ot
-        @sheet_panel.reload
-        @sheet_panel.t.should eq 0
+        @item2.store @ot
+        @item.reload
+        @item.t.should eq 0
       end
       it '既存のt4には変化がない' do
-        @sheet_panel2.store @ot
-        @sheet_panel5.reload
-        @sheet_panel5.t.should eq 4
+        @item2.store @ot
+        @item5.reload
+        @item5.t.should eq 4
       end
       it '既存のt1を3にシフトしている' do
-        @sheet_panel2.store @ot
-        @sheet_panel2.reload
-        @sheet_panel2.t.should eq 3
+        @item2.store @ot
+        @item2.reload
+        @item2.t.should eq 3
       end
       it '既存のt2を1にシフトしている' do
-        @sheet_panel2.store @ot
-        @sheet_panel3.reload
-        @sheet_panel3.t.should eq 1
+        @item2.store @ot
+        @item3.reload
+        @item3.t.should eq 1
       end
       it '既存のt3を2にシフトしている' do
-        @sheet_panel2.store @ot
-        @sheet_panel4.reload
-        @sheet_panel4.t.should eq 2
+        @item2.store @ot
+        @item4.reload
+        @item4.t.should eq 2
       end
       it '他の用紙に影響がない' do
-        @sheet_panel2.store @ot
-        @sheet_panelc2.reload
-        @sheet_panelc2.t.should eq 0
+        @item2.store @ot
+        @itemc2.reload
+        @itemc2.t.should eq 0
       end
     end
     #ロールバックテスト。入れ替えが直接DBをいじるので、すべてのケースで確実にロールバックを確認する
@@ -1691,31 +1323,31 @@ describe SheetPanel do
       before do
         SheetPanel.any_instance.stub(:save).with(any_args).and_return(false)
         @sheet2 = FactoryGirl.create :sheet, :author_id => @author.id
-        @sheet_panelc2 = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet2.id, :panel_id => @panel.id, :author_id => @author.id
-        @sheet_panel = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
-        @sheet_panel2 = FactoryGirl.create :sheet_panel, :t => 1, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
-        @sheet_panel3 = FactoryGirl.create :sheet_panel, :t => 2, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
-        @sheet_panel4 = FactoryGirl.create :sheet_panel, :t => 3, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
-        @sheet_panel5 = FactoryGirl.create :sheet_panel, :t => 4, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
-        @sheet_panel6 = FactoryGirl.build :sheet_panel, :t => 2, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @itemc2 = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet2.id, :panel_id => @panel.id, :author_id => @author.id
+        @item = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item2 = FactoryGirl.create :sheet_panel, :t => 1, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item3 = FactoryGirl.create :sheet_panel, :t => 2, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item4 = FactoryGirl.create :sheet_panel, :t => 3, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item5 = FactoryGirl.create :sheet_panel, :t => 4, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item6 = FactoryGirl.build :sheet_panel, :t => 2, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
       end
       it '既存のtに変化がない' do
-        @sheet_panel6.store
-        @sheet_panel.reload
-        @sheet_panel.t.should eq 0
-        @sheet_panel2.reload
-        @sheet_panel2.t.should eq 1
-        @sheet_panel3.reload
-        @sheet_panel3.t.should eq 2
-        @sheet_panel4.reload
-        @sheet_panel4.t.should eq 3
-        @sheet_panel5.reload
-        @sheet_panel5.t.should eq 4
-        @sheet_panelc2.reload
-        @sheet_panelc2.t.should eq 0
+        @item6.store
+        @item.reload
+        @item.t.should eq 0
+        @item2.reload
+        @item2.t.should eq 1
+        @item3.reload
+        @item3.t.should eq 2
+        @item4.reload
+        @item4.t.should eq 3
+        @item5.reload
+        @item5.t.should eq 4
+        @itemc2.reload
+        @itemc2.t.should eq 0
       end
       it 'falseを返す' do
-        r = @sheet_panel6.store
+        r = @item6.store
         r.should be_false
       end
     end
@@ -1723,48 +1355,48 @@ describe SheetPanel do
       before do
         SheetPanel.stub(:validate_t).with(any_args).and_return(false)
         @sheet2 = FactoryGirl.create :sheet, :author_id => @author.id
-        @sheet_panelc2 = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet2.id, :panel_id => @panel.id, :author_id => @author.id
-        @sheet_panel = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
-        @sheet_panel2 = FactoryGirl.create :sheet_panel, :t => 1, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
-        @sheet_panel3 = FactoryGirl.create :sheet_panel, :t => 2, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
-        @sheet_panel4 = FactoryGirl.create :sheet_panel, :t => 3, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
-        @sheet_panel5 = FactoryGirl.create :sheet_panel, :t => 4, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
-        @ot = @sheet_panel4.t
-        @sheet_panel4.t = 1
+        @itemc2 = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet2.id, :panel_id => @panel.id, :author_id => @author.id
+        @item = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item2 = FactoryGirl.create :sheet_panel, :t => 1, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item3 = FactoryGirl.create :sheet_panel, :t => 2, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item4 = FactoryGirl.create :sheet_panel, :t => 3, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item5 = FactoryGirl.create :sheet_panel, :t => 4, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @ot = @item4.t
+        @item4.t = 1
       end
       it '既存のtに変化がない' do
-        @sheet_panel4.store @ot
-        @sheet_panel.reload
-        @sheet_panel.t.should eq 0
-        @sheet_panel2.reload
-        @sheet_panel2.t.should eq 1
-        @sheet_panel3.reload
-        @sheet_panel3.t.should eq 2
-        @sheet_panel4.reload
-        @sheet_panel4.t.should eq 3
-        @sheet_panel5.reload
-        @sheet_panel5.t.should eq 4
-        @sheet_panelc2.reload
-        @sheet_panelc2.t.should eq 0
+        @item4.store @ot
+        @item.reload
+        @item.t.should eq 0
+        @item2.reload
+        @item2.t.should eq 1
+        @item3.reload
+        @item3.t.should eq 2
+        @item4.reload
+        @item4.t.should eq 3
+        @item5.reload
+        @item5.t.should eq 4
+        @itemc2.reload
+        @itemc2.t.should eq 0
       end
       it 'falseを返す' do
-        r = @sheet_panel4.store @ot
+        r = @item4.store @ot
         r.should be_false
       end
       it 'tにエラーメッセージが入っている' do
-        @sheet_panel4.store @ot
-        @sheet_panel4.errors[:t].should_not be_empty
-        @sheet_panel4.valid?.should be_true
+        @item4.store @ot
+        @item4.errors[:t].should_not be_empty
+        @item4.valid?.should be_true
       end
     end
     context '編集不可だったとき' do
       before do
-        @sheet_panel = FactoryGirl.build :sheet_panel, :t => 0, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item = FactoryGirl.build :sheet_panel, :t => 0, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
         SheetPanel.any_instance.stub(:allow?).and_return(false)
       end
       it '403Forbidden例外を返す' do
         lambda{
-          @sheet_panel.store
+          @item.store
         }.should raise_error(ActiveRecord::Forbidden)
       end
     end
@@ -1773,16 +1405,16 @@ describe SheetPanel do
     before do
       @sheet = FactoryGirl.create :sheet, :author_id => @author.id
       @panel = FactoryGirl.create :panel, :author_id => @author.id
-      @sheet_panel = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+      @item = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
     end
     context 'つつがなく終わるとき' do
       it '削除される' do
         lambda{
-          @sheet_panel.destroy_and_shorten
+          @item.destroy_and_shorten
         }.should change(SheetPanel, :count ).by(-1)
       end
       it 'Trueを返す' do
-        r = @sheet_panel.destroy_and_shorten
+        r = @item.destroy_and_shorten
         r.should be_true 
       end
     end
@@ -1792,100 +1424,100 @@ describe SheetPanel do
       end
       it 'ロールバックされる' do
         lambda{
-          @sheet_panel.destroy_and_shorten
+          @item.destroy_and_shorten
         }.should_not change(SheetPanel, :count )
       end
       it 'Falseを返す' do
-        r = @sheet_panel.destroy_and_shorten
+        r = @item.destroy_and_shorten
         r.should be_false
       end
     end
     #連携テスト。切り詰めが直接DBをいじる
     context '2件で先頭を削除したとき' do
       before do
-        @sheet_panel2 = FactoryGirl.create :sheet_panel, :t => 1, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item2 = FactoryGirl.create :sheet_panel, :t => 1, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
       end
       it '行が削除される' do
         lambda{
-          @sheet_panel.destroy_and_shorten
+          @item.destroy_and_shorten
         }.should change(SheetPanel, :count ).by(-1)
       end
       it '先頭は削除される' do
-        @sheet_panel.destroy_and_shorten
+        @item.destroy_and_shorten
         lambda{
-          SheetPanel.find @sheet_panel.id
+          SheetPanel.find @item.id
         }.should raise_error(ActiveRecord::RecordNotFound)
       end
       it '2件目は前に詰められる' do
-        @sheet_panel.destroy_and_shorten
-        @sheet_panel2.reload
-        @sheet_panel2.t.should eq 0
+        @item.destroy_and_shorten
+        @item2.reload
+        @item2.t.should eq 0
       end
     end
     context '3件で先頭を削除したとき' do
       before do
-        @sheet_panel2 = FactoryGirl.create :sheet_panel, :t => 1, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
-        @sheet_panel3 = FactoryGirl.create :sheet_panel, :t => 2, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item2 = FactoryGirl.create :sheet_panel, :t => 1, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item3 = FactoryGirl.create :sheet_panel, :t => 2, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
       end
       it '行が削除される' do
         lambda{
-          @sheet_panel.destroy_and_shorten
+          @item.destroy_and_shorten
         }.should change(SheetPanel, :count ).by(-1)
       end
       it '先頭は削除される' do
-        @sheet_panel.destroy_and_shorten
+        @item.destroy_and_shorten
         lambda{
-          SheetPanel.find @sheet_panel.id
+          SheetPanel.find @item.id
         }.should raise_error(ActiveRecord::RecordNotFound)
       end
       it '2件目は前に詰められる' do
-        @sheet_panel.destroy_and_shorten
-        @sheet_panel2.reload
-        @sheet_panel2.t.should eq 0
+        @item.destroy_and_shorten
+        @item2.reload
+        @item2.t.should eq 0
       end
       it '3件目は前に詰められる' do
-        @sheet_panel.destroy_and_shorten
-        @sheet_panel3.reload
-        @sheet_panel3.t.should eq 1
+        @item.destroy_and_shorten
+        @item3.reload
+        @item3.t.should eq 1
       end
     end
     context '5件で3件目を削除したとき' do
       before do
-        @sheet_panel2 = FactoryGirl.create :sheet_panel, :t => 1, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
-        @sheet_panel3 = FactoryGirl.create :sheet_panel, :t => 2, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
-        @sheet_panel4 = FactoryGirl.create :sheet_panel, :t => 3, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
-        @sheet_panel5 = FactoryGirl.create :sheet_panel, :t => 4, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item2 = FactoryGirl.create :sheet_panel, :t => 1, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item3 = FactoryGirl.create :sheet_panel, :t => 2, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item4 = FactoryGirl.create :sheet_panel, :t => 3, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+        @item5 = FactoryGirl.create :sheet_panel, :t => 4, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
       end
       it '行が削除される' do
         lambda{
-          @sheet_panel3.destroy_and_shorten
+          @item3.destroy_and_shorten
         }.should change(SheetPanel, :count ).by(-1)
       end
       it '1件目は変化がない' do
-        @sheet_panel3.destroy_and_shorten
-        @sheet_panel.reload
-        @sheet_panel.t.should eq 0
+        @item3.destroy_and_shorten
+        @item.reload
+        @item.t.should eq 0
       end
       it '2件目は変化がない' do
-        @sheet_panel3.destroy_and_shorten
-        @sheet_panel2.reload
-        @sheet_panel2.t.should eq 1
+        @item3.destroy_and_shorten
+        @item2.reload
+        @item2.t.should eq 1
       end
       it '3件目は削除される' do
-        @sheet_panel3.destroy_and_shorten
+        @item3.destroy_and_shorten
         lambda{
-          SheetPanel.find @sheet_panel3.id
+          SheetPanel.find @item3.id
         }.should raise_error(ActiveRecord::RecordNotFound)
       end
       it '4件目は前に詰められる' do
-        @sheet_panel3.destroy_and_shorten
-        @sheet_panel4.reload
-        @sheet_panel4.t.should eq 2
+        @item3.destroy_and_shorten
+        @item4.reload
+        @item4.t.should eq 2
       end
       it '5件目は前に詰められる' do
-        @sheet_panel3.destroy_and_shorten
-        @sheet_panel5.reload
-        @sheet_panel5.t.should eq 3
+        @item3.destroy_and_shorten
+        @item5.reload
+        @item5.t.should eq 3
       end
     end
     #ロールバックテスト。切り詰めが直接DBをいじるので、すべてのケースで確実にロールバックを確認する
index bb17296..e91c434 100644 (file)
@@ -50,6 +50,34 @@ describe Comic do
     @author_yas =  @user_yas.author
   end
   
+  describe '生成メソッドに於いて' do
+    before do
+      @item =  FactoryGirl.create :comic_doc_with_comic_stories, author: @author_yas
+    end
+    
+    describe 'leaf_itemsに於いて' do
+      it 'ぶら下がるそれぞれのリーフを取得できる' do
+        define_leaf_items? @item, [ComicStory]
+      end
+    end
+    
+    describe 'leafs_itemsに於いて' do
+      it 'すべてのリーフを取得できる' do
+        define_leafs_items? @item, [ComicStory]
+      end
+    end
+    
+  end
+  
+  describe 'boostに於いて' do
+    before do
+      @item =  FactoryGirl.create :comic_doc_with_comic_stories, author: @author_yas
+    end
+    
+    it 'ブーストメッセージをリーフに伝搬する' do
+    end
+  end
+  
 end
 
 describe Story do
@@ -61,5 +89,33 @@ describe Story do
     @author_yas =  @user_yas.author
   end
   
+  describe '生成メソッドに於いて' do
+    before do
+      @item =  FactoryGirl.create :story_install_with_story_sheets, author: @author_yas
+    end
+    
+    describe 'leaf_itemsに於いて' do
+      it 'ぶら下がるそれぞれのリーフを取得できる' do
+        define_leaf_items? @item, [StorySheet]
+      end
+    end
+    
+    describe 'leafs_itemsに於いて' do
+      it 'すべてのリーフを取得できる' do
+        define_leafs_items? @item, [StorySheet]
+      end
+    end
+    
+  end
+  
+  describe 'boostに於いて' do
+    before do
+      @item =  FactoryGirl.create :story_install, author: @author_yas
+    end
+    
+    it 'ブーストメッセージをリーフに伝搬する' do
+    end
+  end
+  
 end
 
index 439e2da..3652177 100644 (file)
@@ -8,34 +8,38 @@ describe Author do
     @admin =FactoryGirl.create :admin
     @user_yas = FactoryGirl.create :user_yas_with_owner
     @user_rom = FactoryGirl.create :user_rom
+    @user_itojun = FactoryGirl.create :user_itojun_with_owner
     @author_yas =  @user_yas.author
+    @artist_yas =  @user_yas.artist
+    @author_itojun =  @user_itojun.author
+    @artist_itojun =  @user_itojun.artist
+    @operator = Operator.new [@user_yas]
+    @model = Author
   end
   
-  describe '生成メソッドに於いて' do
+  describe 'editに於いて' do
     before do
-      @item =  FactoryGirl.create :scroll_hello_with_scroll_panels, author: @author_yas
     end
     
-    describe 'leaf_itemsに於いて' do
-      it 'ぶら下がるそれぞれのリーフを取得できる' do
-        define_leaf_items? @item, [ScrollPanel]
-      end
+    it 'オペレータが自分を編集しようとしているなら返す' do
+      allow_any_instance_of(@model).to receive(:own?).and_return(true)
+      expect(@model.edit(@author_yas.id, @operator)).to eq @author_yas
     end
     
-    describe 'leafs_itemsに於いて' do
-      it 'すべてのリーフを取得できる' do
-        define_leafs_items? @item, [ScrollPanel]
-      end
+    it '他人が変更を加えようとしているときは例外を発生させる' do
+      allow_any_instance_of(@model).to receive(:own?).and_return(false)
+      expect {@model.edit(@author_yas.id, @operator)}.to raise_error(ActiveRecord::Forbidden)
     end
-    
   end
   
-  describe 'boostに於いて' do
+  describe 'overwriteに於いて' do
     before do
-      @item =  FactoryGirl.create :scroll_hello_with_scroll_panels, author: @author_yas
     end
     
-    it 'ブーストメッセージをリーフに伝搬する' do
+    it 'ユーザーIDをオペレーターで上書きしている' do
+      @author_yas.user_id = nil
+      @author_yas.overwrite(@operator)
+      expect(@author_yas.user_id).to eq @user_yas.id
     end
   end
   
@@ -47,33 +51,38 @@ describe Artist do
     @admin =FactoryGirl.create :admin
     @user_yas = FactoryGirl.create :user_yas_with_owner
     @user_rom = FactoryGirl.create :user_rom
+    @user_itojun = FactoryGirl.create :user_itojun_with_owner
     @author_yas =  @user_yas.author
+    @artist_yas =  @user_yas.artist
+    @author_itojun =  @user_itojun.author
+    @artist_itojun =  @user_itojun.artist
+    @operator = Operator.new [@author_yas]
+    @model = Artist
   end
   
-  describe '生成メソッドに於いて' do
+  describe 'editに於いて' do
     before do
     end
     
-    describe 'leaf_itemsに於いて' do
-      it 'ぶら下がるそれぞれのリーフを取得できる' do
-        define_leaf_items? @item, [ComicStory]
-      end
+    it 'オペレータが自分を編集しようとしているなら返す' do
+      allow_any_instance_of(@model).to receive(:own?).and_return(true)
+      expect(@model.edit(@artist_yas.id, @operator)).to eq @artist_yas
     end
     
-    describe 'leafs_itemsに於いて' do
-      it 'すべてのリーフを取得できる' do
-        define_leafs_items? @item, [ComicStory]
-      end
+    it '他人が変更を加えようとしているときは例外を発生させる' do
+      allow_any_instance_of(@model).to receive(:own?).and_return(false)
+      expect {@model.edit(@artist_yas.id, @operator)}.to raise_error(ActiveRecord::Forbidden)
     end
-    
   end
   
-  describe 'boostに於いて' do
+  describe 'overwriteに於いて' do
     before do
-      @item =  FactoryGirl.create :scroll_hello_with_scroll_panels, author: @author_yas
     end
     
-    it 'ブーストメッセージをリーフに伝搬する' do
+    it 'ユーザーIDをオペレーターで上書きしている' do
+      @artist_yas.user_id = nil
+      @artist_yas.overwrite(@operator)
+      expect(@artist_yas.user_id).to eq @user_yas.id
     end
   end