OSDN Git Service

t#31470:create pager
[pettanr/pettanr.git] / spec / controllers / ground_colors_controller_spec.rb
index 7b0e131..147aecd 100644 (file)
@@ -1,6 +1,6 @@
 # -*- encoding: utf-8 -*-
 require 'spec_helper'
-#選択色地
+#色地
 
 describe GroundColorsController do
   before do
@@ -12,7 +12,6 @@ describe GroundColorsController do
     @author = FactoryGirl.create :author, :user_id => @user.id
     @artist = FactoryGirl.create :artist_yas, :author_id => @author.id
     @panel = FactoryGirl.create :panel, :author_id => @author.id
-    @color = FactoryGirl.create :color
   end
 
 if MagicNumber['run_mode'] == 1
@@ -53,7 +52,7 @@ if MagicNumber['run_mode'] == 1
         get :index
         response.should be_success 
       end
-      it '選択色地モデルに一覧を問い合わせている' do
+      it '色地モデルに一覧を問い合わせている' do
         GroundColor.should_receive(:list).exactly(1)
         get :index
       end
@@ -62,6 +61,10 @@ if MagicNumber['run_mode'] == 1
         assigns(:ground_colors).should have_at_least(3).items
       end
       context 'html形式' do
+        it '@paginateにページ制御を取得している' do
+          get :index
+          assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
+        end
         it 'indexテンプレートを描画する' do
           get :index
           response.should render_template("index")
@@ -72,7 +75,7 @@ if MagicNumber['run_mode'] == 1
           get :index, :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 :index, :format => :json
         end
@@ -81,16 +84,16 @@ if MagicNumber['run_mode'] == 1
           json = JSON.parse response.body
           json.should have_at_least(3).items
         end
-        it 'リストの先頭くらいは選択色地っぽいものであって欲しい' do
+        it 'リストの先頭くらいは色地っぽいものであって欲しい' do
           get :index, :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
     end
-    context 'ä½\9c家権é\99\90ã\81\8cã\81ªã\81\84ã\81¨ã\81\8d' do
+    context 'ã\83¦ã\83¼ã\82¶æ¨©é\99\90ã\81\8cã\81ªã\81\84ã\81¨ã\81\8d' do
       before do
         sign_out @user
       end
@@ -115,6 +118,25 @@ if MagicNumber['run_mode'] == 1
         end
       end
     end
+    context 'ユーザ権限はないが管理者権限があるとき' do
+      before do
+        sign_out @user
+        sign_in @admin
+      end
+      it 'ステータスコード200 OKを返す' do
+        get :index
+        response.should be_success 
+      end
+    end
+    context 'ユーザだが作家登録していないとき' do
+      before do
+        @author.destroy
+      end
+      it 'ステータスコード200 OKを返す' do
+        get :index
+        response.should be_success 
+      end
+    end
   end
   
   describe '単体表示に於いて' do
@@ -128,7 +150,7 @@ if MagicNumber['run_mode'] == 1
         get :show, :id => @gc.id
         response.should be_success
       end
-      it '選択色地モデルに単体取得を問い合わせている' do
+      it '色地モデルに単体取得を問い合わせている' do
         GroundColor.should_receive(:show).exactly(1)
         get :show
       end
@@ -147,7 +169,7 @@ if MagicNumber['run_mode'] == 1
           get :show, :id => @gc.id, :format => :json
           lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
         end
-        it '選択色地モデルにjson単体出力オプションを問い合わせている' do
+        it '色地モデルにjson単体出力オプションを問い合わせている' do
           GroundColor.should_receive(:show_json_opt).exactly(1)
           get :show, :id => @gc.id, :format => :json
         end
@@ -156,11 +178,11 @@ if MagicNumber['run_mode'] == 1
           json = JSON.parse response.body
           json["panel_id"].should_not be_nil
           json["z"].should_not be_nil
-          json["color_id"].should_not be_nil
+          json["code"].should_not be_nil
         end
       end
     end
-    context 'ä½\9c家権é\99\90ã\81\8cã\81ªã\81\84ã\81¨ã\81\8d' do
+    context 'ã\83¦ã\83¼ã\82¶æ¨©é\99\90ã\81\8cã\81ªã\81\84ã\81¨ã\81\8d' do
       before do
         sign_out @user
       end
@@ -185,6 +207,25 @@ if MagicNumber['run_mode'] == 1
         end
       end
     end
+    context 'ユーザ権限はないが管理者権限があるとき' do
+      before do
+        sign_out @user
+        sign_in @admin
+      end
+      it 'ステータスコード200 OKを返す' do
+        get :show, :id => @gc.id
+        response.should be_success 
+      end
+    end
+    context 'ユーザだが作家登録していないとき' do
+      before do
+        @author.destroy
+      end
+      it 'ステータスコード200 OKを返す' do
+        get :show, :id => @gc.id
+        response.should be_success 
+      end
+    end
   end
   
 else
@@ -212,7 +253,7 @@ else
         end
       end
     end
-    context 'ä½\9c家権é\99\90ã\81\8cã\81ªã\81\84ã\81¨ã\81\8d' do
+    context 'ã\83¦ã\83¼ã\82¶æ¨©é\99\90ã\81\8cã\81ªã\81\84ã\81¨ã\81\8d' do
       before do
         sign_out @user
       end
@@ -259,7 +300,7 @@ else
         end
       end
     end
-    context 'ä½\9c家権é\99\90ã\81\8cã\81ªã\81\84ã\81¨ã\81\8d' do
+    context 'ã\83¦ã\83¼ã\82¶æ¨©é\99\90ã\81\8cã\81ªã\81\84ã\81¨ã\81\8d' do
       before do
         sign_out @user
       end