OSDN Git Service

Merge branch 'v05' of git.sourceforge.jp:/gitroot/pettanr/pettanr into v05client
[pettanr/pettanr.git] / spec / controllers / panels_controller_spec.rb
index 3ccd6c6..0231c39 100644 (file)
@@ -88,7 +88,7 @@ if MagicNumber['run_mode'] == 1
         end\r
       end\r
     end\r
-    context 'ä½\9c家権é\99\90ã\81\8cã\81ªã\81\84ã\81¨ã\81\8d' do\r
+    context 'ã\83¦ã\83¼ã\82¶æ¨©é\99\90ã\81\8cã\81ªã\81\84ã\81¨ã\81\8d' do\r
       before do\r
         sign_out @user\r
       end\r
@@ -113,12 +113,32 @@ if MagicNumber['run_mode'] == 1
         end\r
       end\r
     end\r
+    context 'ユーザ権限はないが管理者権限があるとき' do\r
+      before do\r
+        sign_out @user\r
+        sign_in @admin\r
+      end\r
+      it 'ステータスコード200 OKを返す' do\r
+        get :index\r
+        response.should be_success \r
+      end\r
+    end\r
+    context 'ユーザだが作家登録していないとき' do\r
+      before do\r
+        @author.destroy\r
+      end\r
+      it 'ステータスコード200 OKを返す' do\r
+        get :index\r
+        response.should be_success \r
+      end\r
+    end\r
   end\r
   \r
   describe '単体表示に於いて' do\r
     before do\r
       @panel = FactoryGirl.create :panel, :author_id => @user.author.id\r
-      Panel.stub(:show).with(@panel.id.to_s, @author).and_return(@panel)\r
+      Panel.stub(:show).with(@panel.id.to_s, [@user, nil]).and_return(@panel)\r
+      Panel.stub(:show).with(@panel.id.to_s, [nil, @admin]).and_return(@panel)\r
       sign_in @user\r
     end\r
     context 'つつがなく終わるとき' do\r
@@ -160,7 +180,7 @@ if MagicNumber['run_mode'] == 1
         end\r
       end\r
     end\r
-    context 'ä½\9c家権é\99\90ã\81\8cã\81ªã\81\84ã\81¨ã\81\8d' do\r
+    context 'ã\83¦ã\83¼ã\82¶æ¨©é\99\90ã\81\8cã\81ªã\81\84ã\81¨ã\81\8d' do\r
       before do\r
         sign_out @user\r
       end\r
@@ -185,6 +205,25 @@ if MagicNumber['run_mode'] == 1
         end\r
       end\r
     end\r
+    context 'ユーザ権限はないが管理者権限があるとき' do\r
+      before do\r
+        sign_out @user\r
+        sign_in @admin\r
+      end\r
+      it 'ステータスコード200 OKを返す' do\r
+          get :show, :id => @panel.id\r
+        response.should be_success \r
+      end\r
+    end\r
+    context 'ユーザだが作家登録していないとき' do\r
+      before do\r
+        @author.destroy\r
+      end\r
+      it 'ステータスコード200 OKを返す' do\r
+          get :show, :id => @panel.id\r
+        response.should be_success \r
+      end\r
+    end\r
 =begin\r
     context '対象コマがないとき' do\r
       context 'html形式' do\r
@@ -289,7 +328,7 @@ if MagicNumber['run_mode'] == 1
         end\r
       end\r
     end\r
-    context 'ä½\9c家権é\99\90ã\81\8cã\81ªã\81\84ã\81¨ã\81\8d' do\r
+    context 'ã\83¦ã\83¼ã\82¶æ¨©é\99\90ã\81\8cã\81ªã\81\84ã\81¨ã\81\8d' do\r
       before do\r
         sign_out @user\r
       end\r
@@ -314,6 +353,37 @@ if MagicNumber['run_mode'] == 1
         end\r
       end\r
     end\r
+    context 'ユーザ権限はないが管理者権限があるとき' do\r
+      before do\r
+        sign_out @user\r
+        sign_in @admin\r
+      end\r
+      context 'html形式' do\r
+        it 'ステータスコード302 Foundを返す' do\r
+          get :new\r
+          response.status.should eq 302\r
+        end\r
+        it 'サインインページへ遷移する' do\r
+          get :new\r
+          response.body.should redirect_to '/users/sign_in'\r
+        end\r
+      end\r
+    end\r
+    context 'ユーザだが作家登録していないとき' do\r
+      before do\r
+        @author.destroy\r
+      end\r
+      context 'html形式' do\r
+        it 'ステータスコード302 Foundを返す' do\r
+          get :new\r
+          response.status.should eq 302\r
+        end\r
+        it '作家登録ページへ遷移する' do\r
+          get :new\r
+          response.body.should redirect_to new_author_path\r
+        end\r
+      end\r
+    end\r
   end\r
   \r
   describe '新規作成に於いて' do\r
@@ -389,7 +459,7 @@ if MagicNumber['run_mode'] == 1
         end\r
       end\r
     end\r
-    context 'ä½\9c家権é\99\90ã\81\8cã\81ªã\81\84ã\81¨ã\81\8d' do\r
+    context 'ã\83¦ã\83¼ã\82¶æ¨©é\99\90ã\81\8cã\81ªã\81\84ã\81¨ã\81\8d' do\r
       before do\r
         sign_out @user\r
       end\r
@@ -414,6 +484,37 @@ if MagicNumber['run_mode'] == 1
         end\r
       end\r
     end\r
+    context 'ユーザ権限はないが管理者権限があるとき' do\r
+      before do\r
+        sign_out @user\r
+        sign_in @admin\r
+      end\r
+      context 'html形式' do\r
+        it 'ステータスコード302 Foundを返す' do\r
+          post :create, :panel => @attr\r
+          response.status.should eq 302\r
+        end\r
+        it 'サインインページへ遷移する' do\r
+          post :create, :panel => @attr\r
+          response.body.should redirect_to '/users/sign_in'\r
+        end\r
+      end\r
+    end\r
+    context 'ユーザだが作家登録していないとき' do\r
+      before do\r
+        @author.destroy\r
+      end\r
+      context 'html形式' do\r
+        it 'ステータスコード302 Foundを返す' do\r
+          post :create, :panel => @attr\r
+          response.status.should eq 302\r
+        end\r
+        it '作家登録ページへ遷移する' do\r
+          post :create, :panel => @attr\r
+          response.body.should redirect_to new_author_path\r
+        end\r
+      end\r
+    end\r
     context '検証、保存に失敗した' do\r
       before do\r
         Panel.any_instance.stub(:store).and_return(false)\r
@@ -481,7 +582,7 @@ if MagicNumber['run_mode'] == 1
         end\r
       end\r
     end\r
-    context 'ä½\9c家権é\99\90ã\81\8cã\81ªã\81\84ã\81¨ã\81\8d' do\r
+    context 'ã\83¦ã\83¼ã\82¶æ¨©é\99\90ã\81\8cã\81ªã\81\84ã\81¨ã\81\8d' do\r
       before do\r
         sign_out @user\r
       end\r
@@ -506,6 +607,37 @@ if MagicNumber['run_mode'] == 1
         end\r
       end\r
     end\r
+    context 'ユーザ権限はないが管理者権限があるとき' do\r
+      before do\r
+        sign_out @user\r
+        sign_in @admin\r
+      end\r
+      context 'html形式' do\r
+        it 'ステータスコード302 Foundを返す' do\r
+          get :edit, :id => @panel.id\r
+          response.status.should eq 302\r
+        end\r
+        it 'サインインページへ遷移する' do\r
+          get :edit, :id => @panel.id\r
+          response.body.should redirect_to '/users/sign_in'\r
+        end\r
+      end\r
+    end\r
+    context 'ユーザだが作家登録していないとき' do\r
+      before do\r
+        @author.destroy\r
+      end\r
+      context 'html形式' do\r
+        it 'ステータスコード302 Foundを返す' do\r
+          get :edit, :id => @panel.id\r
+          response.status.should eq 302\r
+        end\r
+        it '作家登録ページへ遷移する' do\r
+          get :edit, :id => @panel.id\r
+          response.body.should redirect_to new_author_path\r
+        end\r
+      end\r
+    end\r
   end\r
 \r
   describe '更新に於いて' do\r
@@ -576,7 +708,7 @@ if MagicNumber['run_mode'] == 1
         end\r
       end\r
     end\r
-    context 'ä½\9c家権é\99\90ã\81\8cã\81ªã\81\84ã\81¨ã\81\8d' do\r
+    context 'ã\83¦ã\83¼ã\82¶æ¨©é\99\90ã\81\8cã\81ªã\81\84ã\81¨ã\81\8d' do\r
       before do\r
         sign_out @user\r
       end\r
@@ -601,6 +733,37 @@ if MagicNumber['run_mode'] == 1
         end\r
       end\r
     end\r
+    context 'ユーザ権限はないが管理者権限があるとき' do\r
+      before do\r
+        sign_out @user\r
+        sign_in @admin\r
+      end\r
+      context 'html形式' do\r
+        it 'ステータスコード302 Foundを返す' do\r
+          put :update, :id => @panel.id, :panel => @attr\r
+          response.status.should eq 302\r
+        end\r
+        it 'サインインページへ遷移する' do\r
+          put :update, :id => @panel.id, :panel => @attr\r
+          response.body.should redirect_to '/users/sign_in'\r
+        end\r
+      end\r
+    end\r
+    context 'ユーザだが作家登録していないとき' do\r
+      before do\r
+        @author.destroy\r
+      end\r
+      context 'html形式' do\r
+        it 'ステータスコード302 Foundを返す' do\r
+          put :update, :id => @panel.id, :panel => @attr\r
+          response.status.should eq 302\r
+        end\r
+        it '作家登録ページへ遷移する' do\r
+          put :update, :id => @panel.id, :panel => @attr\r
+          response.body.should redirect_to new_author_path\r
+        end\r
+      end\r
+    end\r
     context '検証、保存に失敗した' do\r
       before do\r
         Panel.any_instance.stub(:store).and_return(false)\r
@@ -669,7 +832,7 @@ if MagicNumber['run_mode'] == 1
         end\r
       end\r
     end\r
-    context 'ä½\9c家権é\99\90ã\81\8cã\81ªã\81\84ã\81¨ã\81\8d' do\r
+    context 'ã\83¦ã\83¼ã\82¶æ¨©é\99\90ã\81\8cã\81ªã\81\84ã\81¨ã\81\8d' do\r
       before do\r
         sign_out @user\r
       end\r
@@ -694,6 +857,37 @@ if MagicNumber['run_mode'] == 1
         end\r
       end\r
     end\r
+    context 'ユーザ権限はないが管理者権限があるとき' do\r
+      before do\r
+        sign_out @user\r
+        sign_in @admin\r
+      end\r
+      context 'html形式' do\r
+        it 'ステータスコード302 Foundを返す' do\r
+          delete :destroy, :id => @panel.id\r
+          response.status.should eq 302\r
+        end\r
+        it 'サインインページへ遷移する' do\r
+          delete :destroy, :id => @panel.id\r
+          response.body.should redirect_to '/users/sign_in'\r
+        end\r
+      end\r
+    end\r
+    context 'ユーザだが作家登録していないとき' do\r
+      before do\r
+        @author.destroy\r
+      end\r
+      context 'html形式' do\r
+        it 'ステータスコード302 Foundを返す' do\r
+          delete :destroy, :id => @panel.id\r
+          response.status.should eq 302\r
+        end\r
+        it '作家登録ページへ遷移する' do\r
+          delete :destroy, :id => @panel.id\r
+          response.body.should redirect_to new_author_path\r
+        end\r
+      end\r
+    end\r
     context '削除に失敗したとき' do\r
       before do\r
         Panel.any_instance.stub(:destroy_with_elements).and_return(false)\r
@@ -756,7 +950,7 @@ else
         end\r
       end\r
     end\r
-    context 'ä½\9c家権é\99\90ã\81\8cã\81ªã\81\84ã\81¨ã\81\8d' do\r
+    context 'ã\83¦ã\83¼ã\82¶æ¨©é\99\90ã\81\8cã\81ªã\81\84ã\81¨ã\81\8d' do\r
       before do\r
         sign_out @user\r
       end\r
@@ -786,8 +980,9 @@ else
   describe '単体表示に於いて' do\r
     before do\r
       @panel = FactoryGirl.create :panel, :author_id => @user.author.id\r
-      Panel.stub(:show).with(@panel.id.to_s, @author).and_return(@panel)\r
-      Panel.stub(:show).with(@panel.id.to_s, nil).and_return(@panel)\r
+      Panel.stub(:show).with(@panel.id.to_s, [nil, nil]).and_return(@panel)\r
+      Panel.stub(:show).with(@panel.id.to_s, [@user, nil]).and_return(@panel)\r
+      Panel.stub(:show).with(@panel.id.to_s, [nil, @admin]).and_return(@panel)\r
       sign_in @user\r
     end\r
     context 'つつがなく終わるとき' do\r
@@ -812,7 +1007,7 @@ else
         end\r
       end\r
     end\r
-    context 'ä½\9c家権é\99\90ã\81\8cã\81ªã\81\84ã\81¨ã\81\8d' do\r
+    context 'ã\83¦ã\83¼ã\82¶æ¨©é\99\90ã\81\8cã\81ªã\81\84ã\81¨ã\81\8d' do\r
       before do\r
         sign_out @user\r
       end\r
@@ -886,7 +1081,7 @@ else
         end\r
       end\r
     end\r
-    context 'ä½\9c家権é\99\90ã\81\8cã\81ªã\81\84ã\81¨ã\81\8d' do\r
+    context 'ã\83¦ã\83¼ã\82¶æ¨©é\99\90ã\81\8cã\81ªã\81\84ã\81¨ã\81\8d' do\r
       before do\r
         sign_out @user\r
       end\r
@@ -944,7 +1139,7 @@ else
         end\r
       end\r
     end\r
-    context 'ä½\9c家権é\99\90ã\81\8cã\81ªã\81\84ã\81¨ã\81\8d' do\r
+    context 'ã\83¦ã\83¼ã\82¶æ¨©é\99\90ã\81\8cã\81ªã\81\84ã\81¨ã\81\8d' do\r
       before do\r
         sign_out @user\r
       end\r
@@ -999,7 +1194,7 @@ else
         end\r
       end\r
     end\r
-    context 'ä½\9c家権é\99\90ã\81\8cã\81ªã\81\84ã\81¨ã\81\8d' do\r
+    context 'ã\83¦ã\83¼ã\82¶æ¨©é\99\90ã\81\8cã\81ªã\81\84ã\81¨ã\81\8d' do\r
       before do\r
         sign_out @user\r
       end\r
@@ -1058,7 +1253,7 @@ else
         end\r
       end\r
     end\r
-    context 'ä½\9c家権é\99\90ã\81\8cã\81ªã\81\84ã\81¨ã\81\8d' do\r
+    context 'ã\83¦ã\83¼ã\82¶æ¨©é\99\90ã\81\8cã\81ªã\81\84ã\81¨ã\81\8d' do\r
       before do\r
         sign_out @user\r
       end\r
@@ -1109,7 +1304,7 @@ else
         end\r
       end\r
     end\r
-    context 'ä½\9c家権é\99\90ã\81\8cã\81ªã\81\84ã\81¨ã\81\8d' do\r
+    context 'ã\83¦ã\83¼ã\82¶æ¨©é\99\90ã\81\8cã\81ªã\81\84ã\81¨ã\81\8d' do\r
       before do\r
         sign_out @user\r
       end\r