OSDN Git Service

t#31085:raise err when input invalid encoding string
[pettanr/pettanr.git] / spec / controllers / comics_controller_spec.rb
index c475426..087107f 100644 (file)
@@ -85,7 +85,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
@@ -110,6 +110,27 @@ 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
+      context 'html形式' do\r
+        it 'ステータスコード200 OKを返す' do\r
+          get :index\r
+          response.should be_success \r
+        end\r
+      end\r
+    end\r
   end\r
   \r
   describe '単体表示に於いて' do\r
@@ -154,7 +175,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
@@ -179,6 +200,27 @@ 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 => @comic.id\r
+        response.should be_success \r
+      end\r
+    end\r
+    context 'ユーザだが作家登録していないとき' do\r
+      before do\r
+        @author.destroy\r
+      end\r
+      context 'html形式' do\r
+        it 'ステータスコード200 OKを返す' do\r
+          get :show, :id => @comic.id\r
+          response.should be_success\r
+        end\r
+      end\r
+    end\r
 =begin\r
     context '対象コミックがないとき' do\r
       context 'html形式' do\r
@@ -282,7 +324,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
@@ -317,6 +359,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, @attr\r
+          response.status.should eq 302\r
+        end\r
+        it '作家登録ページへ遷移する' do\r
+          get :new, @attr\r
+          response.body.should redirect_to new_author_path\r
+        end\r
+      end\r
+    end\r
   end\r
 \r
   describe '新規作成に於いて' do\r
@@ -378,7 +451,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
@@ -403,6 +476,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, :comic => @attr\r
+          response.status.should eq 302\r
+        end\r
+        it 'サインインページへ遷移する' do\r
+          post :create, :comic => @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, :comic => @attr\r
+          response.status.should eq 302\r
+        end\r
+        it '作家登録ページへ遷移する' do\r
+          post :create, :comic => @attr\r
+          response.body.should redirect_to new_author_path\r
+        end\r
+      end\r
+    end\r
     context '検証、保存に失敗した' do\r
       before do\r
         Comic.any_instance.stub(:save).and_return(false)\r
@@ -466,7 +570,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
@@ -491,6 +595,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 => @comic.id\r
+          response.status.should eq 302\r
+        end\r
+        it 'サインインページへ遷移する' do\r
+          get :edit, :id => @comic.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 => @comic.id\r
+          response.status.should eq 302\r
+        end\r
+        it '作家登録ページへ遷移する' do\r
+          get :edit, :id => @comic.id\r
+          response.body.should redirect_to new_author_path\r
+        end\r
+      end\r
+    end\r
   end\r
 \r
   describe '更新に於いて' do\r
@@ -552,15 +687,15 @@ 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
-      it 'ステータスコード302 Foundを返す' do\r
-        put :update, :id => @comic.id, :comic => @attr\r
-        response.status.should eq 302\r
-      end\r
       context 'html形式' do\r
+        it 'ステータスコード302 Foundを返す' do\r
+          put :update, :id => @comic.id, :comic => @attr\r
+          response.status.should eq 302\r
+        end\r
         it 'サインインページへ遷移する' do\r
           put :update, :id => @comic.id, :comic => @attr\r
           response.body.should redirect_to '/users/sign_in'\r
@@ -573,6 +708,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 => @comic.id, :comic => @attr\r
+          response.status.should eq 302\r
+        end\r
+        it 'サインインページへ遷移する' do\r
+          put :update, :id => @comic.id, :comic => @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 => @comic.id, :comic => @attr\r
+          response.status.should eq 302\r
+        end\r
+        it '作家登録ページへ遷移する' do\r
+          put :update, :id => @comic.id, :comic => @attr\r
+          response.body.should redirect_to new_author_path\r
+        end\r
+      end\r
+    end\r
     context '検証、保存に失敗したとき' do\r
       before do\r
         Comic.any_instance.stub(:save).and_return(false)\r
@@ -657,15 +823,15 @@ 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
-      it 'ステータスコード302 Foundを返す' do\r
-        delete :destroy, :id => @comic.id\r
-        response.status.should eq 302\r
-      end\r
       context 'html形式' do\r
+        it 'ステータスコード302 Foundを返す' do\r
+          delete :destroy, :id => @comic.id\r
+          response.status.should eq 302\r
+        end\r
         it 'サインインページへ遷移する' do\r
           delete :destroy, :id => @comic.id\r
           response.body.should redirect_to '/users/sign_in'\r
@@ -678,6 +844,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 => @comic.id\r
+          response.status.should eq 302\r
+        end\r
+        it 'サインインページへ遷移する' do\r
+          delete :destroy, :id => @comic.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 => @comic.id\r
+          response.status.should eq 302\r
+        end\r
+        it '作家登録ページへ遷移する' do\r
+          delete :destroy, :id => @comic.id\r
+          response.body.should redirect_to new_author_path\r
+        end\r
+      end\r
+    end\r
     context '削除に失敗したとき' do\r
       before do\r
         Comic.any_instance.stub(:destroy_with_story).and_return(false)\r
@@ -730,7 +927,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
@@ -777,7 +974,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
@@ -846,7 +1043,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
@@ -913,7 +1110,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
@@ -964,7 +1161,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
@@ -1022,7 +1219,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
@@ -1072,7 +1269,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