assigns(:original_pictures).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")
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
end
end
end
- context '作家が絵師でないとき' do
+ context 'ユーザ権限はないが管理者権限があるとき' do
before do
- Author.any_instance.stub(:artist?).and_return(false)
+ sign_out @user
+ sign_in @admin
+ end
+ context 'html形式' do
+ it 'ステータスコード302 Foundを返す' do
+ get :index
+ response.status.should eq 302
+ end
+ it 'サインインページへ遷移する' do
+ get :index
+ response.should redirect_to '/users/sign_in'
+ end
+ end
+ end
+ context 'ユーザが絵師でないとき' do
+ before do
+ @artist.destroy
end
context 'html形式' do
it 'ステータスコード302 Foundを返す' do
end
end
context 'json形式' do
- it '応答メッセージにUnauthorizedを返す' do
- get :index, :format => :json
- response.message.should match(/Unauthorized/)
+ it '例外403 forbiddenを返す' do
+ lambda{
+ get :index, :format => :json
+ }.should raise_error(ActiveRecord::Forbidden)
end
end
end
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
end
end
end
- context '作家が絵師でないとき' do
+ context 'ユーザ権限はないが管理者権限があるとき' do
before do
- Author.any_instance.stub(:artist?).and_return(false)
+ sign_out @user
+ sign_in @admin
end
- context 'html形式' do
- it 'ステータスコード302 Foundを返す' do
- get :show, :id => @pic.id
- response.status.should eq 302
- end
- it '絵師登録ページへ遷移する' do
- get :show, :id => @pic.id
- response.should redirect_to new_artist_path
- end
+ it 'ステータスコード200 OKを返す' do
+ get :show, :id => @pic.id
+ response.should be_success
end
- context 'json形式' do
- it '応答メッセージにUnauthorizedを返す' do
- get :show, :id => @pic.id, :format => :json
- response.message.should match(/Unauthorized/)
- end
+ end
+ context 'ユーザが絵師でないとき' do
+ before do
+ @artist.destroy
+ end
+ it 'ステータスコード200 OKを返す' do
+ get :show, :id => @pic.id
+ response.should be_success
end
end
=begin
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
end
end
end
- context '作家が絵師でないとき' do
+ context 'ユーザ権限はないが管理者権限があるとき' do
before do
- Author.any_instance.stub(:artist?).and_return(false)
+ sign_out @user
+ sign_in @admin
end
- context 'html形式' do
- it 'ステータスコード302 Foundを返す' do
- get :history, :id => @op.id
- response.status.should eq 302
- end
- it '絵師登録ページへ遷移する' do
- get :history, :id => @op.id
- response.should redirect_to new_artist_path
- end
+ it 'ステータスコード200 OKを返す' do
+ get :history, :id => @op.id
+ response.should be_success
end
- context 'json形式' do
- it '応答メッセージにUnauthorizedを返す' do
- get :history, :id => @op.id, :format => :json
- response.message.should match(/Unauthorized/)
- end
+ end
+ context 'ユーザが絵師でないとき' do
+ before do
+ @artist.destroy
+ end
+ it 'ステータスコード200 OKを返す' do
+ get :history, :id => @op.id
+ response.should be_success
end
end
end
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
end
end
end
- context '作家が絵師でないとき' do
+ context 'ユーザ権限はないが管理者権限があるとき' do
before do
- Author.any_instance.stub(:artist?).and_return(false)
+ sign_out @user
+ sign_in @admin
end
context 'html形式' do
it 'ステータスコード302 Foundを返す' do
get :new
response.status.should eq 302
end
- it '絵師登録ページへ遷移する' do
+ it 'サインインページへ遷移する' do
get :new
- response.should redirect_to new_artist_path
+ response.body.should redirect_to '/users/sign_in'
end
end
- context 'js形式' do
- it 'ステータスコード200 Okを返す' do
- get :new, :format => :js
- response.status.should eq 200
+ end
+ context 'ユーザが絵師でないとき' do
+ before do
+ @artist.destroy
+ end
+ context 'html形式' do
+ it 'ステータスコード302 Foundを返す' do
+ get :new
+ response.status.should eq 302
end
- it '絵師登録é\83¨å\88\86ã\83\86ã\83³ã\83\97ã\83¬ã\83¼ã\83\88artists/new.jsã\82\92æ\8f\8fç\94»ã\81\99ã\82\8b' do
- get :new, :format => :js
- response.should render_template("artists/new")
+ it '絵師登録ã\83\9aã\83¼ã\82¸ã\81¸é\81·ç§»ã\81\99ã\82\8b' do
+ get :new
+ response.should redirect_to new_artist_path
end
end
context 'json形式' do
- it '応答メッセージにUnauthorizedを返す' do
- get :new, :format => :json
- response.message.should match(/Unauthorized/)
+ it '例外403 forbiddenを返す' do
+ lambda{
+ get :new, :format => :json
+ }.should raise_error(ActiveRecord::Forbidden)
end
end
end
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
end
end
end
- context '作家が絵師でないとき' do
+ context 'ユーザ権限はないが管理者権限があるとき' do
+ before do
+ sign_out @user
+ sign_in @admin
+ end
+ context 'html形式' do
+ it 'ステータスコード302 Foundを返す' do
+ post :create, @attr
+ response.status.should eq 302
+ end
+ it 'サインインページへ遷移する' do
+ post :create, @attr
+ response.body.should redirect_to '/users/sign_in'
+ end
+ end
+ end
+ context 'ユーザが絵師でないとき' do
before do
- Author.any_instance.stub(:artist?).and_return(false)
+ @artist.destroy
end
context 'html形式' do
it 'ステータスコード302 Foundを返す' do
before do
@attr.merge!({:format => :json})
end
- it '応答メッセージにUnauthorizedを返す' do
- post :create, @attr
- response.message.should match(/Unauthorized/)
+ it '例外403 forbiddenを返す' do
+ @attr.merge!({:format => :json})
+ lambda{
+ post :create, @attr
+ }.should raise_error(ActiveRecord::Forbidden)
end
end
end
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
end
end
end
- context '作家が絵師でないとき' do
+ context 'ユーザ権限はないが管理者権限があるとき' do
before do
- Author.any_instance.stub(:artist?).and_return(false)
+ sign_out @user
+ sign_in @admin
+ end
+ context 'html形式' do
+ it 'ステータスコード302 Foundを返す' do
+ get :edit, :id => @pic.id
+ response.status.should eq 302
+ end
+ it 'サインインページへ遷移する' do
+ get :edit, :id => @pic.id
+ response.body.should redirect_to '/users/sign_in'
+ end
+ end
+ end
+ context 'ユーザが絵師でないとき' do
+ before do
+ @artist.destroy
end
context 'html形式' do
it 'ステータスコード302 Foundを返す' do
response.should redirect_to new_artist_path
end
end
- context 'js形式' do
- it 'ステータスコード200 Okを返す' do
- get :edit, :id => @pic.id, :format => :js
- response.status.should eq 200
- end
- it '絵師登録部分テンプレートartists/new.jsを描画する' do
- get :edit, :id => @pic.id, :format => :js
- response.should render_template("artists/new")
+ context 'json形式' do
+ it '例外403 forbiddenを返す' do
+ lambda{
+ get :edit, :id => @pic.id, :format => :json
+ }.should raise_error(ActiveRecord::Forbidden)
end
end
end
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
end
end
end
- context '作家が絵師でないとき' do
+ context 'ユーザ権限はないが管理者権限があるとき' do
+ before do
+ sign_out @user
+ sign_in @admin
+ end
+ context 'html形式' do
+ it 'ステータスコード302 Foundを返す' do
+ put :update, :id => @op.id, :original_picture => @attr
+ response.status.should eq 302
+ end
+ it 'サインインページへ遷移する' do
+ put :update, :id => @op.id, :original_picture => @attr
+ response.body.should redirect_to '/users/sign_in'
+ end
+ end
+ end
+ context 'ユーザが絵師でないとき' do
before do
- Author.any_instance.stub(:artist?).and_return(false)
+ @artist.destroy
end
context 'html形式' do
it 'ステータスコード302 Foundを返す' do
end
end
context 'json形式' do
- it '応答メッセージにUnauthorizedを返す' do
- put :update, :id => @op.id, :original_picture => @attr, :format => :json
- response.message.should match(/Unauthorized/)
+ it '例外403 forbiddenを返す' do
+ lambda{
+ put :update, :id => @op.id, :original_picture => @attr, :format => :json
+ }.should raise_error(ActiveRecord::Forbidden)
end
end
end
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
- it 'ステータスコード302 Foundを返す' do
- delete :destroy, :id => @op.id
- response.status.should eq 302
- end
context 'html形式' do
+ it 'ステータスコード302 Foundを返す' do
+ delete :destroy, :id => @op.id
+ response.status.should eq 302
+ end
it 'サインインページへ遷移する' do
delete :destroy, :id => @op.id
response.body.should redirect_to '/users/sign_in'
end
end
end
- context '作家が絵師でないとき' do
+ context 'ユーザ権限はないが管理者権限があるとき' do
+ before do
+ sign_out @user
+ sign_in @admin
+ end
+ context 'html形式' do
+ it 'ステータスコード302 Foundを返す' do
+ delete :destroy, :id => @op.id
+ response.status.should eq 302
+ end
+ it 'サインインページへ遷移する' do
+ delete :destroy, :id => @op.id
+ response.body.should redirect_to '/users/sign_in'
+ end
+ end
+ end
+ context 'ユーザが絵師でないとき' do
before do
- Author.any_instance.stub(:artist?).and_return(false)
+ @artist.destroy
end
context 'html形式' do
it 'ステータスコード302 Foundを返す' do
end
end
context 'json形式' do
- it '応答メッセージにUnauthorizedを返す' do
- delete :destroy, :id => @op.id, :format => :json
- response.message.should match(/Unauthorized/)
+ it '例外403 forbiddenを返す' do
+ lambda{
+ delete :destroy, :id => @op.id, :format => :json
+ }.should raise_error(ActiveRecord::Forbidden)
end
end
end
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
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
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
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
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
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
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
end
end
end
- context '作家が絵師でないとき' do
- before do
- Author.any_instance.stub(:artist?).and_return(false)
- end
- context 'html形式' do
- it 'ステータスコード302 Foundを返す' do
- put :update, :id => @op.id, :original_picture => @attr
- response.status.should eq 302
- end
- it '絵師登録ページへ遷移する' do
- put :update, :id => @op.id, :original_picture => @attr
- response.should redirect_to new_artist_path
- end
- end
- context 'json形式' do
- it '例外403 forbiddenを返す' do
- lambda{
- put :update, :id => @op.id, :original_picture => @attr, :format => :json
- }.should raise_error(ActiveRecord::Forbidden)
- end
- end
- end
context '検証、保存に失敗した' do
before do
PettanImager.stub(:load).with("abc\ndef\nghi").and_return(@imager)
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