OSDN Git Service

t#31326:drop color
[pettanr/pettanr.git] / spec / controllers / home_controller_spec.rb
index 102c43a..bf701bc 100644 (file)
@@ -11,7 +11,6 @@ describe HomeController do
     @user = FactoryGirl.create( :user_yas)
     @author = FactoryGirl.create :author, :user_id => @user.id
     @artist = FactoryGirl.create :artist_yas, :author_id => @author.id
-    @color = FactoryGirl.create :color
     @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
@@ -65,9 +64,9 @@ if MagicNumber['run_mode'] == 1
         assigns(:comics).should have_at_least(3).items
       end
       context 'html形式' do
-        it 'comicテンプレートを描画する' do
+        it 'comicsテンプレートを描画する' do
           get :comics
-          response.should render_template("comic")
+          response.should render_template("comics")
         end
       end
       context 'json形式' do
@@ -165,9 +164,9 @@ if MagicNumber['run_mode'] == 1
           get :panels
           response.should be_success 
         end
-        it 'panelテンプレートを描画する' do
+        it 'panelsテンプレートを描画する' do
           get :panels
-          response.should render_template("panel")
+          response.should render_template("panels")
         end
       end
       context 'json形式' do
@@ -269,9 +268,9 @@ if MagicNumber['run_mode'] == 1
         assigns(:panel_pictures).should have_at_least(3).items
       end
       context 'html形式' do
-        it 'panel_pictureテンプレートを描画する' do
+        it 'panel_picturesテンプレートを描画する' do
           get :panel_pictures
-          response.should render_template("panel_picture")
+          response.should render_template("panel_pictures")
         end
       end
       context 'json形式' do
@@ -324,108 +323,7 @@ if MagicNumber['run_mode'] == 1
     end
   end
   
-  describe '自分のコマの色背景一覧表示に於いて' do
-    before do
-      @pc = FactoryGirl.create :panel_color, :panel_id => @panel.id
-      sign_in @user
-      PanelColor.stub(:mylist).and_return([@pc, @pc, @pc])
-    end
-    context 'パラメータpageについて' do
-      it '@pageに値が入る' do
-        get :panel_colors, :page => 5
-        assigns(:page).should eq 5
-      end
-      it '省略されると@pageに1値が入る' do
-        get :panel_colors
-        assigns(:page).should eq 1
-      end
-      it '与えられたpage_sizeがセットされている' do
-        get :panel_colors, :page_size => 15
-        assigns(:page_size).should eq 15
-      end
-      it '省略されると@page_sizeにデフォルト値が入る' do
-        get :panel_colors
-        assigns(:page_size).should eq Author.default_panel_color_page_size
-      end
-      it '最大を超えると@page_sizeにデフォルト最大値が入る' do
-        get :panel_colors, :page_size => 1500
-        assigns(:page_size).should eq Author.panel_color_max_page_size
-      end
-      it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
-        get :panel_colors, :page_size => 0
-        assigns(:page_size).should eq Author.default_panel_color_page_size
-      end
-    end
-    context 'つつがなく終わるとき' do
-      it 'ステータスコード200 OKを返す' do
-        get :panel_colors
-        response.should be_success 
-      end
-      it 'コマの色背景モデルに一覧を問い合わせている' do
-        PanelColor.should_receive(:mylist).exactly(1)
-        get :panel_colors
-      end
-      it '@panel_colorsにリストを取得している' do
-        get :panel_colors
-        assigns(:panel_colors).should have_at_least(3).items
-      end
-      context 'html形式' do
-        it 'panel_colorテンプレートを描画する' do
-          get :panel_colors
-          response.should render_template("panel_color")
-        end
-      end
-      context 'json形式' do
-        it 'jsonデータを返す' do
-          get :panel_colors, :format => :json
-          lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
-        end
-        it 'コマの色背景モデルにjson一覧出力オプションを問い合わせている' do
-          PanelColor.should_receive(:list_json_opt).exactly(1)
-          get :panel_colors, :format => :json
-        end
-        it 'データがリスト構造になっている' do
-          get :panel_colors, :format => :json
-          json = JSON.parse response.body
-          json.should have_at_least(3).items
-        end
-        it 'リストの先頭くらいはコマの色背景っぽいものであって欲しい' do
-          get :panel_colors, :format => :json
-          json = JSON.parse response.body
-          json.first.has_key?("panel_id").should be_true
-          json.first.has_key?("code").should be_true
-          json.first.has_key?("z").should be_true
-        end
-      end
-    end
-    context '作家権限がないとき' do
-      before do
-        sign_out @user
-      end
-      context 'html形式' do
-        it 'ステータスコード302 Foundを返す' do
-          get :panel_colors
-          response.status.should eq 302
-        end
-        it 'サインインページへ遷移する' do
-          get :panel_colors
-          response.should redirect_to '/users/sign_in'
-        end
-      end
-      context 'json形式' do
-        it 'ステータスコード401 Unauthorizedを返す' do
-          get :panel_colors, :format => :json
-          response.status.should eq 401
-        end
-        it '応答メッセージにUnauthorizedを返す' do
-          get :panel_colors, :format => :json
-          response.message.should match(/Unauthorized/)
-        end
-      end
-    end
-  end
-  
-  describe '自分のコマの画像背景一覧表示に於いて' do
+  describe '自分のコマの絵地一覧表示に於いて' do
     before do
       @gp = FactoryGirl.create :ground_picture, :panel_id => @panel.id, :picture_id => @p.id
       sign_in @user
@@ -462,7 +360,7 @@ if MagicNumber['run_mode'] == 1
         get :ground_pictures
         response.should be_success 
       end
-      it 'コマの画像背景モデルに一覧を問い合わせている' do
+      it '絵地モデルに一覧を問い合わせている' do
         GroundPicture.should_receive(:mylist).exactly(1)
         get :ground_pictures
       end
@@ -471,9 +369,9 @@ if MagicNumber['run_mode'] == 1
         assigns(:ground_pictures).should have_at_least(3).items
       end
       context 'html形式' do
-        it 'ground_pictureテンプレートを描画する' do
+        it 'ground_picturesテンプレートを描画する' do
           get :ground_pictures
-          response.should render_template("ground_picture")
+          response.should render_template("ground_pictures")
         end
       end
       context 'json形式' do
@@ -481,7 +379,7 @@ if MagicNumber['run_mode'] == 1
           get :ground_pictures, :format => :json
           lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
         end
-        it 'コマの画像背景モデルにjson一覧出力オプションを問い合わせている' do
+        it '絵地モデルにjson一覧出力オプションを問い合わせている' do
           GroundPicture.should_receive(:list_json_opt).exactly(1)
           get :ground_pictures, :format => :json
         end
@@ -490,7 +388,7 @@ if MagicNumber['run_mode'] == 1
           json = JSON.parse response.body
           json.should have_at_least(3).items
         end
-        it 'リストの先頭くらいはコマの画像背景っぽいものであって欲しい' do
+        it 'リストの先頭くらいは絵地っぽいものであって欲しい' do
           get :ground_pictures, :format => :json
           json = JSON.parse response.body
           json.first.has_key?("panel_id").should be_true
@@ -526,7 +424,7 @@ if MagicNumber['run_mode'] == 1
     end
   end
   
-  describe '自分の間接背景一覧表示に於いて' do
+  describe '自分の色地一覧表示に於いて' do
     before do
       @gc = FactoryGirl.create :ground_color
       sign_in @user
@@ -563,7 +461,7 @@ if MagicNumber['run_mode'] == 1
         get :ground_colors
         response.should be_success 
       end
-      it '間接背景モデルに一覧を問い合わせている' do
+      it '色地モデルに一覧を問い合わせている' do
         GroundColor.should_receive(:mylist).exactly(1)
         get :ground_colors
       end
@@ -572,9 +470,9 @@ if MagicNumber['run_mode'] == 1
         assigns(:ground_colors).should have_at_least(3).items
       end
       context 'html形式' do
-        it 'ground_colorテンプレートを描画する' do
+        it 'ground_colorsテンプレートを描画する' do
           get :ground_colors
-          response.should render_template("ground_color")
+          response.should render_template("ground_colors")
         end
       end
       context 'json形式' do
@@ -582,7 +480,7 @@ if MagicNumber['run_mode'] == 1
           get :ground_colors, :format => :json
           lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
         end
-        it '間接背景モデルにjson一覧出力オプションを問い合わせている' do
+          it '色地モデルにjson一覧出力オプションを問い合わせている' do
           GroundColor.should_receive(:list_json_opt).exactly(1)
           get :ground_colors, :format => :json
         end
@@ -591,11 +489,11 @@ if MagicNumber['run_mode'] == 1
           json = JSON.parse response.body
           json.should have_at_least(3).items
         end
-        it 'リストの先頭くらいは間接背景っぽいものであって欲しい' do
+        it 'リストの先頭くらいは色地っぽいものであって欲しい' do
           get :ground_colors, :format => :json
           json = JSON.parse response.body
           json.first.has_key?("panel_id").should be_true
-          json.first.has_key?("color_id").should be_true
+          json.first.has_key?("code").should be_true
           json.first.has_key?("z").should be_true
         end
       end
@@ -675,9 +573,9 @@ if MagicNumber['run_mode'] == 1
         assigns(:resource_pictures).should have_at_least(3).items
       end
       context 'html形式' do
-        it 'resource_pictureテンプレートを描画する' do
+        it 'resource_picturesテンプレートを描画する' do
           get :resource_pictures
-          response.should render_template("resource_picture")
+          response.should render_template("resource_pictures")
         end
       end
       context 'json形式' do
@@ -764,9 +662,9 @@ else
         response.should be_success 
       end
       context 'html形式' do
-        it 'comicテンプレートを描画する' do
+        it 'comicsテンプレートを描画する' do
           get :comics
-          response.should render_template("comic")
+          response.should render_template("comics")
         end
       end
       context 'json形式' do
@@ -815,9 +713,9 @@ else
           get :panels
           response.should be_success 
         end
-        it 'panelテンプレートを描画する' do
+        it 'panelsテンプレートを描画する' do
           get :panels
-          response.should render_template("panel")
+          response.should render_template("panels")
         end
       end
       context 'json形式' do
@@ -871,9 +769,9 @@ else
         response.should be_success 
       end
       context 'html形式' do
-        it 'panel_pictureテンプレートを描画する' do
+        it 'panel_picturesテンプレートを描画する' do
           get :panel_pictures
-          response.should render_template("panel_picture")
+          response.should render_template("panel_pictures")
         end
       end
       context 'json形式' do
@@ -910,58 +808,8 @@ else
     end
   end
   
-  describe '自分のコマの色背景一覧表示に於いて' do
-    before do
-      @pc = FactoryGirl.create :panel_color, :panel_id => @panel.id
-      sign_in @user
-      PanelColor.stub(:mylist).and_return([@pc, @pc, @pc])
-    end
-    context 'つつがなく終わるとき' do
-      it 'ステータスコード200 OKを返す' do
-        get :panel_colors
-        response.should be_success 
-      end
-      context 'html形式' do
-        it 'panel_colorテンプレートを描画する' do
-          get :panel_colors
-          response.should render_template("panel_color")
-        end
-      end
-      context 'json形式' do
-        it 'jsonデータを返す' do
-          get :panel_colors, :format => :json
-          lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
-        end
-      end
-    end
-    context '作家権限がないとき' do
-      before do
-        sign_out @user
-      end
-      context 'html形式' do
-        it 'ステータスコード302 Foundを返す' do
-          get :panel_colors
-          response.status.should eq 302
-        end
-        it 'サインインページへ遷移する' do
-          get :panel_colors
-          response.should redirect_to '/users/sign_in'
-        end
-      end
-      context 'json形式' do
-        it 'ステータスコード401 Unauthorizedを返す' do
-          get :panel_colors, :format => :json
-          response.status.should eq 401
-        end
-        it '応答メッセージにUnauthorizedを返す' do
-          get :panel_colors, :format => :json
-          response.message.should match(/Unauthorized/)
-        end
-      end
-    end
-  end
   
-  describe 'è\87ªå\88\86ã\81®ã\82³ã\83\9eã\81®ç\94»å\83\8fè\83\8cæ\99¯一覧表示に於いて' do
+  describe 'è\87ªå\88\86ã\81®ã\82³ã\83\9eã\81®çµµå\9c°一覧表示に於いて' do
     before do
       @gp = FactoryGirl.create :ground_picture, :panel_id => @panel.id, :picture_id => @p.id
       sign_in @user
@@ -973,9 +821,9 @@ else
         response.should be_success 
       end
       context 'html形式' do
-        it 'ground_pictureテンプレートを描画する' do
+        it 'ground_picturesテンプレートを描画する' do
           get :ground_pictures
-          response.should render_template("ground_picture")
+          response.should render_template("ground_pictures")
         end
       end
       context 'json形式' do
@@ -1012,7 +860,7 @@ else
     end
   end
   
-  describe '自分の間接背景一覧表示に於いて' do
+  describe '自分の色地一覧表示に於いて' do
     before do
       @gc = FactoryGirl.create :ground_color
       sign_in @user
@@ -1024,9 +872,9 @@ else
         response.should be_success 
       end
       context 'html形式' do
-        it 'ground_colorテンプレートを描画する' do
+        it 'ground_colorsテンプレートを描画する' do
           get :ground_colors
-          response.should render_template("ground_color")
+          response.should render_template("ground_colors")
         end
       end
       context 'json形式' do
@@ -1077,9 +925,9 @@ else
         response.should be_success 
       end
       context 'html形式' do
-        it 'resource_pictureテンプレートを描画する' do
+        it 'resource_picturesテンプレートを描画する' do
           get :resource_pictures
-          response.should render_template("resource_picture")
+          response.should render_template("resource_pictures")
         end
       end
       context 'json形式' do