@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, "name" => "circle@pettan.com", "classname" => "CircleSpeechBalloon", "caption" => "cc", "system_picture_id" => @sp.id, "settings" => '{}'
+ @writing_format = FactoryGirl.create :writing_format
@user = FactoryGirl.create( :user_yas)
@author = FactoryGirl.create :author, :user_id => @user.id
@artist = FactoryGirl.create :artist_yas, :author_id => @author.id
@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
- @sbt = FactoryGirl.create :speech_balloon_template
end
describe '検証に於いて' do
end
end
end
- describe 'list関連テーブルプションに於いて' do
- it 'includeキーを含んでいる' do
- r = Story.list_opt
- r.has_key?(:include).should be_true
- end
- it '3つの項目を含んでいる' do
- r = Story.list_opt[:include]
- r.should have(3).items
- end
- it 'コミックを含んでいる' do
- r = Story.list_opt[:include]
- r.has_key?(:comic).should be_true
- end
- it 'コミックは作家を含んでいる' do
- r = Story.list_opt[:include]
- r[:comic].has_key?(:author).should be_true
- end
- it '作家を含んでいる' do
- r = Story.list_opt[:include]
- r.has_key?(:author).should be_true
- end
- it 'コマを含んでいる' do
- r = Story.list_opt[:include]
- r.has_key?(:panel).should be_true
- end
- it 'コマは作家を含んでいる' do
- r = Story.list_opt[:include]
- r[:panel].has_key?(:author).should be_true
- end
- it 'コマはコマ絵を含んでいる' do
- r = Story.list_opt[:include]
- r[:panel].has_key?(:panel_pictures).should be_true
- end
- it 'コマ絵は実素材を含んでいる' do
- r = Story.list_opt[:include]
- r[:panel][:panel_pictures].has_key?(:picture).should be_true
- end
- it '実素材は絵師を含んでいる' do
- r = Story.list_opt[:include]
- r[:panel][:panel_pictures][:picture].has_key?(:artist).should be_true
- end
- it '実素材はライセンスを含んでいる' do
- r = Story.list_opt[:include]
- r[:panel][:panel_pictures][:picture].has_key?(:license).should be_true
- end
- it 'コマはフキダシを含んでいる' do
- r = Story.list_opt[:include]
- r[:panel].has_key?(:speech_balloons).should be_true
- end
- it 'フキダシはフキダシ枠を含んでいる' do
- r = Story.list_opt[:include]
- r[:panel][:speech_balloons].has_key?(:balloons).should be_true
- end
- it 'フキダシはセリフを含んでいる' do
- r = Story.list_opt[:include]
- r[:panel][:speech_balloons].has_key?(:speeches).should be_true
- end
- end
- describe 'json一覧出力オプションに於いて' do
- end
describe '一覧取得に於いて' do
before do
l.should eq [@story]
end
end
- context 'DBに5件あって1ページの件数を2件に変えたとして' do
- before do
- @story2 = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id, :t => 1, :updated_at => Time.now + 100
- @story3 = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id, :t => 2, :updated_at => Time.now + 200
- @story4 = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id, :t => 3, :updated_at => Time.now + 300
- @story5 = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id, :t => 4, :updated_at => Time.now + 400
- Story.stub(:default_page_size).and_return(2)
- end
- it '件数0は全件(5件)を返す' do
- r = Story.list 5, 0
- r.should have(5).items
- end
- end
end
describe '自分のストーリー一覧取得に於いて' do
l.should eq [@story]
end
end
- context 'DBに5件あって1ページの件数を2件に変えたとして' do
- before do
- @story2 = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id, :t => 1, :updated_at => Time.now + 100
- @story3 = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id, :t => 2, :updated_at => Time.now + 200
- @story4 = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id, :t => 3, :updated_at => Time.now + 300
- @story5 = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id, :t => 4, :updated_at => Time.now + 400
- Author.stub(:default_story_page_size).and_return(2)
- end
- it '件数0は全件(5件)を返す' do
- r = Story.mylist @author, 5, 0
- r.should have(5).items
- end
- end
end
describe '他作家のストーリー一覧取得に於いて' do
l.should eq [@other_story]
end
end
- context 'DBに5件あって1ページの件数を2件に変えたとして' do
- before do
- @other_story2 = FactoryGirl.create :story, :author_id => @other_author.id, :comic_id => @other_comic.id, :panel_id => @other_panel.id, :t => 1, :updated_at => Time.now + 100
- @other_story3 = FactoryGirl.create :story, :author_id => @other_author.id, :comic_id => @other_comic.id, :panel_id => @other_panel.id, :t => 2, :updated_at => Time.now + 200
- @other_story4 = FactoryGirl.create :story, :author_id => @other_author.id, :comic_id => @other_comic.id, :panel_id => @other_panel.id, :t => 3, :updated_at => Time.now + 300
- @other_story5 = FactoryGirl.create :story, :author_id => @other_author.id, :comic_id => @other_comic.id, :panel_id => @other_panel.id, :t => 4, :updated_at => Time.now + 400
- Author.stub(:default_story_page_size).and_return(2)
- end
- it '件数0は全件(5件)を返す' do
- r = Story.himlist @other_author, 5, 0
- r.should have(5).items
+ end
+
+ describe 'ストーリー一覧ページ制御に於いて' do
+ before do
+ Story.stub(:count).with(any_args).and_return(100)
+ end
+ it 'ページ制御を返す' do
+ r = Story.list_paginate
+ r.is_a?(Kaminari::PaginatableArray).should be_true
+ end
+ it 'ストーリー一覧の取得条件を利用している' do
+ Story.stub(:list_where).with(any_args).and_return('')
+ Story.should_receive(:list_where).with(any_args).exactly(1)
+ r = Story.list_paginate
+ end
+ it 'ページ件数10のとき、3ページ目のオフセットは20から始まる' do
+ r = Story.list_paginate 3, 10
+ r.limit_value.should eq 10
+ r.offset_value.should eq 20
+ end
+ end
+
+ describe '自分のストーリー一覧ページ制御に於いて' do
+ before do
+ Story.stub(:count).with(any_args).and_return(100)
+ end
+ it 'ページ制御を返す' do
+ r = Story.mylist_paginate @author
+ r.is_a?(Kaminari::PaginatableArray).should be_true
+ end
+ it '自分のストーリー一覧の取得条件を利用している' do
+ Story.stub(:mylist_where).with(any_args).and_return('')
+ Story.should_receive(:mylist_where).with(any_args).exactly(1)
+ r = Story.mylist_paginate @author
+ end
+ it 'ページ件数10のとき、3ページ目のオフセットは20から始まる' do
+ r = Story.mylist_paginate @author, 3, 10
+ r.limit_value.should eq 10
+ r.offset_value.should eq 20
+ end
+ end
+
+ describe '他作家のストーリー一覧ページ制御に於いて' do
+ before do
+ Story.stub(:count).with(any_args).and_return(100)
+ end
+ it 'ページ制御を返す' do
+ r = Story.himlist_paginate @other_author
+ r.is_a?(Kaminari::PaginatableArray).should be_true
+ end
+ it '他作家のストーリー一覧の取得条件を利用している' do
+ Story.stub(:himlist_where).with(any_args).and_return('')
+ Story.should_receive(:himlist_where).with(any_args).exactly(1)
+ r = Story.himlist_paginate @other_author
+ end
+ it 'ページ件数10のとき、3ページ目のオフセットは20から始まる' do
+ r = Story.himlist_paginate @other_author, 3, 10
+ r.limit_value.should eq 10
+ r.offset_value.should eq 20
+ end
+ end
+
+ describe 'list関連テーブルプションに於いて' do
+ it '3つの項目を含んでいる' do
+ r = Story.list_opt
+ r.should have(3).items
+ end
+ it 'コミックを含んでいる' do
+ r = Story.list_opt
+ r.has_key?(:comic).should be_true
+ end
+ it 'コミックは作家を含んでいる' do
+ r = Story.list_opt
+ r[:comic].has_key?(:author).should be_true
end
+ it '作家を含んでいる' do
+ r = Story.list_opt
+ r.has_key?(:author).should be_true
+ end
+ it 'コマを含んでいる' do
+ r = Story.list_opt
+ r.has_key?(:panel).should be_true
end
+ it 'コマは作家を含んでいる' do
+ r = Story.list_opt
+ r[:panel].has_key?(:author).should be_true
+ end
+ it 'コマはコマ絵を含んでいる' do
+ r = Story.list_opt
+ r[:panel].has_key?(:panel_pictures).should be_true
+ end
+ it 'コマ絵は実素材を含んでいる' do
+ r = Story.list_opt
+ r[:panel][:panel_pictures].has_key?(:picture).should be_true
+ end
+ it '実素材は絵師を含んでいる' do
+ r = Story.list_opt
+ r[:panel][:panel_pictures][:picture].has_key?(:artist).should be_true
+ end
+ it '実素材はライセンスを含んでいる' do
+ r = Story.list_opt
+ r[:panel][:panel_pictures][:picture].has_key?(:license).should be_true
+ end
+ it 'コマはフキダシを含んでいる' do
+ r = Story.list_opt
+ r[:panel].has_key?(:speech_balloons).should be_true
+ end
+ it 'フキダシはフキダシ枠を含んでいる' do
+ r = Story.list_opt
+ r[:panel][:speech_balloons].has_key?(:balloon).should be_true
+ end
+ it 'フキダシはセリフを含んでいる' do
+ r = Story.list_opt
+ r[:panel][:speech_balloons].has_key?(:speech).should be_true
+ end
+ end
+ describe 'json一覧出力オプションに於いて' do
end
describe '単体取得に於いて' do
end
it 'フキダシはフキダシ枠を含んでいる' do
r = Story.show_opt[:include]
- r[:panel][:speech_balloons].has_key?(:balloons).should be_true
+ r[:panel][:speech_balloons].has_key?(:balloon).should be_true
end
it 'フキダシはセリフを含んでいる' do
r = Story.show_opt[:include]
- r[:panel][:speech_balloons].has_key?(:speeches).should be_true
+ r[:panel][:speech_balloons].has_key?(:speech).should be_true
end
end
describe 'json単体取得オプションに於いて' do
#コマを作成しておく。
@panel = FactoryGirl.create :panel, :author_id => @author.id
@pp = FactoryGirl.create :panel_picture, :panel_id => @panel.id, :t => 1, :width => @p.width, :height => @p.height
- @sb = @panel.speech_balloons.create(
- FactoryGirl.attributes_for(:speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @sbt.id, :t => 0)
+ @sb = FactoryGirl.build :speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @speech_balloon_template.id
+ @speech = @sb.build_speech(
+ FactoryGirl.attributes_for(:speech, :writing_format_id => @writing_format.id)
+ )
+ @balloon = @sb.build_balloon(
+ FactoryGirl.attributes_for(:balloon, :system_picture_id => @sp.id)
)
+ @sb.boost
+ @sb.save!
@gc = @panel.ground_colors.create(
FactoryGirl.attributes_for(:ground_color, :panel_id => @panel.id)
)