OSDN Git Service

t#31470:create pager
[pettanr/pettanr.git] / spec / models / panel_spec.rb
index 9fa263d..2f35a47 100644 (file)
@@ -7,7 +7,6 @@ describe Panel do
     @sp = FactoryGirl.create :system_picture\r
     @lg = FactoryGirl.create :license_group\r
     @license = FactoryGirl.create :license, :license_group_id => @lg.id, :system_picture_id => @sp.id\r
-    @color = FactoryGirl.create :color\r
     @user = FactoryGirl.create( :user_yas)\r
     @author = FactoryGirl.create :author, :user_id => @user.id\r
     @artist = FactoryGirl.create :artist_yas, :author_id => @author.id\r
@@ -171,6 +170,22 @@ describe Panel do
     end\r
   end\r
   \r
+  describe '文字コード検証に於いて' do\r
+    before do\r
+      @panel = FactoryGirl.build :panel, :author_id => @author.id\r
+    end\r
+    \r
+    context 'captionを検証するとき' do\r
+      it 'Shift JISなら失敗する' do\r
+        @panel.caption = "\x83G\x83r\x83]\x83D"\r
+        lambda{\r
+          @panel.valid_encode\r
+        }.should raise_error(Pettanr::BadRequest)\r
+      end\r
+    end\r
+    \r
+  end\r
+  \r
   describe 'デフォルト値補充に於いて' do\r
     before do\r
       @panel = FactoryGirl.build :panel, :author_id => @author.id\r
@@ -384,91 +399,6 @@ describe Panel do
         pl.should eq [@panel]\r
       end\r
     end\r
-    context 'DBに5件あって1ページの件数を2件に変えたとして' do\r
-      before do\r
-        @npl2 = FactoryGirl.create :panel, :author_id => @author.id, :updated_at => Time.now + 100\r
-        @npl3 = FactoryGirl.create :panel, :author_id => @author.id, :updated_at => Time.now + 200\r
-        @npl4 = FactoryGirl.create :panel, :author_id => @author.id, :updated_at => Time.now + 300\r
-        @npl5 = FactoryGirl.create :panel, :author_id => @author.id, :updated_at => Time.now + 400\r
-        Panel.stub(:default_page_size).and_return(2)\r
-      end\r
-      it '件数0は全件(5件)を返す' do\r
-        r = Panel.list 5, 0\r
-        r.should have(5).items \r
-      end\r
-    end\r
-  end\r
-  describe '一覧取得オプションに於いて' do\r
-    it 'includeキーを含んでいる' do\r
-      r = Panel.list_opt\r
-      r.has_key?(:include).should be_true\r
-    end\r
-    it '6つの項目を含んでいる' do\r
-      r = Panel.list_opt[:include]\r
-      r.should have(6).items\r
-    end\r
-    it 'コマ絵を含んでいる' do\r
-      r = Panel.list_opt[:include]\r
-      r.has_key?(:panel_pictures).should be_true\r
-    end\r
-      it 'コマ絵は実素材を含んでいる' do\r
-        r = Panel.list_opt[:include]\r
-        r[:panel_pictures].has_key?(:picture).should be_true\r
-      end\r
-        it '実素材は絵師を含んでいる' do\r
-          r = Panel.list_opt[:include]\r
-          r[:panel_pictures][:picture].has_key?(:artist).should be_true\r
-        end\r
-        it '実素材はライセンスを含んでいる' do\r
-          r = Panel.list_opt[:include]\r
-          r[:panel_pictures][:picture].has_key?(:license).should be_true\r
-        end\r
-    it 'フキダシを含んでいる' do\r
-      r = Panel.list_opt[:include]\r
-      r.has_key?(:speech_balloons).should be_true\r
-    end\r
-      it 'フキダシはフキダシ枠を含んでいる' do\r
-        r = Panel.list_opt[:include]\r
-        r[:speech_balloons].has_key?(:balloons).should be_true\r
-      end\r
-      it 'フキダシはセリフを含んでいる' do\r
-        r = Panel.list_opt[:include]\r
-        r[:speech_balloons].has_key?(:speeches).should be_true\r
-      end\r
-    it '景色画像を含んでいる' do\r
-      r = Panel.list_opt[:include]\r
-      r.has_key?(:ground_pictures).should be_true\r
-    end\r
-      it '景色画像は実素材を含んでいる' do\r
-        r = Panel.list_opt[:include]\r
-        r[:ground_pictures].has_key?(:picture).should be_true\r
-      end\r
-        it '実素材は絵師を含んでいる' do\r
-          r = Panel.list_opt[:include]\r
-          r[:ground_pictures][:picture].has_key?(:artist).should be_true\r
-        end\r
-        it '実素材はライセンスを含んでいる' do\r
-          r = Panel.list_opt[:include]\r
-          r[:ground_pictures][:picture].has_key?(:license).should be_true\r
-        end\r
-    it '間接色を含んでいる' do\r
-      r = Panel.list_opt[:include]\r
-      r.has_key?(:ground_colors).should be_true\r
-    end\r
-      it '間接色は色を含んでいる' do\r
-        r = Panel.list_opt[:include]\r
-        r[:ground_colors].has_key?(:color).should be_true\r
-      end\r
-    it '景色を含んでいる' do\r
-      r = Panel.list_opt[:include]\r
-      r.has_key?(:panel_colors).should be_true\r
-    end\r
-    it '作家を含んでいる' do\r
-      r = Panel.list_opt[:include]\r
-      r.has_key?(:author).should be_true\r
-    end\r
-  end\r
-  describe 'json一覧出力オプションに於いて' do\r
   end\r
   \r
   describe '自分のコマ一覧取得に於いて' do\r
@@ -502,7 +432,7 @@ describe Panel do
         @npl5 = FactoryGirl.create :panel, :author_id => @author.id, :updated_at => Time.now + 400\r
       end\r
       it '通常は2件を返す' do\r
-        pl = Panel.list 1, 2\r
+        pl = Panel.mylist @author, 1, 2\r
         pl.should have(2).items \r
       end\r
       it 'page=1なら末尾2件を返す' do\r
@@ -519,21 +449,175 @@ describe Panel do
         pl.should eq [@panel]\r
       end\r
     end\r
-    context 'DBに5件あって1ページの件数を0件に変えたとして' do\r
+  end\r
+  \r
+  describe '他作家のコマ一覧取得に於いて' do\r
+    before do\r
+      @panel = FactoryGirl.create :panel, :author_id => @author.id\r
+      @other_panel = FactoryGirl.create :panel, :author_id => @other_author.id, :publish => 1\r
+    end\r
+    it 'リストを返す' do\r
+      r = Panel.himlist @other_author\r
+      r.should eq [@other_panel]\r
+    end\r
+    it '時系列で並んでいる' do\r
+      npl = FactoryGirl.create :panel, :author_id => @other_author.id, :updated_at => Time.now + 100\r
+      r = Panel.himlist @other_author\r
+      r.should eq [npl, @other_panel]\r
+    end\r
+    it '公開コマに限る' do\r
+      npl = FactoryGirl.create :panel, :author_id => @other_author.id, :publish => 0\r
+      r = Panel.himlist @other_author\r
+      r.should eq [@other_panel]\r
+    end\r
+    context 'DBに5件あって1ページの件数を2件に変えたとして' do\r
       before do\r
-        @npl2 = FactoryGirl.create :panel, :author_id => @author.id, :updated_at => Time.now + 100\r
-        @npl3 = FactoryGirl.create :panel, :author_id => @author.id, :updated_at => Time.now + 200\r
-        @npl4 = FactoryGirl.create :panel, :author_id => @author.id, :updated_at => Time.now + 300\r
-        @npl5 = FactoryGirl.create :panel, :author_id => @author.id, :updated_at => Time.now + 400\r
-        Author.stub(:default_panel_page_size).and_return(2)\r
+        @other_panel2 = FactoryGirl.create :panel, :author_id => @other_author.id, :updated_at => Time.now + 100\r
+        @other_panel3 = FactoryGirl.create :panel, :author_id => @other_author.id, :updated_at => Time.now + 200\r
+        @other_panel4 = FactoryGirl.create :panel, :author_id => @other_author.id, :updated_at => Time.now + 300\r
+        @other_panel5 = FactoryGirl.create :panel, :author_id => @other_author.id, :updated_at => Time.now + 400\r
+      end\r
+      it '通常は2件を返す' do\r
+        pl = Panel.himlist @other_author, 1, 2\r
+        pl.should have(2).items \r
+      end\r
+      it 'page=1なら末尾2件を返す' do\r
+        #時系列で並んでいる\r
+        pl = Panel.himlist @other_author, 1, 2\r
+        pl.should eq [@other_panel5, @other_panel4]\r
+      end\r
+      it 'page=2なら中間2件を返す' do\r
+        pl = Panel.himlist @other_author, 2, 2\r
+        pl.should eq [@other_panel3, @other_panel2]\r
       end\r
-      it '通常は全件(5件)を返す' do\r
-        r = Panel.mylist @author, 5, 0\r
-        r.should have(5).items \r
+      it 'page=3なら先頭1件を返す' do\r
+        pl = Panel.himlist @other_author, 3, 2\r
+        pl.should eq [@other_panel]\r
       end\r
     end\r
   end\r
   \r
+  describe 'コマ一覧ページ制御に於いて' do\r
+    before do\r
+      Panel.stub(:count).with(any_args).and_return(100)\r
+    end\r
+    it 'ページ制御を返す' do\r
+      r = Panel.list_paginate \r
+      r.is_a?(Kaminari::PaginatableArray).should be_true\r
+    end\r
+    it 'コマ一覧の取得条件を利用している' do\r
+      Panel.stub(:list_where).with(any_args).and_return('')\r
+      Panel.should_receive(:list_where).with(any_args).exactly(1)\r
+      r = Panel.list_paginate \r
+    end\r
+    it 'ページ件数10のとき、3ページ目のオフセットは20から始まる' do\r
+      r = Panel.list_paginate 3, 10\r
+      r.limit_value.should eq 10\r
+      r.offset_value.should eq 20\r
+    end\r
+  end\r
+  \r
+  describe '自分のコマ一覧ページ制御に於いて' do\r
+    before do\r
+      Panel.stub(:count).with(any_args).and_return(100)\r
+    end\r
+    it 'ページ制御を返す' do\r
+      r = Panel.mylist_paginate @author\r
+      r.is_a?(Kaminari::PaginatableArray).should be_true\r
+    end\r
+    it '自分のコマ一覧の取得条件を利用している' do\r
+      Panel.stub(:mylist_where).with(any_args).and_return('')\r
+      Panel.should_receive(:mylist_where).with(any_args).exactly(1)\r
+      r = Panel.mylist_paginate @author\r
+    end\r
+    it 'ページ件数10のとき、3ページ目のオフセットは20から始まる' do\r
+      r = Panel.mylist_paginate @author, 3, 10\r
+      r.limit_value.should eq 10\r
+      r.offset_value.should eq 20\r
+    end\r
+  end\r
+  \r
+  describe '他作家のコマ一覧ページ制御に於いて' do\r
+    before do\r
+      Panel.stub(:count).with(any_args).and_return(100)\r
+    end\r
+    it 'ページ制御を返す' do\r
+      r = Panel.himlist_paginate @other_author\r
+      r.is_a?(Kaminari::PaginatableArray).should be_true\r
+    end\r
+    it '他作家のコマ一覧の取得条件を利用している' do\r
+      Panel.stub(:himlist_where).with(any_args).and_return('')\r
+      Panel.should_receive(:himlist_where).with(any_args).exactly(1)\r
+      r = Panel.himlist_paginate @other_author\r
+    end\r
+    it 'ページ件数10のとき、3ページ目のオフセットは20から始まる' do\r
+      r = Panel.himlist_paginate @other_author, 3, 10\r
+      r.limit_value.should eq 10\r
+      r.offset_value.should eq 20\r
+    end\r
+  end\r
+  \r
+  describe '一覧取得オプションに於いて' do\r
+    it '5つの項目を含んでいる' do\r
+      r = Panel.list_opt\r
+      r.should have(5).items\r
+    end\r
+    it 'コマ絵を含んでいる' do\r
+      r = Panel.list_opt\r
+      r.has_key?(:panel_pictures).should be_true\r
+    end\r
+      it 'コマ絵は実素材を含んでいる' do\r
+        r = Panel.list_opt\r
+        r[:panel_pictures].has_key?(:picture).should be_true\r
+      end\r
+        it '実素材は絵師を含んでいる' do\r
+          r = Panel.list_opt\r
+          r[:panel_pictures][:picture].has_key?(:artist).should be_true\r
+        end\r
+        it '実素材はライセンスを含んでいる' do\r
+          r = Panel.list_opt\r
+          r[:panel_pictures][:picture].has_key?(:license).should be_true\r
+        end\r
+    it 'フキダシを含んでいる' do\r
+      r = Panel.list_opt\r
+      r.has_key?(:speech_balloons).should be_true\r
+    end\r
+      it 'フキダシはフキダシ枠を含んでいる' do\r
+        r = Panel.list_opt\r
+        r[:speech_balloons].has_key?(:balloons).should be_true\r
+      end\r
+      it 'フキダシはセリフを含んでいる' do\r
+        r = Panel.list_opt\r
+        r[:speech_balloons].has_key?(:speeches).should be_true\r
+      end\r
+    it '絵地を含んでいる' do\r
+      r = Panel.list_opt\r
+      r.has_key?(:ground_pictures).should be_true\r
+    end\r
+      it '絵地は実素材を含んでいる' do\r
+        r = Panel.list_opt\r
+        r[:ground_pictures].has_key?(:picture).should be_true\r
+      end\r
+        it '実素材は絵師を含んでいる' do\r
+          r = Panel.list_opt\r
+          r[:ground_pictures][:picture].has_key?(:artist).should be_true\r
+        end\r
+        it '実素材はライセンスを含んでいる' do\r
+          r = Panel.list_opt\r
+          r[:ground_pictures][:picture].has_key?(:license).should be_true\r
+        end\r
+    it '色地を含んでいる' do\r
+      r = Panel.list_opt\r
+      r.has_key?(:ground_colors).should be_true\r
+    end\r
+    it '作家を含んでいる' do\r
+      r = Panel.list_opt\r
+      r.has_key?(:author).should be_true\r
+    end\r
+  end\r
+  describe 'json一覧出力オプションに於いて' do\r
+  end\r
+  \r
   describe '単体取得に於いて' do\r
     before do\r
       @panel = FactoryGirl.create :panel, :author_id => @author.id\r
@@ -613,9 +697,9 @@ describe Panel do
       r = Panel.show_opt\r
       r.has_key?(:include).should be_true\r
     end\r
-    it '6つの項目を含んでいる' do\r
+    it '5つの項目を含んでいる' do\r
       r = Panel.show_opt[:include]\r
-      r.should have(6).items\r
+      r.should have(5).items\r
     end\r
     it 'コマ絵を含んでいる' do\r
       r = Panel.show_opt[:include]\r
@@ -645,11 +729,11 @@ describe Panel do
         r = Panel.show_opt[:include]\r
         r[:speech_balloons].has_key?(:speeches).should be_true\r
       end\r
-    it '景色画像を含んでいる' do\r
+    it '絵地を含んでいる' do\r
       r = Panel.show_opt[:include]\r
       r.has_key?(:ground_pictures).should be_true\r
     end\r
-      it '景色画像は実素材を含んでいる' do\r
+      it '絵地は実素材を含んでいる' do\r
         r = Panel.show_opt[:include]\r
         r[:ground_pictures].has_key?(:picture).should be_true\r
       end\r
@@ -661,18 +745,10 @@ describe Panel do
           r = Panel.show_opt[:include]\r
           r[:ground_pictures][:picture].has_key?(:license).should be_true\r
         end\r
-    it '間接色を含んでいる' do\r
+    it '色地を含んでいる' do\r
       r = Panel.show_opt[:include]\r
       r.has_key?(:ground_colors).should be_true\r
     end\r
-      it '間接色は色を含んでいる' do\r
-        r = Panel.show_opt[:include]\r
-        r[:ground_colors].has_key?(:color).should be_true\r
-      end\r
-    it '景色を含んでいる' do\r
-      r = Panel.show_opt[:include]\r
-      r.has_key?(:panel_colors).should be_true\r
-    end\r
     it '作家を含んでいる' do\r
       r = Panel.show_opt[:include]\r
       r.has_key?(:author).should be_true\r
@@ -689,14 +765,11 @@ describe Panel do
         FactoryGirl.attributes_for(:speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @sbt.id, :t => 0)\r
       )\r
       @gc = @panel.ground_colors.create(\r
-        FactoryGirl.attributes_for(:ground_color, :panel_id => @panel.id, :color_id => @color.id)\r
+        FactoryGirl.attributes_for(:ground_color, :panel_id => @panel.id)\r
       )\r
       @gp = @panel.ground_pictures.create(\r
         FactoryGirl.attributes_for(:ground_picture, :panel_id => @panel.id, :picture_id => @p.id)\r
       )\r
-      @pc = @panel.panel_colors.create(\r
-        FactoryGirl.attributes_for(:panel_color, :panel_id => @panel.id, :code => 0xff0000)\r
-      )\r
       @panel.reload\r
     end\r
     it 'リストを返している' do\r
@@ -708,11 +781,10 @@ describe Panel do
       r.include?(@pp).should be_true\r
       r.include?(@sb).should be_true\r
     end\r
-    it '景色素材と景色カラーと景色カラーコードを含んでいない' do\r
+    it '絵地と色地を含んでいない' do\r
       r = @panel.parts_element\r
       r.include?(@gc).should_not be_true\r
       r.include?(@gp).should_not be_true\r
-      r.include?(@pc).should_not be_true\r
     end\r
   end\r
   describe 'コマ部品に於いて' do\r
@@ -724,14 +796,11 @@ describe Panel do
         FactoryGirl.attributes_for(:speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @sbt.id, :t => 0)\r
       )\r
       @gc = @panel.ground_colors.create(\r
-        FactoryGirl.attributes_for(:ground_color, :panel_id => @panel.id, :color_id => @color.id)\r
+        FactoryGirl.attributes_for(:ground_color, :panel_id => @panel.id)\r
       )\r
       @gp = @panel.ground_pictures.create(\r
         FactoryGirl.attributes_for(:ground_picture, :panel_id => @panel.id, :picture_id => @p.id)\r
       )\r
-      @pc = @panel.panel_colors.create(\r
-        FactoryGirl.attributes_for(:panel_color, :panel_id => @panel.id, :code => 0xff0000)\r
-      )\r
       @panel.reload\r
     end\r
     context 'つつがなく終わるとき' do\r
@@ -775,25 +844,21 @@ describe Panel do
         FactoryGirl.attributes_for(:speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @sbt.id, :t => 0)\r
       )\r
       @gc = @panel.ground_colors.create(\r
-        FactoryGirl.attributes_for(:ground_color, :panel_id => @panel.id, :color_id => @color.id)\r
+        FactoryGirl.attributes_for(:ground_color, :panel_id => @panel.id)\r
       )\r
       @gp = @panel.ground_pictures.create(\r
         FactoryGirl.attributes_for(:ground_picture, :panel_id => @panel.id, :picture_id => @p.id)\r
       )\r
-      @pc = @panel.panel_colors.create(\r
-        FactoryGirl.attributes_for(:panel_color, :panel_id => @panel.id, :code => 0xff0000)\r
-      )\r
       @panel.reload\r
     end\r
     it 'リストを返している' do\r
       r = @panel.grounds\r
       r.is_a?(Array).should be_true\r
     end\r
-    it '景色素材と景色カラーと景色カラーコードを合わせている' do\r
+    it '絵地と色地を合わせている' do\r
       r = @panel.grounds\r
       r.include?(@gc).should be_true\r
       r.include?(@gp).should be_true\r
-      r.include?(@pc).should be_true\r
     end\r
     it 'コマ絵とフキダシを含んでいない' do\r
       r = @panel.grounds\r
@@ -810,14 +875,11 @@ describe Panel do
         FactoryGirl.attributes_for(:speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @sbt.id, :t => 0)\r
       )\r
       @gc = @panel.ground_colors.create(\r
-        FactoryGirl.attributes_for(:ground_color, :panel_id => @panel.id, :color_id => @color.id)\r
+        FactoryGirl.attributes_for(:ground_color, :panel_id => @panel.id)\r
       )\r
       @gp = @panel.ground_pictures.create(\r
         FactoryGirl.attributes_for(:ground_picture, :panel_id => @panel.id, :picture_id => @p.id)\r
       )\r
-      @pc = @panel.panel_colors.create(\r
-        FactoryGirl.attributes_for(:panel_color, :panel_id => @panel.id, :code => 0xff0000)\r
-      )\r
       @panel.reload\r
     end\r
     context 'つつがなく終わるとき' do\r
@@ -841,11 +903,10 @@ describe Panel do
       r.include?(@pp).should be_true\r
       r.include?(@sb).should be_true\r
     end\r
-    it '景色素材と景色カラーと景色カラーコードを合わせている' do\r
+    it '絵地と色地を合わせている' do\r
       r = @panel.panel_elements\r
       r.include?(@gc).should be_true\r
       r.include?(@gp).should be_true\r
-      r.include?(@pc).should be_true\r
     end\r
     it 'tでソートしている[t順にソートできる部品の方が優先順位は高い。]' do\r
       r = @panel.panel_elements\r
@@ -862,14 +923,11 @@ describe Panel do
         FactoryGirl.attributes_for(:speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @sbt.id, :t => 0)\r
       )\r
       @gc = @panel.ground_colors.create(\r
-        FactoryGirl.attributes_for(:ground_color, :panel_id => @panel.id, :color_id => @color.id)\r
+        FactoryGirl.attributes_for(:ground_color, :panel_id => @panel.id)\r
       )\r
       @gp = @panel.ground_pictures.create(\r
         FactoryGirl.attributes_for(:ground_picture, :panel_id => @panel.id, :picture_id => @p.id)\r
       )\r
-      @pc = @panel.panel_colors.create(\r
-        FactoryGirl.attributes_for(:panel_color, :panel_id => @panel.id, :code => 0xff0000)\r
-      )\r
       @panel.reload\r
     end\r
     context 'つつがなく終わるとき' do\r
@@ -878,7 +936,6 @@ describe Panel do
         Panel.stub(:elm_json_opt).with(@sb).and_return({})\r
         Panel.stub(:elm_json_opt).with(@gp).and_return({})\r
         Panel.stub(:elm_json_opt).with(@gc).and_return({})\r
-        Panel.stub(:elm_json_opt).with(@pc).and_return({})\r
       end\r
       it 'コマ要素のjson出力オプションにコマ絵json出力オプションを依頼している' do\r
         Panel.should_receive(:elm_json_opt).with(@pp).exactly(1)\r
@@ -888,18 +945,14 @@ describe Panel do
         Panel.should_receive(:elm_json_opt).with(@sb).exactly(1)\r
         r = @panel.elements\r
       end\r
-      it 'コマ要素のjson出力オプションに景色素材json出力オプションを依頼している' do\r
+      it 'コマ要素のjson出力オプションに絵地json出力オプションを依頼している' do\r
         Panel.should_receive(:elm_json_opt).with(@gp).exactly(1)\r
         r = @panel.elements\r
       end\r
-      it 'コマ要素のjson出力オプションに景色カラーjson出力オプションを依頼している' do\r
+      it 'コマ要素のjson出力オプションに色地json出力オプションを依頼している' do\r
         Panel.should_receive(:elm_json_opt).with(@gc).exactly(1)\r
         r = @panel.elements\r
       end\r
-      it 'コマ要素のjson出力オプションに景色カラーコードjson出力オプションを依頼している' do\r
-        Panel.should_receive(:elm_json_opt).with(@pc).exactly(1)\r
-        r = @panel.elements\r
-      end\r
     end\r
     it 'リストを返している' do\r
       r = @panel.elements\r
@@ -915,14 +968,11 @@ describe Panel do
         FactoryGirl.attributes_for(:speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @sbt.id, :t => 0)\r
       )\r
       @gc = @panel.ground_colors.create(\r
-        FactoryGirl.attributes_for(:ground_color, :panel_id => @panel.id, :color_id => @color.id)\r
+        FactoryGirl.attributes_for(:ground_color, :panel_id => @panel.id)\r
       )\r
       @gp = @panel.ground_pictures.create(\r
         FactoryGirl.attributes_for(:ground_picture, :panel_id => @panel.id, :picture_id => @p.id)\r
       )\r
-      @pc = @panel.panel_colors.create(\r
-        FactoryGirl.attributes_for(:panel_color, :panel_id => @panel.id, :code => 0xff0000)\r
-      )\r
       @panel.reload\r
     end\r
     context 'つつがなく終わるとき' do\r
@@ -985,14 +1035,11 @@ describe Panel do
         FactoryGirl.attributes_for(:speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @sbt.id, :t => 0)\r
       )\r
       @gc = @panel.ground_colors.create(\r
-        FactoryGirl.attributes_for(:ground_color, :panel_id => @panel.id, :color_id => @color.id)\r
+        FactoryGirl.attributes_for(:ground_color, :panel_id => @panel.id)\r
       )\r
       @gp = @panel.ground_pictures.create(\r
         FactoryGirl.attributes_for(:ground_picture, :panel_id => @panel.id, :picture_id => @p2.id)\r
       )\r
-      @pc = @panel.panel_colors.create(\r
-        FactoryGirl.attributes_for(:panel_color, :panel_id => @panel.id, :code => 0xff0000)\r
-      )\r
       @panel.reload\r
     end\r
     context '事前チェック' do\r
@@ -1151,15 +1198,15 @@ describe Panel do
         Panel.any_instance.should_receive(:overwrite).exactly(1)\r
         r = @panel.store @attr, @author\r
       end\r
-      it '従属データの検証を依頼している' do\r
-        Panel.any_instance.should_receive(:validate_child).with(any_args).exactly(1)\r
-        r = @panel.store @attr, @author\r
-      end\r
       it '保存を依頼している' do\r
         Panel.any_instance.should_receive(:save).with(any_args).exactly(1)\r
         @panel = FactoryGirl.build :panel, :author_id => @author.id\r
         r = @panel.store @attr, @author\r
       end\r
+      it '従属データの検証を依頼している' do\r
+        Panel.any_instance.should_receive(:validate_child).with(any_args).exactly(1)\r
+        r = @panel.store @attr, @author\r
+      end\r
     end\r
     context 'つつがなく終わるとき' do\r
       before do\r
@@ -1186,6 +1233,7 @@ describe Panel do
     end\r
     context '従属データの検証に失敗したとき' do\r
       before do\r
+        Panel.any_instance.stub(:save).with(any_args).and_return(true)\r
         Panel.any_instance.stub(:validate_child).with(any_args).and_return(false)\r
       end\r
       it 'エラーメッセージがセットされている' do\r
@@ -1213,14 +1261,11 @@ describe Panel do
         FactoryGirl.attributes_for(:speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @sbt.id, :t => 0)\r
       )\r
       @gc = @panel.ground_colors.create(\r
-        FactoryGirl.attributes_for(:ground_color, :panel_id => @panel.id, :color_id => @color.id)\r
+        FactoryGirl.attributes_for(:ground_color, :panel_id => @panel.id)\r
       )\r
       @gp = @panel.ground_pictures.create(\r
         FactoryGirl.attributes_for(:ground_picture, :panel_id => @panel.id, :picture_id => @p.id)\r
       )\r
-      @pc = @panel.panel_colors.create(\r
-        FactoryGirl.attributes_for(:panel_color, :panel_id => @panel.id, :code => 0xff0000)\r
-      )\r
     end\r
     context 'つつがなく終わるとき' do\r
       it '自身を削除する' do\r