From: yasushiito Date: Thu, 24 Jan 2013 22:50:38 +0000 (+0900) Subject: t#30558:fix auth filter X-Git-Url: http://git.osdn.net/view?p=pettanr%2Fpettanr.git;a=commitdiff_plain;h=2aa10ee1ef8c348a958cb53b44c51b2cebfaadb7 t#30558:fix auth filter --- diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 0fb6577c..ddc723e7 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -79,13 +79,15 @@ class ApplicationController < ActionController::Base end def authenticate_artist - if @admin or (@author and @author.artist?) + if @artist true else respond_to do |format| format.html { redirect_to main_app.new_artist_path, :status => :found } format.js { render "artists/new" } - format.json { render :text => {:error => I18n.t('devise.failure.unauthenticated')}.to_json, :status => :unauthorized } + format.json { + raise ActiveRecord::Forbidden + } end false end diff --git a/app/controllers/artists_controller.rb b/app/controllers/artists_controller.rb index b5b29566..032a98a8 100644 --- a/app/controllers/artists_controller.rb +++ b/app/controllers/artists_controller.rb @@ -2,9 +2,11 @@ class ArtistsController < ApplicationController layout 'test' if MagicNumber['test_layout'] if MagicNumber['run_mode'] == 0 before_filter :authenticate_user, :only => [:new, :create, :edit, :update, :destroy] + before_filter :authenticate_author, :only => [:new, :create, :edit, :update, :destroy] else before_filter :authenticate_resource_reader, :only => [:index, :show] before_filter :authenticate_user, :only => [:new, :create, :edit, :update, :destroy] + before_filter :authenticate_author, :only => [:new, :create, :edit, :update, :destroy] end before_filter :authenticate_admin!, :only => [:list, :browse] @@ -24,7 +26,7 @@ class ArtistsController < ApplicationController # GET /artists/1 # GET /artists/1.json def show - @ar = Artist.show(params[:id], @author) + @ar = Artist.show(params[:id], [@user, @admin, @demand_user]) respond_to do |format| format.html # show.html.erb diff --git a/app/controllers/authors_controller.rb b/app/controllers/authors_controller.rb index d5d0b5c6..5e8632e6 100644 --- a/app/controllers/authors_controller.rb +++ b/app/controllers/authors_controller.rb @@ -2,9 +2,11 @@ class AuthorsController < ApplicationController layout 'test' if MagicNumber['test_layout'] if MagicNumber['run_mode'] == 0 before_filter :authenticate_user, :only => [:new, :create, :edit, :update] + before_filter :authenticate_author, :only => [:edit, :update] else before_filter :authenticate_reader, :only => [:index, :show] before_filter :authenticate_user, :only => [:new, :create, :edit, :update] + before_filter :authenticate_author, :only => [:edit, :update] end before_filter :authenticate_admin!, :only => [:list, :browse] @@ -20,7 +22,7 @@ class AuthorsController < ApplicationController end def show - @au = Author.show(params[:id], [@author, @admin]) + @au = Author.show(params[:id], [@user, @admin]) respond_to do |format| format.html diff --git a/app/controllers/balloons_controller.rb b/app/controllers/balloons_controller.rb index cb01d58b..d3c67272 100644 --- a/app/controllers/balloons_controller.rb +++ b/app/controllers/balloons_controller.rb @@ -2,9 +2,11 @@ class BalloonsController < ApplicationController layout 'test' if MagicNumber['test_layout'] if MagicNumber['run_mode'] == 0 before_filter :authenticate_user, :only => [] + before_filter :authenticate_author, :only => [] else before_filter :authenticate_reader, :only => [:index, :show] before_filter :authenticate_user, :only => [] + before_filter :authenticate_author, :only => [] end before_filter :authenticate_admin!, :only => [:list, :browse] @@ -20,7 +22,7 @@ class BalloonsController < ApplicationController end def show - @balloon = Balloon.show(params[:id], [@author, @admin]) + @balloon = Balloon.show(params[:id], [@user, @admin]) respond_to do |format| format.html # show.html.erb format.json { render json: @balloon.to_json(Balloon.show_json_opt) } diff --git a/app/controllers/comics_controller.rb b/app/controllers/comics_controller.rb index ec79f360..0539fe5c 100644 --- a/app/controllers/comics_controller.rb +++ b/app/controllers/comics_controller.rb @@ -2,9 +2,11 @@ class ComicsController < ApplicationController layout 'test' if MagicNumber['test_layout'] if MagicNumber['run_mode'] == 0 before_filter :authenticate_user, :only => [:new, :create, :edit, :update, :destroy] + before_filter :authenticate_author, :only => [:new, :create, :edit, :update, :destroy] else before_filter :authenticate_reader, :only => [:top, :index, :show] before_filter :authenticate_user, :only => [:new, :create, :edit, :update, :destroy] + before_filter :authenticate_author, :only => [:new, :create, :edit, :update, :destroy] end before_filter :authenticate_admin!, :only => [:list, :browse] @@ -25,7 +27,7 @@ class ComicsController < ApplicationController end def show - @comic = Comic.show(params[:id], [@author, @admin]) + @comic = Comic.show(params[:id], [@user, @admin]) respond_to do |format| format.html # show.html.erb diff --git a/app/controllers/ground_colors_controller.rb b/app/controllers/ground_colors_controller.rb index 39ecdda8..da5244f2 100644 --- a/app/controllers/ground_colors_controller.rb +++ b/app/controllers/ground_colors_controller.rb @@ -2,9 +2,11 @@ class GroundColorsController < ApplicationController layout 'test' if MagicNumber['test_layout'] if MagicNumber['run_mode'] == 0 before_filter :authenticate_user, :only => [] + before_filter :authenticate_author, :only => [] else before_filter :authenticate_reader, :only => [:index, :show] before_filter :authenticate_user, :only => [] + before_filter :authenticate_author, :only => [] end # GET /ground_colors @@ -21,7 +23,7 @@ class GroundColorsController < ApplicationController end def show - @ground_color = GroundColor.show(params[:id], [@author, @admin]) + @ground_color = GroundColor.show(params[:id], [@user, @admin]) respond_to do |format| format.html # show.html.erb format.json { render json: @ground_color.to_json(GroundColor.show_json_opt) } diff --git a/app/controllers/ground_pictures_controller.rb b/app/controllers/ground_pictures_controller.rb index 88367796..f940c586 100644 --- a/app/controllers/ground_pictures_controller.rb +++ b/app/controllers/ground_pictures_controller.rb @@ -2,9 +2,11 @@ class GroundPicturesController < ApplicationController layout 'test' if MagicNumber['test_layout'] if MagicNumber['run_mode'] == 0 before_filter :authenticate_user, :only => [] + before_filter :authenticate_author, :only => [] else before_filter :authenticate_reader, :only => [:index, :show] before_filter :authenticate_user, :only => [] + before_filter :authenticate_author, :only => [] end # GET /ground_pictures @@ -21,7 +23,7 @@ class GroundPicturesController < ApplicationController end def show - @ground_picture = GroundPicture.show(params[:id], [@author, @admin]) + @ground_picture = GroundPicture.show(params[:id], [@user, @admin]) respond_to do |format| format.html # show.html.erb format.json { render json: @ground_picture.to_json(GroundPicture.show_json_opt) } diff --git a/app/controllers/original_pictures_controller.rb b/app/controllers/original_pictures_controller.rb index fb6a7a3c..d90de173 100644 --- a/app/controllers/original_pictures_controller.rb +++ b/app/controllers/original_pictures_controller.rb @@ -3,8 +3,8 @@ class OriginalPicturesController < ApplicationController layout 'test' if MagicNumber['test_layout'] before_filter :authenticate_reader, :only => [:show, :history] before_filter :authenticate_user, :only => [:index, :new, :edit, :create, :update, :destroy] + before_filter :authenticate_artist, :only => [:index, :new, :edit, :create, :update, :destroy] before_filter :authenticate_admin!, :only => [:list, :browse] - before_filter :authenticate_artist, :only => [:index, :show, :history, :new, :edit, :create, :update, :destroy] # GET /original_pictures # GET /original_pictures.json diff --git a/app/controllers/panel_colors_controller.rb b/app/controllers/panel_colors_controller.rb index 2fe78854..eaaf34df 100644 --- a/app/controllers/panel_colors_controller.rb +++ b/app/controllers/panel_colors_controller.rb @@ -2,9 +2,11 @@ class PanelColorsController < ApplicationController layout 'test' if MagicNumber['test_layout'] if MagicNumber['run_mode'] == 0 before_filter :authenticate_user, :only => [] + before_filter :authenticate_author, :only => [] else before_filter :authenticate_reader, :only => [:index, :show] before_filter :authenticate_user, :only => [] + before_filter :authenticate_author, :only => [] end # GET /ground_pictures @@ -21,7 +23,7 @@ class PanelColorsController < ApplicationController end def show - @panel_color = PanelColor.show(params[:id], [@author, @admin]) + @panel_color = PanelColor.show(params[:id], [@user, @admin]) respond_to do |format| format.html # show.html.erb format.json { render json: @panel_color.to_json(PanelColor.show_json_opt) } diff --git a/app/controllers/panel_pictures_controller.rb b/app/controllers/panel_pictures_controller.rb index 22f98d4e..bf0cb615 100644 --- a/app/controllers/panel_pictures_controller.rb +++ b/app/controllers/panel_pictures_controller.rb @@ -2,8 +2,11 @@ class PanelPicturesController < ApplicationController layout 'test' if MagicNumber['test_layout'] if MagicNumber['run_mode'] == 0 before_filter :authenticate_user, :only => [] + before_filter :authenticate_author, :only => [] else before_filter :authenticate_reader, :only => [:index, :show] + before_filter :authenticate_user, :only => [] + before_filter :authenticate_author, :only => [] end before_filter :authenticate_admin!, :only => [:list, :browse] @@ -21,7 +24,7 @@ class PanelPicturesController < ApplicationController end def show - @panel_picture = PanelPicture.show(params[:id], [@author, @admin]) + @panel_picture = PanelPicture.show(params[:id], [@user, @admin]) respond_to do |format| format.html diff --git a/app/controllers/panels_controller.rb b/app/controllers/panels_controller.rb index 3a880eae..37572988 100644 --- a/app/controllers/panels_controller.rb +++ b/app/controllers/panels_controller.rb @@ -2,9 +2,11 @@ class PanelsController < ApplicationController layout 'test' if MagicNumber['test_layout'] if MagicNumber['run_mode'] == 0 before_filter :authenticate_user, :only => [:new, :edit, :create, :update, :destroy] + before_filter :authenticate_author, :only => [:new, :edit, :create, :update, :destroy] else before_filter :authenticate_reader, :only => [:index, :show] before_filter :authenticate_user, :only => [:new, :edit, :create, :update, :destroy] + before_filter :authenticate_author, :only => [:new, :edit, :create, :update, :destroy] end before_filter :authenticate_admin!, :only => [:list, :browse] @@ -22,7 +24,7 @@ class PanelsController < ApplicationController end def show - @panel = Panel.show(params[:id], [@author, @admin]) + @panel = Panel.show(params[:id], [@user, @admin]) respond_to do |format| format.html # show.html.erb diff --git a/app/controllers/pictures_controller.rb b/app/controllers/pictures_controller.rb index 12fc5f66..b8ab99dc 100644 --- a/app/controllers/pictures_controller.rb +++ b/app/controllers/pictures_controller.rb @@ -2,14 +2,16 @@ class PicturesController < ApplicationController layout 'test' if MagicNumber['test_layout'] if MagicNumber['run_mode'] == 0 before_filter :authenticate_user, :only => [] + before_filter :authenticate_author, :only => [] else before_filter :authenticate_user, :only => [] before_filter :authenticate_resource_reader, :only => [:show, :credit, :search] + before_filter :authenticate_author, :only => [] end before_filter :authenticate_admin!, :only => [:list, :browse] def show - @picture = Picture.show(params[:id], [@author, @admin, @demand_user]) + @picture = Picture.show(params[:id], [@user, @admin, @demand_user]) respond_to do |format| opt = {:type => @picture.mime_type, :disposition=>"inline"} @@ -22,7 +24,7 @@ class PicturesController < ApplicationController end def credit - @picture = Picture.show(params[:id], [@author, @admin, @demand_user]) + @picture = Picture.show(params[:id], [@user, @admin, @demand_user]) respond_to do |format| format.html { render :layout => false } # show.html.erb diff --git a/app/controllers/resource_pictures_controller.rb b/app/controllers/resource_pictures_controller.rb index 4f9479b9..322abfe8 100644 --- a/app/controllers/resource_pictures_controller.rb +++ b/app/controllers/resource_pictures_controller.rb @@ -2,11 +2,11 @@ class ResourcePicturesController < ApplicationController layout 'test' if MagicNumber['test_layout'] if MagicNumber['run_mode'] == 0 before_filter :authenticate_user, :only => [:new, :create, :update, :destroy] - before_filter :authenticate_artist, :only => [:new, :create, :destroy] + before_filter :authenticate_artist, :only => [:new, :create, :update, :destroy] else before_filter :authenticate_resource_reader, :only => [:index, :show, :credit] before_filter :authenticate_user, :only => [:new, :create, :update, :destroy] - before_filter :authenticate_artist, :only => [:new, :create, :destroy] + before_filter :authenticate_artist, :only => [:new, :create, :update, :destroy] end before_filter :authenticate_admin!, :only => [:list, :browse] @@ -26,7 +26,7 @@ class ResourcePicturesController < ApplicationController # GET /resource_pictures/1 # GET /resource_pictures/1.json def show - @resource_picture = ResourcePicture.show(params[:id], [@author, @admin, @demand_user]) + @resource_picture = ResourcePicture.show(params[:id], [@user, @admin, @demand_user]) respond_to do |format| opt = {:type => @resource_picture.mime_type, :disposition=>"inline"} @@ -39,7 +39,7 @@ class ResourcePicturesController < ApplicationController end def credit - @resource_picture = ResourcePicture.show(params[:id], @author) + @resource_picture = ResourcePicture.show(params[:id], [@user, @admin, @demand_user]) respond_to do |format| format.html { render :layout => false } # show.html.erb diff --git a/app/controllers/speech_balloon_templates_controller.rb b/app/controllers/speech_balloon_templates_controller.rb index 607554bd..051b9da8 100644 --- a/app/controllers/speech_balloon_templates_controller.rb +++ b/app/controllers/speech_balloon_templates_controller.rb @@ -22,7 +22,7 @@ class SpeechBalloonTemplatesController < ApplicationController # GET /speech_balloon_templates/1 # GET /speech_balloon_templates/1.json def show - @speech_balloon_template = SpeechBalloonTemplate.show(params[:id], [@author, @admin]) + @speech_balloon_template = SpeechBalloonTemplate.show(params[:id], [@user, @admin]) respond_to do |format| format.html # show.html.erb diff --git a/app/controllers/speech_balloons_controller.rb b/app/controllers/speech_balloons_controller.rb index 5d2d7117..c34dd277 100644 --- a/app/controllers/speech_balloons_controller.rb +++ b/app/controllers/speech_balloons_controller.rb @@ -2,9 +2,11 @@ class SpeechBalloonsController < ApplicationController layout 'test' if MagicNumber['test_layout'] if MagicNumber['run_mode'] == 0 before_filter :authenticate_user, :only => [] + before_filter :authenticate_author, :only => [] else before_filter :authenticate_reader, :only => [:index, :show] before_filter :authenticate_user, :only => [] + before_filter :authenticate_author, :only => [] end before_filter :authenticate_admin!, :only => [:list, :browse] @@ -20,7 +22,7 @@ class SpeechBalloonsController < ApplicationController end def show - @speech_balloon = SpeechBalloon.show(params[:id], [@author, @admin]) + @speech_balloon = SpeechBalloon.show(params[:id], [@user, @admin]) respond_to do |format| format.html # show.html.erb format.json { render json: @speech_balloon.to_json(SpeechBalloon.show_json_opt) } diff --git a/app/controllers/speeches_controller.rb b/app/controllers/speeches_controller.rb index 48141d36..1095fdb7 100644 --- a/app/controllers/speeches_controller.rb +++ b/app/controllers/speeches_controller.rb @@ -2,9 +2,11 @@ class SpeechesController < ApplicationController layout 'test' if MagicNumber['test_layout'] if MagicNumber['run_mode'] == 0 before_filter :authenticate_user, :only => [] + before_filter :authenticate_author, :only => [] else before_filter :authenticate_reader, :only => [:index, :show] before_filter :authenticate_user, :only => [] + before_filter :authenticate_author, :only => [] end before_filter :authenticate_admin!, :only => [:list, :browse] @@ -20,7 +22,7 @@ class SpeechesController < ApplicationController end def show - @speech = Speech.show(params[:id], [@author, @admin]) + @speech = Speech.show(params[:id], [@user, @admin]) respond_to do |format| format.html # show.html.erb format.json { render json: @speech.to_json(Speech.show_json_opt) } diff --git a/app/controllers/stories_controller.rb b/app/controllers/stories_controller.rb index ec4aefb4..7d129124 100644 --- a/app/controllers/stories_controller.rb +++ b/app/controllers/stories_controller.rb @@ -2,9 +2,11 @@ class StoriesController < ApplicationController layout 'test' if MagicNumber['test_layout'] if MagicNumber['run_mode'] == 0 before_filter :authenticate_user, :only => [:new, :create, :edit, :update, :destroy] + before_filter :authenticate_author, :only => [:new, :create, :edit, :update, :destroy] else before_filter :authenticate_reader, :only => [:index, :show, :comic] before_filter :authenticate_user, :only => [:new, :create, :edit, :update, :destroy] + before_filter :authenticate_author, :only => [:new, :create, :edit, :update, :destroy] end before_filter :authenticate_admin!, :only => [:list, :browse] @@ -20,7 +22,7 @@ class StoriesController < ApplicationController end def show - @story = Story.show(params[:id], [@author, @admin]) + @story = Story.show(params[:id], [@user, @admin]) respond_to do |format| format.html # show.html.erb @@ -29,7 +31,7 @@ class StoriesController < ApplicationController end def comic - @comic = Comic.show(params[:id], [@author, @admin]) + @comic = Comic.show(params[:id], [@user, @admin]) cnt = Story.count(:conditions => ['comic_id = ?', @comic.id]).to_i @offset = Story.offset cnt, params[:offset] @panel_count = Story.panel_count cnt, params[:count] diff --git a/app/controllers/system_pictures_controller.rb b/app/controllers/system_pictures_controller.rb index 8523ed02..ae6a671e 100644 --- a/app/controllers/system_pictures_controller.rb +++ b/app/controllers/system_pictures_controller.rb @@ -2,9 +2,11 @@ class SystemPicturesController < ApplicationController layout 'test' if MagicNumber['test_layout'] if MagicNumber['run_mode'] == 0 before_filter :authenticate_user, :only => [] + before_filter :authenticate_author, :only => [] else before_filter :authenticate_resource_reader, :only => [:index, :show] before_filter :authenticate_user, :only => [] + before_filter :authenticate_author, :only => [] end before_filter :authenticate_admin!, :only => [:list, :browse, :new, :create] @@ -24,7 +26,7 @@ class SystemPicturesController < ApplicationController # GET /system_pictures/1 # GET /system_pictures/1.json def show - @system_picture = SystemPicture.show(params[:id], @author) + @system_picture = SystemPicture.show(params[:id], [@user, @admin, @demand_user]) respond_to do |format| opt = {:type => @system_picture.mime_type, :disposition=>"inline"} diff --git a/spec/controllers/artists_controller_spec.rb b/spec/controllers/artists_controller_spec.rb index 2a6c289e..d1f7a3a2 100644 --- a/spec/controllers/artists_controller_spec.rb +++ b/spec/controllers/artists_controller_spec.rb @@ -86,7 +86,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -111,7 +111,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限はないが管理者権限があるとき' do + context 'ユーザ権限はないが管理者権限があるとき' do before do sign_out @user sign_in @admin @@ -121,7 +121,7 @@ if MagicNumber['run_mode'] == 1 response.should be_success end end - context '作家権限はないが借手権限があるとき' do + context 'ユーザ権限はないが借手権限があるとき' do before do sign_out @user sign_in @demand_user @@ -131,6 +131,15 @@ if MagicNumber['run_mode'] == 1 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 @@ -173,7 +182,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -198,7 +207,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限はないが管理者権限があるとき' do + context 'ユーザ権限はないが管理者権限があるとき' do before do sign_out @user sign_in @admin @@ -208,7 +217,7 @@ if MagicNumber['run_mode'] == 1 response.should be_success end end - context '作家権限はないが借手権限があるとき' do + context 'ユーザ権限はないが借手権限があるとき' do before do sign_out @user sign_in @demand_user @@ -218,6 +227,15 @@ if MagicNumber['run_mode'] == 1 response.should be_success end end + context 'ユーザだが作家登録していないとき' do + before do + @author.destroy + end + it 'ステータスコード200 OKを返す' do + get :show, :id => @artist.id + response.should be_success + end + end =begin context '対象作家がないとき' do context 'html形式' do @@ -302,7 +320,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -337,7 +355,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限はないが管理者権限があるとき' do + context 'ユーザ権限はないが管理者権限があるとき' do before do sign_out @user sign_in @admin @@ -353,6 +371,21 @@ if MagicNumber['run_mode'] == 1 end end end + context 'ユーザだが作家登録していないとき' do + before do + @author.destroy + end + context 'html形式' do + it 'ステータスコード302 Foundを返す' do + get :new + response.status.should eq 302 + end + it '作家登録ページへ遷移する' do + get :new + response.body.should redirect_to new_author_path + end + end + end end describe '新規作成に於いて' do @@ -417,7 +450,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -442,7 +475,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限はないが管理者権限があるとき' do + context 'ユーザ権限はないが管理者権限があるとき' do before do sign_out @user sign_in @admin @@ -458,6 +491,21 @@ if MagicNumber['run_mode'] == 1 end end end + context 'ユーザだが作家登録していないとき' do + before do + @author.destroy + end + context 'html形式' do + it 'ステータスコード302 Foundを返す' do + post :create, :artist => @attr + response.status.should eq 302 + end + it '作家登録ページへ遷移する' do + post :create, :artist => @attr + response.body.should redirect_to new_author_path + end + end + end context '検証、保存に失敗した' do before do Artist.any_instance.stub(:save).and_return(false) @@ -520,7 +568,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -545,7 +593,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限はないが管理者権限があるとき' do + context 'ユーザ権限はないが管理者権限があるとき' do before do sign_out @user sign_in @admin @@ -561,6 +609,21 @@ if MagicNumber['run_mode'] == 1 end end end + context 'ユーザだが作家登録していないとき' do + before do + @author.destroy + end + context 'html形式' do + it 'ステータスコード302 Foundを返す' do + get :edit, :id => @artist.id + response.status.should eq 302 + end + it '作家登録ページへ遷移する' do + get :edit, :id => @artist.id + response.body.should redirect_to new_author_path + end + end + end end describe '更新に於いて' do @@ -621,7 +684,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -642,7 +705,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限はないが管理者権限があるとき' do + context 'ユーザ権限はないが管理者権限があるとき' do before do sign_out @user sign_in @admin @@ -658,6 +721,21 @@ if MagicNumber['run_mode'] == 1 end end end + context 'ユーザだが作家登録していないとき' do + before do + @author.destroy + end + context 'html形式' do + it 'ステータスコード302 Foundを返す' do + put :update, :id => @artist.id, :artist => @attr + response.status.should eq 302 + end + it '作家登録ページへ遷移する' do + put :update, :id => @artist.id, :artist => @attr + response.body.should redirect_to new_author_path + end + end + end context '検証、保存に失敗したとき' do before do Artist.any_instance.stub(:save).and_return(false) @@ -710,7 +788,7 @@ else end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -756,7 +834,7 @@ else end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -826,7 +904,7 @@ else end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -893,7 +971,7 @@ else end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -943,7 +1021,7 @@ else end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -1000,7 +1078,7 @@ else end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end diff --git a/spec/controllers/authors_controller_spec.rb b/spec/controllers/authors_controller_spec.rb index dac4d6d1..b0e68170 100644 --- a/spec/controllers/authors_controller_spec.rb +++ b/spec/controllers/authors_controller_spec.rb @@ -86,7 +86,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -111,7 +111,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限はないが管理者権限があるとき' do + context 'ユーザ権限はないが管理者権限があるとき' do before do sign_out @user sign_in @admin @@ -121,6 +121,15 @@ if MagicNumber['run_mode'] == 1 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 @@ -165,7 +174,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -190,7 +199,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限はないが管理者権限があるとき' do + context 'ユーザ権限はないが管理者権限があるとき' do before do sign_out @user sign_in @admin @@ -200,6 +209,15 @@ if MagicNumber['run_mode'] == 1 response.should be_success end end + context 'ユーザだが作家登録していないとき' do + before do + @author.destroy + end + it 'ステータスコード200 OKを返す' do + get :show, :id => @author.id + response.should be_success + end + end =begin context '対象作家がないとき' do context 'html形式' do @@ -285,7 +303,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @new_user end @@ -320,7 +338,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限はないが管理者権限があるとき' do + context 'ユーザ権限はないが管理者権限があるとき' do before do sign_out @user sign_in @admin @@ -336,6 +354,15 @@ if MagicNumber['run_mode'] == 1 end end end + context 'ユーザだが作家登録していないとき' do + before do + @author.destroy + end + it 'ステータスコード200 OKを返す' do + get :new + response.should be_success + end + end end describe '新規作成に於いて' do @@ -401,7 +428,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @new_user end @@ -426,7 +453,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限はないが管理者権限があるとき' do + context 'ユーザ権限はないが管理者権限があるとき' do before do sign_out @user sign_in @admin @@ -505,7 +532,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -530,7 +557,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限はないが管理者権限があるとき' do + context 'ユーザ権限はないが管理者権限があるとき' do before do sign_out @user sign_in @admin @@ -546,6 +573,23 @@ if MagicNumber['run_mode'] == 1 end end end + context 'ユーザだが作家登録していないとき' do + before do + @other_user = FactoryGirl.create( :user_yas) + @other_author = FactoryGirl.create :author, :user_id => @other_user.id + @author.destroy + end + context 'html形式' do + it 'ステータスコード302 Foundを返す' do + get :edit, :id => @other_author.id + response.status.should eq 302 + end + it '作家登録ページへ遷移する' do + get :edit, :id => @other_author.id + response.body.should redirect_to new_author_path + end + end + end end describe '更新に於いて' do @@ -609,7 +653,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -630,7 +674,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限はないが管理者権限があるとき' do + context 'ユーザ権限はないが管理者権限があるとき' do before do sign_out @user sign_in @admin @@ -646,6 +690,23 @@ if MagicNumber['run_mode'] == 1 end end end + context 'ユーザだが作家登録していないとき' do + before do + @other_user = FactoryGirl.create( :user_yas) + @other_author = FactoryGirl.create :author, :user_id => @other_user.id + @author.destroy + end + context 'html形式' do + it 'ステータスコード302 Foundを返す' do + get :update, :id => @other_author.id + response.status.should eq 302 + end + it '作家登録ページへ遷移する' do + get :update, :id => @other_author.id + response.body.should redirect_to new_author_path + end + end + end context '検証、保存に失敗したとき' do before do Author.any_instance.stub(:save).and_return(false) @@ -698,7 +759,7 @@ else end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -744,7 +805,7 @@ else end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -815,7 +876,7 @@ else end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @new_user end @@ -879,7 +940,7 @@ else end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @new_user end @@ -929,7 +990,7 @@ else end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -991,7 +1052,7 @@ else end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end diff --git a/spec/controllers/balloons_controller_spec.rb b/spec/controllers/balloons_controller_spec.rb index fc48e410..381bc1a3 100644 --- a/spec/controllers/balloons_controller_spec.rb +++ b/spec/controllers/balloons_controller_spec.rb @@ -93,7 +93,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -118,7 +118,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限はないが管理者権限があるとき' do + context 'ユーザ権限はないが管理者権限があるとき' do before do sign_out @user sign_in @admin @@ -128,6 +128,15 @@ if MagicNumber['run_mode'] == 1 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 @@ -175,7 +184,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -200,7 +209,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限はないが管理者権限があるとき' do + context 'ユーザ権限はないが管理者権限があるとき' do before do sign_out @user sign_in @admin @@ -210,6 +219,15 @@ if MagicNumber['run_mode'] == 1 response.should be_success end end + context 'ユーザだが作家登録していないとき' do + before do + @author.destroy + end + it 'ステータスコード200 OKを返す' do + get :show, :id => @balloon.id + response.should be_success + end + end end else @@ -239,7 +257,7 @@ else end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -288,7 +306,7 @@ else end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end diff --git a/spec/controllers/comics_controller_spec.rb b/spec/controllers/comics_controller_spec.rb index 9f69a0d1..087107f2 100644 --- a/spec/controllers/comics_controller_spec.rb +++ b/spec/controllers/comics_controller_spec.rb @@ -85,7 +85,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -110,7 +110,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限はないが管理者権限があるとき' do + context 'ユーザ権限はないが管理者権限があるとき' do before do sign_out @user sign_in @admin @@ -120,6 +120,17 @@ if MagicNumber['run_mode'] == 1 response.should be_success end end + context 'ユーザだが作家登録していないとき' do + before do + @author.destroy + end + context 'html形式' do + it 'ステータスコード200 OKを返す' do + get :index + response.should be_success + end + end + end end describe '単体表示に於いて' do @@ -164,7 +175,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -189,7 +200,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限はないが管理者権限があるとき' do + context 'ユーザ権限はないが管理者権限があるとき' do before do sign_out @user sign_in @admin @@ -199,6 +210,17 @@ if MagicNumber['run_mode'] == 1 response.should be_success end end + context 'ユーザだが作家登録していないとき' do + before do + @author.destroy + end + context 'html形式' do + it 'ステータスコード200 OKを返す' do + get :show, :id => @comic.id + response.should be_success + end + end + end =begin context '対象コミックがないとき' do context 'html形式' do @@ -302,7 +324,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -337,7 +359,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限はないが管理者権限があるとき' do + context 'ユーザ権限はないが管理者権限があるとき' do before do sign_out @user sign_in @admin @@ -353,6 +375,21 @@ if MagicNumber['run_mode'] == 1 end end end + context 'ユーザだが作家登録していないとき' do + before do + @author.destroy + end + context 'html形式' do + it 'ステータスコード302 Foundを返す' do + get :new, @attr + response.status.should eq 302 + end + it '作家登録ページへ遷移する' do + get :new, @attr + response.body.should redirect_to new_author_path + end + end + end end describe '新規作成に於いて' do @@ -414,7 +451,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -439,7 +476,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限はないが管理者権限があるとき' do + context 'ユーザ権限はないが管理者権限があるとき' do before do sign_out @user sign_in @admin @@ -455,6 +492,21 @@ if MagicNumber['run_mode'] == 1 end end end + context 'ユーザだが作家登録していないとき' do + before do + @author.destroy + end + context 'html形式' do + it 'ステータスコード302 Foundを返す' do + post :create, :comic => @attr + response.status.should eq 302 + end + it '作家登録ページへ遷移する' do + post :create, :comic => @attr + response.body.should redirect_to new_author_path + end + end + end context '検証、保存に失敗した' do before do Comic.any_instance.stub(:save).and_return(false) @@ -518,7 +570,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -543,7 +595,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限はないが管理者権限があるとき' do + context 'ユーザ権限はないが管理者権限があるとき' do before do sign_out @user sign_in @admin @@ -559,6 +611,21 @@ if MagicNumber['run_mode'] == 1 end end end + context 'ユーザだが作家登録していないとき' do + before do + @author.destroy + end + context 'html形式' do + it 'ステータスコード302 Foundを返す' do + get :edit, :id => @comic.id + response.status.should eq 302 + end + it '作家登録ページへ遷移する' do + get :edit, :id => @comic.id + response.body.should redirect_to new_author_path + end + end + end end describe '更新に於いて' do @@ -620,7 +687,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -641,7 +708,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限はないが管理者権限があるとき' do + context 'ユーザ権限はないが管理者権限があるとき' do before do sign_out @user sign_in @admin @@ -657,6 +724,21 @@ if MagicNumber['run_mode'] == 1 end end end + context 'ユーザだが作家登録していないとき' do + before do + @author.destroy + end + context 'html形式' do + it 'ステータスコード302 Foundを返す' do + put :update, :id => @comic.id, :comic => @attr + response.status.should eq 302 + end + it '作家登録ページへ遷移する' do + put :update, :id => @comic.id, :comic => @attr + response.body.should redirect_to new_author_path + end + end + end context '検証、保存に失敗したとき' do before do Comic.any_instance.stub(:save).and_return(false) @@ -741,7 +823,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -762,7 +844,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限はないが管理者権限があるとき' do + context 'ユーザ権限はないが管理者権限があるとき' do before do sign_out @user sign_in @admin @@ -778,6 +860,21 @@ if MagicNumber['run_mode'] == 1 end end end + context 'ユーザだが作家登録していないとき' do + before do + @author.destroy + end + context 'html形式' do + it 'ステータスコード302 Foundを返す' do + delete :destroy, :id => @comic.id + response.status.should eq 302 + end + it '作家登録ページへ遷移する' do + delete :destroy, :id => @comic.id + response.body.should redirect_to new_author_path + end + end + end context '削除に失敗したとき' do before do Comic.any_instance.stub(:destroy_with_story).and_return(false) @@ -830,7 +927,7 @@ else end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -877,7 +974,7 @@ else end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -946,7 +1043,7 @@ else end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -1013,7 +1110,7 @@ else end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -1064,7 +1161,7 @@ else end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -1122,7 +1219,7 @@ else end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -1172,7 +1269,7 @@ else end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end diff --git a/spec/controllers/ground_colors_controller_spec.rb b/spec/controllers/ground_colors_controller_spec.rb index fb689b8f..be486366 100644 --- a/spec/controllers/ground_colors_controller_spec.rb +++ b/spec/controllers/ground_colors_controller_spec.rb @@ -90,7 +90,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -115,7 +115,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限はないが管理者権限があるとき' do + context 'ユーザ権限はないが管理者権限があるとき' do before do sign_out @user sign_in @admin @@ -125,6 +125,15 @@ if MagicNumber['run_mode'] == 1 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 @@ -170,7 +179,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -195,7 +204,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限はないが管理者権限があるとき' do + context 'ユーザ権限はないが管理者権限があるとき' do before do sign_out @user sign_in @admin @@ -205,6 +214,15 @@ if MagicNumber['run_mode'] == 1 response.should be_success end end + context 'ユーザだが作家登録していないとき' do + before do + @author.destroy + end + it 'ステータスコード200 OKを返す' do + get :show, :id => @gc.id + response.should be_success + end + end end else @@ -232,7 +250,7 @@ else end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -279,7 +297,7 @@ else end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end diff --git a/spec/controllers/ground_pictures_controller_spec.rb b/spec/controllers/ground_pictures_controller_spec.rb index 10b68b3b..aaf392e8 100644 --- a/spec/controllers/ground_pictures_controller_spec.rb +++ b/spec/controllers/ground_pictures_controller_spec.rb @@ -92,7 +92,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -117,7 +117,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限はないが管理者権限があるとき' do + context 'ユーザ権限はないが管理者権限があるとき' do before do sign_out @user sign_in @admin @@ -127,6 +127,15 @@ if MagicNumber['run_mode'] == 1 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 @@ -172,7 +181,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -197,7 +206,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限はないが管理者権限があるとき' do + context 'ユーザ権限はないが管理者権限があるとき' do before do sign_out @user sign_in @admin @@ -207,6 +216,15 @@ if MagicNumber['run_mode'] == 1 response.should be_success end end + context 'ユーザだが作家登録していないとき' do + before do + @author.destroy + end + it 'ステータスコード200 OKを返す' do + get :show, :id => @gp.id + response.should be_success + end + end end else @@ -234,7 +252,7 @@ else end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -281,7 +299,7 @@ else end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end diff --git a/spec/controllers/home_controller_spec.rb b/spec/controllers/home_controller_spec.rb index 292308c1..feba48d5 100644 --- a/spec/controllers/home_controller_spec.rb +++ b/spec/controllers/home_controller_spec.rb @@ -742,9 +742,10 @@ if MagicNumber['run_mode'] == 1 end end context 'json形式' do - it '応答メッセージにUnauthorizedを返す' do - get :resource_picture, :format => :json - response.message.should match(/Unauthorized/) + it '例外403 forbiddenを返す' do + lambda{ + get :resource_picture, :format => :json + }.should raise_error(ActiveRecord::Forbidden) end end end @@ -1115,7 +1116,7 @@ else end context '作家が絵師でないとき' do before do - Author.any_instance.stub(:artist?).and_return(false) + @artist.destroy end context 'html形式' do it 'ステータスコード302 Foundを返す' do diff --git a/spec/controllers/original_pictures_controller_spec.rb b/spec/controllers/original_pictures_controller_spec.rb index b28ba4d0..fd6c3419 100644 --- a/spec/controllers/original_pictures_controller_spec.rb +++ b/spec/controllers/original_pictures_controller_spec.rb @@ -89,7 +89,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -114,7 +114,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限はないが管理者権限があるとき' do + context 'ユーザ権限はないが管理者権限があるとき' do before do sign_out @user sign_in @admin @@ -130,9 +130,9 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家が絵師でないとき' do + context 'ユーザが絵師でないとき' do before do - Author.any_instance.stub(:artist?).and_return(false) + @artist.destroy end context 'html形式' do it 'ステータスコード302 Foundを返す' do @@ -145,9 +145,10 @@ if MagicNumber['run_mode'] == 1 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 @@ -254,7 +255,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -279,7 +280,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限はないが管理者権限があるとき' do + context 'ユーザ権限はないが管理者権限があるとき' do before do sign_out @user sign_in @admin @@ -289,25 +290,13 @@ if MagicNumber['run_mode'] == 1 response.should be_success end end - context '作家が絵師でないとき' do + context 'ユーザが絵師でないとき' do before do - Author.any_instance.stub(:artist?).and_return(false) + @artist.destroy 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 - end - context 'json形式' do - it '応答メッセージにUnauthorizedを返す' do - get :show, :id => @pic.id, :format => :json - response.message.should match(/Unauthorized/) - end + it 'ステータスコード200 OKを返す' do + get :show, :id => @pic.id + response.should be_success end end =begin @@ -402,7 +391,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -427,7 +416,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限はないが管理者権限があるとき' do + context 'ユーザ権限はないが管理者権限があるとき' do before do sign_out @user sign_in @admin @@ -437,25 +426,13 @@ if MagicNumber['run_mode'] == 1 response.should be_success end end - context '作家が絵師でないとき' do + context 'ユーザが絵師でないとき' do before do - Author.any_instance.stub(:artist?).and_return(false) + @artist.destroy 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 - end - context 'json形式' do - it '応答メッセージにUnauthorizedを返す' do - get :history, :id => @op.id, :format => :json - response.message.should match(/Unauthorized/) - end + it 'ステータスコード200 OKを返す' do + get :history, :id => @op.id + response.should be_success end end end @@ -504,7 +481,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -529,7 +506,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限はないが管理者権限があるとき' do + context 'ユーザ権限はないが管理者権限があるとき' do before do sign_out @user sign_in @admin @@ -545,9 +522,9 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家が絵師でないとき' do + context 'ユーザが絵師でないとき' do before do - Author.any_instance.stub(:artist?).and_return(false) + @artist.destroy end context 'html形式' do it 'ステータスコード302 Foundを返す' do @@ -559,20 +536,11 @@ if MagicNumber['run_mode'] == 1 response.should redirect_to new_artist_path end end - context 'js形式' do - it 'ステータスコード200 Okを返す' do - get :new, :format => :js - response.status.should eq 200 - end - it '絵師登録部分テンプレートartists/new.jsを描画する' do - get :new, :format => :js - response.should render_template("artists/new") - 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 @@ -651,7 +619,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -679,7 +647,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限はないが管理者権限があるとき' do + context 'ユーザ権限はないが管理者権限があるとき' do before do sign_out @user sign_in @admin @@ -695,9 +663,9 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家が絵師でないとき' do + context 'ユーザが絵師でないとき' do before do - Author.any_instance.stub(:artist?).and_return(false) + @artist.destroy end context 'html形式' do it 'ステータスコード302 Foundを返す' do @@ -713,9 +681,11 @@ if MagicNumber['run_mode'] == 1 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 @@ -819,7 +789,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -844,7 +814,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限はないが管理者権限があるとき' do + context 'ユーザ権限はないが管理者権限があるとき' do before do sign_out @user sign_in @admin @@ -860,9 +830,9 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家が絵師でないとき' do + context 'ユーザが絵師でないとき' do before do - Author.any_instance.stub(:artist?).and_return(false) + @artist.destroy end context 'html形式' do it 'ステータスコード302 Foundを返す' do @@ -874,14 +844,11 @@ if MagicNumber['run_mode'] == 1 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 @@ -947,7 +914,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -972,7 +939,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限はないが管理者権限があるとき' do + context 'ユーザ権限はないが管理者権限があるとき' do before do sign_out @user sign_in @admin @@ -988,9 +955,9 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家が絵師でないとき' do + context 'ユーザが絵師でないとき' do before do - Author.any_instance.stub(:artist?).and_return(false) + @artist.destroy end context 'html形式' do it 'ステータスコード302 Foundを返す' do @@ -1003,9 +970,10 @@ if MagicNumber['run_mode'] == 1 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 @@ -1111,7 +1079,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -1132,7 +1100,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限はないが管理者権限があるとき' do + context 'ユーザ権限はないが管理者権限があるとき' do before do sign_out @user sign_in @admin @@ -1148,9 +1116,9 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家が絵師でないとき' do + context 'ユーザが絵師でないとき' do before do - Author.any_instance.stub(:artist?).and_return(false) + @artist.destroy end context 'html形式' do it 'ステータスコード302 Foundを返す' do @@ -1163,9 +1131,10 @@ if MagicNumber['run_mode'] == 1 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 @@ -1221,7 +1190,7 @@ else end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -1272,7 +1241,7 @@ else end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -1326,7 +1295,7 @@ else end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -1385,7 +1354,7 @@ else end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -1447,7 +1416,7 @@ else end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -1501,7 +1470,7 @@ else end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -1562,7 +1531,7 @@ else end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -1587,28 +1556,6 @@ else 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) @@ -1685,7 +1632,7 @@ else end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end diff --git a/spec/controllers/panel_colors_controller_spec.rb b/spec/controllers/panel_colors_controller_spec.rb index e77f91af..d13900d1 100644 --- a/spec/controllers/panel_colors_controller_spec.rb +++ b/spec/controllers/panel_colors_controller_spec.rb @@ -89,7 +89,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -114,7 +114,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限はないが管理者権限があるとき' do + context 'ユーザ権限はないが管理者権限があるとき' do before do sign_out @user sign_in @admin @@ -124,6 +124,15 @@ if MagicNumber['run_mode'] == 1 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 @@ -169,7 +178,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -194,7 +203,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限はないが管理者権限があるとき' do + context 'ユーザ権限はないが管理者権限があるとき' do before do sign_out @user sign_in @admin @@ -204,6 +213,15 @@ if MagicNumber['run_mode'] == 1 response.should be_success end end + context 'ユーザだが作家登録していないとき' do + before do + @author.destroy + end + it 'ステータスコード200 OKを返す' do + get :show, :id => @pc.id + response.should be_success + end + end end else @@ -231,7 +249,7 @@ else end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -278,7 +296,7 @@ else end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end diff --git a/spec/controllers/panel_pictures_controller_spec.rb b/spec/controllers/panel_pictures_controller_spec.rb index 5e483517..043c31c2 100644 --- a/spec/controllers/panel_pictures_controller_spec.rb +++ b/spec/controllers/panel_pictures_controller_spec.rb @@ -93,7 +93,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -118,7 +118,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限はないが管理者権限があるとき' do + context 'ユーザ権限はないが管理者権限があるとき' do before do sign_out @user sign_in @admin @@ -128,6 +128,15 @@ if MagicNumber['run_mode'] == 1 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 @@ -173,7 +182,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -198,7 +207,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限はないが管理者権限があるとき' do + context 'ユーザ権限はないが管理者権限があるとき' do before do sign_out @user sign_in @admin @@ -208,6 +217,15 @@ if MagicNumber['run_mode'] == 1 response.should be_success end end + context 'ユーザだが作家登録していないとき' do + before do + @author.destroy + end + it 'ステータスコード200 OKを返す' do + get :show, :id => @panel_picture.id + response.should be_success + end + end end else @@ -235,7 +253,7 @@ else end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -282,7 +300,7 @@ else end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end diff --git a/spec/controllers/panels_controller_spec.rb b/spec/controllers/panels_controller_spec.rb index 1463f156..0231c39f 100644 --- a/spec/controllers/panels_controller_spec.rb +++ b/spec/controllers/panels_controller_spec.rb @@ -88,7 +88,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -113,7 +113,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限はないが管理者権限があるとき' do + context 'ユーザ権限はないが管理者権限があるとき' do before do sign_out @user sign_in @admin @@ -123,12 +123,21 @@ if MagicNumber['run_mode'] == 1 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 @panel = FactoryGirl.create :panel, :author_id => @user.author.id - Panel.stub(:show).with(@panel.id.to_s, [@author, nil]).and_return(@panel) + Panel.stub(:show).with(@panel.id.to_s, [@user, nil]).and_return(@panel) Panel.stub(:show).with(@panel.id.to_s, [nil, @admin]).and_return(@panel) sign_in @user end @@ -171,7 +180,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -196,7 +205,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限はないが管理者権限があるとき' do + context 'ユーザ権限はないが管理者権限があるとき' do before do sign_out @user sign_in @admin @@ -206,6 +215,15 @@ if MagicNumber['run_mode'] == 1 response.should be_success end end + context 'ユーザだが作家登録していないとき' do + before do + @author.destroy + end + it 'ステータスコード200 OKを返す' do + get :show, :id => @panel.id + response.should be_success + end + end =begin context '対象コマがないとき' do context 'html形式' do @@ -310,7 +328,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -335,7 +353,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限はないが管理者権限があるとき' do + context 'ユーザ権限はないが管理者権限があるとき' do before do sign_out @user sign_in @admin @@ -351,6 +369,21 @@ if MagicNumber['run_mode'] == 1 end end end + context 'ユーザだが作家登録していないとき' do + before do + @author.destroy + end + context 'html形式' do + it 'ステータスコード302 Foundを返す' do + get :new + response.status.should eq 302 + end + it '作家登録ページへ遷移する' do + get :new + response.body.should redirect_to new_author_path + end + end + end end describe '新規作成に於いて' do @@ -426,7 +459,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -451,7 +484,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限はないが管理者権限があるとき' do + context 'ユーザ権限はないが管理者権限があるとき' do before do sign_out @user sign_in @admin @@ -467,6 +500,21 @@ if MagicNumber['run_mode'] == 1 end end end + context 'ユーザだが作家登録していないとき' do + before do + @author.destroy + end + context 'html形式' do + it 'ステータスコード302 Foundを返す' do + post :create, :panel => @attr + response.status.should eq 302 + end + it '作家登録ページへ遷移する' do + post :create, :panel => @attr + response.body.should redirect_to new_author_path + end + end + end context '検証、保存に失敗した' do before do Panel.any_instance.stub(:store).and_return(false) @@ -534,7 +582,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -559,7 +607,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限はないが管理者権限があるとき' do + context 'ユーザ権限はないが管理者権限があるとき' do before do sign_out @user sign_in @admin @@ -575,6 +623,21 @@ if MagicNumber['run_mode'] == 1 end end end + context 'ユーザだが作家登録していないとき' do + before do + @author.destroy + end + context 'html形式' do + it 'ステータスコード302 Foundを返す' do + get :edit, :id => @panel.id + response.status.should eq 302 + end + it '作家登録ページへ遷移する' do + get :edit, :id => @panel.id + response.body.should redirect_to new_author_path + end + end + end end describe '更新に於いて' do @@ -645,7 +708,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -670,7 +733,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限はないが管理者権限があるとき' do + context 'ユーザ権限はないが管理者権限があるとき' do before do sign_out @user sign_in @admin @@ -686,6 +749,21 @@ if MagicNumber['run_mode'] == 1 end end end + context 'ユーザだが作家登録していないとき' do + before do + @author.destroy + end + context 'html形式' do + it 'ステータスコード302 Foundを返す' do + put :update, :id => @panel.id, :panel => @attr + response.status.should eq 302 + end + it '作家登録ページへ遷移する' do + put :update, :id => @panel.id, :panel => @attr + response.body.should redirect_to new_author_path + end + end + end context '検証、保存に失敗した' do before do Panel.any_instance.stub(:store).and_return(false) @@ -754,7 +832,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -779,7 +857,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限はないが管理者権限があるとき' do + context 'ユーザ権限はないが管理者権限があるとき' do before do sign_out @user sign_in @admin @@ -795,6 +873,21 @@ if MagicNumber['run_mode'] == 1 end end end + context 'ユーザだが作家登録していないとき' do + before do + @author.destroy + end + context 'html形式' do + it 'ステータスコード302 Foundを返す' do + delete :destroy, :id => @panel.id + response.status.should eq 302 + end + it '作家登録ページへ遷移する' do + delete :destroy, :id => @panel.id + response.body.should redirect_to new_author_path + end + end + end context '削除に失敗したとき' do before do Panel.any_instance.stub(:destroy_with_elements).and_return(false) @@ -857,7 +950,7 @@ else end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -887,8 +980,9 @@ else describe '単体表示に於いて' do before do @panel = FactoryGirl.create :panel, :author_id => @user.author.id - Panel.stub(:show).with(@panel.id.to_s, @author).and_return(@panel) - Panel.stub(:show).with(@panel.id.to_s, nil).and_return(@panel) + Panel.stub(:show).with(@panel.id.to_s, [nil, nil]).and_return(@panel) + Panel.stub(:show).with(@panel.id.to_s, [@user, nil]).and_return(@panel) + Panel.stub(:show).with(@panel.id.to_s, [nil, @admin]).and_return(@panel) sign_in @user end context 'つつがなく終わるとき' do @@ -913,7 +1007,7 @@ else end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -987,7 +1081,7 @@ else end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -1045,7 +1139,7 @@ else end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -1100,7 +1194,7 @@ else end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -1159,7 +1253,7 @@ else end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -1210,7 +1304,7 @@ else end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end diff --git a/spec/controllers/pictures_controller_spec.rb b/spec/controllers/pictures_controller_spec.rb index 23dbd0f7..b7cd668b 100644 --- a/spec/controllers/pictures_controller_spec.rb +++ b/spec/controllers/pictures_controller_spec.rb @@ -20,7 +20,7 @@ if MagicNumber['run_mode'] == 1 before do @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id sign_in @user - Picture.stub(:show).with(@p.id.to_s, [@author, nil, nil]).and_return(@p) + Picture.stub(:show).with(@p.id.to_s, [@user, nil, nil]).and_return(@p) Picture.stub(:show).with(@p.id.to_s, [nil, @admin, nil]).and_return(@p) Picture.stub(:show).with(@p.id.to_s, [nil, nil, @demand_user]).and_return(@p) end @@ -92,7 +92,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -117,7 +117,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限はないが管理者権限があるとき' do + context 'ユーザ権限はないが管理者権限があるとき' do before do sign_out @user sign_in @admin @@ -127,7 +127,7 @@ if MagicNumber['run_mode'] == 1 response.should be_success end end - context '作家権限はないが借手権限があるとき' do + context 'ユーザ権限はないが借手権限があるとき' do before do sign_out @user sign_in @demand_user @@ -137,6 +137,15 @@ if MagicNumber['run_mode'] == 1 response.should be_success end end + context 'ユーザだが作家登録していないとき' do + before do + @author.destroy + end + it 'ステータスコード200 OKを返す' do + get :show, :id => @p.id + response.should be_success + end + end =begin context '対象素材がないとき' do before do @@ -184,7 +193,7 @@ if MagicNumber['run_mode'] == 1 before do @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id sign_in @user - Picture.stub(:show).with(@p.id.to_s, [@author, nil, nil]).and_return(@p) + Picture.stub(:show).with(@p.id.to_s, [@user, nil, nil]).and_return(@p) Picture.stub(:show).with(@p.id.to_s, [nil, @admin, nil]).and_return(@p) Picture.stub(:show).with(@p.id.to_s, [nil, nil, @demand_user]).and_return(@p) end @@ -220,7 +229,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -245,7 +254,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限はないが管理者権限があるとき' do + context 'ユーザ権限はないが管理者権限があるとき' do before do sign_out @user sign_in @admin @@ -255,7 +264,7 @@ if MagicNumber['run_mode'] == 1 response.should be_success end end - context '作家権限はないが借手権限があるとき' do + context 'ユーザ権限はないが借手権限があるとき' do before do sign_out @user sign_in @demand_user @@ -265,6 +274,15 @@ if MagicNumber['run_mode'] == 1 response.should be_success end end + context 'ユーザだが作家登録していないとき' do + before do + @author.destroy + end + it 'ステータスコード200 OKを返す' do + get :credit, :id => @p.id + response.should be_success + end + end =begin context '対象素材がないとき' do before do @@ -337,7 +355,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -362,7 +380,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限はないが管理者権限があるとき' do + context 'ユーザ権限はないが管理者権限があるとき' do before do sign_out @user sign_in @admin @@ -372,7 +390,7 @@ if MagicNumber['run_mode'] == 1 response.should be_success end end - context '作家権限はないが借手権限があるとき' do + context 'ユーザ権限はないが借手権限があるとき' do before do sign_out @user sign_in @demand_user @@ -382,6 +400,15 @@ if MagicNumber['run_mode'] == 1 response.should be_success end end + context 'ユーザだが作家登録していないとき' do + before do + @author.destroy + end + it 'ステータスコード200 OKを返す' do + get :search, :md5 => 'a'*32 + response.should be_success + end + end end else @@ -389,8 +416,10 @@ else before do @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id sign_in @user - Picture.stub(:show).with(@p.id.to_s, @author).and_return(@p) - Picture.stub(:show).with(@p.id.to_s, nil).and_return(@p) + Picture.stub(:show).with(@p.id.to_s, [nil, nil, nil]).and_return(@p) + Picture.stub(:show).with(@p.id.to_s, [@user, nil, nil]).and_return(@p) + Picture.stub(:show).with(@p.id.to_s, [nil, @admin, nil]).and_return(@p) + Picture.stub(:show).with(@p.id.to_s, [nil, nil, @demand_user]).and_return(@p) end context 'つつがなく終わるとき as json' do it 'ステータスコード200 OKを返す' do @@ -410,7 +439,7 @@ else end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -437,8 +466,10 @@ else before do @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id sign_in @user - Picture.stub(:show).with(@p.id.to_s, @author).and_return(@p) - Picture.stub(:show).with(@p.id.to_s, nil).and_return(@p) + Picture.stub(:show).with(@p.id.to_s, [nil, nil, nil]).and_return(@p) + Picture.stub(:show).with(@p.id.to_s, [@user, nil, nil]).and_return(@p) + Picture.stub(:show).with(@p.id.to_s, [nil, @admin, nil]).and_return(@p) + Picture.stub(:show).with(@p.id.to_s, [nil, nil, @demand_user]).and_return(@p) end context 'つつがなく終わるとき' do it 'ステータスコード200 OKを返す' do @@ -458,7 +489,7 @@ else end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -509,7 +540,7 @@ else end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end diff --git a/spec/controllers/resource_pictures_controller_spec.rb b/spec/controllers/resource_pictures_controller_spec.rb index 1835a8d7..0115ac8e 100644 --- a/spec/controllers/resource_pictures_controller_spec.rb +++ b/spec/controllers/resource_pictures_controller_spec.rb @@ -95,7 +95,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -120,7 +120,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限はないが管理者権限があるとき' do + context 'ユーザ権限はないが管理者権限があるとき' do before do sign_out @user sign_in @admin @@ -130,7 +130,7 @@ if MagicNumber['run_mode'] == 1 response.should be_success end end - context '作家権限はないが借手権限があるとき' do + context 'ユーザ権限はないが借手権限があるとき' do before do sign_out @user sign_in @demand_user @@ -140,6 +140,15 @@ if MagicNumber['run_mode'] == 1 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 @@ -147,7 +156,7 @@ if MagicNumber['run_mode'] == 1 @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id sign_in @user - ResourcePicture.stub(:show).with(@rp.id.to_s, [@author, nil, nil]).and_return(@rp) + ResourcePicture.stub(:show).with(@rp.id.to_s, [@user, nil, nil]).and_return(@rp) ResourcePicture.stub(:show).with(@rp.id.to_s, [nil, @admin, nil]).and_return(@rp) ResourcePicture.stub(:show).with(@rp.id.to_s, [nil, nil, @demand_user]).and_return(@rp) end @@ -249,7 +258,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -274,7 +283,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限はないが管理者権限があるとき' do + context 'ユーザ権限はないが管理者権限があるとき' do before do sign_out @user sign_in @admin @@ -284,7 +293,7 @@ if MagicNumber['run_mode'] == 1 response.should be_success end end - context '作家権限はないが借手権限があるとき' do + context 'ユーザ権限はないが借手権限があるとき' do before do sign_out @user sign_in @demand_user @@ -294,6 +303,15 @@ if MagicNumber['run_mode'] == 1 response.should be_success end end + context 'ユーザだが作家登録していないとき' do + before do + @author.destroy + end + it 'ステータスコード200 OKを返す' do + get :show, :id => @rp.id + response.should be_success + end + end =begin context '対象素材がないとき' do before do @@ -366,8 +384,9 @@ if MagicNumber['run_mode'] == 1 @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id sign_in @user - ResourcePicture.stub(:show).with(@rp.id.to_s, @author).and_return(@rp) - ResourcePicture.stub(:show).with(@rp.id.to_s, nil).and_return(@rp) + ResourcePicture.stub(:show).with(@rp.id.to_s, [@user, nil, nil]).and_return(@rp) + ResourcePicture.stub(:show).with(@rp.id.to_s, [nil, @admin, nil]).and_return(@rp) + ResourcePicture.stub(:show).with(@rp.id.to_s, [nil, nil, @demand_user]).and_return(@rp) end context 'つつがなく終わるとき' do it '素材モデルに単体取得を問い合わせている' do @@ -410,7 +429,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -435,7 +454,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限はないが管理者権限があるとき' do + context 'ユーザ権限はないが管理者権限があるとき' do before do sign_out @user sign_in @admin @@ -445,7 +464,7 @@ if MagicNumber['run_mode'] == 1 response.should be_success end end - context '作家権限はないが借手権限があるとき' do + context 'ユーザ権限はないが借手権限があるとき' do before do sign_out @user sign_in @demand_user @@ -455,6 +474,15 @@ if MagicNumber['run_mode'] == 1 response.should be_success end end + context 'ユーザだが作家登録していないとき' do + before do + @author.destroy + end + it 'ステータスコード200 OKを返す' do + get :credit, :id => @rp.id + response.should be_success + end + end =begin context '対象素材がないとき' do before do @@ -597,7 +625,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -625,7 +653,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限はないが管理者権限があるとき' do + context 'ユーザ権限はないが管理者権限があるとき' do before do sign_out @user sign_in @admin @@ -641,7 +669,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限はないが借手権限があるとき' do + context 'ユーザ権限はないが借手権限があるとき' do before do sign_out @user sign_in @demand_user @@ -657,9 +685,9 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家が絵師でないとき' do + context 'ユーザが絵師でないとき' do before do - Author.any_instance.stub(:artist?).and_return(false) + @artist.destroy end context 'html形式' do it 'ステータスコード302 Foundを返す' do @@ -885,7 +913,7 @@ if MagicNumber['run_mode'] == 1 }.should_not change(ResourcePicture, :count) end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -913,7 +941,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限はないが管理者権限があるとき' do + context 'ユーザ権限はないが管理者権限があるとき' do before do sign_out @user sign_in @admin @@ -929,7 +957,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限はないが借手権限があるとき' do + context 'ユーザ権限はないが借手権限があるとき' do before do sign_out @user sign_in @demand_user @@ -945,9 +973,9 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家が絵師でないとき' do + context 'ユーザが絵師でないとき' do before do - Author.any_instance.stub(:artist?).and_return(false) + @artist.destroy end context 'html形式' do it 'ステータスコード302 Foundを返す' do @@ -960,12 +988,11 @@ if MagicNumber['run_mode'] == 1 end end context 'json形式' do - before do + it '例外403 forbiddenを返す' do @attr.merge!({:format => :json}) - end - it '応答メッセージにUnauthorizedを返す' do - post :create, @attr - response.message.should match(/Unauthorized/) + lambda{ + post :create, @attr + }.should raise_error(ActiveRecord::Forbidden) end end end @@ -1054,7 +1081,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -1075,7 +1102,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限はないが管理者権限があるとき' do + context 'ユーザ権限はないが管理者権限があるとき' do before do sign_out @user sign_in @admin @@ -1091,7 +1118,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限はないが借手権限があるとき' do + context 'ユーザ権限はないが借手権限があるとき' do before do sign_out @user sign_in @demand_user @@ -1107,9 +1134,9 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家が絵師でないとき' do + context 'ユーザが絵師でないとき' do before do - Author.any_instance.stub(:artist?).and_return(false) + @artist.destroy end context 'html形式' do it 'ステータスコード302 Foundを返す' do @@ -1122,9 +1149,10 @@ if MagicNumber['run_mode'] == 1 end end context 'json形式' do - it '応答メッセージにUnauthorizedを返す' do - delete :destroy, :id => @rp.id, :format => :json - response.message.should match(/Unauthorized/) + it '例外403 forbiddenを返す' do + lambda{ + delete :destroy, :id => @rp.id, :format => :json + }.should raise_error(ActiveRecord::Forbidden) end end end @@ -1185,7 +1213,7 @@ else end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -1217,8 +1245,10 @@ else @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id sign_in @user - ResourcePicture.stub(:show).with(@rp.id.to_s, @author).and_return(@rp) - ResourcePicture.stub(:show).with(@rp.id.to_s, nil).and_return(@rp) + ResourcePicture.stub(:show).with(@rp.id.to_s, [nil, nil, nil]).and_return(@rp) + ResourcePicture.stub(:show).with(@rp.id.to_s, [@user, nil, nil]).and_return(@rp) + ResourcePicture.stub(:show).with(@rp.id.to_s, [nil, @admin, nil]).and_return(@rp) + ResourcePicture.stub(:show).with(@rp.id.to_s, [nil, nil, @demand_user]).and_return(@rp) end context 'つつがなく終わるとき' do context 'html形式' do @@ -1242,7 +1272,7 @@ else end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -1293,8 +1323,10 @@ else @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id @rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id sign_in @user - ResourcePicture.stub(:show).with(@rp.id.to_s, @author).and_return(@rp) - ResourcePicture.stub(:show).with(@rp.id.to_s, nil).and_return(@rp) + ResourcePicture.stub(:show).with(@rp.id.to_s, [nil, nil, nil]).and_return(@rp) + ResourcePicture.stub(:show).with(@rp.id.to_s, [@user, nil, nil]).and_return(@rp) + ResourcePicture.stub(:show).with(@rp.id.to_s, [nil, @admin, nil]).and_return(@rp) + ResourcePicture.stub(:show).with(@rp.id.to_s, [nil, nil, @demand_user]).and_return(@rp) end context 'つつがなく終わるとき' do context 'html形式' do @@ -1318,7 +1350,7 @@ else end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -1392,7 +1424,7 @@ else end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -1472,6 +1504,21 @@ else end end end + context 'ユーザ権限がないとき' do + before do + sign_out @user + end + context 'html形式' do + it 'ステータスコード302 Foundを返す' do + post :create, @newattr + response.status.should eq 302 + end + it 'サインインページへ遷移する' do + post :create, @newattr + response.body.should redirect_to '/users/sign_in' + end + end + end end describe '削除に於いて' do @@ -1505,7 +1552,7 @@ else end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end diff --git a/spec/controllers/speech_balloon_templates_controller_spec.rb b/spec/controllers/speech_balloon_templates_controller_spec.rb index afad3fab..08eb32f9 100644 --- a/spec/controllers/speech_balloon_templates_controller_spec.rb +++ b/spec/controllers/speech_balloon_templates_controller_spec.rb @@ -65,7 +65,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -90,7 +90,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限はないが管理者権限があるとき' do + context 'ユーザ権限はないが管理者権限があるとき' do before do sign_out @user sign_in @admin @@ -100,12 +100,21 @@ if MagicNumber['run_mode'] == 1 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, 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 @@ -147,7 +156,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -172,7 +181,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限はないが管理者権限があるとき' do + context 'ユーザ権限はないが管理者権限があるとき' do before do sign_out @user sign_in @admin @@ -182,6 +191,15 @@ if MagicNumber['run_mode'] == 1 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 @@ -212,7 +230,7 @@ else end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -242,8 +260,9 @@ else 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 @@ -267,7 +286,7 @@ else end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end diff --git a/spec/controllers/speech_balloons_controller_spec.rb b/spec/controllers/speech_balloons_controller_spec.rb index f6f0e451..3c555a0a 100644 --- a/spec/controllers/speech_balloons_controller_spec.rb +++ b/spec/controllers/speech_balloons_controller_spec.rb @@ -90,7 +90,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -115,7 +115,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限はないが管理者権限があるとき' do + context 'ユーザ権限はないが管理者権限があるとき' do before do sign_out @user sign_in @admin @@ -125,6 +125,15 @@ if MagicNumber['run_mode'] == 1 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 @@ -170,7 +179,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -195,7 +204,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限はないが管理者権限があるとき' do + context 'ユーザ権限はないが管理者権限があるとき' do before do sign_out @user sign_in @admin @@ -205,6 +214,15 @@ if MagicNumber['run_mode'] == 1 response.should be_success end end + context 'ユーザだが作家登録していないとき' do + before do + @author.destroy + end + it 'ステータスコード200 OKを返す' do + get :show, :id => @sb.id + response.should be_success + end + end end else @@ -232,7 +250,7 @@ else end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -279,7 +297,7 @@ else end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end diff --git a/spec/controllers/speeches_controller_spec.rb b/spec/controllers/speeches_controller_spec.rb index 00277ba0..abb4ba24 100644 --- a/spec/controllers/speeches_controller_spec.rb +++ b/spec/controllers/speeches_controller_spec.rb @@ -93,7 +93,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -118,7 +118,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限はないが管理者権限があるとき' do + context 'ユーザ権限はないが管理者権限があるとき' do before do sign_out @user sign_in @admin @@ -128,6 +128,15 @@ if MagicNumber['run_mode'] == 1 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 @@ -175,7 +184,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -200,7 +209,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限はないが管理者権限があるとき' do + context 'ユーザ権限はないが管理者権限があるとき' do before do sign_out @user sign_in @admin @@ -210,6 +219,15 @@ if MagicNumber['run_mode'] == 1 response.should be_success end end + context 'ユーザだが作家登録していないとき' do + before do + @author.destroy + end + it 'ステータスコード200 OKを返す' do + get :show, :id => @speech.id + response.should be_success + end + end end else @@ -239,7 +257,7 @@ else end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -288,7 +306,7 @@ else end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end diff --git a/spec/controllers/stories_controller_spec.rb b/spec/controllers/stories_controller_spec.rb index 3b8345fd..0268c4ec 100644 --- a/spec/controllers/stories_controller_spec.rb +++ b/spec/controllers/stories_controller_spec.rb @@ -88,7 +88,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -113,7 +113,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限はないが管理者権限があるとき' do + context 'ユーザ権限はないが管理者権限があるとき' do before do sign_out @user sign_in @admin @@ -123,20 +123,29 @@ if MagicNumber['run_mode'] == 1 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 @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - Comic.stub(:show).with(@comic.id.to_s, [@author, nil]).and_return(@comic) + Comic.stub(:show).with(@comic.id.to_s, [@user, nil]).and_return(@comic) Comic.stub(:show).with(@comic.id.to_s, [nil, @admin]).and_return(@comic) - Story.stub(:show).with(@story.id.to_s, [@author, nil]).and_return(@story) + Story.stub(:show).with(@story.id.to_s, [@user, nil]).and_return(@story) Story.stub(:show).with(@story.id.to_s, [nil, @admin]).and_return(@story) end context 'つつがなく終わるとき' do it 'ストーリーモデルに単体取得を問い合わせている' do - Story.should_receive(:show).with(@story.id.to_s, [@author, nil]).exactly(1) + Story.should_receive(:show).with(@story.id.to_s, [@user, nil]).exactly(1) get :show, :id => @story.id end it '@storyにアレを取得している' do @@ -175,7 +184,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -200,7 +209,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限はないが管理者権限があるとき' do + context 'ユーザ権限はないが管理者権限があるとき' do before do sign_out @user sign_in @admin @@ -210,12 +219,21 @@ if MagicNumber['run_mode'] == 1 response.should be_success end end + context 'ユーザだが作家登録していないとき' do + before do + @author.destroy + end + it 'ステータスコード200 OKを返す' do + get :show, :id => @story.id + response.should be_success + end + end end describe '閲覧に於いて' do before do @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - Comic.stub(:show).with(@comic.id.to_s, [@author, nil]).and_return(@comic) + Comic.stub(:show).with(@comic.id.to_s, [@user, nil]).and_return(@comic) Comic.stub(:show).with(@comic.id.to_s, [nil, @admin]).and_return(@comic) Story.stub(:count).and_return(10) Story.stub(:play_list).with(any_args).and_return([@story, @story, @story]) @@ -249,7 +267,7 @@ if MagicNumber['run_mode'] == 1 end context '事前チェックする' do it 'コミックモデルに単体取得を問い合わせている' do - Comic.should_receive(:show).with(@comic.id.to_s, [@author, nil]).exactly(1) + Comic.should_receive(:show).with(@comic.id.to_s, [@user, nil]).exactly(1) get :comic, :id => @comic.id end it 'ストーリーモデルにプレイリスト取得を問い合わせている' do @@ -299,7 +317,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -324,7 +342,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限はないが管理者権限があるとき' do + context 'ユーザ権限はないが管理者権限があるとき' do before do sign_out @user sign_in @admin @@ -334,6 +352,15 @@ if MagicNumber['run_mode'] == 1 response.should be_success end end + context 'ユーザだが作家登録していないとき' do + before do + @author.destroy + end + it 'ステータスコード200 OKを返す' do + get :comic, :id => @comic.id + response.should be_success + end + end end describe '新規作成フォーム表示に於いて' do @@ -391,7 +418,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -416,7 +443,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限はないが管理者権限があるとき' do + context 'ユーザ権限はないが管理者権限があるとき' do before do sign_out @user sign_in @admin @@ -432,6 +459,21 @@ if MagicNumber['run_mode'] == 1 end end end + context 'ユーザだが作家登録していないとき' do + before do + @author.destroy + end + context 'html形式' do + it 'ステータスコード302 Foundを返す' do + get :new + response.status.should eq 302 + end + it '作家登録ページへ遷移する' do + get :new + response.body.should redirect_to new_author_path + end + end + end end describe '新規作成に於いて' do @@ -504,7 +546,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -529,7 +571,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限はないが管理者権限があるとき' do + context 'ユーザ権限はないが管理者権限があるとき' do before do sign_out @user sign_in @admin @@ -545,6 +587,21 @@ if MagicNumber['run_mode'] == 1 end end end + context 'ユーザだが作家登録していないとき' do + before do + @author.destroy + end + context 'html形式' do + it 'ステータスコード302 Foundを返す' do + post :create, :story => @attr + response.status.should eq 302 + end + it '作家登録ページへ遷移する' do + post :create, :story => @attr + response.body.should redirect_to new_author_path + end + end + end context '検証、保存に失敗した' do before do Story.any_instance.stub(:store).and_return(false) @@ -612,7 +669,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -637,7 +694,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限はないが管理者権限があるとき' do + context 'ユーザ権限はないが管理者権限があるとき' do before do sign_out @user sign_in @admin @@ -653,6 +710,21 @@ if MagicNumber['run_mode'] == 1 end end end + context 'ユーザだが作家登録していないとき' do + before do + @author.destroy + end + context 'html形式' do + it 'ステータスコード302 Foundを返す' do + get :edit, :id => @story.id + response.status.should eq 302 + end + it '作家登録ページへ遷移する' do + get :edit, :id => @story.id + response.body.should redirect_to new_author_path + end + end + end end describe '更新に於いて' do @@ -705,7 +777,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -730,7 +802,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限はないが管理者権限があるとき' do + context 'ユーザ権限はないが管理者権限があるとき' do before do sign_out @user sign_in @admin @@ -746,6 +818,21 @@ if MagicNumber['run_mode'] == 1 end end end + context 'ユーザだが作家登録していないとき' do + before do + @author.destroy + end + context 'html形式' do + it 'ステータスコード302 Foundを返す' do + put :update, :id => @story.id, :story => @attr + response.status.should eq 302 + end + it '作家登録ページへ遷移する' do + put :update, :id => @story.id, :story => @attr + response.body.should redirect_to new_author_path + end + end + end context '検証、保存に失敗した' do before do Story.any_instance.stub(:store).and_return(false) @@ -822,7 +909,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -847,7 +934,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限はないが管理者権限があるとき' do + context 'ユーザ権限はないが管理者権限があるとき' do before do sign_out @user sign_in @admin @@ -863,6 +950,21 @@ if MagicNumber['run_mode'] == 1 end end end + context 'ユーザだが作家登録していないとき' do + before do + @author.destroy + end + context 'html形式' do + it 'ステータスコード302 Foundを返す' do + delete :destroy, :id => @story.id + response.status.should eq 302 + end + it '作家登録ページへ遷移する' do + delete :destroy, :id => @story.id + response.body.should redirect_to new_author_path + end + end + end context '削除に失敗したとき' do before do Story.any_instance.stub(:destroy_and_shorten).with(any_args()).and_return(false) @@ -921,7 +1023,7 @@ else end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -948,10 +1050,12 @@ else before do sign_in @user @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - Comic.stub(:show).with(@comic.id.to_s, @author).and_return(@comic) - Comic.stub(:show).with(@comic.id.to_s, nil).and_return(@comic) - Story.stub(:show).with(@story.id.to_s, @author).and_return(@story) - Story.stub(:show).with(@story.id.to_s, nil).and_return(@story) + Comic.stub(:show).with(@comic.id.to_s, [nil, nil]).and_return(@comic) + Comic.stub(:show).with(@comic.id.to_s, [@user, nil]).and_return(@comic) + Comic.stub(:show).with(@comic.id.to_s, [nil, @admin]).and_return(@comic) + Story.stub(:show).with(@story.id.to_s, [nil, nil]).and_return(@story) + Story.stub(:show).with(@story.id.to_s, [@user, nil]).and_return(@story) + Story.stub(:show).with(@story.id.to_s, [nil, @admin]).and_return(@story) end context 'つつがなく終わるとき' do context 'html形式' do @@ -975,7 +1079,7 @@ else end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -1005,8 +1109,9 @@ else describe '閲覧に於いて' do before do @story = FactoryGirl.create :story, :t => 0, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id - Comic.stub(:show).with(@comic.id.to_s, @author).and_return(@comic) - Comic.stub(:show).with(@comic.id.to_s, nil).and_return(@comic) + Comic.stub(:show).with(@comic.id.to_s, [nil, nil]).and_return(@comic) + Comic.stub(:show).with(@comic.id.to_s, [@user, nil]).and_return(@comic) + Comic.stub(:show).with(@comic.id.to_s, [nil, @admin]).and_return(@comic) Story.stub(:count).and_return(10) Story.stub(:play_list).with(any_args).and_return([@story, @story, @story]) sign_in @user @@ -1033,7 +1138,7 @@ else end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -1096,7 +1201,7 @@ else end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -1153,7 +1258,7 @@ else end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -1208,7 +1313,7 @@ else end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -1262,7 +1367,7 @@ else end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -1316,7 +1421,7 @@ else end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end diff --git a/spec/controllers/system_pictures_controller_spec.rb b/spec/controllers/system_pictures_controller_spec.rb index 0db04858..b8bd139c 100644 --- a/spec/controllers/system_pictures_controller_spec.rb +++ b/spec/controllers/system_pictures_controller_spec.rb @@ -91,7 +91,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -116,7 +116,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限はないが管理者権限があるとき' do + context 'ユーザ権限はないが管理者権限があるとき' do before do sign_out @user sign_in @admin @@ -126,7 +126,7 @@ if MagicNumber['run_mode'] == 1 response.should be_success end end - context '作家権限はないが借手権限があるとき' do + context 'ユーザ権限はないが借手権限があるとき' do before do sign_out @user sign_in @demand_user @@ -237,7 +237,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -262,7 +262,7 @@ if MagicNumber['run_mode'] == 1 end end end - context '作家権限はないが管理者権限があるとき' do + context 'ユーザ権限はないが管理者権限があるとき' do before do sign_out @user sign_in @admin @@ -272,7 +272,7 @@ if MagicNumber['run_mode'] == 1 response.should be_success end end - context '作家権限はないが借手権限があるとき' do + context 'ユーザ権限はないが借手権限があるとき' do before do sign_out @user sign_in @demand_user @@ -354,7 +354,7 @@ else end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end @@ -404,7 +404,7 @@ else end end end - context '作家権限がないとき' do + context 'ユーザ権限がないとき' do before do sign_out @user end