OSDN Git Service

t#30473:fix authenticate
[pettanr/pettanr.git] / spec / controllers / system_pictures_controller_spec.rb
index 9306edf..0db0485 100644 (file)
@@ -5,6 +5,7 @@ require 'spec_helper'
 describe SystemPicturesController do
   before do
     @admin = FactoryGirl.create :admin
+    @demand_user = FactoryGirl.create :demand_user
     @user = FactoryGirl.create( :user_yas)
     @author = FactoryGirl.create :author, :user_id => @user.id
     @artist = FactoryGirl.create :artist_yas, :author_id => @author.id
@@ -17,7 +18,6 @@ if MagicNumber['run_mode'] == 1
   describe '一覧表示に於いて' do
     before do
       sign_in @user
-      sign_in @admin
       SystemPicture.stub(:list).and_return([@sp, @sp, @sp])
     end
     context 'パラメータpageについて' do
@@ -116,6 +116,26 @@ 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
+        sign_out @user
+        sign_in @demand_user
+      end
+      it 'ステータスコード200 OKを返す' do
+        get :index
+        response.should be_success 
+      end
+    end
   end
   
   describe '単体表示に於いて' do
@@ -242,6 +262,26 @@ 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 => @sp.id
+        response.should be_success 
+      end
+    end
+    context '作家権限はないが借手権限があるとき' do
+      before do
+        sign_out @user
+        sign_in @demand_user
+      end
+      it 'ステータスコード200 OKを返す' do
+        get :show, :id => @sp.id
+        response.should be_success 
+      end
+    end
 =begin
     context '対象システム画像がないとき' do
       before do