OSDN Git Service

create provider
[pettanr/pettanr.git] / spec / models / comic_spec.rb
index 5ffdb64..908b415 100644 (file)
@@ -100,53 +100,53 @@ describe Comic do
         before do
           MagicNumber['run_mode'] = 1
         end
-        it '不許可を返す。' do\r
+        it '不許可を返す。' do
           r = @comic.visible?(nil)
           r.should be_false
-        end\r
-      end\r
+        end
+      end
       context 'オープンモードのとき' do
         before do
           MagicNumber['run_mode'] = 0
         end
-        it '公開コミックなら許可する' do\r
-          Comic.any_instance.stub(:visible).and_return(1)\r
+        it '公開コミックなら許可する' do
+          Comic.any_instance.stub(:visible).and_return(1)
           r = @comic.visible?(nil)
           r.should be_true
-        end\r
-        it '非公開コミックなら許可しない' do\r
-          Comic.any_instance.stub(:visible).and_return(0)\r
+        end
+        it '非公開コミックなら許可しない' do
+          Comic.any_instance.stub(:visible).and_return(0)
           r = @comic.visible?(nil)
           r.should be_false
-        end\r
-      end\r
-    end\r
+        end
+      end
+    end
     context '検査対象が作家のとき' do
-      it '自分のコミックなら許可する' do\r
-        Comic.any_instance.stub(:own?).and_return(true)\r
-        Comic.any_instance.stub(:visible).and_return(0)\r
+      it '自分のコミックなら許可する' do
+        Comic.any_instance.stub(:own?).and_return(true)
+        Comic.any_instance.stub(:visible).and_return(0)
         r = @comic.visible?(@author)
         r.should == true
-      end\r
-      it '他人の非公開コミックなら許可しない' do\r
-        Comic.any_instance.stub(:own?).and_return(false)\r
-        Comic.any_instance.stub(:visible).and_return(0)\r
+      end
+      it '他人の非公開コミックなら許可しない' do
+        Comic.any_instance.stub(:own?).and_return(false)
+        Comic.any_instance.stub(:visible).and_return(0)
         r = @comic.visible?(@author)
         r.should == false
-      end\r
-      it '他人のコミックでも公開なら許可する' do\r
-        Comic.any_instance.stub(:own?).and_return(false)\r
-        Comic.any_instance.stub(:visible).and_return(1)\r
+      end
+      it '他人のコミックでも公開なら許可する' do
+        Comic.any_instance.stub(:own?).and_return(false)
+        Comic.any_instance.stub(:visible).and_return(1)
         r = @comic.visible?(@author)
         r.should == true
-      end\r
-    end\r
+      end
+    end
     context '検査対象がそれ以外のとき' do
-      it '不許可を返す。' do\r
+      it '不許可を返す。' do
         r = @comic.visible?(@admin)
         r.should be_false
-      end\r
-    end\r
+      end
+    end
   end
   
   describe '一覧取得に於いて' do
@@ -178,13 +178,13 @@ describe Comic do
         Comic.page_size('1000').should eq Comic.max_page_size
       end
     end
-    context 'つつがなく終わるとき' do\r
-      it '一覧取得オプションを利用している' do\r
-        Comic.stub(:list_opt).with(any_args).and_return({})\r
-        Comic.should_receive(:list_opt).with(any_args).exactly(1)\r
+    context 'つつがなく終わるとき' do
+      it '一覧取得オプションを利用している' do
+        Comic.stub(:list_opt).with(any_args).and_return({})
+        Comic.should_receive(:list_opt).with(any_args).exactly(1)
         r = Comic.list
-      end\r
-    end\r
+      end
+    end
     it 'リストを返す' do
       c = Comic.list
       c.should eq [@comic]
@@ -264,10 +264,10 @@ describe Comic do
   end
   describe 'json一覧出力オプションに於いて' do
     before do
-      @op = FactoryGirl.create :original_picture, :artist_id => @artist.id\r
-      @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id\r
-      @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id\r
-      @sbt = FactoryGirl.create :speech_balloon_template\r
+      @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
+      @sbt = FactoryGirl.create :speech_balloon_template
       @comic = FactoryGirl.create :comic, :author_id => @author.id, :visible => 1
       @panel = FactoryGirl.create :panel, :author_id => @author.id, :publish => 1
       @story = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id
@@ -297,13 +297,13 @@ describe Comic do
     before do
       @comic = FactoryGirl.create :comic, :author_id => @author.id
     end
-    context 'つつがなく終わるとき' do\r
-      it '一覧取得オプションを利用している' do\r
-        Comic.stub(:list_opt).with(any_args).and_return({})\r
-        Comic.should_receive(:list_opt).with(any_args).exactly(1)\r
+    context 'つつがなく終わるとき' do
+      it '一覧取得オプションを利用している' do
+        Comic.stub(:list_opt).with(any_args).and_return({})
+        Comic.should_receive(:list_opt).with(any_args).exactly(1)
         r = Comic.mylist @author
-      end\r
-    end\r
+      end
+    end
     it 'リストを返す' do
       c = Comic.mylist @author
       c.should eq [@comic]
@@ -354,7 +354,7 @@ describe Comic do
         @comic3 = FactoryGirl.create :comic, :author_id => @author.id, :updated_at => Time.now + 200
         @comic4 = FactoryGirl.create :comic, :author_id => @author.id, :updated_at => Time.now + 300
         @comic5 = FactoryGirl.create :comic, :author_id => @author.id, :updated_at => Time.now + 400
-        Author.stub(:default_comic_page_size).and_return(2)\r
+        Author.stub(:default_comic_page_size).and_return(2)
       end
       it '通常は全件(5件)を返す' do
         r = Comic.mylist @author, 5, 0
@@ -367,55 +367,55 @@ describe Comic do
     before do
       @comic = FactoryGirl.create :comic, :author_id => @author.id
     end
-    context 'つつがなく終わるとき' do\r
-      it '単体取得オプションを利用している' do\r
-        Comic.stub(:show_opt).with(any_args).and_return({})\r
-        Comic.should_receive(:show_opt).with(any_args).exactly(1)\r
+    context 'つつがなく終わるとき' do
+      it '単体取得オプションを利用している' do
+        Comic.stub(:show_opt).with(any_args).and_return({})
+        Comic.should_receive(:show_opt).with(any_args).exactly(1)
         r = Comic.show @comic.id, @author
-      end\r
-      it '閲覧許可を問い合わせている' do\r
-        Comic.any_instance.stub(:visible?).with(any_args).and_return(true)\r
-        Comic.any_instance.should_receive(:visible?).with(any_args).exactly(1)\r
+      end
+      it '閲覧許可を問い合わせている' do
+        Comic.any_instance.stub(:visible?).with(any_args).and_return(true)
+        Comic.any_instance.should_receive(:visible?).with(any_args).exactly(1)
         r = Comic.show @comic.id, @author
-      end\r
-    end\r
+      end
+    end
     it '指定のコミックを返す' do
       c = Comic.show @comic.id, @author
       c.should eq @comic
     end
-    context '閲覧許可が出なかったとき' do\r
-      it '403Forbidden例外を返す' do\r
-        Comic.any_instance.stub(:visible?).and_return(false)\r
-        lambda{\r
-          Comic.show @comic.id, @author\r
-        }.should raise_error(ActiveRecord::Forbidden)\r
-      end\r
-    end\r
-    context '存在しない作家を開こうとしたとき' do\r
-      it '404RecordNotFound例外を返す' do\r
-        lambda{\r
-          Comic.show 110, @author\r
-        }.should raise_error(ActiveRecord::RecordNotFound)\r
-      end\r
-    end\r
+    context '閲覧許可が出なかったとき' do
+      it '403Forbidden例外を返す' do
+        Comic.any_instance.stub(:visible?).and_return(false)
+        lambda{
+          Comic.show @comic.id, @author
+        }.should raise_error(ActiveRecord::Forbidden)
+      end
+    end
+    context '存在しないコミックを開こうとしたとき' do
+      it '404RecordNotFound例外を返す' do
+        lambda{
+          Comic.show 110, @author
+        }.should raise_error(ActiveRecord::RecordNotFound)
+      end
+    end
   end
   
   describe '編集取得に於いて' do
     before do
       @comic = FactoryGirl.create :comic, :author_id => @author.id
     end
-    context 'つつがなく終わるとき' do\r
-      it '単体取得オプションを利用している' do\r
-        Comic.stub(:show_opt).with(any_args).and_return({})\r
-        Comic.should_receive(:show_opt).with(any_args).exactly(1)\r
+    context 'つつがなく終わるとき' do
+      it '単体取得オプションを利用している' do
+        Comic.stub(:show_opt).with(any_args).and_return({})
+        Comic.should_receive(:show_opt).with(any_args).exactly(1)
         r = Comic.edit @comic.id, @author
-      end\r
-      it '所持判定を問い合わせている' do\r
-        Comic.any_instance.stub(:own?).with(any_args).and_return(true)\r
-        Comic.any_instance.should_receive(:own?).with(any_args).exactly(1)\r
+      end
+      it '所持判定を問い合わせている' do
+        Comic.any_instance.stub(:own?).with(any_args).and_return(true)
+        Comic.any_instance.should_receive(:own?).with(any_args).exactly(1)
         r = Comic.edit @comic.id, @author
-      end\r
-    end\r
+      end
+    end
     it '指定のコミックを返す' do
       Comic.any_instance.stub(:own?).and_return(true)
       c = Comic.edit @comic.id, @author.id
@@ -461,10 +461,10 @@ describe Comic do
   end
   describe 'json単体出力オプションに於いて' do
     before do
-      @op = FactoryGirl.create :original_picture, :artist_id => @artist.id\r
-      @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id\r
-      @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id\r
-      @sbt = FactoryGirl.create :speech_balloon_template\r
+      @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
+      @sbt = FactoryGirl.create :speech_balloon_template
       @comic = FactoryGirl.create :comic, :author_id => @author.id, :visible => 1
       @panel = FactoryGirl.create :panel, :author_id => @author.id, :publish => 1
       @story = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id