end
if MagicNumber['run_mode'] == 1
- describe 'è\87ªå\88\86ã\81®ã\82³ã\83\9fã\83\83ã\82¯一覧表示に於いて' do
+ describe 'è\87ªå\88\86ã\81®ã\82¹ã\82¯ã\83ã\83¼ã\83«一覧表示に於いて' do
before do
@scroll = FactoryGirl.create :scroll, :author_id => @author.id
sign_in @user
get :scrolls
response.should be_success
end
- it 'ã\82³ã\83\9fã\83\83ã\82¯モデルに一覧を問い合わせている' do
+ it 'ã\82¹ã\82¯ã\83ã\83¼ã\83«モデルに一覧を問い合わせている' do
Scroll.should_receive(:mylist).exactly(1)
get :scrolls
end
get :scrolls, :format => :json
lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
end
- it 'ã\82³ã\83\9fã\83\83ã\82¯モデルにjson一覧出力オプションを問い合わせている' do
+ it 'ã\82¹ã\82¯ã\83ã\83¼ã\83«モデルにjson一覧出力オプションを問い合わせている' do
Scroll.should_receive(:list_json_opt).exactly(1)
get :scrolls, :format => :json
end
json = JSON.parse response.body
json.should have_at_least(3).items
end
- it 'ã\83ªã\82¹ã\83\88ã\81®å\85\88é ã\81\8fã\82\89ã\81\84ã\81¯ã\82³ã\83\9fã\83\83ã\82¯っぽいものであって欲しい' do
+ it 'ã\83ªã\82¹ã\83\88ã\81®å\85\88é ã\81\8fã\82\89ã\81\84ã\81¯ã\82¹ã\82¯ã\83ã\83¼ã\83«っぽいものであって欲しい' do
get :scrolls, :format => :json
json = JSON.parse response.body
json.first.has_key?("title").should be_true
end
end
+ describe '自分のスクコマ一覧表示に於いて' do
+ before do
+ @scroll = FactoryGirl.create :scroll, :author_id => @author.id
+ @scroll_panel = FactoryGirl.create :scroll_panel, :author_id => @author.id, :scroll_id => @scroll.id
+ sign_in @user
+ ScrollPanel.stub(:mylist).and_return([@scroll_panel, @scroll_panel, @scroll_panel])
+ end
+ context 'パラメータpageについて' do
+ it '@pageに値が入る' do
+ get :scroll_panels, :page => 5
+ assigns(:page).should eq 5
+ end
+ it '省略されると@pageに1値が入る' do
+ get :scroll_panels
+ assigns(:page).should eq 1
+ end
+ it '与えられたpage_sizeがセットされている' do
+ get :scroll_panels, :page_size => 15
+ assigns(:page_size).should eq 15
+ end
+ it '省略されると@page_sizeにデフォルト値が入る' do
+ get :scroll_panels
+ assigns(:page_size).should eq Author.default_scroll_panel_page_size
+ end
+ it '最大を超えると@page_sizeにデフォルト最大値が入る' do
+ get :scroll_panels, :page_size => 1500
+ assigns(:page_size).should eq Author.scroll_panel_max_page_size
+ end
+ it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
+ get :scroll_panels, :page_size => 0
+ assigns(:page_size).should eq Author.default_scroll_panel_page_size
+ end
+ end
+ context 'つつがなく終わるとき' do
+ it 'ステータスコード200 OKを返す' do
+ get :scroll_panels
+ response.should be_success
+ end
+ it 'スクコマモデルに一覧を問い合わせている' do
+ ScrollPanel.should_receive(:mylist).exactly(1)
+ get :scroll_panels
+ end
+ it '@scroll_panelsにリストを取得している' do
+ get :scroll_panels
+ assigns(:scroll_panels).should have_at_least(3).items
+ end
+ context 'html形式' do
+ it '@paginateにページ制御を取得している' do
+ get :scroll_panels
+ assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
+ end
+ it 'scroll_panelsテンプレートを描画する' do
+ get :scroll_panels
+ response.should render_template("scroll_panels")
+ end
+ end
+ context 'json形式' do
+ it 'jsonデータを返す' do
+ get :scroll_panels, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ it 'スクコマモデルにjson一覧出力オプションを問い合わせている' do
+ ScrollPanel.should_receive(:list_json_opt).exactly(1)
+ get :scroll_panels, :format => :json
+ end
+ it 'データがリスト構造になっている' do
+ get :scroll_panels, :format => :json
+ json = JSON.parse response.body
+ json.should have_at_least(3).items
+ end
+ it 'リストの先頭くらいはスクコマっぽいものであって欲しい' do
+ get :scroll_panels, :format => :json
+ json = JSON.parse response.body
+ json.first.has_key?("scroll_id").should be_true
+ json.first.has_key?("panel_id").should be_true
+ end
+ end
+ end
+ context '作家権限がないとき' do
+ before do
+ sign_out @user
+ end
+ context 'html形式' do
+ it 'ステータスコード302 Foundを返す' do
+ get :scroll_panels
+ response.status.should eq 302
+ end
+ it 'サインインページへ遷移する' do
+ get :scroll_panels
+ response.should redirect_to '/users/sign_in'
+ end
+ end
+ context 'json形式' do
+ it 'ステータスコード401 Unauthorizedを返す' do
+ get :scroll_panels, :format => :json
+ response.status.should eq 401
+ end
+ it '応答メッセージにUnauthorizedを返す' do
+ get :scroll_panels, :format => :json
+ response.message.should match(/Unauthorized/)
+ end
+ end
+ end
+ end
+
+ describe '自分の用紙一覧表示に於いて' do
+ before do
+ @sheet = FactoryGirl.create :sheet, :author_id => @author.id
+ sign_in @user
+ Sheet.stub(:mylist).and_return([@sheet, @sheet, @sheet])
+ end
+ context 'パラメータpageについて' do
+ it '@pageに値が入る' do
+ get :sheets, :page => 5
+ assigns(:page).should eq 5
+ end
+ it '省略されると@pageに1値が入る' do
+ get :sheets
+ assigns(:page).should eq 1
+ end
+ it '与えられたpage_sizeがセットされている' do
+ get :sheets, :page_size => 15
+ assigns(:page_size).should eq 15
+ end
+ it '省略されると@page_sizeにデフォルト値が入る' do
+ get :sheets
+ assigns(:page_size).should eq Author.default_sheet_page_size
+ end
+ it '最大を超えると@page_sizeにデフォルト最大値が入る' do
+ get :sheets, :page_size => 1500
+ assigns(:page_size).should eq Author.sheet_max_page_size
+ end
+ it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
+ get :sheets, :page_size => 0
+ assigns(:page_size).should eq Author.default_sheet_page_size
+ end
+ end
+ context 'つつがなく終わるとき' do
+ it 'ステータスコード200 OKを返す' do
+ get :sheets
+ response.should be_success
+ end
+ it '用紙モデルに一覧を問い合わせている' do
+ Sheet.should_receive(:mylist).exactly(1)
+ get :sheets
+ end
+ it '@sheetsにリストを取得している' do
+ get :sheets
+ assigns(:sheets).should have_at_least(3).items
+ end
+ context 'html形式' do
+ it '@paginateにページ制御を取得している' do
+ get :sheets
+ assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
+ end
+ it 'sheetsテンプレートを描画する' do
+ get :sheets
+ response.should render_template("sheets")
+ end
+ end
+ context 'json形式' do
+ it 'jsonデータを返す' do
+ get :sheets, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ it '用紙モデルにjson一覧出力オプションを問い合わせている' do
+ Sheet.should_receive(:list_json_opt).exactly(1)
+ get :sheets, :format => :json
+ end
+ it 'データがリスト構造になっている' do
+ get :sheets, :format => :json
+ json = JSON.parse response.body
+ json.should have_at_least(3).items
+ end
+ it 'リストの先頭くらいは用紙っぽいものであって欲しい' do
+ get :sheets, :format => :json
+ json = JSON.parse response.body
+ json.first.has_key?("caption").should be_true
+ json.first.has_key?("visible").should be_true
+ end
+ end
+ end
+ context '作家権限がないとき' do
+ before do
+ sign_out @user
+ end
+ context 'html形式' do
+ it 'ステータスコード302 Foundを返す' do
+ get :sheets
+ response.status.should eq 302
+ end
+ it 'サインインページへ遷移する' do
+ get :sheets
+ response.should redirect_to '/users/sign_in'
+ end
+ end
+ context 'json形式' do
+ it 'ステータスコード401 Unauthorizedを返す' do
+ get :sheets, :format => :json
+ response.status.should eq 401
+ end
+ it '応答メッセージにUnauthorizedを返す' do
+ get :sheets, :format => :json
+ response.message.should match(/Unauthorized/)
+ end
+ end
+ end
+ end
+
+ describe '自分の紙コマ一覧表示に於いて' do
+ before do
+ @sheet = FactoryGirl.create :sheet, :author_id => @user.author.id
+ @sheet_panel = FactoryGirl.create :sheet_panel, :t => 0, :sheet_id => @sheet.id, :panel_id => @panel.id, :author_id => @author.id
+ sign_in @user
+ SheetPanel.stub(:mylist).and_return([@sheet_panel, @sheet_panel, @sheet_panel])
+ end
+ context 'パラメータpageについて' do
+ it '@pageに値が入る' do
+ get :sheet_panels, :page => 5
+ assigns(:page).should eq 5
+ end
+ it '省略されると@pageに1値が入る' do
+ get :sheet_panels
+ assigns(:page).should eq 1
+ end
+ it '与えられたpage_sizeがセットされている' do
+ get :sheet_panels, :page_size => 15
+ assigns(:page_size).should eq 15
+ end
+ it '省略されると@page_sizeにデフォルト値が入る' do
+ get :sheet_panels
+ assigns(:page_size).should eq Author.default_sheet_panel_page_size
+ end
+ it '最大を超えると@page_sizeにデフォルト最大値が入る' do
+ get :sheet_panels, :page_size => 1500
+ assigns(:page_size).should eq Author.sheet_panel_max_page_size
+ end
+ it '不正な値が入ると@page_sizeにデフォルト最大値が入る' do
+ get :sheet_panels, :page_size => 0
+ assigns(:page_size).should eq Author.default_sheet_panel_page_size
+ end
+ end
+ context 'つつがなく終わるとき' do
+ it 'ステータスコード200 OKを返す' do
+ get :sheet_panels
+ response.should be_success
+ end
+ it '紙コマモデルに一覧を問い合わせている' do
+ SheetPanel.should_receive(:mylist).exactly(1)
+ get :sheet_panels
+ end
+ it '@sheet_panelsにリストを取得している' do
+ get :sheet_panels
+ assigns(:sheet_panels).should have_at_least(3).items
+ end
+ context 'html形式' do
+ it '@paginateにページ制御を取得している' do
+ get :sheet_panels
+ assigns(:paginate).is_a?(Kaminari::PaginatableArray).should be_true
+ end
+ it 'sheet_panelsテンプレートを描画する' do
+ get :sheet_panels
+ response.should render_template("sheet_panels")
+ end
+ end
+ context 'json形式' do
+ it 'jsonデータを返す' do
+ get :sheet_panels, :format => :json
+ lambda{JSON.parse(response.body)}.should_not raise_error(JSON::ParserError)
+ end
+ it '紙コマモデルにjson一覧出力オプションを問い合わせている' do
+ SheetPanel.should_receive(:list_json_opt).exactly(1)
+ get :sheet_panels, :format => :json
+ end
+ it 'データがリスト構造になっている' do
+ get :sheet_panels, :format => :json
+ json = JSON.parse response.body
+ json.should have_at_least(3).items
+ end
+ it 'リストの先頭くらいは紙コマっぽいものであって欲しい' do
+ get :sheet_panels, :format => :json
+ json = JSON.parse response.body
+ json.first.has_key?("panel_id").should be_true
+ json.first.has_key?("sheet_id").should be_true
+ end
+ end
+ end
+ context '作家権限がないとき' do
+ before do
+ sign_out @user
+ end
+ context 'html形式' do
+ it 'ステータスコード302 Foundを返す' do
+ get :sheet_panels
+ response.status.should eq 302
+ end
+ it 'サインインページへ遷移する' do
+ get :sheet_panels
+ response.should redirect_to '/users/sign_in'
+ end
+ end
+ context 'json形式' do
+ it 'ステータスコード401 Unauthorizedを返す' do
+ get :sheet_panels, :format => :json
+ response.status.should eq 401
+ end
+ it '応答メッセージにUnauthorizedを返す' do
+ get :sheet_panels, :format => :json
+ response.message.should match(/Unauthorized/)
+ end
+ end
+ end
+ end
+
describe '自分のコマ一覧表示に於いて' do
before do
@panel = FactoryGirl.create :panel, :author_id => @author.id
end
else
- describe 'è\87ªå\88\86ã\81®ã\82³ã\83\9fã\83\83ã\82¯一覧表示に於いて' do
+ describe 'è\87ªå\88\86ã\81®ã\82¹ã\82¯ã\83ã\83¼ã\83«一覧表示に於いて' do
before do
@scroll = FactoryGirl.create :scroll, :author_id => @author.id
sign_in @user