describe '一覧表示に於いて' do
before do
sign_in @user
- SpeechBalloonTemplate.stub(:list).and_return([@sbt, @sbt, @sbt])
+ SpeechBalloonTemplate.stub(:enable_list).and_return([@sbt, @sbt, @sbt])
end
context 'つつがなく終わるとき' do
it 'フキダシテンプレートモデルに一覧を問い合わせている' do
- SpeechBalloonTemplate.should_receive(:list).exactly(1)
+ SpeechBalloonTemplate.should_receive(:enable_list).exactly(1)
get :index
end
it '@speech_balloon_templatesにリストを取得している' do
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
+ 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
before do
sign_in @user
- SpeechBalloonTemplate.stub(:show).with(@sbt.id.to_s, @author).and_return(@sbt)
+ SpeechBalloonTemplate.stub(:show).with(@sbt.id.to_s, [@user, nil]).and_return(@sbt)
+ SpeechBalloonTemplate.stub(:show).with(@sbt.id.to_s, [nil, @admin]).and_return(@sbt)
end
context 'つつがなく終わるとき' do
it 'フキダシテンプレートモデルに単体取得を問い合わせている' do
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
context 'html形式' do
it 'ステータスコード302 Foundを返す' do
- get :index
+ get :show, :id => @sbt.id
response.status.should eq 302
end
it 'サインインページへ遷移する' do
- get :index
+ get :show, :id => @sbt.id
response.should redirect_to '/users/sign_in'
end
end
context 'json形式' do
it 'ステータスコード401 Unauthorizedを返す' do
- get :index, :format => :json
+ get :show, :id => @sbt.id, :format => :json
response.status.should eq 401
end
it '応答メッセージにUnauthorizedを返す' do
- get :index, :format => :json
+ get :show, :id => @sbt.id, :format => :json
response.message.should match(/Unauthorized/)
end
end
end
+ context 'ユーザ権限はないが管理者権限があるとき' do
+ before do
+ sign_out @user
+ sign_in @admin
+ end
+ it 'ステータスコード200 OKを返す' do
+ get :show, :id => @sbt.id
+ response.should be_success
+ end
+ end
+ context 'ユーザだが作家登録していないとき' do
+ before do
+ @author.destroy
+ end
+ it 'ステータスコード200 OKを返す' do
+ get :show, :id => @sbt.id
+ response.should be_success
+ end
+ end
end
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
describe '単体表示に於いて' do
before do
sign_in @user
- SpeechBalloonTemplate.stub(:show).with(@sbt.id.to_s, @author).and_return(@sbt)
- SpeechBalloonTemplate.stub(:show).with(@sbt.id.to_s, nil).and_return(@sbt)
+ SpeechBalloonTemplate.stub(:show).with(@sbt.id.to_s, [nil, nil]).and_return(@sbt)
+ SpeechBalloonTemplate.stub(:show).with(@sbt.id.to_s, [@user, nil]).and_return(@sbt)
+ SpeechBalloonTemplate.stub(:show).with(@sbt.id.to_s, [nil, @admin]).and_return(@sbt)
end
context 'つつがなく終わるとき' do
context 'html形式' do
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