//
//= require jquery
//= require jquery_ujs
-//= require jquery-1.6.2.min
+//= require jquery-162min
//= require system
+//= require peta-common
+//= require peta-apps
// #= require_tree .
class ArtistsController < ApplicationController
layout 'test' if MagicNumber['test_layout']
- before_filter :authenticate_user!, :only => [:index, :show, :new, :create, :edit, :update, :destroy]
- before_filter :authenticate_author, :only => [:index, :show, :new, :create, :edit, :update, :destroy]
+ 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_user!, :only => [:index, :show, :new, :create, :edit, :update, :destroy]
+ before_filter :authenticate_author, :only => [:index, :show, :new, :create, :edit, :update, :destroy]
+ end
before_filter :authenticate_admin!, :only => [:list, :browse]
# GET /artists
class AuthorsController < ApplicationController
layout 'test' if MagicNumber['test_layout']
- before_filter :authenticate_user!, :only => [:index, :show, :new, :create, :edit, :update]
- before_filter :authenticate_author, :only => [:index, :show, :edit, :update]
+ 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_user!, :only => [:index, :show, :new, :create, :edit, :update]
+ before_filter :authenticate_author, :only => [:index, :show, :edit, :update]
+ end
before_filter :authenticate_admin!, :only => [:list, :browse]
def index
class BalloonsController < ApplicationController
layout 'test' if MagicNumber['test_layout']
- before_filter :authenticate_user!, :only => [:index, :show]
- before_filter :authenticate_author, :only => [:index, :show]
+ if MagicNumber['run_mode'] == 0
+ before_filter :authenticate_user!, :only => []
+ before_filter :authenticate_author, :only => []
+ else
+ before_filter :authenticate_user!, :only => [:index, :show]
+ before_filter :authenticate_author, :only => [:index, :show]
+ end
before_filter :authenticate_admin!, :only => [:list, :browse]
def index
class GroundColorsController < ApplicationController
layout 'test' if MagicNumber['test_layout']
- before_filter :authenticate_user!, :only => [:index, :show]
- before_filter :authenticate_author, :only => [:index, :show]
+ if MagicNumber['run_mode'] == 0
+ before_filter :authenticate_user!, :only => []
+ before_filter :authenticate_author, :only => []
+ else
+ before_filter :authenticate_user!, :only => [:index, :show]
+ before_filter :authenticate_author, :only => [:index, :show]
+ end
# GET /ground_colors
# GET /ground_colors.json
class GroundPicturesController < ApplicationController
layout 'test' if MagicNumber['test_layout']
- before_filter :authenticate_user!, :only => [:index, :show]
- before_filter :authenticate_author, :only => [:index, :show]
+ if MagicNumber['run_mode'] == 0
+ before_filter :authenticate_user!, :only => []
+ before_filter :authenticate_author, :only => []
+ else
+ before_filter :authenticate_user!, :only => [:index, :show]
+ before_filter :authenticate_author, :only => [:index, :show]
+ end
# GET /ground_pictures
# GET /ground_pictures.json
class PanelColorsController < ApplicationController
layout 'test' if MagicNumber['test_layout']
- before_filter :authenticate_user!, :only => [:index, :show]
- before_filter :authenticate_author, :only => [:index, :show]
+ if MagicNumber['run_mode'] == 0
+ before_filter :authenticate_user!, :only => []
+ before_filter :authenticate_author, :only => []
+ else
+ before_filter :authenticate_user!, :only => [:index, :show]
+ before_filter :authenticate_author, :only => [:index, :show]
+ end
# GET /ground_pictures
# GET /ground_pictures.json
class PanelPicturesController < ApplicationController
layout 'test' if MagicNumber['test_layout']
- before_filter :authenticate_user!, :only => [:index, :show]
- before_filter :authenticate_author, :only => [:index, :show]
+ if MagicNumber['run_mode'] == 0
+ before_filter :authenticate_user!, :only => []
+ before_filter :authenticate_author, :only => []
+ else
+ before_filter :authenticate_user!, :only => [:index, :show]
+ before_filter :authenticate_author, :only => [:index, :show]
+ end
before_filter :authenticate_admin!, :only => [:list, :browse]
# GET /panel_pictures
class PanelsController < ApplicationController
layout 'test' if MagicNumber['test_layout']
- before_filter :authenticate_user!, :only => [:index, :show, :new, :edit, :create, :update, :destroy]
- before_filter :authenticate_author, :only => [:index, :show, :new, :edit, :create, :update, :destroy]
+ 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_user!, :only => [:index, :show, :new, :edit, :create, :update, :destroy]
+ before_filter :authenticate_author, :only => [:index, :show, :new, :edit, :create, :update, :destroy]
+ end
before_filter :authenticate_admin!, :only => [:list, :browse]
public
class PicturesController < ApplicationController
layout 'test' if MagicNumber['test_layout']
- before_filter :authenticate_user!, :only => [:show, :credit, :search]
- before_filter :authenticate_author, :only => [:show, :credit, :search]
+ if MagicNumber['run_mode'] == 0
+ before_filter :authenticate_user!, :only => []
+ before_filter :authenticate_author, :only => []
+ else
+ before_filter :authenticate_user!, :only => [:show, :credit, :search]
+ before_filter :authenticate_author, :only => [:show, :credit, :search]
+ end
before_filter :authenticate_admin!, :only => [:list, :browse]
def show
class ResourcePicturesController < ApplicationController
layout 'test' if MagicNumber['test_layout']
- before_filter :authenticate_user!, :only => [:index, :show, :credit, :new, :create, :update, :destroy]
- before_filter :authenticate_author, :only => [:index, :show, :credit, :new, :create, :update, :destroy]
+ if MagicNumber['run_mode'] == 0
+ before_filter :authenticate_user!, :only => [:new, :create, :update, :destroy]
+ before_filter :authenticate_author, :only => [:new, :create, :update, :destroy]
+ before_filter :authenticate_artist, :only => [:new, :create, :destroy]
+ else
+ before_filter :authenticate_user!, :only => [:index, :show, :credit, :new, :create, :update, :destroy]
+ before_filter :authenticate_author, :only => [:index, :show, :credit, :new, :create, :update, :destroy]
+ before_filter :authenticate_artist, :only => [:new, :create, :destroy]
+ end
before_filter :authenticate_admin!, :only => [:list, :browse]
- before_filter :authenticate_artist, :only => [:new, :create, :destroy]
# GET /resource_pictures
# GET /resource_pictures.json
class SpeechBalloonTemplatesController < ApplicationController
layout 'test' if MagicNumber['test_layout']
- before_filter :authenticate_user!, :only => [:index, :show]
- before_filter :authenticate_author, :only => [:index, :show]
+ if MagicNumber['run_mode'] == 0
+ before_filter :authenticate_user!, :only => []
+ before_filter :authenticate_author, :only => []
+ else
+ before_filter :authenticate_user!, :only => [:index, :show]
+ before_filter :authenticate_author, :only => [:index, :show]
+ end
before_filter :authenticate_admin!, :only => [:list, :browse, :destroy]
# GET /speech_balloon_templates
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_user!, :only => [:index, :show]
+ before_filter :authenticate_author, :only => [:index, :show]
+ end
before_filter :authenticate_admin!, :only => [:list, :browse]
+ def index
+ @page = SpeechBalloon.page params[:page]
+ @page_size = SpeechBalloon.page_size params[:page_size]
+ @speech_balloons = SpeechBalloon.list(@page, @page_size)
+
+ respond_to do |format|
+ format.html # index.html.erb
+ format.json { render json: @speech_balloons.to_json(SpeechBalloon.list_json_opt) }
+ end
+ end
+
+ def show
+ @speech_balloon = SpeechBalloon.show(params[:id], @author)
+ respond_to do |format|
+ format.html # show.html.erb
+ format.json { render json: @speech_balloon.to_json(SpeechBalloon.show_json_opt) }
+ end
+ end
+
def list
@speech_balloons = SpeechBalloon.all
class SpeechesController < ApplicationController
layout 'test' if MagicNumber['test_layout']
- before_filter :authenticate_user!, :only => [:index, :show]
- before_filter :authenticate_author, :only => [:index, :show]
+ if MagicNumber['run_mode'] == 0
+ before_filter :authenticate_user!, :only => []
+ before_filter :authenticate_author, :only => []
+ else
+ before_filter :authenticate_user!, :only => [:index, :show]
+ before_filter :authenticate_author, :only => [:index, :show]
+ end
before_filter :authenticate_admin!, :only => [:list, :browse]
def index
class SystemPicturesController < ApplicationController
layout 'test' if MagicNumber['test_layout']
- before_filter :authenticate_user!, :only => [:index, :show]
- before_filter :authenticate_author, :only => [:index, :show]
+ if MagicNumber['run_mode'] == 0
+ before_filter :authenticate_user!, :only => []
+ before_filter :authenticate_author, :only => []
+ else
+ before_filter :authenticate_user!, :only => [:index, :show]
+ before_filter :authenticate_author, :only => [:index, :show]
+ end
before_filter :authenticate_admin!, :only => [:list, :browse, :new, :create]
# GET /system_pictures
</div>\r
</td>\r
<td>\r
- <%= link_to t('home.configure.title'), '/home/configure' %>\r
- <%= link_to t('home.sign_out.title'), main_app.destroy_user_session_path, :method => :delete %>\r
- </td>\r
+ <% if user_signed_in? %>\r
+ <%= link_to t('home.configure.title'), '/home/configure' %>\r
+ <%= link_to t('home.sign_out.title'), main_app.destroy_user_session_path, :method => :delete %>\r
+ <% else %>\r
+ <%= link_to "sign in", main_app.new_user_session_path %>\r
+ <% end %>\r
+ </td>\r
</tr>\r
</table>\r
</div>\r
<%= link_to t_m('Author'), main_app.authors_path %>\r
<%= link_to t_m('Artist'), main_app.artists_path %>\r
</div>\r
-<div width="100%" style="background-color: #fadddd; padding: 5px;">\r
- <% if user_signed_in? %>\r
+<% if user_signed_in? %>\r
+ <div width="100%" style="background-color: #fadddd; padding: 5px;">\r
<%= link_to t('tab.creator.home'), '/home' %>\r
<%= link_to t('tab.creator.comic'), '/home/comic' %>\r
<%= link_to t('tab.creator.panel'), '/home/panel' %>\r
<% if @artist %>\r
<%= link_to t('tab.creator.picture'), main_app.original_pictures_path %>\r
<% end %>\r
- <% else %>\r
- <%= link_to "sign in", main_app.new_user_session_path %>\r
- <% end %>\r
-</div>\r
+ </div>\r
+<% end %>\r
<%= yield %>\r
<div width="100%" style="background-color: #faddfa; padding: 5px;">\r
<%= link_to t('tab.demander.title'), main_app.demanders_path %>\r
--- /dev/null
+<h1><%= t '.title' -%></h1>
+
--- /dev/null
+<h1><%= t('.title') %></h1>
+<p id="notice"><%= notice %></p>
+
@artist = FactoryGirl.create :artist_yas, :author_id => @author.id
end
+if MagicNumber['run_mode'] == 1
describe '一覧表示に於いて' do
before do
Artist.stub(:list).and_return([@artist, @artist, @artist])
end
end
+else
+ describe '一覧表示に於いて' do
+ before do
+ Artist.stub(:list).and_return([@artist, @artist, @artist])
+ sign_in @user
+ end
+ context 'つつがなく終わるとき' do
+ it 'ステータスコード200 OKを返す' do
+ get :index
+ response.should be_success
+ end
+ context 'html形式' do
+ it 'indexテンプレートを描画する' do
+ get :index
+ response.should render_template("index")
+ end
+ end
+ context 'json形式' do
+ it 'jsonデータを返す' do
+ get :index, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ end
+ end
+ context '作家権限がないとき' do
+ before do
+ sign_out @user
+ end
+ it 'ステータスコード200 OKを返す' do
+ get :index
+ response.should be_success
+ end
+ context 'html形式' do
+ it 'indexテンプレートを描画する' do
+ get :index
+ response.should render_template("index")
+ end
+ end
+ context 'json形式' do
+ it 'jsonデータを返す' do
+ get :index, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ end
+ end
+ end
+
+ describe '閲覧に於いて' do
+ before do
+ Artist.stub(:show).and_return(@artist)
+ sign_in @user
+ end
+ context 'つつがなく終わるとき' do
+ it 'ステータスコード200 OKを返す' do
+ get :show, :id => @artist.id
+ response.should be_success
+ end
+ context 'html形式' do
+ it 'showテンプレートを描画する' do
+ get :show, :id => @artist.id
+ response.should render_template("show")
+ end
+ end
+ context 'json形式' do
+ it 'jsonデータを返す' do
+ get :show, :id => @artist.id, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ end
+ end
+ context '作家権限がないとき' do
+ before do
+ sign_out @user
+ end
+ it 'ステータスコード200 OKを返す' do
+ get :show, :id => @artist.id
+ response.should be_success
+ end
+ context 'html形式' do
+ it 'showテンプレートを描画する' do
+ get :show, :id => @artist.id
+ response.should render_template("show")
+ end
+ end
+ context 'json形式' do
+ it 'jsonデータを返す' do
+ get :show, :id => @artist.id, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ end
+ end
+ end
+
+ describe '絵師数取得に於いて' do
+ before do
+ Artist.should_receive(:visible_count).and_return(3)
+# sign_in @user
+ end
+ context 'つつがなく終わるとき' do
+ it 'ステータスコード200 OKを返す' do
+ get :count, :format => :json
+ response.should be_success
+ end
+ context 'json形式' do
+ it 'jsonデータを返す' do
+ get :count, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ end
+ end
+ end
+
+ describe '新規作成フォーム表示に於いて' do
+ before do
+ sign_in @user
+ end
+ context 'つつがなく終わるとき' do
+ it 'ステータスコード200 OKを返す' do
+ get :new
+ response.should be_success
+ end
+ context 'html形式' do
+ it 'newテンプレートを描画する' do
+ get :new
+ response.should render_template("new")
+ end
+ end
+ context 'js形式' do
+ it 'new.jsテンプレートを描画する' do
+ get :new, :format => :js
+ response.should render_template("new")
+ end
+ end
+ context 'json形式' do
+ it 'jsonデータを返す' do
+ get :new, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ end
+ end
+ context '作家権限がないとき' do
+ before do
+ sign_out @user
+ 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 '/users/sign_in'
+ end
+ end
+ context 'js形式' do
+ it 'ステータスコード401 Unauthorizedを返す' do
+ get :new, :format => :js
+ response.status.should eq 401
+ end
+ it '応答メッセージにUnauthorizedを返す' do
+ get :new, :format => :js
+ response.message.should match(/Unauthorized/)
+ end
+ end
+ context 'json形式' do
+ it 'ステータスコード401 Unauthorizedを返す' do
+ get :new, :format => :json
+ response.status.should eq 401
+ end
+ it '応答メッセージにUnauthorizedを返す' do
+ get :new, :format => :json
+ response.message.should match(/Unauthorized/)
+ end
+ end
+ end
+ end
+
+ describe '新規作成に於いて' do
+ before do
+ sign_in @user
+ @attr = FactoryGirl.attributes_for(:artist, :author_id => @author.id, :name => 'ken')
+ end
+ context 'つつがなく終わるとき' do
+ context 'html形式' do
+ it 'ステータスコード302 Foundを返す' do
+ Artist.any_instance.stub(:save).and_return(true)
+ post :create, :artist => @attr
+ response.status.should eq 302
+ end
+ it 'トップページへ遷移する' do
+# Artist.any_instance.stub(:save).and_return(true)
+ post :create, :artist => @attr
+ response.should redirect_to(root_path)
+ end
+ end
+ context 'json形式' do
+ it 'ステータスコード200 OKを返す' do
+# Artist.any_instance.stub(:save).and_return(true)
+ post :create, :artist => @attr, :format => :json
+ response.should be_success
+ end
+ it '作成された絵師をjsonデータで返す' do
+ post :create, :artist => @attr, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ end
+ end
+ context '作家権限がないとき' do
+ before do
+ sign_out @user
+ 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 '/users/sign_in'
+ end
+ end
+ context 'json形式' do
+ it 'ステータスコード401 Unauthorizedを返す' do
+ post :create, :artist => @attr, :format => :json
+ response.status.should eq 401
+ end
+ it '応答メッセージにUnauthorizedを返す' do
+ post :create, :artist => @attr, :format => :json
+ response.message.should match(/Unauthorized/)
+ end
+ end
+ end
+ end
+
+ describe '編集フォーム表示に於いて' do
+ before do
+ sign_in @user
+ Artist.stub(:edit).and_return(@artist)
+ end
+ context 'つつがなく終わるとき' do
+ it 'ステータスコード200 OKを返す' do
+ get :edit, :id => @artist.id
+ response.should be_success
+ end
+ context 'html形式' do
+ it 'editテンプレートを描画する' do
+ get :edit, :id => @artist.id
+ response.should render_template("edit")
+ end
+ end
+ context 'js形式' do
+ it 'edit.jsテンプレートを描画する' do
+ get :edit, :id => @artist.id, :format => :js
+ response.should render_template("edit")
+ end
+ end
+ end
+ context '作家権限がないとき' do
+ before do
+ sign_out @user
+ 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 '/users/sign_in'
+ end
+ end
+ context 'js形式' do
+ it 'ステータスコード401 Unauthorizedを返す' do
+ get :edit, :id => @artist.id, :format => :js
+ response.status.should eq 401
+ end
+ it '応答メッセージにUnauthorizedを返す' do
+ get :edit, :id => @artist.id, :format => :js
+ response.message.should match(/Unauthorized/)
+ end
+ end
+ end
+ end
+
+ describe '更新に於いて' do
+ before do
+ @attr = FactoryGirl.attributes_for(:artist, :author_id => @author.id, :name => 'ryu')
+ sign_in @user
+ end
+ context 'つつがなく終わるとき' do
+ context 'html形式' do
+ it 'ステータスコード302 Foundを返す' do
+ Artist.any_instance.stub(:save).with(any_args()).and_return(true)
+ put :update, :id => @artist.id, :artist => @attr
+ response.status.should eq 302
+ end
+ it '設定ページへ遷移する' do
+ put :update, :id => @artist.id, :artist => @attr
+ response.should redirect_to('/home/configure')
+ end
+ end
+ context 'json形式' do
+ it 'ステータスコード200 OKを返す' do
+ Artist.any_instance.stub(:save).with(any_args()).and_return(true)
+ put :update, :id => @artist.id, :artist => @attr, :format => :json
+ response.should be_success
+ end
+ it 'ページ本体は特に返さない' do
+ Artist.any_instance.stub(:save).with(any_args()).and_return(true)
+ put :update, :id => @artist.id, :artist => @attr, :format => :json
+ response.body.should match /./
+ end
+ end
+ end
+ context '作家権限がないとき' do
+ before do
+ sign_out @user
+ end
+ it 'ステータスコード302 Foundを返す' do
+ put :update, :id => @artist.id, :artist => @attr
+ response.status.should eq 302
+ end
+ context 'html形式' do
+ it 'サインインページへ遷移する' do
+ put :update, :id => @artist.id, :artist => @attr
+ response.body.should redirect_to '/users/sign_in'
+ end
+ end
+ context 'json形式' do
+ it '応答メッセージにUnauthorizedを返す' do
+ put :update, :id => @artist.id, :artist => @attr, :format => :json
+ response.message.should match(/Unauthorized/)
+ end
+ end
+ end
+ end
+
+end
end
@artist = FactoryGirl.create :artist_yas, :author_id => @author.id
end
+if MagicNumber['run_mode'] == 1
describe '一覧表示に於いて' do
before do
Author.stub(:list).and_return([@author, @author, @author])
end
end
+else
+ describe '一覧表示に於いて' do
+ before do
+ Author.stub(:list).and_return([@author, @author, @author])
+ sign_in @user
+ end
+ context 'つつがなく終わるとき' do
+ it 'ステータスコード200 OKを返す' do
+ get :index
+ response.should be_success
+ end
+ context 'html形式' do
+ it 'indexテンプレートを描画する' do
+ get :index
+ response.should render_template("index")
+ end
+ end
+ context 'json形式' do
+ it 'jsonデータを返す' do
+ get :index, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ end
+ end
+ context '作家権限がないとき' do
+ before do
+ sign_out @user
+ end
+ it 'ステータスコード200 OKを返す' do
+ get :index
+ response.should be_success
+ end
+ context 'html形式' do
+ it 'indexテンプレートを描画する' do
+ get :index
+ response.should render_template("index")
+ end
+ end
+ context 'json形式' do
+ it 'jsonデータを返す' do
+ get :index, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ end
+ end
+ end
+
+ describe '閲覧に於いて' do
+ before do
+ Author.stub(:show).and_return(@author)
+ sign_in @user
+ end
+ context 'つつがなく終わるとき' do
+ it 'ステータスコード200 OKを返す' do
+ get :show, :id => @author.id
+ response.should be_success
+ end
+ context 'html形式' do
+ it 'showテンプレートを描画する' do
+ get :show, :id => @author.id
+ response.should render_template("show")
+ end
+ end
+ context 'json形式' do
+ it 'jsonデータを返す' do
+ get :show, :id => @author.id, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ end
+ end
+ context '作家権限がないとき' do
+ before do
+ sign_out @user
+ end
+ it 'ステータスコード200 OKを返す' do
+ get :show, :id => @author.id
+ response.should be_success
+ end
+ context 'html形式' do
+ it 'showテンプレートを描画する' do
+ get :show, :id => @author.id
+ response.should render_template("show")
+ end
+ end
+ context 'json形式' do
+ it 'jsonデータを返す' do
+ get :show, :id => @author.id, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ end
+ end
+ end
+
+ describe '作家数取得に於いて' do
+ before do
+ Author.should_receive(:visible_count).and_return(3)
+# sign_in @user
+ end
+ context 'つつがなく終わるとき' do
+ it 'ステータスコード200 OKを返す' do
+ get :count, :format => :json
+ response.should be_success
+ end
+ context 'json形式' do
+ it 'jsonデータを返す' do
+ get :count, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ end
+ end
+ end
+
+ describe '新規作成フォーム表示に於いて' do
+ before do
+ @new_user = FactoryGirl.create( :user_yas)
+ sign_in @new_user
+ end
+ context 'つつがなく終わるとき' do
+ it 'ステータスコード200 OKを返す' do
+ get :new
+ response.should be_success
+ end
+ context 'html形式' do
+ it 'newテンプレートを描画する' do
+ get :new
+ response.should render_template("new")
+ end
+ end
+ context 'js形式' do
+ it 'new.jsテンプレートを描画する' do
+ get :new, :format => :js
+ response.should render_template("new")
+ end
+ end
+ context 'json形式' do
+ it 'jsonデータを返す' do
+ get :new, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ end
+ end
+ context '作家権限がないとき' do
+ before do
+ sign_out @new_user
+ 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 '/users/sign_in'
+ end
+ end
+ context 'js形式' do
+ it 'ステータスコード401 Unauthorizedを返す' do
+ get :new, :format => :js
+ response.status.should eq 401
+ end
+ it '応答メッセージにUnauthorizedを返す' do
+ get :new, :format => :js
+ response.message.should match(/Unauthorized/)
+ end
+ end
+ context 'json形式' do
+ it 'ステータスコード401 Unauthorizedを返す' do
+ get :new, :format => :json
+ response.status.should eq 401
+ end
+ it '応答メッセージにUnauthorizedを返す' do
+ get :new, :format => :json
+ response.message.should match(/Unauthorized/)
+ end
+ end
+ end
+ end
+
+ describe '新規作成に於いて' do
+ before do
+ @new_user = FactoryGirl.create( :user_yas)
+ sign_in @new_user
+ @attr = FactoryGirl.attributes_for(:author, :user_id => @new_user.id, :name => 'ken')
+ end
+ context 'つつがなく終わるとき' do
+ context 'html形式' do
+ it 'ステータスコード302 Foundを返す' do
+ Author.any_instance.stub(:save).and_return(true)
+ post :create, :author => @attr
+ response.status.should eq 302
+ end
+ it 'トップページへ遷移する' do
+# Author.any_instance.stub(:save).and_return(true)
+ post :create, :author => @attr
+ response.should redirect_to(root_path)
+ end
+ end
+ context 'json形式' do
+ it 'ステータスコード200 OKを返す' do
+# Author.any_instance.stub(:save).and_return(true)
+ post :create, :author => @attr, :format => :json
+ response.should be_success
+ end
+ end
+ end
+ context '作家権限がないとき' do
+ before do
+ sign_out @new_user
+ end
+ context 'html形式' do
+ it 'ステータスコード302 Foundを返す' do
+ post :create, :author => @attr
+ response.status.should eq 302
+ end
+ it 'サインインページへ遷移する' do
+ post :create, :author => @attr
+ response.body.should redirect_to '/users/sign_in'
+ end
+ end
+ context 'json形式' do
+ it 'ステータスコード401 Unauthorizedを返す' do
+ post :create, :author => @attr, :format => :json
+ response.status.should eq 401
+ end
+ it '応答メッセージにUnauthorizedを返す' do
+ post :create, :author => @attr, :format => :json
+ response.message.should match(/Unauthorized/)
+ end
+ end
+ end
+ end
+
+ describe '編集フォーム表示に於いて' do
+ before do
+ sign_in @user
+ Author.stub(:edit).and_return(@author)
+ end
+ context 'つつがなく終わるとき' do
+ it 'ステータスコード200 OKを返す' do
+ get :edit, :id => @author.id
+ response.should be_success
+ end
+ context 'html形式' do
+ it 'editテンプレートを描画する' do
+ get :edit, :id => @author.id
+ response.should render_template("edit")
+ end
+ end
+ context 'js形式' do
+ it 'edit.jsテンプレートを描画する' do
+ get :edit, :id => @author.id, :format => :js
+ response.should render_template("edit")
+ end
+ end
+ end
+ context '作家権限がないとき' do
+ before do
+ sign_out @user
+ end
+ context 'html形式' do
+ it 'ステータスコード302 Foundを返す' do
+ get :edit, :id => @author.id
+ response.status.should eq 302
+ end
+ it 'サインインページへ遷移する' do
+ get :edit, :id => @author.id
+ response.body.should redirect_to '/users/sign_in'
+ end
+ end
+ context 'js形式' do
+ it 'ステータスコード401 Unauthorizedを返す' do
+ get :edit, :id => @author.id, :format => :js
+ response.status.should eq 401
+ end
+ it '応答メッセージにUnauthorizedを返す' do
+ get :edit, :id => @author.id, :format => :js
+ response.message.should match(/Unauthorized/)
+ end
+ end
+ end
+ end
+
+ describe '更新に於いて' do
+ before do
+ @attr = @author.attributes
+ @attr['name'] = 'ryu'
+ sign_in @user
+ end
+ context 'つつがなく終わるとき' do
+ it '更新される' do
+ put :update, :id => @author.id, :author => @attr
+ Author.find(@author.id).name.should eq 'ryu'
+ end
+ context 'html形式' do
+ it 'ステータスコード302 Foundを返す' do
+ Author.any_instance.stub(:save).with(any_args()).and_return(true)
+ put :update, :id => @author.id, :author => @attr
+ response.status.should eq 302
+ end
+ it '設定ページへ遷移する' do
+ put :update, :id => @author.id, :author => @attr
+ response.should redirect_to('/home/configure')
+ end
+ end
+ context 'json形式' do
+ it 'ステータスコード200 OKを返す' do
+ Author.any_instance.stub(:save).with(any_args()).and_return(true)
+ put :update, :id => @author.id, :author => @attr, :format => :json
+ response.should be_success
+ end
+ it 'ページ本体は特に返さない' do
+ Author.any_instance.stub(:save).with(any_args()).and_return(true)
+ put :update, :id => @author.id, :author => @attr, :format => :json
+ response.body.should match /./
+ end
+ end
+ end
+ context '作家権限がないとき' do
+ before do
+ sign_out @user
+ end
+ it 'ステータスコード302 Foundを返す' do
+ put :update, :id => @author.id, :author => @attr
+ response.status.should eq 302
+ end
+ context 'html形式' do
+ it 'サインインページへ遷移する' do
+ put :update, :id => @author.id, :author => @attr
+ response.body.should redirect_to '/users/sign_in'
+ end
+ end
+ context 'json形式' do
+ it '応答メッセージにUnauthorizedを返す' do
+ put :update, :id => @author.id, :author => @attr, :format => :json
+ response.message.should match(/Unauthorized/)
+ end
+ end
+ end
+ end
+
+end
end
@panel = FactoryGirl.create :panel, :author_id => @author.id
end
+if MagicNumber['run_mode'] == 1
describe '一覧表示に於いて' do
before do
@sb = FactoryGirl.create :speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @speech_balloon_template.id
end
end
+else
+ describe '一覧表示に於いて' do
+ before do
+ @sb = FactoryGirl.create :speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @speech_balloon_template.id
+ @balloon = FactoryGirl.create :balloon, :speech_balloon_id => @sb.id, :system_picture_id => @sp.id
+ @speech = FactoryGirl.create :speech, :speech_balloon_id => @sb.id
+ sign_in @user
+ Balloon.stub(:list).and_return([@balloon, @balloon, @balloon])
+ end
+ context 'つつがなく終わるとき' do
+ it 'ステータスコード200 OKを返す' do
+ get :index
+ response.should be_success
+ end
+ context 'html形式' do
+ it 'indexテンプレートを描画する' do
+ get :index
+ response.should render_template("index")
+ end
+ end
+ context 'json形式' do
+ it 'jsonデータを返す' do
+ get :index, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ end
+ end
+ context '作家権限がないとき' do
+ before do
+ sign_out @user
+ end
+ it 'ステータスコード200 OKを返す' do
+ get :index
+ response.should be_success
+ end
+ context 'html形式' do
+ it 'indexテンプレートを描画する' do
+ get :index
+ response.should render_template("index")
+ end
+ end
+ context 'json形式' do
+ it 'jsonデータを返す' do
+ get :index, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ end
+ end
+ end
+
+ describe '単体表示に於いて' do
+ before do
+ sign_in @user
+ @sb = FactoryGirl.create :speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @speech_balloon_template.id
+ @balloon = FactoryGirl.create :balloon, :speech_balloon_id => @sb.id, :system_picture_id => @sp.id
+ @speech = FactoryGirl.create :speech, :speech_balloon_id => @sb.id
+ Balloon.stub(:show).and_return(@balloon)
+ end
+ context 'つつがなく終わるとき' do
+ it 'ステータスコード200 OKを返す' do
+ get :show, :id => @balloon.id
+ response.should be_success
+ end
+ context 'html形式' do
+ it 'showテンプレートを描画する' do
+ get :show, :id => @balloon.id
+ response.should render_template("show")
+ end
+ end
+ context 'json形式' do
+ it 'jsonデータを返す' do
+ get :show, :id => @balloon.id, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ end
+ end
+ context '作家権限がないとき' do
+ before do
+ sign_out @user
+ end
+ it 'ステータスコード200 OKを返す' do
+ get :show, :id => @balloon.id
+ response.should be_success
+ end
+ context 'html形式' do
+ it 'showテンプレートを描画する' do
+ get :show, :id => @balloon.id
+ response.should render_template("show")
+ end
+ end
+ context 'json形式' do
+ it 'jsonデータを返す' do
+ get :show, :id => @balloon.id, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ end
+ end
+ end
+
+end
end
@license = FactoryGirl.create :license, :license_group_id => @lg.id, :system_picture_id => @sp.id
end
+if MagicNumber['run_mode'] == 1
describe '一覧表示に於いて' do
before do
sign_in @user
end
end
+else
+ describe '一覧表示に於いて' do
+ before do
+ sign_in @user
+ @color = FactoryGirl.create :color
+ Color.stub(:list).and_return([@color, @color, @color])
+ end
+ context 'つつがなく終わるとき' do
+ it 'ステータスコード200 OKを返す' do
+ get :index
+ response.should be_success
+ end
+ context 'html形式' do
+ it 'indexテンプレートを描画する' do
+ get :index
+ response.should render_template("index")
+ end
+ end
+ context 'json形式' do
+ it 'jsonデータを返す' do
+ get :index, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ end
+ end
+ context '作家権限がないとき' do
+ before do
+ sign_out @user
+ end
+ it 'ステータスコード200 okを返す' do
+ get :index
+ response.status.should eq 200
+ end
+ context 'html形式' do
+ it 'indexテンプレートを描画する' do
+ get :index
+ response.should render_template("index")
+ end
+ end
+ context 'json形式' do
+ it 'jsonデータを返す' do
+ get :index, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ end
+ end
+ end
+
+ describe '単体表示に於いて' do
+ before do
+ sign_in @user
+ @color = FactoryGirl.create :color
+ Color.stub(:show).and_return(@color)
+ end
+ context 'つつがなく終わるとき' do
+ it 'ステータスコード200 OKを返す' do
+ get :show, :id => @color.id
+ response.should be_success
+ end
+ context 'html形式' do
+ it 'showテンプレートを描画する' do
+ get :show, :id => @color.id
+ response.should render_template("show")
+ end
+ end
+ context 'json形式' do
+ it 'jsonデータを返す' do
+ get :show, :id => @color.id, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ end
+ end
+ context '作家権限がないとき' do
+ before do
+ sign_out @user
+ end
+ it 'ステータスコード200 okを返す' do
+ get :show, :id => @color.id
+ response.status.should eq 200
+ end
+ context 'html形式' do
+ it 'showテンプレートを描画する' do
+ get :show, :id => @color.id
+ response.should render_template("show")
+ end
+ end
+ context 'json形式' do
+ it 'jsonデータを返す' do
+ get :show, :id => @color.id, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ end
+ end
+ end
+
+end
end
# -*- encoding: utf-8 -*-\r
require 'spec_helper'\r
#コミック\r
-\r
describe ComicsController do\r
before do\r
@admin =FactoryGirl.create :admin\r
@author = FactoryGirl.create :author, :user_id => @user.id\r
end\r
\r
+if MagicNumber['run_mode'] == 1\r
describe '一覧表示に於いて' do\r
before do\r
@comic = FactoryGirl.create :comic, :author_id => @user.author.id\r
end\r
end\r
\r
+else\r
+ describe '一覧表示に於いて' do\r
+ before do\r
+ @comic = FactoryGirl.create :comic, :author_id => @user.author.id\r
+ Comic.stub(:list).and_return([@comic, @comic, @comic])\r
+ sign_in @user\r
+ end\r
+ context 'つつがなく終わるとき' do\r
+ it 'ステータスコード200 OKを返す' do\r
+ get :index\r
+ response.should be_success \r
+ end\r
+ context 'html形式' do\r
+ it 'indexテンプレートを描画する' do\r
+ get :index\r
+ response.should render_template("index")\r
+ end\r
+ end\r
+ context 'json形式' do\r
+ it 'jsonデータを返す' do\r
+ get :index, :format => :json\r
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)\r
+ end\r
+ end\r
+ end\r
+ context '作家権限がないとき' do\r
+ before do\r
+ sign_out @user\r
+ end\r
+ it 'ステータスコード200 OKを返す' do\r
+ get :index\r
+ response.should be_success \r
+ end\r
+ context 'html形式' do\r
+ it 'indexテンプレートを描画する' do\r
+ get :index\r
+ response.should render_template("index")\r
+ end\r
+ end\r
+ context 'json形式' do\r
+ it 'jsonデータを返す' do\r
+ get :index, :format => :json\r
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)\r
+ end\r
+ end\r
+ end\r
+ end\r
+ \r
+ describe '単体表示に於いて' do\r
+ before do\r
+ @comic = FactoryGirl.create :comic, :author_id => @user.author.id, :title => 'normal'\r
+ Comic.stub(:show).and_return(@comic)\r
+ sign_in @user\r
+ end\r
+ context 'つつがなく終わるとき' do\r
+ it 'ステータスコード200 OKを返す' do\r
+ get :show, :id => @comic.id\r
+ response.should be_success\r
+ end\r
+ context 'html形式' do\r
+ it 'showテンプレートを描画する' do\r
+ get :show, :id => @comic.id\r
+ response.should render_template("show")\r
+ end\r
+ end\r
+ context 'json形式' do\r
+ it 'jsonデータを返す' do\r
+ get :show, :id => @comic.id, :format => :json\r
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)\r
+ end\r
+ end\r
+ end\r
+ context '作家権限がないとき' do\r
+ before do\r
+ sign_out @user\r
+ end\r
+ it 'ステータスコード200 OKを返す' do\r
+ get :show, :id => @comic.id\r
+ response.should be_success\r
+ end\r
+ context 'html形式' do\r
+ it 'showテンプレートを描画する' do\r
+ get :show, :id => @comic.id\r
+ response.should render_template("show")\r
+ end\r
+ end\r
+ context 'json形式' do\r
+ it 'jsonデータを返す' do\r
+ get :show, :id => @comic.id, :format => :json\r
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)\r
+ end\r
+ end\r
+ end\r
+ end\r
+ describe 'コミック数取得に於いて' do\r
+ before do\r
+ Comic.should_receive(:visible_count).and_return(3)\r
+ sign_out @user\r
+ end\r
+ context 'つつがなく終わるとき' do\r
+ it 'ステータスコード200 OKを返す' do\r
+ get :count, :format => :json\r
+ response.should be_success \r
+ end\r
+ context 'json形式' do\r
+ it 'jsonデータを返す' do\r
+ get :count, :format => :json\r
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)\r
+ end\r
+ end\r
+ end\r
+ end\r
+\r
+ describe '新規作成フォーム表示に於いて' do\r
+ before do\r
+ sign_in @user\r
+ end\r
+ context 'つつがなく終わるとき' do\r
+ it 'ステータスコード200 OKを返す' do\r
+ get :new\r
+ response.should be_success \r
+ end\r
+ context 'html形式' do\r
+ it 'newテンプレートを描画する' do\r
+ get :new\r
+ response.should render_template("new")\r
+ end\r
+ end\r
+ context 'js形式' do\r
+ it 'new.jsテンプレートを描画する' do\r
+ get :new, :format => :js\r
+ response.should render_template("new")\r
+ end\r
+ end\r
+ context 'json形式' do\r
+ it 'jsonデータを返す' do\r
+ get :new, :format => :json\r
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)\r
+ end\r
+ end\r
+ end\r
+ context '作家権限がないとき' do\r
+ before do\r
+ sign_out @user\r
+ end\r
+ context 'html形式' do\r
+ it 'ステータスコード302 Foundを返す' do\r
+ get :new\r
+ response.status.should eq 302\r
+ end\r
+ it 'サインインページへ遷移する' do\r
+ get :new\r
+ response.body.should redirect_to '/users/sign_in'\r
+ end\r
+ end\r
+ context 'js形式' do\r
+ it 'ステータスコード401 Unauthorizedを返す' do\r
+ get :new, :format => :js\r
+ response.status.should eq 401\r
+ end\r
+ it '応答メッセージにUnauthorizedを返す' do\r
+ get :new, :format => :js\r
+ response.message.should match(/Unauthorized/)\r
+ end\r
+ end\r
+ context 'json形式' do\r
+ it 'ステータスコード401 Unauthorizedを返す' do\r
+ get :new, :format => :json\r
+ response.status.should eq 401\r
+ end\r
+ it '応答メッセージにUnauthorizedを返す' do\r
+ get :new, :format => :json\r
+ response.message.should match(/Unauthorized/)\r
+ end\r
+ end\r
+ end\r
+ end\r
+\r
+ describe '新規作成に於いて' do\r
+ before do\r
+ sign_in @user\r
+ @attr = FactoryGirl.attributes_for(:comic, :author_id => @author.id, :title => 'normal')\r
+ end\r
+ context 'つつがなく終わるとき' do\r
+ context 'html形式' do\r
+ it 'ステータスコード302 Foundを返す' do\r
+ Comic.any_instance.stub(:save).and_return(true)\r
+ post :create, :comic => @attr\r
+ response.status.should eq 302\r
+ end\r
+ it '作成されたコミックの表示ページへ遷移する' do\r
+# Comic.any_instance.stub(:save).and_return(true)\r
+ post :create, :comic => @attr\r
+ response.should redirect_to(Comic.last)\r
+ end\r
+ end\r
+ context 'json形式' do\r
+ it 'ステータスコード200 OKを返す' do\r
+# Comic.any_instance.stub(:save).and_return(true)\r
+ post :create, :comic => @attr, :format => :json\r
+ response.should be_success \r
+ end\r
+ it '作成されたコミックをjsonデータで返す' do\r
+ post :create, :comic => @attr, :format => :json\r
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)\r
+ end\r
+ end\r
+ end\r
+ context '作家権限がないとき' do\r
+ before do\r
+ sign_out @user\r
+ end\r
+ context 'html形式' do\r
+ it 'ステータスコード302 Foundを返す' do\r
+ post :create, :comic => @attr\r
+ response.status.should eq 302\r
+ end\r
+ it 'サインインページへ遷移する' do\r
+ post :create, :comic => @attr\r
+ response.body.should redirect_to '/users/sign_in'\r
+ end\r
+ end\r
+ context 'json形式' do\r
+ it 'ステータスコード401 Unauthorizedを返す' do\r
+ post :create, :comic => @attr, :format => :json\r
+ response.status.should eq 401\r
+ end\r
+ it '応答メッセージにUnauthorizedを返す' do\r
+ post :create, :comic => @attr, :format => :json\r
+ response.message.should match(/Unauthorized/)\r
+ end\r
+ end\r
+ end\r
+ end\r
+\r
+ describe '編集フォーム表示に於いて' do\r
+ before do\r
+ @comic = FactoryGirl.create :comic, :author_id => @user.author.id\r
+ sign_in @user\r
+ Comic.stub(:edit).and_return(@comic)\r
+ end\r
+ context 'つつがなく終わるとき' do\r
+ it 'ステータスコード200 OKを返す' do\r
+ get :edit, :id => @comic.id\r
+ response.should be_success \r
+ end\r
+ context 'html形式' do\r
+ it 'editテンプレートを描画する' do\r
+ get :edit, :id => @comic.id\r
+ response.should render_template("edit")\r
+ end\r
+ end\r
+ context 'js形式' do\r
+ it 'edit.jsテンプレートを描画する' do\r
+ get :edit, :id => @comic.id, :format => :js\r
+ response.should render_template("edit")\r
+ end\r
+ end\r
+ end\r
+ context '作家権限がないとき' do\r
+ before do\r
+ sign_out @user\r
+ end\r
+ context 'html形式' do\r
+ it 'ステータスコード302 Foundを返す' do\r
+ get :edit, :id => @comic.id\r
+ response.status.should eq 302\r
+ end\r
+ it 'サインインページへ遷移する' do\r
+ get :edit, :id => @comic.id\r
+ response.body.should redirect_to '/users/sign_in'\r
+ end\r
+ end\r
+ context 'js形式' do\r
+ it 'ステータスコード401 Unauthorizedを返す' do\r
+ get :edit, :id => @comic.id, :format => :js\r
+ response.status.should eq 401\r
+ end\r
+ it '応答メッセージにUnauthorizedを返す' do\r
+ get :edit, :id => @comic.id, :format => :js\r
+ response.message.should match(/Unauthorized/)\r
+ end\r
+ end\r
+ end\r
+ end\r
+\r
+ describe '更新に於いて' do\r
+ before do\r
+ @comic = FactoryGirl.create :comic, :author => @author\r
+ @attr = FactoryGirl.attributes_for(:comic, :author_id => @author.id, :title => 'updated title', :visible => 0)\r
+ sign_in @user\r
+ end\r
+ context 'つつがなく終わるとき' do\r
+ context 'html形式' do\r
+ it 'ステータスコード302 Foundを返す' do\r
+ Comic.any_instance.stub(:save).with(any_args()).and_return(true)\r
+ put :update, :id => @comic.id, :comic => @attr\r
+ response.status.should eq 302\r
+ end\r
+ it '更新されたコミックの表示ページへ遷移する' do\r
+ put :update, :id => @comic.id, :comic => @attr\r
+ response.should redirect_to(@comic)\r
+ end\r
+ end\r
+ context 'json形式' do\r
+ it 'ステータスコード200 OKを返す' do\r
+ Comic.any_instance.stub(:save).with(any_args()).and_return(true)\r
+ put :update, :id => @comic.id, :comic => @attr, :format => :json\r
+ response.should be_success \r
+ end\r
+ it 'ページ本体は特に返さない' do\r
+ Comic.any_instance.stub(:save).with(any_args()).and_return(true)\r
+ put :update, :id => @comic.id, :comic => @attr, :format => :json\r
+ response.body.should match /./\r
+ end\r
+ end\r
+ end\r
+ context '作家権限がないとき' do\r
+ before do\r
+ sign_out @user\r
+ end\r
+ it 'ステータスコード302 Foundを返す' do\r
+ put :update, :id => @comic.id, :comic => @attr\r
+ response.status.should eq 302\r
+ end\r
+ context 'html形式' do\r
+ it 'サインインページへ遷移する' do\r
+ put :update, :id => @comic.id, :comic => @attr\r
+ response.body.should redirect_to '/users/sign_in'\r
+ end\r
+ end\r
+ end\r
+ end\r
+\r
+ describe '削除に於いて' do\r
+ before do\r
+ @comic = FactoryGirl.create :comic, :author => @author\r
+ sign_in @user\r
+ end\r
+ context 'つつがなく終わるとき' do\r
+ context 'html形式' do\r
+ before do\r
+ Comic.any_instance.stub(:destroy_with_story).with(any_args()).and_return(true)\r
+ end\r
+ it 'ステータスコード302 Foundを返す' do\r
+ delete :destroy, :id => @comic.id\r
+ response.status.should eq 302\r
+ end\r
+ it 'マイコミックの一覧ページへ遷移する' do\r
+ delete :destroy, :id => @comic.id\r
+ response.should redirect_to('/home/comic')\r
+ end\r
+ end\r
+ context 'json形式' do\r
+ before do\r
+ Comic.any_instance.stub(:destroy_with_story).with(any_args()).and_return(true)\r
+ end\r
+ it 'ステータスコード200 OKを返す' do\r
+ delete :destroy, :id => @comic.id, :format => :json\r
+ response.should be_success \r
+ end\r
+ it 'ページ本体は特に返さない' do\r
+ delete :destroy, :id => @comic.id, :format => :json\r
+ response.body.should match /./\r
+ end\r
+ end\r
+ end\r
+ context '作家権限がないとき' do\r
+ before do\r
+ sign_out @user\r
+ end\r
+ it 'ステータスコード302 Foundを返す' do\r
+ delete :destroy, :id => @comic.id\r
+ response.status.should eq 302\r
+ end\r
+ context 'html形式' do\r
+ it 'サインインページへ遷移する' do\r
+ delete :destroy, :id => @comic.id\r
+ response.body.should redirect_to '/users/sign_in'\r
+ end\r
+ end\r
+ context 'json形式' do\r
+ it '応答メッセージにUnauthorizedを返す' do\r
+ delete :destroy, :id => @comic.id, :format => :json\r
+ response.message.should match(/Unauthorized/)\r
+ end\r
+ end\r
+ end\r
+ end\r
+\r
+end\r
+\r
end\r
@color = FactoryGirl.create :color
end
+if MagicNumber['run_mode'] == 1
describe '一覧表示に於いて' do
before do
sign_in @user
end
end
+else
+ describe '一覧表示に於いて' do
+ before do
+ sign_in @user
+ @gc = FactoryGirl.create :ground_color
+ GroundColor.stub(:list).and_return([@gc, @gc, @gc])
+ end
+ context 'つつがなく終わるとき' do
+ it 'ステータスコード200 OKを返す' do
+ get :index
+ response.should be_success
+ end
+ context 'html形式' do
+ it 'indexテンプレートを描画する' do
+ get :index
+ response.should render_template("index")
+ end
+ end
+ context 'json形式' do
+ it 'jsonデータを返す' do
+ get :index, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ end
+ end
+ context '作家権限がないとき' do
+ before do
+ sign_out @user
+ end
+ it 'ステータスコード200 OKを返す' do
+ get :index
+ response.should be_success
+ end
+ context 'html形式' do
+ it 'indexテンプレートを描画する' do
+ get :index
+ response.should render_template("index")
+ end
+ end
+ context 'json形式' do
+ it 'jsonデータを返す' do
+ get :index, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ end
+ end
+ end
+
+ describe '単体表示に於いて' do
+ before do
+ sign_in @user
+ @gc = FactoryGirl.create :ground_color
+ GroundColor.stub(:show).and_return(@gc)
+ end
+ context 'つつがなく終わるとき' do
+ it 'ステータスコード200 OKを返す' do
+ get :show, :id => @gc.id
+ response.should be_success
+ end
+ context 'html形式' do
+ it 'showテンプレートを描画する' do
+ get :show, :id => @gc.id
+ response.should render_template("show")
+ end
+ end
+ context 'json形式' do
+ it 'jsonデータを返す' do
+ get :show, :id => @gc.id, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ end
+ end
+ context '作家権限がないとき' do
+ before do
+ sign_out @user
+ end
+ it 'ステータスコード200 OKを返す' do
+ get :show, :id => @gc.id
+ response.should be_success
+ end
+ context 'html形式' do
+ it 'showテンプレートを描画する' do
+ get :show, :id => @gc.id
+ response.should render_template("show")
+ end
+ end
+ context 'json形式' do
+ it 'jsonデータを返す' do
+ get :show, :id => @gc.id, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ end
+ end
+ end
+
+end
end
@panel = FactoryGirl.create :panel, :author_id => @author.id
end
+if MagicNumber['run_mode'] == 1
describe '一覧表示に於いて' do
before do
sign_in @user
end
end
+else
+ describe '一覧表示に於いて' do
+ before do
+ sign_in @user
+ @gp = FactoryGirl.create :ground_picture, :panel_id => @panel.id, :picture_id => @p.id
+ GroundPicture.stub(:list).and_return([@gp, @gp, @gp])
+ end
+ context 'つつがなく終わるとき' do
+ it 'ステータスコード200 OKを返す' do
+ get :index
+ response.should be_success
+ end
+ context 'html形式' do
+ it 'indexテンプレートを描画する' do
+ get :index
+ response.should render_template("index")
+ end
+ end
+ context 'json形式' do
+ it 'jsonデータを返す' do
+ get :index, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ end
+ end
+ context '作家権限がないとき' do
+ before do
+ sign_out @user
+ end
+ it 'ステータスコード200 OKを返す' do
+ get :index
+ response.should be_success
+ end
+ context 'html形式' do
+ it 'indexテンプレートを描画する' do
+ get :index
+ response.should render_template("index")
+ end
+ end
+ context 'json形式' do
+ it 'jsonデータを返す' do
+ get :index, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ end
+ end
+ end
+
+ describe '単体表示に於いて' do
+ before do
+ sign_in @user
+ @gp = FactoryGirl.create :ground_picture, :panel_id => @panel.id, :picture_id => @p.id
+ GroundPicture.stub(:show).and_return(@gp)
+ end
+ context 'つつがなく終わるとき' do
+ it 'ステータスコード200 OKを返す' do
+ get :show, :id => @gp.id
+ response.should be_success
+ end
+ context 'html形式' do
+ it 'showテンプレートを描画する' do
+ get :show, :id => @gp.id
+ response.should render_template("show")
+ end
+ end
+ context 'json形式' do
+ it 'jsonデータを返す' do
+ get :show, :id => @gp.id, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ end
+ end
+ context '作家権限がないとき' do
+ before do
+ sign_out @user
+ end
+ it 'ステータスコード200 OKを返す' do
+ get :show, :id => @gp.id
+ response.should be_success
+ end
+ context 'html形式' do
+ it 'showテンプレートを描画する' do
+ get :show, :id => @gp.id
+ response.should render_template("show")
+ end
+ end
+ context 'json形式' do
+ it 'jsonデータを返す' do
+ get :show, :id => @gp.id, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ end
+ end
+ end
+
+end
end
@panel = FactoryGirl.create :panel, :author_id => @author.id
end
+if MagicNumber['run_mode'] == 1
describe '自分のコミック一覧表示に於いて' do
before do
@comic = FactoryGirl.create :comic, :author_id => @author.id
end
end
+else
+ describe '自分のコミック一覧表示に於いて' do
+ before do
+ @comic = FactoryGirl.create :comic, :author_id => @author.id
+ sign_in @user
+ Comic.stub(:mylist).and_return([@comic, @comic, @comic])
+ end
+ context 'つつがなく終わるとき' do
+ it 'ステータスコード200 OKを返す' do
+ get :comic
+ response.should be_success
+ end
+ context 'html形式' do
+ it 'comicテンプレートを描画する' do
+ get :comic
+ response.should render_template("comic")
+ end
+ end
+ context 'json形式' do
+ it 'jsonデータを返す' do
+ get :comic, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ end
+ end
+ context '作家権限がないとき' do
+ before do
+ sign_out @user
+ end
+ context 'html形式' do
+ it 'ステータスコード302 Foundを返す' do
+ get :comic
+ response.status.should eq 302
+ end
+ it 'サインインページへ遷移する' do
+ get :comic
+ response.should redirect_to '/users/sign_in'
+ end
+ end
+ context 'json形式' do
+ it 'ステータスコード401 Unauthorizedを返す' do
+ get :comic, :format => :json
+ response.status.should eq 401
+ end
+ it '応答メッセージにUnauthorizedを返す' do
+ get :comic, :format => :json
+ response.message.should match(/Unauthorized/)
+ end
+ end
+ end
+ end
+
+ describe '自分のコマ一覧表示に於いて' do
+ before do
+ @panel = FactoryGirl.create :panel, :author_id => @author.id
+ sign_in @user
+ Panel.stub(:mylist).and_return([@panel, @panel, @panel])
+ end
+ context 'つつがなく終わるとき' do
+ context 'html形式' do
+ it 'ステータスコード200 OKを返す' do
+ get :panel
+ response.should be_success
+ end
+ it 'panelテンプレートを描画する' do
+ get :panel
+ response.should render_template("panel")
+ end
+ end
+ context 'json形式' do
+ it 'ステータスコード200 OKを返す' do
+ get :panel, :format => :json
+ response.should be_success
+ end
+ it 'jsonデータを返す' do
+ get :panel, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ end
+ end
+ context '作家権限がないとき' do
+ before do
+ sign_out @user
+ end
+ context 'html形式' do
+ it 'ステータスコード302 Foundを返す' do
+ get :panel
+ response.status.should eq 302
+ end
+ it 'サインインページへ遷移する' do
+ get :panel
+ response.should redirect_to '/users/sign_in'
+ end
+ end
+ context 'json形式' do
+ it 'ステータスコード401 Unauthorizedを返す' do
+ get :panel, :format => :json
+ response.status.should eq 401
+ end
+ it '応答メッセージにUnauthorizedを返す' do
+ get :panel, :format => :json
+ response.message.should match(/Unauthorized/)
+ end
+ end
+ end
+ end
+
+ describe '自分のコマ絵一覧表示に於いて' do
+ before do
+ @pp = FactoryGirl.create :panel_picture, :panel_id => @panel.id, :picture_id => @p.id,
+ :width => @p.width, :height => @p.height
+ sign_in @user
+ PanelPicture.stub(:mylist).and_return([@pp, @pp, @pp])
+ end
+ context 'つつがなく終わるとき' do
+ it 'ステータスコード200 OKを返す' do
+ get :panel_picture
+ response.should be_success
+ end
+ context 'html形式' do
+ it 'panel_pictureテンプレートを描画する' do
+ get :panel_picture
+ response.should render_template("panel_picture")
+ end
+ end
+ context 'json形式' do
+ it 'jsonデータを返す' do
+ get :panel_picture, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ end
+ end
+ context '作家権限がないとき' do
+ before do
+ sign_out @user
+ end
+ context 'html形式' do
+ it 'ステータスコード302 Foundを返す' do
+ get :panel_picture
+ response.status.should eq 302
+ end
+ it 'サインインページへ遷移する' do
+ get :panel_picture
+ response.should redirect_to '/users/sign_in'
+ end
+ end
+ context 'json形式' do
+ it 'ステータスコード401 Unauthorizedを返す' do
+ get :panel_picture, :format => :json
+ response.status.should eq 401
+ end
+ it '応答メッセージにUnauthorizedを返す' do
+ get :panel_picture, :format => :json
+ response.message.should match(/Unauthorized/)
+ end
+ end
+ end
+ end
+
+ describe '自分のコマの色背景一覧表示に於いて' do
+ before do
+ @pc = FactoryGirl.create :panel_color, :panel_id => @panel.id
+ sign_in @user
+ PanelColor.stub(:mylist).and_return([@pc, @pc, @pc])
+ end
+ context 'つつがなく終わるとき' do
+ it 'ステータスコード200 OKを返す' do
+ get :panel_color
+ response.should be_success
+ end
+ context 'html形式' do
+ it 'panel_colorテンプレートを描画する' do
+ get :panel_color
+ response.should render_template("panel_color")
+ end
+ end
+ context 'json形式' do
+ it 'jsonデータを返す' do
+ get :panel_color, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ end
+ end
+ context '作家権限がないとき' do
+ before do
+ sign_out @user
+ end
+ context 'html形式' do
+ it 'ステータスコード302 Foundを返す' do
+ get :panel_color
+ response.status.should eq 302
+ end
+ it 'サインインページへ遷移する' do
+ get :panel_color
+ response.should redirect_to '/users/sign_in'
+ end
+ end
+ context 'json形式' do
+ it 'ステータスコード401 Unauthorizedを返す' do
+ get :panel_color, :format => :json
+ response.status.should eq 401
+ end
+ it '応答メッセージにUnauthorizedを返す' do
+ get :panel_color, :format => :json
+ response.message.should match(/Unauthorized/)
+ end
+ end
+ end
+ end
+
+ describe '自分のコマの画像背景一覧表示に於いて' do
+ before do
+ @gp = FactoryGirl.create :ground_picture, :panel_id => @panel.id, :picture_id => @p.id
+ sign_in @user
+ GroundPicture.stub(:mylist).and_return([@gp, @gp, @gp])
+ end
+ context 'つつがなく終わるとき' do
+ it 'ステータスコード200 OKを返す' do
+ get :ground_picture
+ response.should be_success
+ end
+ context 'html形式' do
+ it 'ground_pictureテンプレートを描画する' do
+ get :ground_picture
+ response.should render_template("ground_picture")
+ end
+ end
+ context 'json形式' do
+ it 'jsonデータを返す' do
+ get :ground_picture, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ end
+ end
+ context '作家権限がないとき' do
+ before do
+ sign_out @user
+ end
+ context 'html形式' do
+ it 'ステータスコード302 Foundを返す' do
+ get :ground_picture
+ response.status.should eq 302
+ end
+ it 'サインインページへ遷移する' do
+ get :ground_picture
+ response.should redirect_to '/users/sign_in'
+ end
+ end
+ context 'json形式' do
+ it 'ステータスコード401 Unauthorizedを返す' do
+ get :ground_picture, :format => :json
+ response.status.should eq 401
+ end
+ it '応答メッセージにUnauthorizedを返す' do
+ get :ground_picture, :format => :json
+ response.message.should match(/Unauthorized/)
+ end
+ end
+ end
+ end
+
+ describe '自分の間接背景一覧表示に於いて' do
+ before do
+ @gc = FactoryGirl.create :ground_color
+ sign_in @user
+ GroundColor.stub(:mylist).and_return([@gc, @gc, @gc])
+ end
+ context 'つつがなく終わるとき' do
+ it 'ステータスコード200 OKを返す' do
+ get :ground_color
+ response.should be_success
+ end
+ context 'html形式' do
+ it 'ground_colorテンプレートを描画する' do
+ get :ground_color
+ response.should render_template("ground_color")
+ end
+ end
+ context 'json形式' do
+ it 'jsonデータを返す' do
+ get :ground_color, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ end
+ end
+ context '作家権限がないとき' do
+ before do
+ sign_out @user
+ end
+ context 'html形式' do
+ it 'ステータスコード302 Foundを返す' do
+ get :ground_color
+ response.status.should eq 302
+ end
+ it 'サインインページへ遷移する' do
+ get :ground_color
+ response.should redirect_to '/users/sign_in'
+ end
+ end
+ context 'json形式' do
+ it 'ステータスコード401 Unauthorizedを返す' do
+ get :ground_color, :format => :json
+ response.status.should eq 401
+ end
+ it '応答メッセージにUnauthorizedを返す' do
+ get :ground_color, :format => :json
+ response.message.should match(/Unauthorized/)
+ end
+ end
+ end
+ end
+
+ describe '自分の素材一覧表示に於いて' do
+ before do
+ @op = FactoryGirl.create :original_picture, :artist_id => @artist.id
+ @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(:mylist).and_return([@rp, @rp, @rp])
+ end
+ context 'つつがなく終わるとき' do
+ it 'ステータスコード200 OKを返す' do
+ get :resource_picture
+ response.should be_success
+ end
+ context 'html形式' do
+ it 'resource_pictureテンプレートを描画する' do
+ get :resource_picture
+ response.should render_template("resource_picture")
+ end
+ end
+ context 'json形式' do
+ it 'jsonデータを返す' do
+ get :resource_picture, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ end
+ end
+ context '作家権限がないとき' do
+ before do
+ sign_out @user
+ end
+ context 'html形式' do
+ it 'ステータスコード302 Foundを返す' do
+ get :resource_picture
+ response.status.should eq 302
+ end
+ it 'サインインページへ遷移する' do
+ get :resource_picture
+ response.should redirect_to '/users/sign_in'
+ end
+ end
+ context 'json形式' do
+ it 'ステータスコード401 Unauthorizedを返す' do
+ get :resource_picture, :format => :json
+ response.status.should eq 401
+ end
+ it '応答メッセージにUnauthorizedを返す' do
+ get :resource_picture, :format => :json
+ response.message.should match(/Unauthorized/)
+ end
+ end
+ end
+ context '作家が絵師でないとき' do
+ before do
+ Author.any_instance.stub(:artist?).and_return(false)
+ end
+ context 'html形式' do
+ it 'ステータスコード302 Foundを返す' do
+ get :resource_picture
+ response.status.should eq 302
+ end
+ it '絵師登録ページへ遷移する' do
+ get :resource_picture
+ response.should redirect_to new_artist_path
+ end
+ end
+ context 'json形式' do
+ it '例外403 forbiddenを返す' do
+ lambda{
+ get :resource_picture, :format => :json
+ }.should raise_error(ActiveRecord::Forbidden)
+ end
+ end
+ end
+ end
+
+end
end
@license = FactoryGirl.create :license, :license_group_id => @lg.id, :system_picture_id => @sp.id
end
+if MagicNumber['run_mode'] == 1
describe '一覧表示に於いて' do
before do
sign_in @user
end
end
-
+else
+ describe '一覧表示に於いて' do
+ before do
+ sign_in @user
+ LicenseGroup.stub(:list).and_return([@lg, @lg, @lg])
+ end
+ context 'つつがなく終わるとき' do
+ it 'ステータスコード200 OKを返す' do
+ get :index
+ response.should be_success
+ end
+ context 'html形式' do
+ it 'indexテンプレートを描画する' do
+ get :index
+ response.should render_template("index")
+ end
+ end
+ context 'json形式' do
+ it 'jsonデータを返す' do
+ get :index, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ end
+ end
+ context '作家権限がないとき' do
+ before do
+ sign_out @user
+ end
+ it 'ステータスコード200 okを返す' do
+ get :index
+ response.status.should eq 200
+ end
+ context 'html形式' do
+ it 'indexテンプレートを描画する' do
+ get :index
+ response.should render_template("index")
+ end
+ end
+ context 'json形式' do
+ it 'jsonデータを返す' do
+ get :index, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ end
+ end
+ end
+
+ describe '単体表示に於いて' do
+ before do
+ sign_in @user
+ LicenseGroup.stub(:show).and_return(@lg)
+ end
+ context 'つつがなく終わるとき' do
+ it 'ステータスコード200 OKを返す' do
+ get :show, :id => @lg.id
+ response.should be_success
+ end
+ context 'html形式' do
+ it 'showテンプレートを描画する' do
+ get :show, :id => @lg.id
+ response.should render_template("show")
+ end
+ end
+ context 'json形式' do
+ it 'jsonデータを返す' do
+ get :show, :id => @lg.id, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ end
+ end
+ context '作家権限がないとき' do
+ before do
+ sign_out @user
+ end
+ it 'ステータスコード200 okを返す' do
+ get :show, :id => @lg.id
+ response.status.should eq 200
+ end
+ context 'html形式' do
+ it 'showテンプレートを描画する' do
+ get :show, :id => @lg.id
+ response.should render_template("show")
+ end
+ end
+ context 'json形式' do
+ it 'jsonデータを返す' do
+ get :show, :id => @lg.id, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ end
+ end
+ end
+
+end
end
@artist = FactoryGirl.create :artist_yas, :author_id => @author.id
end
+if MagicNumber['run_mode'] == 1
describe '一覧表示に於いて' do
before do
@l = FactoryGirl.create :license, :license_group_id => @lg.id, :system_picture_id => @sp.id
end
end
+else
+ describe '一覧表示に於いて' do
+ before do
+ @l = FactoryGirl.create :license, :license_group_id => @lg.id, :system_picture_id => @sp.id
+ sign_in @user
+ License.stub(:list).and_return([@l, @l, @l])
+ end
+ context 'つつがなく終わるとき' do
+ it 'ステータスコード200 OKを返す' do
+ get :index
+ response.should be_success
+ end
+ context 'html形式' do
+ it 'indexテンプレートを描画する' do
+ get :index
+ response.should render_template("index")
+ end
+ end
+ context 'json形式' do
+ it 'jsonデータを返す' do
+ get :index, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ end
+ end
+ context '作家権限がないとき' do
+ before do
+ sign_out @user
+ end
+ it 'ステータスコード200 okを返す' do
+ get :index
+ response.status.should eq 200
+ end
+ context 'html形式' do
+ it 'indexテンプレートを描画する' do
+ get :index
+ response.should render_template("index")
+ end
+ end
+ context 'json形式' do
+ it 'jsonデータを返す' do
+ get :index, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ end
+ end
+ end
+
+ describe '単体表示に於いて' do
+ before do
+ sign_in @user
+ @l = FactoryGirl.create :license, :license_group_id => @lg.id, :system_picture_id => @sp.id
+ License.stub(:show).and_return(@l)
+ end
+ context 'つつがなく終わるとき' do
+ it 'ステータスコード200 OKを返す' do
+ get :show, :id => @l.id
+ response.should be_success
+ end
+ context 'html形式' do
+ it 'showテンプレートを描画する' do
+ get :show, :id => @l.id
+ response.should render_template("show")
+ end
+ end
+ context 'json形式' do
+ it 'jsonデータを返す' do
+ get :show, :id => @l.id, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ end
+ end
+ context '作家権限がないとき' do
+ before do
+ sign_out @user
+ end
+ it 'ステータスコード200 okを返す' do
+ get :show, :id => @l.id
+ response.status.should eq 200
+ end
+ context 'html形式' do
+ it 'showテンプレートを描画する' do
+ get :show, :id => @l.id
+ response.should render_template("show")
+ end
+ end
+ context 'json形式' do
+ it 'jsonデータを返す' do
+ get :show, :id => @l.id, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ end
+ end
+ end
+
+end
end
+++ /dev/null
-# -*- encoding: utf-8 -*-\r
-require 'spec_helper'
-
-describe ComicsController do
- # This should return the minimal set of attributes required to create a valid
- # Comic. As you add validations to Comic, be sure to
- # update the return value of this method accordingly.
- def valid_attributes
- {:title => 'test comic', :width => 100, :height => 50, :visible => 0, :editable => 0}
- end
-
- describe '一覧表示に於いて' do
- before do
- FactoryGirl.create :admin
- @user = FactoryGirl.create( :user_yas)
- FactoryGirl.create :normal_comic, :author_id => 1
- FactoryGirl.create :visible_comic, :author_id => 1
- Factory:editable_comic, :author_id => 1
- FactoryGirl.create :hidden_comic, :author_id => 1
- sign_in @user
- end
- context '作家権限がないとき' do
- context 'ただし、公開型のときだけは' do
- it 'ステータスコード200 OKを返す' do
- sign_out @user
- Const.run_mode = 0
- get :index
- response.should be_success
- end
- end
- end
- end
-
- describe '単体表示に於いて' do
- before do
- FactoryGirl.create :admin
- @user = FactoryGirl.create( :user_yas)
- @comic = FactoryGirl.create :normal_comic, :author_id => 1
- FactoryGirl.create :visible_comic, :author_id => 1
- Factory:editable_comic, :author_id => 1
- @hidden = FactoryGirl.create :hidden_comic, :author_id => 1
- sign_in @user
- end
- context '作家権限がないとき' do
- context 'ただし、公開型のときだけは' do
- it 'ステータスコード200 OKを返す' do
- sign_out @user
- get :show, :id => @comic.id
- response.should be_success
- end
- end
- end
- end
-
-
-end
@op = FactoryGirl.create :original_picture, :artist_id => @artist.id
end
+if MagicNumber['run_mode'] == 1
describe '新規作成フォーム表示に於いて' do
before do
sign_in @user
end
end
end
+
+else
+ describe '新規作成フォーム表示に於いて' do
+ before do
+ sign_in @user
+ end
+ context 'つつがなく終わるとき' do
+ before do
+ @attr = {:original_picture_id => @op.id}
+ @attrj = @attr.merge({:format => :js})
+ end
+ it 'ステータスコード200 OKを返す' do
+ get :new, @attr
+ response.should be_success
+ end
+ context 'html形式' do
+ it 'ページテンプレートnewを描画する' do
+ get :new, @attr
+ response.should render_template("new")
+ end
+ end
+ context 'js形式' do
+ it '部分テンプレートnew.jsを描画する' do
+ get :new, @attrj
+ response.should render_template("new")
+ end
+ end
+ end
+ context '作家権限がないとき' do
+ before do
+ sign_out @user
+ @attr = {:original_picture_id => @op.id}
+ @attrj = @attr.merge({:format => :js})
+ 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 '/users/sign_in'
+ end
+ end
+ context 'js形式' do
+ it 'ステータスコード401 Unauthorizedを返す' do
+ get :new, @attrj
+ response.status.should eq 401
+ end
+ it '応答メッセージにUnauthorizedを返す' do
+ get :new, @attrj
+ response.message.should match(/Unauthorized/)
+ end
+ end
+ end
+ end
+
+ describe '新規作成に於いて' do
+ before do
+ sign_in @user
+ end
+ context 'つつがなく終わるとき' do
+ before do
+ @attr = {:original_picture_id => @op.id, :original_picture_license_group => {:original_picture_id => @op.id, :license_group_id => @lg.id}}
+ @attrj = @attr.merge({:format => :js})
+ end
+ context 'html形式' do
+ it 'ステータスコード200 OKを返す' do
+ post :create, @attr
+ response.should be_success
+ end
+ it 'ライセンスクラスの新規作成テンプレートnewを描画する' do
+ post :create, @attr
+ response.should render_template("pettanr_unknown_v01_licenses/attributes/new")
+ end
+ end
+ context 'js形式' do
+ it 'ステータスコード200 OKを返す' do
+ post :create, @attrj
+ response.should be_success
+ end
+ it 'ライセンスクラスの新規作成部分テンプレートnew.jsを描画する' do
+ post :create, @attrj
+ response.should render_template("pettanr_unknown_v01_licenses/attributes/new")
+ end
+ end
+ end
+ context '作家権限がないとき' do
+ before do
+ sign_out @user
+ @attr = {:original_picture_id => @op.id, :original_picture_license_group => {:original_picture_id => @op.id, :license_group_id => @lg.id}}
+ @attrj = @attr.merge({:format => :js})
+ end
+ context 'html形式' do
+ it 'ステータスコード302 Foundを返す' do
+ post :create, @attr
+ response.status.should eq 302
+ end
+ it 'サインインページへ遷移する' do
+ post :create, @attr
+ response.body.should redirect_to '/users/sign_in'
+ end
+ end
+ context 'json形式' do
+ it 'ステータスコード401 Unauthorizedを返す' do
+ post :create, @attrj
+ response.status.should eq 401
+ end
+ it '応答メッセージにUnauthorizedを返す' do
+ post :create, @attrj
+ response.message.should match(/Unauthorized/)
+ end
+ end
+ end
+ end
+
+end
end
@license = FactoryGirl.create :license, :license_group_id => @lg.id, :system_picture_id => @sp.id
end
+if MagicNumber['run_mode'] == 1
describe '一覧表示に於いて' do
before do
@op = FactoryGirl.create :original_picture, :artist_id => @artist.id
end
end
end
+
+else
+ describe '一覧表示に於いて' do
+ before do
+ @op = FactoryGirl.create :original_picture, :artist_id => @artist.id
+ sign_in @user
+ OriginalPicture.stub(:mylist).and_return([@op, @op, @op])
+ end
+ context 'つつがなく終わるとき' do
+ it 'ステータスコード200 OKを返す' do
+ get :index
+ response.should be_success
+ end
+ context 'html形式' do
+ it 'indexテンプレートを描画する' do
+ get :index
+ response.should render_template("index")
+ end
+ end
+ context 'json形式' do
+ it 'jsonデータを返す' do
+ get :index, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ end
+ end
+ context '作家権限がないとき' do
+ before do
+ sign_out @user
+ end
+ context 'html形式' do
+ it 'ステータスコード302 Foundを返す' do
+ get :index
+ response.status.should eq 302
+ end
+ it 'サインインページへ遷移する' do
+ get :index
+ response.should redirect_to '/users/sign_in'
+ end
+ end
+ context 'json形式' do
+ it 'ステータスコード401 Unauthorizedを返す' do
+ get :index, :format => :json
+ response.status.should eq 401
+ end
+ it '応答メッセージにUnauthorizedを返す' do
+ get :index, :format => :json
+ response.message.should match(/Unauthorized/)
+ end
+ end
+ end
+ end
+
+ describe '単体表示に於いて' do
+ before do
+ @pic = FactoryGirl.create :original_picture, :artist_id => @artist.id
+ sign_in @user
+ OriginalPicture.stub(:show).and_return(@pic)
+ end
+ context 'つつがなく終わるとき' do
+ it 'ステータスコード200 OKを返す' do
+ get :show, :id => @pic.id
+ response.should be_success
+ end
+ context 'html形式' do
+ it 'showテンプレートを描画する' do
+ get :show, :id => @pic.id
+ response.should render_template("show")
+ end
+ end
+ context 'json形式' do
+ it 'jsonデータを返す' do
+ get :show, :id => @pic.id, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ end
+ end
+ context '作家権限がないとき' do
+ before do
+ sign_out @user
+ 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.body.should redirect_to '/users/sign_in'
+ end
+ end
+ context 'json形式' do
+ it 'ステータスコード401 Unauthorizedを返す' do
+ get :show, :id => @pic.id, :format => :json
+ response.status.should eq 401
+ end
+ it '応答メッセージにUnauthorizedを返す' do
+ get :show, :id => @pic.id, :format => :json
+ response.message.should match(/Unauthorized/)
+ end
+ end
+ end
+ end
+
+ describe '履歴一覧表示に於いて' do
+ before do
+ @op = FactoryGirl.create :original_picture, :artist_id => @artist.id
+ @p = FactoryGirl.create :picture, :artist_id => @artist.id, :license_id => @license.id, :revision => 0,
+ :original_picture_id => @op.id
+ sign_in @user
+ OriginalPicture.stub(:show).and_return(@op)
+ OriginalPicture.any_instance.stub(:history).and_return([@p, @p, @p])
+ end
+ context 'つつがなく終わるとき' do
+ it 'ステータスコード200 OKを返す' do
+ get :history, :id => @op.id
+ response.should be_success
+ end
+ context 'html形式' do
+ it 'historyテンプレートを描画する' do
+ get :history, :id => @op.id
+ response.should render_template("history")
+ end
+ end
+ context 'json形式' do
+ it 'jsonデータを返す' do
+ get :history, :id => @op.id, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ end
+ end
+ context '作家権限がないとき' do
+ before do
+ sign_out @user
+ 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 '/users/sign_in'
+ end
+ end
+ context 'json形式' do
+ it 'ステータスコード401 Unauthorizedを返す' do
+ get :history, :id => @op.id, :format => :json
+ response.status.should eq 401
+ end
+ it '応答メッセージにUnauthorizedを返す' do
+ get :history, :id => @op.id, :format => :json
+ response.message.should match(/Unauthorized/)
+ end
+ end
+ end
+ end
+
+ describe '新規作成フォーム表示に於いて' do
+ before do
+ sign_in @user
+ end
+ context 'つつがなく終わるとき' do
+ context 'html形式' do
+ it 'ステータスコード200 OKを返す' do
+ get :new
+ response.should be_success
+ end
+ it 'ページテンプレートnewを描画する' do
+ get :new
+ response.should render_template("new")
+ end
+ end
+ context 'js形式' do
+ it 'ステータスコード200 OKを返す' do
+ get :new, :format => :js
+ response.should be_success
+ end
+ it '部分テンプレートnew.jsを描画する' do
+ get :new, :format => :js
+ response.should render_template("new")
+ end
+ end
+ context 'json形式' do
+ it 'jsonデータを返す' do
+ get :new, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ end
+ end
+ context '作家権限がないとき' do
+ before do
+ sign_out @user
+ 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 '/users/sign_in'
+ end
+ end
+ context 'js形式' do
+ it 'ステータスコード401 Unauthorizedを返す' do
+ get :new, :format => :js
+ response.status.should eq 401
+ end
+ it '応答メッセージにUnauthorizedを返す' do
+ get :new, :format => :js
+ response.message.should match(/Unauthorized/)
+ end
+ end
+ end
+ end
+
+ describe '新規作成に於いて' do
+ before do
+ sign_in @user
+ @attr = {:original_picture => {:file => "abc\ndef\nghi"}}
+ @imager = ImagerTest.load("abc\ndef\nghi")
+ OriginalPicturesController.any_instance.stub(:set_image).with(any_args()).and_return("abc\ndef\nghi")
+ end
+ context 'つつがなく終わるとき' do
+ before do
+ PettanImager.stub(:load).with("abc\ndef\nghi").and_return(@imager)
+ end
+ context 'html形式' do
+ it 'ステータスコード302 Foundを返す' do
+ post :create, @attr
+ response.status.should eq 302
+ end
+ it '作成された原画の表示ページへ遷移する' do
+ post :create, @attr
+ response.should redirect_to(OriginalPicture.last)
+ end
+ end
+ context 'json形式' do
+ before do
+ @attr.merge!({:format => :json})
+ end
+ it 'ステータスコード200 OKを返す' do
+ post :create, @attr
+ response.should be_success
+ end
+ it '作成された原画をjsonデータで返す' do
+ post :create, @attr
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ end
+ end
+ context '作家権限がないとき' do
+ before do
+ sign_out @user
+ end
+ context 'html形式' do
+ it 'ステータスコード302 Foundを返す' do
+ post :create, @attr
+ response.status.should eq 302
+ end
+ it 'サインインページへ遷移する' do
+ post :create, @attr
+ response.body.should redirect_to '/users/sign_in'
+ end
+ end
+ context 'json形式' do
+ before do
+ @attr.merge!({:format => :json})
+ end
+ it 'ステータスコード401 Unauthorizedを返す' do
+ post :create, @attr
+ response.status.should eq 401
+ end
+ it '応答メッセージにUnauthorizedを返す' do
+ post :create, @attr
+ response.message.should match(/Unauthorized/)
+ end
+ end
+ end
+ end
+
+ describe '編集フォーム表示に於いて' do
+ before do
+ @pic = FactoryGirl.create :original_picture, :artist_id => @artist.id
+ sign_in @user
+ OriginalPicture.stub(:show).and_return(@pic)
+ end
+ context 'つつがなく終わるとき' do
+ it 'ステータスコード200 OKを返す' do
+ get :edit, :id => @pic.id
+ response.should be_success
+ end
+ context 'html形式' do
+ it 'ページテンプレートeditを描画する' do
+ get :edit, :id => @pic.id
+ response.should render_template("edit")
+ end
+ end
+ context 'js形式' do
+ it '部分テンプレートedit.jsを描画する' do
+ get :edit, :id => @pic.id, :format => :js
+ response.should render_template("edit")
+ end
+ end
+ end
+ context '作家権限がないとき' do
+ before do
+ sign_out @user
+ end
+ context 'html形式' do
+ it 'ステータスコード302 Foundを返す' do
+ get :edit, :id => @pic.id
+ response.status.should eq 302
+ end
+ it 'サインインページへ遷移する' do
+ get :edit, :id => @pic.id
+ response.body.should redirect_to '/users/sign_in'
+ end
+ end
+ context 'js形式' do
+ it 'ステータスコード401 Unauthorizedを返す' do
+ get :edit, :id => @pic.id, :format => :js
+ response.status.should eq 401
+ end
+ it '応答メッセージにUnauthorizedを返す' do
+ get :edit, :id => @pic.id, :format => :js
+ response.message.should match(/Unauthorized/)
+ end
+ end
+ end
+ end
+
+ describe '更新に於いて' do
+ before do
+ @op = FactoryGirl.create :original_picture, :artist_id => @artist.id
+ OriginalPicture.stub(:edit).with(@op.id.to_s, @artist).and_return(@op)
+ OriginalPicturesController.any_instance.stub(:set_image).with(any_args()).and_return("abc\ndef\nghi")
+ sign_in @user
+ @attr = {:file => "abc\ndef\nghi"}
+ @imager = ImagerTest.load("abc\ndef\nghi")
+ end
+ context 'つつがなく終わるとき' do
+ before do
+ PettanImager.stub(:load).with("abc\ndef\nghi").and_return(@imager)
+ 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(@pic)
+ end
+ end
+ context 'json形式' do
+ it 'ステータスコード200 OKを返す' do
+ put :update, :id => @op.id, :original_picture => @attr, :format => :json
+ response.should be_success
+ end
+ it 'ページ本体は特に返さない' do
+ put :update, :id => @op.id, :original_picture => @attr, :format => :json
+ response.body.should match /./
+ end
+ end
+ end
+ context '作家権限がないとき' do
+ before do
+ sign_out @user
+ end
+ context 'html形式' do
+ it 'ステータスコード302 Foundを返す' do
+ put :update, :id => @op.id, :original_picture => @attr
+ response.status.should eq 302
+ end
+ it 'サインインページへ遷移する' do
+ put :update, :id => @op.id, :original_picture => @attr
+ response.body.should redirect_to '/users/sign_in'
+ end
+ end
+ context 'json形式' do
+ it 'ステータスコード401 Unauthorizedを返す' do
+ put :update, :id => @op.id, :original_picture => @attr, :format => :json
+ response.status.should eq 401
+ end
+ it '応答メッセージにUnauthorizedを返す' do
+ put :update, :id => @op.id, :original_picture => @attr, :format => :json
+ response.message.should match(/Unauthorized/)
+ 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)
+ OriginalPicture.any_instance.stub(:store).with(@imager).and_return(false)
+ end
+ context 'html形式' do
+ it 'ステータスコード200 Okを返す' do
+ put :update, :id => @op.id, :original_picture => @attr
+ response.status.should eq 200
+ end
+ it '編集ページを描画する' do
+ put :update, :id => @op.id, :original_picture => @attr
+ response.should render_template("edit")
+ end
+ end
+ context 'json形式' do
+ it 'ステータスコード422 unprocessable_entity を返す' do
+ put :update, :id => @op.id, :original_picture => @attr, :format => :json
+ response.status.should eq 422
+ end
+ it '応答メッセージUnprocessable Entityを返す' do
+ put :update, :id => @op.id, :original_picture => @attr, :format => :json
+ response.message.should match(/Unprocessable/)
+ end
+ end
+ end
+ end
+
+ describe '削除に於いて' do
+ before do
+ @op = FactoryGirl.create :original_picture, :artist_id => @artist.id
+ sign_in @user
+ end
+ context '事前チェックしておく' do
+ before do
+ OriginalPicture.stub(:edit).with(any_args()).and_return @op
+ OriginalPicture.any_instance.stub(:destroy_with_resource_picture).with(any_args()).and_return(true)
+ end
+ it '原画モデルに編集取得を問い合わせている' do
+ OriginalPicture.should_receive(:edit).exactly(1)
+ delete :destroy, :id => @op.id
+ end
+ it 'モデルに削除を依頼する' do
+ OriginalPicture.any_instance.should_receive(:destroy_with_resource_picture).exactly(1)
+ delete :destroy, :id => @op.id
+ end
+ it '@original_pictureにアレを取得している' do
+ delete :destroy, :id => @op.id
+ assigns(:original_picture).id.should eq(@op.id)
+ end
+ end
+ context 'つつがなく終わるとき' do
+ before do
+ OriginalPicture.any_instance.stub(:destroy_with_resource_picture).with(any_args()).and_return(true)
+ end
+ context 'html形式' do
+ it 'ステータスコード302 Foundを返す' do
+ delete :destroy, :id => @op.id
+ response.status.should eq 302
+ end
+ it '原画の一覧ページへ遷移する' do
+ delete :destroy, :id => @op.id
+ response.should redirect_to(original_pictures_path)
+ end
+ end
+ context 'json形式' do
+ it 'ステータスコード200 OKを返す' do
+ delete :destroy, :id => @op.id, :format => :json
+ response.should be_success
+ end
+ it 'ページ本体は特に返さない' do
+ delete :destroy, :id => @op.id, :format => :json
+ response.body.should match /./
+ end
+ end
+ end
+ context '作家権限がないとき' do
+ before do
+ sign_out @user
+ end
+ it 'ステータスコード302 Foundを返す' do
+ delete :destroy, :id => @op.id
+ response.status.should eq 302
+ end
+ context 'html形式' do
+ it 'サインインページへ遷移する' do
+ delete :destroy, :id => @op.id
+ response.body.should redirect_to '/users/sign_in'
+ end
+ end
+ context 'json形式' do
+ it '応答メッセージにUnauthorizedを返す' do
+ delete :destroy, :id => @op.id, :format => :json
+ response.message.should match(/Unauthorized/)
+ end
+ end
+ end
+ context '削除に失敗したとき' do
+ before do
+ OriginalPicture.any_instance.stub(:destroy_with_resource_picture).and_return(false)
+ end
+ context 'html形式' do
+ it 'ステータスコード302 Foundを返す' do
+ delete :destroy, :id => @op.id
+ response.status.should eq 302
+ end
+ it 'その原画の詳細ページへ遷移する' do
+ delete :destroy, :id => @op.id
+ response.should redirect_to(original_picture_path(@op))
+ end
+ end
+ context 'json形式' do
+ it 'ステータスコード422 unprocessable_entity を返す' do
+ delete :destroy, :id => @op.id, :format => :json
+ response.status.should eq 422
+ end
+ it '応答メッセージUnprocessable Entityを返す' do
+ delete :destroy, :id => @op.id, :format => :json
+ response.message.should match(/Unprocessable/)
+ end
+ end
+ end
+ end
+end
+
end
@panel = FactoryGirl.create :panel, :author_id => @author.id
end
+if MagicNumber['run_mode'] == 1
describe '一覧表示に於いて' do
before do
sign_in @user
end
end
+else
+ describe '一覧表示に於いて' do
+ before do
+ sign_in @user
+ @pc = FactoryGirl.create :panel_color, :panel_id => @panel.id
+ PanelColor.stub(:list).and_return([@pc, @pc, @pc])
+ end
+ context 'つつがなく終わるとき' do
+ it 'ステータスコード200 OKを返す' do
+ get :index
+ response.should be_success
+ end
+ context 'html形式' do
+ it 'indexテンプレートを描画する' do
+ get :index
+ response.should render_template("index")
+ end
+ end
+ context 'json形式' do
+ it 'jsonデータを返す' do
+ get :index, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ end
+ end
+ context '作家権限がないとき' do
+ before do
+ sign_out @user
+ end
+ it 'ステータスコード200 OKを返す' do
+ get :index
+ response.should be_success
+ end
+ context 'html形式' do
+ it 'indexテンプレートを描画する' do
+ get :index
+ response.should render_template("index")
+ end
+ end
+ context 'json形式' do
+ it 'jsonデータを返す' do
+ get :index, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ end
+ end
+ end
+
+ describe '単体表示に於いて' do
+ before do
+ sign_in @user
+ @pc = FactoryGirl.create :panel_color, :panel_id => @panel.id
+ PanelColor.stub(:show).and_return(@pc)
+ end
+ context 'つつがなく終わるとき' do
+ it 'ステータスコード200 OKを返す' do
+ get :show, :id => @pc.id
+ response.should be_success
+ end
+ context 'html形式' do
+ it 'showテンプレートを描画する' do
+ get :show, :id => @pc.id
+ response.should render_template("show")
+ end
+ end
+ context 'json形式' do
+ it 'jsonデータを返す' do
+ get :show, :id => @pc.id, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ end
+ end
+ context '作家権限がないとき' do
+ before do
+ sign_out @user
+ end
+ it 'ステータスコード200 OKを返す' do
+ get :show, :id => @pc.id
+ response.should be_success
+ end
+ context 'html形式' do
+ it 'showテンプレートを描画する' do
+ get :show, :id => @pc.id
+ response.should render_template("show")
+ end
+ end
+ context 'json形式' do
+ it 'jsonデータを返す' do
+ get :show, :id => @pc.id, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ end
+ end
+ end
+
+end
end
@attr = {:picture_id => @p.id, :panel_id => @panel.id, :width => @p.width, :height => @p.height}
end
+if MagicNumber['run_mode'] == 1
describe '一覧表示に於いて' do
before do
@pp = FactoryGirl.create :panel_picture, @attr
end
end
+else
+ describe '一覧表示に於いて' do
+ before do
+ @pp = FactoryGirl.create :panel_picture, @attr
+ sign_in @user
+ PanelPicture.stub(:list).and_return([@pp, @pp, @pp])
+ end
+ context 'つつがなく終わるとき' do
+ it 'ステータスコード200 OKを返す' do
+ get :index
+ response.should be_success
+ end
+ context 'html形式' do
+ it 'indexテンプレートを描画する' do
+ get :index
+ response.should render_template("index")
+ end
+ end
+ context 'json形式' do
+ it 'jsonデータを返す' do
+ get :index, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ end
+ end
+ context '作家権限がないとき' do
+ before do
+ sign_out @user
+ end
+ it 'ステータスコード200 OKを返す' do
+ get :index
+ response.should be_success
+ end
+ context 'html形式' do
+ it 'indexテンプレートを描画する' do
+ get :index
+ response.should render_template("index")
+ end
+ end
+ context 'json形式' do
+ it 'jsonデータを返す' do
+ get :index, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ end
+ end
+ end
+
+ describe '単体表示に於いて' do
+ before do
+ sign_in @user
+ @panel_picture = FactoryGirl.create :panel_picture, @attr
+ PanelPicture.stub(:show).and_return(@panel_picture)
+ end
+ context 'つつがなく終わるとき' do
+ it 'ステータスコード200 OKを返す' do
+ get :show, :id => @panel_picture.id
+ response.should be_success
+ end
+ context 'html形式' do
+ it 'showテンプレートを描画する' do
+ get :show, :id => @panel_picture.id
+ response.should render_template("show")
+ end
+ end
+ context 'json形式' do
+ it 'jsonデータを返す' do
+ get :show, :id => @panel_picture.id, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ end
+ end
+ context '作家権限がないとき' do
+ before do
+ sign_out @user
+ end
+ it 'ステータスコード200 OKを返す' do
+ get :show, :id => @panel_picture.id
+ response.should be_success
+ end
+ context 'html形式' do
+ it 'showテンプレートを描画する' do
+ get :show, :id => @panel_picture.id
+ response.should render_template("show")
+ end
+ end
+ context 'json形式' do
+ it 'jsonデータを返す' do
+ get :show, :id => @panel_picture.id, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ end
+ end
+ end
+
+end
end
@author = FactoryGirl.create :author, :user_id => @user.id\r
end\r
\r
+if MagicNumber['run_mode'] == 1\r
describe '一覧表示に於いて' do\r
before do\r
@panel = FactoryGirl.create :panel, :author_id => @author.id\r
=end\r
end\r
\r
+else\r
+ describe '一覧表示に於いて' do\r
+ before do\r
+ @panel = FactoryGirl.create :panel, :author_id => @author.id\r
+ Panel.stub(:list).and_return([@panel, @panel, @panel])\r
+ sign_in @user\r
+ end\r
+ context 'つつがなく終わるとき' do\r
+ context 'html形式' do\r
+ it 'ステータスコード200 OKを返す' do\r
+ get :index\r
+ response.should be_success \r
+ end\r
+ it 'indexテンプレートを描画する' do\r
+ get :index\r
+ response.should render_template("index")\r
+ end\r
+ end\r
+ context 'json形式' do\r
+ it 'ステータスコード200 OKを返す' do\r
+ get :index, :format => :json\r
+ response.should be_success \r
+ end\r
+ it 'jsonデータを返す' do\r
+ get :index, :format => :json\r
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)\r
+ end\r
+ end\r
+ end\r
+ context '作家権限がないとき' do\r
+ before do\r
+ sign_out @user\r
+ end\r
+ context 'html形式' do\r
+ it 'ステータスコード200 OKを返す' do\r
+ get :index\r
+ response.should be_success \r
+ end\r
+ it 'indexテンプレートを描画する' do\r
+ get :index\r
+ response.should render_template("index")\r
+ end\r
+ end\r
+ context 'json形式' do\r
+ it 'ステータスコード200 OKを返す' do\r
+ get :index, :format => :json\r
+ response.should be_success \r
+ end\r
+ it 'jsonデータを返す' do\r
+ get :index, :format => :json\r
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)\r
+ end\r
+ end\r
+ end\r
+ end\r
+ \r
+ describe '単体表示に於いて' do\r
+ before do\r
+ @panel = FactoryGirl.create :panel, :author_id => @user.author.id\r
+ Panel.stub(:show).with(@panel.id.to_s, @author).and_return(@panel)\r
+ Panel.stub(:show).with(@panel.id.to_s, nil).and_return(@panel)\r
+ sign_in @user\r
+ end\r
+ context 'つつがなく終わるとき' do\r
+ context 'html形式' do\r
+ it 'ステータスコード200 OKを返す' do\r
+ get :show, :id => @panel.id\r
+ response.should be_success\r
+ end\r
+ it 'showテンプレートを描画する' do\r
+ get :show, :id => @panel.id\r
+ response.should render_template("show")\r
+ end\r
+ end\r
+ context 'json形式' do\r
+ it 'ステータスコード200 OKを返す' do\r
+ get :show, :id => @panel.id, :format => :json\r
+ response.should be_success\r
+ end\r
+ it 'jsonデータを返す' do\r
+ get :show, :id => @panel.id, :format => :json\r
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)\r
+ end\r
+ end\r
+ end\r
+ context '作家権限がないとき' do\r
+ before do\r
+ sign_out @user\r
+ end\r
+ context 'html形式' do\r
+ it 'ステータスコード200 OKを返す' do\r
+ get :show, :id => @panel.id\r
+ response.should be_success\r
+ end\r
+ it 'showテンプレートを描画する' do\r
+ get :show, :id => @panel.id\r
+ response.should render_template("show")\r
+ end\r
+ end\r
+ context 'json形式' do\r
+ it 'ステータスコード200 OKを返す' do\r
+ get :show, :id => @panel.id, :format => :json\r
+ response.should be_success\r
+ end\r
+ it 'jsonデータを返す' do\r
+ get :show, :id => @panel.id, :format => :json\r
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)\r
+ end\r
+ end\r
+ end\r
+ end\r
+ \r
+ describe 'コマ数取得に於いて' do\r
+ before do\r
+ Panel.should_receive(:visible_count).and_return(3)\r
+# sign_in @user\r
+ end\r
+ context 'つつがなく終わるとき' do\r
+ it 'ステータスコード200 OKを返す' do\r
+ get :count, :format => :json\r
+ response.should be_success \r
+ end\r
+ context 'json形式' do\r
+ it 'jsonデータを返す' do\r
+ get :count, :format => :json\r
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)\r
+ end\r
+ end\r
+ end\r
+ end\r
+ \r
+ describe '新規作成フォーム表示に於いて' do\r
+ before do\r
+ sign_in @user\r
+ end\r
+ context 'つつがなく終わるとき' do\r
+ context 'html形式' do\r
+ it 'ステータスコード200 OKを返す' do\r
+ get :new\r
+ response.should be_success \r
+ end\r
+ it 'newテンプレートを描画する' do\r
+ get :new\r
+ response.should render_template("new")\r
+ end\r
+ end\r
+ context 'js形式' do\r
+ it 'new.jsテンプレートを描画する' do\r
+ get :new, :format => :js\r
+ response.should render_template("new")\r
+ end\r
+ end\r
+ context 'json形式' do\r
+ it 'jsonデータを返す' do\r
+ get :new, :format => :json\r
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)\r
+ end\r
+ end\r
+ end\r
+ context '作家権限がないとき' do\r
+ before do\r
+ sign_out @user\r
+ end\r
+ context 'html形式' do\r
+ it 'ステータスコード302 Foundを返す' do\r
+ get :new\r
+ response.status.should eq 302\r
+ end\r
+ it 'サインインページへ遷移する' do\r
+ get :new\r
+ response.body.should redirect_to '/users/sign_in'\r
+ end\r
+ end\r
+ context 'js形式' do\r
+ it 'ステータスコード401 Unauthorizedを返す' do\r
+ get :new, :format => :js\r
+ response.status.should eq 401\r
+ end\r
+ it '応答メッセージにUnauthorizedを返す' do\r
+ get :new, :format => :js\r
+ response.message.should match(/Unauthorized/)\r
+ end\r
+ end\r
+ end\r
+ end\r
+ \r
+ describe '新規作成に於いて' do\r
+ before do\r
+ @panel = FactoryGirl.build :panel, :author_id => @author.id\r
+ @attr = FactoryGirl.attributes_for(:panel, :author_id => @author.id)\r
+ sign_in @user\r
+ end\r
+ context 'つつがなく終わるとき' do\r
+ context 'html形式' do\r
+ it 'ステータスコード302 Foundを返す' do\r
+ Panel.any_instance.stub(:store).and_return(true)\r
+ post :create, :panel => @attr\r
+ response.status.should eq 302\r
+ end\r
+ it '作成されたコマの表示ページへ遷移する' do\r
+# Panel.any_instance.stub(:store).and_return(true)\r
+ post :create, :panel => @attr\r
+ response.should redirect_to(Panel.last)\r
+ end\r
+ end\r
+ context 'json形式' do\r
+ it 'ステータスコード200 OKを返す' do\r
+# Panel.any_instance.stub(:store).and_return(true)\r
+ post :create, :panel => @attr, :format => :json\r
+ response.should be_success \r
+ end\r
+ it '作成されたコマをjsonデータで返す' do\r
+ post :create, :panel => @attr, :format => :json\r
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)\r
+ end\r
+ end\r
+ end\r
+ context '作家権限がないとき' do\r
+ before do\r
+ sign_out @user\r
+ end\r
+ context 'html形式' do\r
+ it 'ステータスコード302 Foundを返す' do\r
+ post :create, :panel => @attr\r
+ response.status.should eq 302\r
+ end\r
+ it 'サインインページへ遷移する' do\r
+ post :create, :panel => @attr\r
+ response.body.should redirect_to '/users/sign_in'\r
+ end\r
+ end\r
+ context 'json形式' do\r
+ it 'ステータスコード401 Unauthorizedを返す' do\r
+ post :create, :panel => @attr, :format => :json\r
+ response.status.should eq 401\r
+ end\r
+ it '応答メッセージにUnauthorizedを返す' do\r
+ post :create, :panel => @attr, :format => :json\r
+ response.message.should match(/Unauthorized/)\r
+ end\r
+ end\r
+ end\r
+ end\r
+\r
+ describe '編集フォーム表示に於いて' do\r
+ before do\r
+ @panel = FactoryGirl.create :panel, :author_id => @author.id\r
+ sign_in @user\r
+ Panel.stub(:show).and_return(@panel)\r
+ end\r
+ context 'つつがなく終わるとき' do\r
+ context 'html形式' do\r
+ it 'ステータスコード200 OKを返す' do\r
+ get :edit, :id => @panel.id\r
+ response.should be_success \r
+ end\r
+ it 'editテンプレートを描画する' do\r
+ get :edit, :id => @panel.id\r
+ response.should render_template("edit")\r
+ end\r
+ end\r
+ context 'js形式' do\r
+ it 'ステータスコード200 OKを返す' do\r
+ get :edit, :id => @panel.id, :format => :js\r
+ response.should be_success \r
+ end\r
+ it 'edit.jsテンプレートを描画する' do\r
+ get :edit, :id => @panel.id, :format => :js\r
+ response.should render_template("edit")\r
+ end\r
+ end\r
+ end\r
+ context '作家権限がないとき' do\r
+ before do\r
+ sign_out @user\r
+ end\r
+ context 'html形式' do\r
+ it 'ステータスコード302 Foundを返す' do\r
+ get :edit, :id => @panel.id\r
+ response.status.should eq 302\r
+ end\r
+ it 'サインインページへ遷移する' do\r
+ get :edit, :id => @panel.id\r
+ response.body.should redirect_to '/users/sign_in'\r
+ end\r
+ end\r
+ context 'js形式' do\r
+ it 'ステータスコード401 Unauthorizedを返す' do\r
+ get :edit, :id => @panel.id, :format => :js\r
+ response.status.should eq 401\r
+ end\r
+ it '応答メッセージにUnauthorizedを返す' do\r
+ get :edit, :id => @panel.id, :format => :js\r
+ response.message.should match(/Unauthorized/)\r
+ end\r
+ end\r
+ end\r
+ end\r
+\r
+ describe '更新に於いて' do\r
+ before do\r
+ @panel = FactoryGirl.create :panel, :author_id => @user.author.id\r
+ @attr = FactoryGirl.attributes_for(:panel, :author_id => @author.id)\r
+ sign_in @user\r
+ end\r
+ context 'つつがなく終わるとき' do\r
+ context 'html形式' do\r
+ it 'ステータスコード302 Foundを返す' do\r
+ Panel.any_instance.stub(:store).and_return(true)\r
+ put :update, :id => @panel.id, :panel => @attr\r
+ response.status.should eq 302\r
+ end\r
+ it '作成されたコマの表示ページへ遷移する' do\r
+# Panel.any_instance.stub(:store).and_return(true)\r
+ put :update, :id => @panel.id, :panel => @attr\r
+ response.should redirect_to(Panel.last)\r
+ end\r
+ end\r
+ context 'json形式' do\r
+ it 'ステータスコード200 OKを返す' do\r
+# Panel.any_instance.stub(:store).and_return(true)\r
+ put :update, :id => @panel.id, :panel => @attr, :format => :json\r
+ response.should be_success \r
+ end\r
+ it 'ページ本体は特に返さない' do\r
+ Panel.any_instance.stub(:save).with(any_args()).and_return(true)\r
+ put :update, :id => @panel.id, :panel => @attr, :format => :json\r
+ response.body.should match /./\r
+ end\r
+ end\r
+ end\r
+ context '作家権限がないとき' do\r
+ before do\r
+ sign_out @user\r
+ end\r
+ context 'html形式' do\r
+ it 'ステータスコード302 Foundを返す' do\r
+ put :update, :id => @panel.id, :panel => @attr\r
+ response.status.should eq 302\r
+ end\r
+ it 'サインインページへ遷移する' do\r
+ put :update, :id => @panel.id, :panel => @attr\r
+ response.body.should redirect_to '/users/sign_in'\r
+ end\r
+ end\r
+ context 'json形式' do\r
+ it 'ステータスコード401 Unauthorizedを返す' do\r
+ put :update, :id => @panel.id, :panel => @attr, :format => :json\r
+ response.status.should eq 401\r
+ end\r
+ it '応答メッセージにUnauthorizedを返す' do\r
+ put :update, :id => @panel.id, :panel => @attr, :format => :json\r
+ response.message.should match(/Unauthorized/)\r
+ end\r
+ end\r
+ end\r
+ end\r
+\r
+ describe '削除に於いて' do\r
+ before do\r
+ @panel = FactoryGirl.create :panel, :author_id => @user.author.id\r
+ Panel.stub(:edit).and_return(@panel)\r
+ sign_in @user\r
+ end\r
+ context 'つつがなく終わるとき' do\r
+ context 'html形式' do\r
+ it 'ステータスコード302 Foundを返す' do\r
+ delete :destroy, :id => @panel.id\r
+ response.status.should eq 302\r
+ end\r
+ it 'マイコマ一覧ページへ遷移する' do\r
+ delete :destroy, :id => @panel.id\r
+ response.should redirect_to('/home/panel')\r
+ end\r
+ end\r
+ context 'json形式' do\r
+ it 'ステータスコード200 OKを返す' do\r
+ delete :destroy, :id => @panel.id, :format => :json\r
+ response.should be_success\r
+ end\r
+ end\r
+ end\r
+ context '作家権限がないとき' do\r
+ before do\r
+ sign_out @user\r
+ end\r
+ context 'html形式' do\r
+ it 'ステータスコード302 Foundを返す' do\r
+ delete :destroy, :id => @panel.id\r
+ response.status.should eq 302\r
+ end\r
+ it 'サインインページへ遷移する' do\r
+ delete :destroy, :id => @panel.id\r
+ response.body.should redirect_to '/users/sign_in'\r
+ end\r
+ end\r
+ context 'json形式' do\r
+ it 'ステータスコード401 Unauthorizedを返す' do\r
+ delete :destroy, :id => @panel.id, :format => :json\r
+ response.status.should eq 401\r
+ end\r
+ it '応答メッセージにUnauthorizedを返す' do\r
+ delete :destroy, :id => @panel.id, :format => :json\r
+ response.message.should match(/Unauthorized/)\r
+ end\r
+ end\r
+ end\r
+ end\r
+ \r
+end\r
end\r
\r
@op = FactoryGirl.create :original_picture, :artist_id => @artist.id
end
+if MagicNumber['run_mode'] == 1
describe '単体表示に於いて' do
before do
@p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id
end
end
+else
+ describe '単体表示に於いて' do
+ 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)
+ end
+ context 'つつがなく終わるとき as json' do
+ it 'ステータスコード200 OKを返す' do
+ get :show, :id => @p.id, :format => :json
+ response.should be_success
+ end
+ context 'html形式' do
+ it 'showテンプレートを描画する' do
+ get :show, :id => @p.id
+ response.should render_template("show")
+ end
+ end
+ context 'json形式' do
+ it 'jsonデータを返す' do
+ get :show, :id => @p.id, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ end
+ end
+ context '作家権限がないとき' do
+ before do
+ sign_out @user
+ end
+ it 'ステータスコード200 OKを返す' do
+ get :show, :id => @p.id, :format => :json
+ response.should be_success
+ end
+ context 'html形式' do
+ it 'showテンプレートを描画する' do
+ get :show, :id => @p.id
+ response.should render_template("show")
+ end
+ end
+ context 'json形式' do
+ it 'jsonデータを返す' do
+ get :show, :id => @p.id, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ end
+ end
+ end
+
+ describe 'クレジット表示に於いて' do
+ 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)
+ end
+ context 'つつがなく終わるとき' do
+ it 'ステータスコード200 OKを返す' do
+ get :credit, :id => @p.id
+ response.should be_success
+ end
+ context 'html形式' do
+ it 'creditテンプレートを描画する' do
+ get :credit, :id => @p.id
+ response.should render_template("credit")
+ end
+ end
+ context 'json形式' do
+ it 'jsonデータを返す' do
+ get :credit, :id => @p.id, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ end
+ end
+ context '作家権限がないとき' do
+ before do
+ sign_out @user
+ end
+ it 'ステータスコード200 OKを返す' do
+ get :credit, :id => @p.id
+ response.should be_success
+ end
+ context 'html形式' do
+ it 'creditテンプレートを描画する' do
+ get :credit, :id => @p.id
+ response.should render_template("credit")
+ end
+ end
+ context 'json形式' do
+ it 'jsonデータを返す' do
+ get :credit, :id => @p.id, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ end
+ end
+ end
+
+ describe 'md5検索の一覧に於いて' do
+ before do
+ @p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id
+ sign_in @user
+ Picture.stub(:list_by_md5).with(any_args).and_return([@p, @p, @p])
+ end
+ context 'つつがなく終わるとき' do
+ context 'html形式' do
+ it 'ステータスコード200 OKを返す' do
+ get :search, :md5 => 'a'*32
+ response.should be_success
+ end
+ it 'searchテンプレートを描画する' do
+ get :search, :md5 => 'a'*32
+ response.should render_template("search")
+ end
+ end
+ context 'json形式' do
+ it 'ステータスコード200 OKを返す' do
+ get :search, :md5 => 'a'*32, :format => :json
+ response.should be_success
+ end
+ it 'jsonデータを返す' do
+ get :search, :md5 => 'a'*32, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ end
+ end
+ context '作家権限がないとき' do
+ before do
+ sign_out @user
+ end
+ context 'html形式' do
+ it 'ステータスコード200 OKを返す' do
+ get :search, :md5 => 'a'*32
+ response.should be_success
+ end
+ it 'searchテンプレートを描画する' do
+ get :search, :md5 => 'a'*32
+ response.should render_template("search")
+ end
+ end
+ context 'json形式' do
+ it 'ステータスコード200 OKを返す' do
+ get :search, :md5 => 'a'*32, :format => :json
+ response.should be_success
+ end
+ it 'jsonデータを返す' do
+ get :search, :md5 => 'a'*32, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ end
+ end
+ end
+
+end
end
@op = FactoryGirl.create :original_picture, :artist_id => @artist.id
end
+if MagicNumber['run_mode'] == 1
describe '一覧表示に於いて' do
before do
@p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id
end
end
+else
+ describe '一覧表示に於いて' do
+ before do
+ @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(:list).and_return([@rp, @rp, @rp])
+ end
+ context 'つつがなく終わるとき' do
+ context 'html形式' do
+ it 'ステータスコード200 OKを返す' do
+ get :index
+ response.should be_success
+ end
+ it 'indexテンプレートを描画する' do
+ get :index
+ response.should render_template("index")
+ end
+ end
+ context 'json形式' do
+ it 'ステータスコード200 OKを返す' do
+ get :index, :format => :json
+ response.should be_success
+ end
+ it 'jsonデータを返す' do
+ get :index, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ end
+ end
+ context '作家権限がないとき' do
+ before do
+ sign_out @user
+ end
+ context 'html形式' do
+ it 'ステータスコード200 OKを返す' do
+ get :index
+ response.should be_success
+ end
+ it 'indexテンプレートを描画する' do
+ get :index
+ response.should render_template("index")
+ end
+ end
+ context 'json形式' do
+ it 'ステータスコード200 OKを返す' do
+ get :index, :format => :json
+ response.should be_success
+ end
+ it 'jsonデータを返す' do
+ get :index, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ end
+ end
+ end
+
+ describe '単体表示に於いて' do
+ before do
+ @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)
+ end
+ context 'つつがなく終わるとき' do
+ context 'html形式' do
+ it 'ステータスコード200 OKを返す' do
+ get :show, :id => @rp.id
+ response.should be_success
+ end
+ it 'showテンプレートを描画する' do
+ get :show, :id => @rp.id
+ response.should render_template("show")
+ end
+ end
+ context 'json形式' do
+ it 'ステータスコード200 OKを返す' do
+ get :show, :id => @rp.id, :format => :json
+ response.should be_success
+ end
+ it 'jsonデータを返す' do
+ get :show, :id => @rp.id, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ end
+ end
+ context '作家権限がないとき' do
+ before do
+ sign_out @user
+ end
+ context 'html形式' do
+ it 'ステータスコード200 OKを返す' do
+ get :show, :id => @rp.id
+ response.should be_success
+ end
+ it 'showテンプレートを描画する' do
+ get :show, :id => @rp.id
+ response.should render_template("show")
+ end
+ end
+ context 'json形式' do
+ it 'ステータスコード200 OKを返す' do
+ get :show, :id => @rp.id, :format => :json
+ response.should be_success
+ end
+ it 'jsonデータを返す' do
+ get :show, :id => @rp.id, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ end
+ end
+ end
+
+ describe '素材数取得に於いて' do
+ before do
+ ResourcePicture.should_receive(:visible_count).and_return(3)
+# sign_in @user
+ end
+ context 'つつがなく終わるとき' do
+ it 'ステータスコード200 OKを返す' do
+ get :count, :format => :json
+ response.should be_success
+ end
+ context 'json形式' do
+ it 'jsonデータを返す' do
+ get :count, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ end
+ end
+ end
+
+ describe 'クレジット表示に於いて' do
+ before do
+ @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)
+ end
+ context 'つつがなく終わるとき' do
+ context 'html形式' do
+ it 'ステータスコード200 OKを返す' do
+ get :credit, :id => @rp.id
+ response.should be_success
+ end
+ it 'creditテンプレートを描画する' do
+ get :credit, :id => @rp.id
+ response.should render_template("credit")
+ end
+ end
+ context 'json形式' do
+ it 'ステータスコード200 OKを返す' do
+ get :credit, :id => @rp.id, :format => :json
+ response.should be_success
+ end
+ it 'jsonデータを返す' do
+ get :credit, :id => @rp.id, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ end
+ end
+ context '作家権限がないとき' do
+ before do
+ sign_out @user
+ end
+ context 'html形式' do
+ it 'ステータスコード200 OKを返す' do
+ get :credit, :id => @rp.id
+ response.should be_success
+ end
+ it 'creditテンプレートを描画する' do
+ get :credit, :id => @rp.id
+ response.should render_template("credit")
+ end
+ end
+ context 'json形式' do
+ it 'ステータスコード200 OKを返す' do
+ get :credit, :id => @rp.id, :format => :json
+ response.should be_success
+ end
+ it 'jsonデータを返す' do
+ get :credit, :id => @rp.id, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ end
+ end
+ end
+
+ #原画にライセンスを与えるため際の確認フォーム
+ describe '新規作成フォーム表示に於いて' do
+ before do
+ sign_in @user
+ @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
+ @attr = {:original_picture_id => @op.id, :original_picture_license_group => {:original_picture_id => @op.id, :license_group_id => @lg.id},
+ :resource_picture => {:original_picture_id => @op.id, :license_id => @license.id, :artist_name => @artist.name, :credit => '{}', :settings => '{}' }}
+ @newop = FactoryGirl.create :original_picture, :artist_id => @artist.id
+ @newattr = {:original_picture_id => @newop.id, :original_picture_license_group => {:original_picture_id => @newop.id, :license_group_id => @lg.id},
+ :resource_picture => {:original_picture_id => @newop.id, :license_id => @license.id, :artist_name => @artist.name, :credit => '{}', :settings => '{}' }}
+ @imager = ImagerTest.load("abc\ndef\nghi")
+ end
+ context 'つつがなく終わるとき' do
+ before do
+ OriginalPicture.stub(:edit).with(@op.id.to_s, @artist).and_return(@op)
+ OriginalPicture.stub(:edit).with(@newop.id.to_s, @artist).and_return(@newop)
+ OriginalPicture.any_instance.stub(:restore).with(any_args()).and_return(@imager.binary)
+ PettanImager.stub(:load).with(@imager.binary).and_return(@imager)
+ LicenseGroup.stub(:show).with(@lg.id).and_return(@lg)
+ ResourcePicture.any_instance.stub(:overwrite).with(@op).and_return(true)
+ ResourcePicture.any_instance.stub(:overwrite).with(@newop).and_return(true)
+ end
+ context 'html形式' do
+ it 'ステータスコード200 OKを返す' do
+ get :new, @attr
+ response.should be_success
+ end
+ it 'ページテンプレートnewを描画する' do
+ get :new, @attr
+ response.should render_template("new")
+ end
+ end
+ context 'js形式' do
+ before do
+ @attr.merge!({:format => :js})
+ end
+ it 'ステータスコード200 OKを返す' do
+ get :new, @attr
+ response.should be_success
+ end
+ it '部分テンプレートnew.jsを描画する' do
+ get :new, @attr
+ response.should render_template("new")
+ end
+ end
+ end
+ context '作家権限がないとき' do
+ before do
+ sign_out @user
+ 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 '/users/sign_in'
+ end
+ end
+ context 'js形式' do
+ before do
+ @attr.merge!({:format => :js})
+ end
+ it 'ステータスコード401 Unauthorizedを返す' do
+ get :new, @attr
+ response.status.should eq 401
+ end
+ it '応答メッセージにUnauthorizedを返す' do
+ get :new, @attr
+ response.message.should match(/Unauthorized/)
+ end
+ end
+ end
+ end
+
+ describe '新規作成に於いて' do
+ before do
+ sign_in @user
+ @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
+ @attr = {:original_picture_id => @op.id, :original_picture_license_group => {:original_picture_id => @op.id, :license_group_id => @lg.id},
+ :resource_picture => {:original_picture_id => @op.id, :license_id => @license.id, :artist_name => @artist.name, :credit => '{}', :settings => '{"new":0}' }}
+ @newop = FactoryGirl.create :original_picture, :artist_id => @artist.id
+ @newattr = {:original_picture_id => @newop.id, :original_picture_license_group => {:original_picture_id => @newop.id, :license_group_id => @lg.id},
+ :resource_picture => {:original_picture_id => @newop.id, :license_id => @license.id, :artist_name => @artist.name, :credit => '{}', :settings => '{"new":1}' }}
+ @imager = ImagerTest.load("abc\ndef\nghi")
+ end
+ context 'つつがなく終わるとき[ライセンスを与えようとしている原画が素材を作成してない]' do
+ before do
+ OriginalPicture.stub(:edit).with(@newop.id.to_s, @artist).and_return(@newop)
+ OriginalPicture.any_instance.stub(:restore).with(any_args()).and_return(@imager.binary)
+ PettanImager.stub(:load).with(@imager.binary).and_return(@imager)
+ LicenseGroup.stub(:show).with(@lg.id).and_return(@lg)
+ ResourcePicture.any_instance.stub(:store).with(@imager).and_return {
+ assigns(:resource_picture).attributes = @newattr[:resource_picture]
+ assigns(:resource_picture).overwrite @newop
+ assigns(:resource_picture).picture_id = @p.id
+ assigns(:resource_picture).save!
+ true
+ }
+ end
+ context 'html形式' do
+ it 'ステータスコード302 Foundを返す' do
+ post :create, @newattr
+ response.status.should eq 302
+ end
+ it '作成された素材の表示ページへ遷移する' do
+ post :create, @newattr
+ response.should redirect_to(ResourcePicture.last)
+ end
+ end
+ context 'json形式' do
+ before do
+ @newattr.merge!({:format => :json})
+ end
+ it 'ステータスコード200 OKを返す' do
+ post :create, @newattr
+ response.should be_success
+ end
+ it '作成された素材をjsonデータで返す' do
+ post :create, @newattr
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ end
+ end
+ end
+
+ describe '削除に於いて' do
+ before do
+ @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
+ end
+ context 'つつがなく終わるとき' do
+ before do
+ ResourcePicture.any_instance.stub(:unpublish).with(any_args()).and_return(true)
+ end
+ context 'html形式' do
+ it 'ステータスコード302 Foundを返す' do
+ delete :destroy, :id => @rp.id
+ response.status.should eq 302
+ end
+ it 'マイ素材の一覧ページへ遷移する' do
+ delete :destroy, :id => @rp.id
+ response.should redirect_to('/home/resource_picture')
+ end
+ end
+ context 'json形式' do
+ it 'ステータスコード200 OKを返す' do
+ delete :destroy, :id => @rp.id, :format => :json
+ response.should be_success
+ end
+ it 'ページ本体は特に返さない' do
+ delete :destroy, :id => @rp.id, :format => :json
+ response.body.should match /./
+ end
+ end
+ end
+ context '作家権限がないとき' do
+ before do
+ sign_out @user
+ end
+ it 'ステータスコード302 Foundを返す' do
+ delete :destroy, :id => @rp.id
+ response.status.should eq 302
+ end
+ context 'html形式' do
+ it 'サインインページへ遷移する' do
+ delete :destroy, :id => @rp.id
+ response.body.should redirect_to '/users/sign_in'
+ end
+ end
+ context 'json形式' do
+ it '応答メッセージにUnauthorizedを返す' do
+ delete :destroy, :id => @rp.id, :format => :json
+ response.message.should match(/Unauthorized/)
+ end
+ end
+ end
+ end
+
+end
end
@sbt = FactoryGirl.create :speech_balloon_template
end
+if MagicNumber['run_mode'] == 1
describe '一覧表示に於いて' do
before do
sign_in @user
end
end
+else
+ describe '一覧表示に於いて' do
+ before do
+ sign_in @user
+ SpeechBalloonTemplate.stub(:list).and_return([@sbt, @sbt, @sbt])
+ end
+ context 'つつがなく終わるとき' do
+ context 'html形式' do
+ it 'ステータスコード200 OKを返す' do
+ get :index
+ response.should be_success
+ end
+ it 'indexテンプレートを描画する' do
+ get :index
+ response.should render_template("index")
+ end
+ end
+ context 'json形式' do
+ it 'ステータスコード200 OKを返す' do
+ get :index, :format => :json
+ response.should be_success
+ end
+ it 'jsonデータを返す' do
+ get :index, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ end
+ end
+ context '作家権限がないとき' do
+ before do
+ sign_out @user
+ end
+ context 'html形式' do
+ it 'ステータスコード200 OKを返す' do
+ get :index
+ response.should be_success
+ end
+ it 'indexテンプレートを描画する' do
+ get :index
+ response.should render_template("index")
+ end
+ end
+ context 'json形式' do
+ it 'ステータスコード200 OKを返す' do
+ get :index, :format => :json
+ response.should be_success
+ end
+ it 'jsonデータを返す' do
+ get :index, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ end
+ end
+ end
+
+ describe '単体表示に於いて' do
+ before do
+ sign_in @user
+ SpeechBalloonTemplate.stub(:show).with(@sbt.id.to_s, @author).and_return(@sbt)
+ SpeechBalloonTemplate.stub(:show).with(@sbt.id.to_s, nil).and_return(@sbt)
+ end
+ context 'つつがなく終わるとき' do
+ context 'html形式' do
+ it 'ステータスコード200 OKを返す' do
+ get :show, :id => @sbt.id
+ response.should be_success
+ end
+ it 'showテンプレートを描画する' do
+ get :show, :id => @sbt.id
+ response.should render_template("show")
+ end
+ end
+ context 'json形式' do
+ it 'ステータスコード200 OKを返す' do
+ get :show, :id => @sbt.id, :format => :json
+ response.should be_success
+ end
+ it 'jsonデータを返す' do
+ get :show, :id => @sbt.id, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ end
+ end
+ context '作家権限がないとき' do
+ before do
+ sign_out @user
+ end
+ context 'html形式' do
+ it 'ステータスコード200 OKを返す' do
+ get :show, :id => @sbt.id
+ response.should be_success
+ end
+ it 'showテンプレートを描画する' do
+ get :show, :id => @sbt.id
+ response.should render_template("show")
+ end
+ end
+ context 'json形式' do
+ it 'ステータスコード200 OKを返す' do
+ get :show, :id => @sbt.id, :format => :json
+ response.should be_success
+ end
+ it 'jsonデータを返す' do
+ get :show, :id => @sbt.id, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ end
+ end
+ end
+
+end
end
#フキダシ
require 'spec_helper'
describe SpeechBalloonsController do
+ before do
+ @admin = FactoryGirl.create :admin
+ @user = FactoryGirl.create( :user_yas)
+ @author = FactoryGirl.create :author, :user_id => @user.id
+ @artist = FactoryGirl.create :artist_yas, :author_id => @author.id
+ @sp = FactoryGirl.create :system_picture
+ @lg = FactoryGirl.create :license_group
+ @license = FactoryGirl.create :license, :license_group_id => @lg.id, :system_picture_id => @sp.id
+
+ @speech_balloon_template = FactoryGirl.create :speech_balloon_template
+ @panel = FactoryGirl.create :panel, :author_id => @author.id
+ end
+
+if MagicNumber['run_mode'] == 1
+ describe '一覧表示に於いて' do
+ before do
+ @sb = FactoryGirl.create :speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @speech_balloon_template.id
+ sign_in @user
+ SpeechBalloon.stub(:list).and_return([@sb, @sb, @sb])
+ end
+ context 'パラメータpageについて' do
+ it '@pageに値が入る' do
+ get :index, :page => 5
+ assigns(:page).should eq 5
+ end
+ it '省略されると@pageに1値が入る' do
+ get :index
+ assigns(:page).should eq 1
+ end
+ it '与えられたpage_sizeがセットされている' do
+ get :index, :page_size => 15
+ assigns(:page_size).should eq 15
+ end
+ it '省略されると@page_sizeにデフォルト値が入る' do
+ get :index
+ assigns(:page_size).should eq SpeechBalloon.default_page_size
+ end
+ it '最大を超えると@page_sizeにデフォルト最大値が入る' do
+ get :index, :page_size => 1500
+ assigns(:page_size).should eq SpeechBalloon.max_page_size
+ end
+ it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
+ get :index, :page_size => 0
+ assigns(:page_size).should eq SpeechBalloon.default_page_size
+ end
+ end
+ context 'つつがなく終わるとき' do
+ it 'ステータスコード200 OKを返す' do
+ get :index
+ response.should be_success
+ end
+ it 'フキダシモデルに一覧を問い合わせている' do
+ SpeechBalloon.should_receive(:list).exactly(1)
+ get :index
+ end
+ it '@speech_balloonsにリストを取得している' do
+ get :index
+ assigns(:speech_balloons).should have_at_least(3).items
+ end
+ context 'html形式' do
+ it 'indexテンプレートを描画する' do
+ get :index
+ response.should render_template("index")
+ end
+ end
+ context 'json形式' do
+ it 'jsonデータを返す' do
+ get :index, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ it 'フキダシモデルにjson一覧出力オプションを問い合わせている' do
+ SpeechBalloon.should_receive(:list_json_opt).exactly(1)
+ get :index, :format => :json
+ end
+ it 'データがリスト構造になっている' do
+ get :index, :format => :json
+ json = JSON.parse response.body
+ json.should have_at_least(3).items
+ end
+ it 'リストの先頭くらいはフキダシっぽいものであって欲しい' do
+ get :index, :format => :json
+ json = JSON.parse response.body
+ json.first.has_key?("panel_id").should be_true
+ json.first.has_key?("z").should be_true
+ json.first.has_key?("speech_balloon_template_id").should be_true
+ end
+ end
+ end
+ context '作家権限がないとき' do
+ before do
+ sign_out @user
+ end
+ context 'html形式' do
+ it 'ステータスコード302 Foundを返す' do
+ get :index
+ response.status.should eq 302
+ end
+ it 'サインインページへ遷移する' do
+ get :index
+ response.should redirect_to '/users/sign_in'
+ end
+ end
+ context 'json形式' do
+ it 'ステータスコード401 Unauthorizedを返す' do
+ get :index, :format => :json
+ response.status.should eq 401
+ end
+ it '応答メッセージにUnauthorizedを返す' do
+ get :index, :format => :json
+ response.message.should match(/Unauthorized/)
+ end
+ end
+ end
+ end
+
+ describe '単体表示に於いて' do
+ before do
+ sign_in @user
+ @sb = FactoryGirl.create :speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @speech_balloon_template.id
+ SpeechBalloon.stub(:show).and_return(@sb)
+ end
+ context 'つつがなく終わるとき' do
+ it 'ステータスコード200 OKを返す' do
+ get :show, :id => @sb.id
+ response.should be_success
+ end
+ it 'フキダシモデルに単体取得を問い合わせている' do
+ SpeechBalloon.should_receive(:show).exactly(1)
+ get :show
+ end
+ it '@speech_balloonにアレを取得している' do
+ get :show, :id => @sb.id
+ assigns(:speech_balloon).should eq(@sb)
+ end
+ context 'html形式' do
+ it 'showテンプレートを描画する' do
+ get :show, :id => @sb.id
+ response.should render_template("show")
+ end
+ end
+ context 'json形式' do
+ it 'jsonデータを返す' do
+ get :show, :id => @sb.id, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ it 'フキダシモデルにjson単体出力オプションを問い合わせている' do
+ SpeechBalloon.should_receive(:show_json_opt).exactly(1)
+ get :show, :id => @sb.id, :format => :json
+ end
+ it 'データがアレになっている' do
+ get :show, :id => @sb.id, :format => :json
+ json = JSON.parse response.body
+ json["panel_id"].should_not be_nil
+ json["z"].should_not be_nil
+ json["speech_balloon_template_id"].should_not be_nil
+ end
+ end
+ end
+ context '作家権限がないとき' do
+ before do
+ sign_out @user
+ end
+ context 'html形式' do
+ it 'ステータスコード302 Foundを返す' do
+ get :show, :id => @sb.id
+ response.status.should eq 302
+ end
+ it 'サインインページへ遷移する' do
+ get :show, :id => @sb.id
+ response.body.should redirect_to '/users/sign_in'
+ end
+ end
+ context 'json形式' do
+ it 'ステータスコード401 Unauthorizedを返す' do
+ get :show, :id => @sb.id, :format => :json
+ response.status.should eq 401
+ end
+ it '応答メッセージにUnauthorizedを返す' do
+ get :show, :id => @sb.id, :format => :json
+ response.message.should match(/Unauthorized/)
+ end
+ end
+ end
+ end
+
+else
+ describe '一覧表示に於いて' do
+ before do
+ @sb = FactoryGirl.create :speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @speech_balloon_template.id
+ sign_in @user
+ SpeechBalloon.stub(:list).and_return([@sb, @sb, @sb])
+ end
+ context 'つつがなく終わるとき' do
+ it 'ステータスコード200 OKを返す' do
+ get :index
+ response.should be_success
+ end
+ context 'html形式' do
+ it 'indexテンプレートを描画する' do
+ get :index
+ response.should render_template("index")
+ end
+ end
+ context 'json形式' do
+ it 'jsonデータを返す' do
+ get :index, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ end
+ end
+ context '作家権限がないとき' do
+ before do
+ sign_out @user
+ end
+ it 'ステータスコード200 OKを返す' do
+ get :index
+ response.should be_success
+ end
+ context 'html形式' do
+ it 'indexテンプレートを描画する' do
+ get :index
+ response.should render_template("index")
+ end
+ end
+ context 'json形式' do
+ it 'jsonデータを返す' do
+ get :index, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ end
+ end
+ end
+
+ describe '単体表示に於いて' do
+ before do
+ sign_in @user
+ @sb = FactoryGirl.create :speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @speech_balloon_template.id
+ SpeechBalloon.stub(:show).and_return(@sb)
+ end
+ context 'つつがなく終わるとき' do
+ it 'ステータスコード200 OKを返す' do
+ get :show, :id => @sb.id
+ response.should be_success
+ end
+ context 'html形式' do
+ it 'showテンプレートを描画する' do
+ get :show, :id => @sb.id
+ response.should render_template("show")
+ end
+ end
+ context 'json形式' do
+ it 'jsonデータを返す' do
+ get :show, :id => @sb.id, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ end
+ end
+ context '作家権限がないとき' do
+ before do
+ sign_out @user
+ end
+ it 'ステータスコード200 OKを返す' do
+ get :show, :id => @sb.id
+ response.should be_success
+ end
+ context 'html形式' do
+ it 'showテンプレートを描画する' do
+ get :show, :id => @sb.id
+ response.should render_template("show")
+ end
+ end
+ context 'json形式' do
+ it 'jsonデータを返す' do
+ get :show, :id => @sb.id, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ end
+ end
+ end
+
+end
end
@panel = FactoryGirl.create :panel, :author_id => @author.id
end
+if MagicNumber['run_mode'] == 1
describe '一覧表示に於いて' do
before do
@sb = FactoryGirl.create :speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @speech_balloon_template.id
end
end
+else
+ describe '一覧表示に於いて' do
+ before do
+ @sb = FactoryGirl.create :speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @speech_balloon_template.id
+ @balloon = FactoryGirl.create :balloon, :speech_balloon_id => @sb.id, :system_picture_id => @sp.id
+ @speech = FactoryGirl.create :speech, :speech_balloon_id => @sb.id
+ sign_in @user
+ Speech.stub(:list).and_return([@speech, @speech, @speech])
+ end
+ context 'つつがなく終わるとき' do
+ it 'ステータスコード200 OKを返す' do
+ get :index
+ response.should be_success
+ end
+ context 'html形式' do
+ it 'indexテンプレートを描画する' do
+ get :index
+ response.should render_template("index")
+ end
+ end
+ context 'json形式' do
+ it 'jsonデータを返す' do
+ get :index, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ end
+ end
+ context '作家権限がないとき' do
+ before do
+ sign_out @user
+ end
+ it 'ステータスコード200 OKを返す' do
+ get :index
+ response.should be_success
+ end
+ context 'html形式' do
+ it 'indexテンプレートを描画する' do
+ get :index
+ response.should render_template("index")
+ end
+ end
+ context 'json形式' do
+ it 'jsonデータを返す' do
+ get :index, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ end
+ end
+ end
+
+ describe '単体表示に於いて' do
+ before do
+ sign_in @user
+ @sb = FactoryGirl.create :speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @speech_balloon_template.id
+ @balloon = FactoryGirl.create :balloon, :speech_balloon_id => @sb.id, :system_picture_id => @sp.id
+ @speech = FactoryGirl.create :speech, :speech_balloon_id => @sb.id
+ Speech.stub(:show).and_return(@speech)
+ end
+ context 'つつがなく終わるとき' do
+ it 'ステータスコード200 OKを返す' do
+ get :show, :id => @speech.id
+ response.should be_success
+ end
+ context 'html形式' do
+ it 'showテンプレートを描画する' do
+ get :show, :id => @speech.id
+ response.should render_template("show")
+ end
+ end
+ context 'json形式' do
+ it 'jsonデータを返す' do
+ get :show, :id => @speech.id, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ end
+ end
+ context '作家権限がないとき' do
+ before do
+ sign_out @user
+ end
+ it 'ステータスコード200 OKを返す' do
+ get :show, :id => @speech.id
+ response.should be_success
+ end
+ context 'html形式' do
+ it 'showテンプレートを描画する' do
+ get :show, :id => @speech.id
+ response.should render_template("show")
+ end
+ end
+ context 'json形式' do
+ it 'jsonデータを返す' do
+ get :show, :id => @speech.id, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ end
+ end
+ end
+
+end
end
@panel = FactoryGirl.create :panel, :author_id => @author.id
end
+if MagicNumber['run_mode'] == 1
describe '一覧表示に於いて' do
before do
sign_in @user
=end
end
+else
+ 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
+ Story.stub(:list).and_return([@story, @story, @story])
+ end
+ context 'つつがなく終わるとき' do
+ it 'ステータスコード200 OKを返す' do
+ get :index
+ response.should be_success
+ end
+ context 'html形式' do
+ it 'indexテンプレートを描画する' do
+ get :index
+ response.should render_template("index")
+ end
+ end
+ context 'json形式' do
+ it 'jsonデータを返す' do
+ get :index, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ end
+ end
+ context '作家権限がないとき' do
+ before do
+ sign_out @user
+ end
+ it 'ステータスコード200 OKを返す' do
+ get :index
+ response.should be_success
+ end
+ context 'html形式' do
+ it 'indexテンプレートを描画する' do
+ get :index
+ response.should render_template("index")
+ end
+ end
+ context 'json形式' do
+ it 'jsonデータを返す' do
+ get :index, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ 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).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)
+ end
+ context 'つつがなく終わるとき' do
+ context 'html形式' do
+ it 'ステータスコード200 OKを返す' do
+ get :show, :id => @story.id
+ response.should be_success
+ end
+ it 'showテンプレートを描画する' do
+ get :show, :id => @story.id
+ response.should render_template("show")
+ end
+ end
+ context 'json形式' do
+ it 'ステータスコード200 OKを返す' do
+ get :show, :id => @story.id, :format => :json
+ response.should be_success
+ end
+ it 'jsonデータを返す' do
+ get :show, :id => @story.id, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ end
+ end
+ context '作家権限がないとき' do
+ before do
+ sign_out @user
+ end
+ context 'html形式' do
+ it 'ステータスコード200 OKを返す' do
+ get :show, :id => @story.id
+ response.should be_success
+ end
+ it 'showテンプレートを描画する' do
+ get :show, :id => @story.id
+ response.should render_template("show")
+ end
+ end
+ context 'json形式' do
+ it 'ステータスコード200 OKを返す' do
+ get :show, :id => @story.id, :format => :json
+ response.should be_success
+ end
+ it 'jsonデータを返す' do
+ get :show, :id => @story.id, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ 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).and_return(@comic)
+ Comic.stub(:show).with(@comic.id.to_s, nil).and_return(@comic)
+ Story.stub(:count).and_return(10)
+ Story.stub(:play_list).with(any_args).and_return([@story, @story, @story])
+ sign_in @user
+ end
+ context 'つつがなく終わるとき' do
+ context 'html形式' do
+ it 'ステータスコード200 OKを返す' do
+ get :comic, :id => @comic.id
+ response.should be_success
+ end
+ it 'comicテンプレートを描画する' do
+ get :comic, :id => @comic.id
+ response.should render_template("comic")
+ end
+ end
+ context 'json形式' do
+ it 'ステータスコード200 OKを返す' do
+ get :comic, :id => @comic.id, :format => :json
+ response.should be_success
+ end
+ it 'jsonデータを返す' do
+ get :comic, :id => @comic.id, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ end
+ end
+ context '作家権限がないとき' do
+ before do
+ sign_out @user
+ end
+ context 'html形式' do
+ it 'ステータスコード200 OKを返す' do
+ get :comic, :id => @comic.id
+ response.should be_success
+ end
+ it 'comicテンプレートを描画する' do
+ get :comic, :id => @comic.id
+ response.should render_template("comic")
+ end
+ end
+ context 'json形式' do
+ it 'ステータスコード200 OKを返す' do
+ get :comic, :id => @comic.id, :format => :json
+ response.should be_success
+ end
+ it 'jsonデータを返す' do
+ get :comic, :id => @comic.id, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ end
+ end
+ end
+
+ describe '新規作成フォーム表示に於いて' do
+ before do
+ sign_in @user
+ end
+ context 'つつがなく終わるとき' do
+ context 'html形式' do
+ it 'ステータスコード200 OKを返す' do
+ get :new
+ response.should be_success
+ end
+ it 'newテンプレートを描画する' do
+ get :new
+ response.should render_template("new")
+ end
+ end
+ context 'js形式' do
+ it 'ステータスコード200 OKを返す' do
+ get :new, :format => :js
+ response.should be_success
+ end
+ it 'new.jsテンプレートを描画する' do
+ get :new, :format => :js
+ response.should render_template("new")
+ end
+ end
+ context 'json形式' do
+ it 'ステータスコード200 OKを返す' do
+ get :new, :format => :json
+ response.should be_success
+ end
+ it 'jsonデータを返す' do
+ get :new, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ end
+ end
+ context '作家権限がないとき' do
+ before do
+ sign_out @user
+ 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 '/users/sign_in'
+ end
+ end
+ context 'json形式' do
+ it 'ステータスコード401 Unauthorizedを返す' do
+ get :new, :format => :json
+ response.status.should eq 401
+ end
+ it '応答メッセージにUnauthorizedを返す' do
+ get :new, :format => :json
+ response.message.should match(/Unauthorized/)
+ end
+ end
+ end
+ end
+
+ describe '新規作成に於いて' do
+ before do
+ @attr = FactoryGirl.attributes_for(:story, :t => nil, :comic_id => @comic.id, :panel_id => @panel.id, :author_id => @author.id)
+ sign_in @user
+ end
+ context 'つつがなく終わるとき' do
+ context 'html形式' do
+ it 'ステータスコード302 Foundを返す' do
+ Story.any_instance.stub(:store).and_return(true)
+ post :create, :story => @attr
+ response.status.should eq 302
+ end
+ it 'コミックのストーリー表示へ遷移する' do
+# Story.any_instance.stub(:store).and_return(true)
+ post :create, :story => @attr
+ response.should redirect_to(:action => :comic, :id => @attr[:comic_id])
+ end
+ end
+ context 'json形式' do
+ it 'ステータスコード200 OKを返す' do
+# Story.any_instance.stub(:store).and_return(true)
+ post :create, :story => @attr, :format => :json
+ response.should be_success
+ end
+ it '作成されたコマをjsonデータで返す' do
+ post :create, :story => @attr, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ end
+ end
+ context '作家権限がないとき' do
+ before do
+ sign_out @user
+ 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 '/users/sign_in'
+ end
+ end
+ context 'json形式' do
+ it 'ステータスコード401 Unauthorizedを返す' do
+ post :create, :story => @attr, :format => :json
+ response.status.should eq 401
+ end
+ it '応答メッセージにUnauthorizedを返す' do
+ post :create, :story => @attr, :format => :json
+ response.message.should match(/Unauthorized/)
+ end
+ end
+ end
+ end
+
+ describe '編集フォーム表示に於いて' do
+ before do
+ @story = FactoryGirl.create :story, :author_id => @author.id
+ sign_in @user
+ Story.stub(:show).and_return(@story)
+ end
+ context 'つつがなく終わるとき' do
+ context 'html形式' do
+ it 'ステータスコード200 OKを返す' do
+ get :edit, :id => @story.id
+ response.should be_success
+ end
+ it 'editテンプレートを描画する' do
+ get :edit, :id => @story.id
+ response.should render_template("edit")
+ end
+ end
+ context 'js形式' do
+ it 'ステータスコード200 OKを返す' do
+ get :edit, :id => @story.id, :format => :js
+ response.should be_success
+ end
+ it 'edit.jsテンプレートを描画する' do
+ get :edit, :id => @story.id, :format => :js
+ response.should render_template("edit")
+ end
+ end
+ end
+ context '作家権限がないとき' do
+ before do
+ sign_out @user
+ 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 '/users/sign_in'
+ end
+ end
+ context 'js形式' do
+ it 'ステータスコード401 Unauthorizedを返す' do
+ get :edit, :id => @story.id, :format => :js
+ response.status.should eq 401
+ end
+ it '応答メッセージにUnauthorizedを返す' do
+ get :edit, :id => @story.id, :format => :js
+ response.message.should match(/Unauthorized/)
+ end
+ end
+ end
+ end
+
+ describe '更新に於いて' do
+ before do
+ @story = FactoryGirl.create :story, :author_id => @user.author.id
+ @attr = FactoryGirl.attributes_for(:story, :author_id => @author.id)
+ sign_in @user
+ end
+ context 'つつがなく終わるとき' do
+ context 'html形式' do
+ it 'ステータスコード302 Foundを返す' do
+ Story.any_instance.stub(:store).and_return(true)
+ put :update, :id => @story.id, :story => @attr
+ response.status.should eq 302
+ end
+ it 'ストーリー表示へ遷移する' do
+# Story.any_instance.stub(:store).and_return(true)
+ put :update, :id => @story.id, :story => @attr
+ response.should redirect_to(:action => :comic, :id => @attr[:comic_id])
+ end
+ end
+ context 'json形式' do
+ it 'ステータスコード200 OKを返す' do
+# Story.any_instance.stub(:store).and_return(true)
+ put :update, :id => @story.id, :story => @attr, :format => :json
+ response.should be_success
+ end
+ end
+ end
+ context '作家権限がないとき' do
+ before do
+ sign_out @user
+ 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 '/users/sign_in'
+ end
+ end
+ context 'json形式' do
+ it 'ステータスコード401 Unauthorizedを返す' do
+ put :update, :id => @story.id, :story => @attr, :format => :json
+ response.status.should eq 401
+ end
+ it '応答メッセージにUnauthorizedを返す' do
+ put :update, :id => @story.id, :story => @attr, :format => :json
+ response.message.should match(/Unauthorized/)
+ end
+ end
+ end
+ end
+
+ describe '削除に於いて' do
+ before do
+ @story = FactoryGirl.create :story, :author_id => @author.id
+ sign_in @user
+ Story.stub(:edit).and_return(@story)
+ end
+ context 'つつがなく終わるとき' do
+ before do
+ Story.any_instance.stub(:destroy_and_shorten).with(any_args()).and_return(true)
+ 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.should redirect_to(:controller => 'stories', :action => :comic, :id => @story.comic_id)
+ end
+ end
+ context 'json形式' do
+ it 'ステータスコード200 OKを返す' do
+ delete :destroy, :id => @story.id, :format => :json
+ response.should be_success
+ end
+ end
+ end
+ context '作家権限がないとき' do
+ before do
+ sign_out @user
+ 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 '/users/sign_in'
+ end
+ end
+ context 'json形式' do
+ it 'ステータスコード401 Unauthorizedを返す' do
+ delete :destroy, :id => @story.id, :format => :json
+ response.status.should eq 401
+ end
+ it '応答メッセージにUnauthorizedを返す' do
+ delete :destroy, :id => @story.id, :format => :json
+ response.message.should match(/Unauthorized/)
+ end
+ end
+ end
+ end
+
+end
end
@license = FactoryGirl.create :license, :license_group_id => @lg.id, :system_picture_id => @sp.id
end
+if MagicNumber['run_mode'] == 1
describe '一覧表示に於いて' do
before do
sign_in @user
=end
end
+else
+ describe '一覧表示に於いて' do
+ before do
+ sign_in @user
+ sign_in @admin
+ SystemPicture.stub(:list).and_return([@sp, @sp, @sp])
+ end
+ context 'つつがなく終わるとき' do
+ context 'html形式' do
+ it 'ステータスコード200 OKを返す' do
+ get :index
+ response.should be_success
+ end
+ it 'indexテンプレートを描画する' do
+ get :index
+ response.should render_template("index")
+ end
+ end
+ context 'json形式' do
+ it 'ステータスコード200 OKを返す' do
+ get :index, :format => :json
+ response.should be_success
+ end
+ it 'jsonデータを返す' do
+ get :index, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ end
+ end
+ context '作家権限がないとき' do
+ before do
+ sign_out @user
+ end
+ context 'html形式' do
+ it 'ステータスコード200 OKを返す' do
+ get :index
+ response.should be_success
+ end
+ it 'indexテンプレートを描画する' do
+ get :index
+ response.should render_template("index")
+ end
+ end
+ context 'json形式' do
+ it 'ステータスコード200 OKを返す' do
+ get :index, :format => :json
+ response.should be_success
+ end
+ it 'jsonデータを返す' do
+ get :index, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ end
+ end
+ end
+
+ describe '単体表示に於いて' do
+ before do
+ sign_in @user
+ SystemPicture.stub(:show).and_return(@sp)
+ end
+ context 'つつがなく終わるとき' do
+ it 'ステータスコード200 OKを返す' do
+ get :show, :id => @sp.id
+ response.should be_success
+ end
+ context 'html形式' do
+ it 'showテンプレートを描画する' do
+ get :show, :id => @sp.id
+ response.should render_template("show")
+ end
+ end
+ context 'json形式' do
+ it 'jsonデータを返す' do
+ get :show, :id => @sp.id, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ end
+ end
+ context '作家権限がないとき' do
+ before do
+ sign_out @user
+ end
+ it 'ステータスコード200 OKを返す' do
+ get :show, :id => @sp.id
+ response.should be_success
+ end
+ context 'html形式' do
+ it 'showテンプレートを描画する' do
+ get :show, :id => @sp.id
+ response.should render_template("show")
+ end
+ end
+ context 'json形式' do
+ it 'jsonデータを返す' do
+ get :show, :id => @sp.id, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ end
+ end
+ end
+end
end