describe SpeechBalloon do
before do
+ SpeechBalloonTemplate.delete_all
@admin = FactoryGirl.create :admin
@user = FactoryGirl.create( :user_yas)
@author = FactoryGirl.create :author, :user_id => @user.id
@license = FactoryGirl.create :license, :license_group_id => @lg.id, :system_picture_id => @sp.id
@panel = FactoryGirl.create :panel, :author_id => @author.id
- @speech_balloon_template = FactoryGirl.create :speech_balloon_template
+ @writing_format = FactoryGirl.create :writing_format
+ @speech_balloon_template = FactoryGirl.create :speech_balloon_template, "name" => "circle@pettan.com", "classname" => "CircleSpeechBalloon", "caption" => "cc", "system_picture_id" => @sp.id, "settings" => '{}'
end
describe '検証に於いて' do
before do
@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!
end
context 'オーソドックスなデータのとき' do
describe '閲覧許可に於いて' do
before do
- @sb = FactoryGirl.create :speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @speech_balloon_template.id
+ @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!
end
context 'オープンモードのとき' do
before do
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
+ @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!
end
context 'page補正について' do
it '文字列から数値に変換される' do
it '時系列で並んでいる' do
#公開されたコマのフキダシは(他人のフキダシであっても)含んでいる
hc = FactoryGirl.create :panel, :author_id => @other_author.id, :publish => 1
- npl = FactoryGirl.create :speech_balloon, :panel_id => hc.id, :speech_balloon_template_id => @speech_balloon_template.id, :updated_at => Time.now + 100
+ npl = FactoryGirl.build :speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @speech_balloon_template.id, :updated_at => Time.now + 100
+ npl.build_speech(
+ FactoryGirl.attributes_for(:speech, :writing_format_id => @writing_format.id)
+ )
+ npl.build_balloon(
+ FactoryGirl.attributes_for(:balloon, :system_picture_id => @sp.id)
+ )
+ npl.boost
+ npl.save!
r = SpeechBalloon.list
r.should eq [npl, @sb]
end
it '非公開のコマのフキダシは自分のフキダシであっても含まない' do
hc = FactoryGirl.create :panel, :author_id => @author.id, :publish => 0
- npl = FactoryGirl.create :speech_balloon, :panel_id => hc.id, :speech_balloon_template_id => @speech_balloon_template.id, :updated_at => Time.now + 100
+ npl = FactoryGirl.build :speech_balloon, :panel_id => hc.id, :speech_balloon_template_id => @speech_balloon_template.id, :updated_at => Time.now + 100
+ npl.build_speech(
+ FactoryGirl.attributes_for(:speech, :writing_format_id => @writing_format.id)
+ )
+ npl.build_balloon(
+ FactoryGirl.attributes_for(:balloon, :system_picture_id => @sp.id)
+ )
+ npl.boost
+ npl.save!
pl = SpeechBalloon.list
pl.should eq [@sb]
end
context 'DBに5件あって1ページの件数を2件に変えたとして' do
before do
- @sb2 = FactoryGirl.create :speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @speech_balloon_template.id, :t => 1, :updated_at => Time.now + 100
- @sb3 = FactoryGirl.create :speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @speech_balloon_template.id, :t => 2, :updated_at => Time.now + 200
- @sb4 = FactoryGirl.create :speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @speech_balloon_template.id, :t => 3, :updated_at => Time.now + 300
- @sb5 = FactoryGirl.create :speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @speech_balloon_template.id, :t => 4, :updated_at => Time.now + 400
+ @sb2 = FactoryGirl.build :speech_balloon, :panel_id => @panel.id, :t => 1, :speech_balloon_template_id => @speech_balloon_template.id, :updated_at => Time.now + 100
+ @speech2 = @sb2.build_speech(
+ FactoryGirl.attributes_for(:speech, :writing_format_id => @writing_format.id)
+ )
+ @balloon2 = @sb2.build_balloon(
+ FactoryGirl.attributes_for(:balloon, :system_picture_id => @sp.id, :updated_at => Time.now + 100)
+ )
+ @sb2.boost
+ @sb2.save!
+ @sb3 = FactoryGirl.build :speech_balloon, :panel_id => @panel.id, :t => 2, :speech_balloon_template_id => @speech_balloon_template.id, :updated_at => Time.now + 200
+ @speech3 = @sb3.build_speech(
+ FactoryGirl.attributes_for(:speech, :writing_format_id => @writing_format.id)
+ )
+ @balloon3 = @sb3.build_balloon(
+ FactoryGirl.attributes_for(:balloon, :system_picture_id => @sp.id, :updated_at => Time.now + 200)
+ )
+ @sb3.boost
+ @sb3.save!
+ @sb4 = FactoryGirl.build :speech_balloon, :panel_id => @panel.id, :t => 3, :speech_balloon_template_id => @speech_balloon_template.id, :updated_at => Time.now + 300
+ @speech4 = @sb4.build_speech(
+ FactoryGirl.attributes_for(:speech, :writing_format_id => @writing_format.id)
+ )
+ @balloon4 = @sb4.build_balloon(
+ FactoryGirl.attributes_for(:balloon, :system_picture_id => @sp.id, :updated_at => Time.now + 300)
+ )
+ @sb4.boost
+ @sb4.save!
+ @sb5 = FactoryGirl.build :speech_balloon, :panel_id => @panel.id, :t => 4, :speech_balloon_template_id => @speech_balloon_template.id, :updated_at => Time.now + 400
+ @speech5 = @sb5.build_speech(
+ FactoryGirl.attributes_for(:speech, :writing_format_id => @writing_format.id)
+ )
+ @balloon5 = @sb5.build_balloon(
+ FactoryGirl.attributes_for(:balloon, :system_picture_id => @sp.id, :updated_at => Time.now + 400)
+ )
+ @sb5.boost
+ @sb5.save!
SpeechBalloon.stub(:default_page_size).and_return(2)
end
it '通常は2件を返す' do
pl.should eq [@sb]
end
end
- context 'DBに5件あって1ページの件数を0件に変えたとして' do
+ end
+
+ describe '自分のフキダシ一覧取得に於いて' do
+ before do
+ @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!
+ end
+ context 'つつがなく終わるとき' do
+ it '一覧取得オプションを利用している' do
+ SpeechBalloon.stub(:list_opt).with(any_args).and_return({:include => :panel})
+ SpeechBalloon.should_receive(:list_opt).with(any_args).exactly(1)
+ r = SpeechBalloon.mylist @author
+ end
+ end
+ it 'リストを返す' do
+ pl = SpeechBalloon.mylist @author
+ pl.should eq [@sb]
+ end
+ it '時系列で並んでいる' do
+ nsb = FactoryGirl.build :speech_balloon, :panel_id => @panel.id, :t => 1, :speech_balloon_template_id => @speech_balloon_template.id, :updated_at => Time.now + 100
+ nsb.build_speech(
+ FactoryGirl.attributes_for(:speech, :writing_format_id => @writing_format.id)
+ )
+ nsb.build_balloon(
+ FactoryGirl.attributes_for(:balloon, :system_picture_id => @sp.id)
+ )
+ nsb.boost
+ nsb.save!
+ pl = SpeechBalloon.mylist @author
+ pl.should eq [nsb, @sb]
+ end
+ it '他人のコマのフキダシは公開コマでも含まない' do
+ hpl = FactoryGirl.create :panel, :author_id => @other_author.id, :publish => 1
+ nsb = FactoryGirl.build :speech_balloon, :panel_id => hpl.id, :t => 1, :speech_balloon_template_id => @speech_balloon_template.id, :updated_at => Time.now + 100
+ nsb.build_speech(
+ FactoryGirl.attributes_for(:speech, :writing_format_id => @writing_format.id)
+ )
+ nsb.build_balloon(
+ FactoryGirl.attributes_for(:balloon, :system_picture_id => @sp.id)
+ )
+ nsb.boost
+ nsb.save!
+ pl = SpeechBalloon.mylist @author
+ pl.should eq [@sb]
+ end
+ it '自分のコマのフキダシは非公開コマでも含んでいる' do
+ pl = FactoryGirl.create :panel, :author_id => @author.id, :publish => 0
+ nsb = FactoryGirl.build :speech_balloon, :panel_id => pl.id, :t => 1, :speech_balloon_template_id => @speech_balloon_template.id, :updated_at => Time.now + 100
+ nsb.build_speech(
+ FactoryGirl.attributes_for(:speech, :writing_format_id => @writing_format.id)
+ )
+ nsb.build_balloon(
+ FactoryGirl.attributes_for(:balloon, :system_picture_id => @sp.id)
+ )
+ nsb.boost
+ nsb.save!
+ r = SpeechBalloon.mylist @author
+ r.should eq [nsb, @sb]
+ end
+ context 'DBに5件あって1ページの件数を2件に変えたとして' do
before do
- @sb2 = FactoryGirl.create :speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @speech_balloon_template.id, :t => 1, :updated_at => Time.now + 100
- @sb3 = FactoryGirl.create :speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @speech_balloon_template.id, :t => 2, :updated_at => Time.now + 200
- @sb4 = FactoryGirl.create :speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @speech_balloon_template.id, :t => 3, :updated_at => Time.now + 300
- @sb5 = FactoryGirl.create :speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @speech_balloon_template.id, :t => 4, :updated_at => Time.now + 400
- SpeechBalloon.stub(:default_page_size).and_return(2)
+ @sb2 = FactoryGirl.build :speech_balloon, :panel_id => @panel.id, :t => 1, :speech_balloon_template_id => @speech_balloon_template.id, :updated_at => Time.now + 100
+ @speech2 = @sb2.build_speech(
+ FactoryGirl.attributes_for(:speech, :writing_format_id => @writing_format.id)
+ )
+ @balloon2 = @sb2.build_balloon(
+ FactoryGirl.attributes_for(:balloon, :system_picture_id => @sp.id, :updated_at => Time.now + 100)
+ )
+ @sb2.boost
+ @sb2.save!
+ @sb3 = FactoryGirl.build :speech_balloon, :panel_id => @panel.id, :t => 2, :speech_balloon_template_id => @speech_balloon_template.id, :updated_at => Time.now + 200
+ @speech3 = @sb3.build_speech(
+ FactoryGirl.attributes_for(:speech, :writing_format_id => @writing_format.id)
+ )
+ @balloon3 = @sb3.build_balloon(
+ FactoryGirl.attributes_for(:balloon, :system_picture_id => @sp.id, :updated_at => Time.now + 200)
+ )
+ @sb3.boost
+ @sb3.save!
+ @sb4 = FactoryGirl.build :speech_balloon, :panel_id => @panel.id, :t => 3, :speech_balloon_template_id => @speech_balloon_template.id, :updated_at => Time.now + 300
+ @speech4 = @sb4.build_speech(
+ FactoryGirl.attributes_for(:speech, :writing_format_id => @writing_format.id)
+ )
+ @balloon4 = @sb4.build_balloon(
+ FactoryGirl.attributes_for(:balloon, :system_picture_id => @sp.id, :updated_at => Time.now + 300)
+ )
+ @sb4.boost
+ @sb4.save!
+ @sb5 = FactoryGirl.build :speech_balloon, :panel_id => @panel.id, :t => 4, :speech_balloon_template_id => @speech_balloon_template.id, :updated_at => Time.now + 400
+ @speech5 = @sb5.build_speech(
+ FactoryGirl.attributes_for(:speech, :writing_format_id => @writing_format.id)
+ )
+ @balloon5 = @sb5.build_balloon(
+ FactoryGirl.attributes_for(:balloon, :system_picture_id => @sp.id, :updated_at => Time.now + 400)
+ )
+ @sb5.boost
+ @sb5.save!
end
- it '通常は全件(5件)を返す' do
- r = SpeechBalloon.list 5, 0
- r.should have(5).items
+ it '通常は2件を返す' do
+ r = SpeechBalloon.mylist @author, 1, 2
+ r.should have(2).items
+ end
+ it 'page=1なら末尾2件を返す' do
+ #時系列で並んでいる
+ r = SpeechBalloon.mylist(@author, 1, 2)
+ r.should eq [@sb5, @sb4]
+ end
+ it 'page=2なら中間2件を返す' do
+ r = SpeechBalloon.mylist(@author, 2, 2)
+ r.should eq [@sb3, @sb2]
+ end
+ it 'page=3なら先頭1件を返す' do
+ r = SpeechBalloon.mylist(@author, 3, 2)
+ r.should eq [@sb]
end
end
end
- describe '一覧取得オプションに於いて' do
- it 'includeキーを含んでいる' do
- r = SpeechBalloon.list_opt
- r.has_key?(:include).should be_true
+
+ describe '他作家のフキダシ一覧取得に於いて' do
+ before do
+ @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!
+ @other_panel = FactoryGirl.create :panel, :author_id => @other_author.id, :publish => 1
+ @other_sb = FactoryGirl.build :speech_balloon, :panel_id => @other_panel.id, :speech_balloon_template_id => @speech_balloon_template.id
+ @other_speech = @other_sb.build_speech(
+ FactoryGirl.attributes_for(:speech, :writing_format_id => @writing_format.id)
+ )
+ @other_balloon = @other_sb.build_balloon(
+ FactoryGirl.attributes_for(:balloon, :system_picture_id => @sp.id)
+ )
+ @other_sb.boost
+ @other_sb.save!
+ end
+ it 'リストを返す' do
+ r = SpeechBalloon.himlist @other_author
+ r.should eq [@other_sb]
+ end
+ it '時系列で並んでいる' do
+ new_panel = FactoryGirl.create :panel, :author_id => @other_author.id, :updated_at => Time.now + 100
+ new_sb = FactoryGirl.build :speech_balloon, :panel_id => new_panel.id, :speech_balloon_template_id => @speech_balloon_template.id, :updated_at => Time.now + 100
+ new_sb.build_speech(
+ FactoryGirl.attributes_for(:speech, :writing_format_id => @writing_format.id)
+ )
+ new_sb.build_balloon(
+ FactoryGirl.attributes_for(:balloon, :system_picture_id => @sp.id)
+ )
+ new_sb.boost
+ new_sb.save!
+ r = SpeechBalloon.himlist @other_author
+ r.should eq [new_sb, @other_sb]
+ end
+ it '公開コマに限る' do
+ hidden_panel = FactoryGirl.create :panel, :author_id => @other_author.id, :publish => 0
+ hidden_sb = FactoryGirl.build :speech_balloon, :panel_id => hidden_panel.id, :speech_balloon_template_id => @speech_balloon_template.id, :updated_at => Time.now + 100
+ hidden_sb.build_speech(
+ FactoryGirl.attributes_for(:speech, :writing_format_id => @writing_format.id)
+ )
+ hidden_sb.build_balloon(
+ FactoryGirl.attributes_for(:balloon, :system_picture_id => @sp.id)
+ )
+ hidden_sb.boost
+ hidden_sb.save!
+ r = SpeechBalloon.himlist @other_author
+ r.should eq [@other_sb]
+ end
+ context 'DBに5件あって1ページの件数を2件に変えたとして' do
+ before do
+ @other_sb2 = FactoryGirl.build :speech_balloon, :panel_id => @other_panel.id, :t => 1, :speech_balloon_template_id => @speech_balloon_template.id, :updated_at => Time.now + 100
+ @other_sb2.build_speech(
+ FactoryGirl.attributes_for(:speech, :writing_format_id => @writing_format.id)
+ )
+ @other_sb2.build_balloon(
+ FactoryGirl.attributes_for(:balloon, :system_picture_id => @sp.id, :updated_at => Time.now + 100)
+ )
+ @other_sb2.boost
+ @other_sb2.save!
+ @other_sb3 = FactoryGirl.build :speech_balloon, :panel_id => @other_panel.id, :t => 2, :speech_balloon_template_id => @speech_balloon_template.id, :updated_at => Time.now + 200
+ @other_sb3.build_speech(
+ FactoryGirl.attributes_for(:speech, :writing_format_id => @writing_format.id)
+ )
+ @other_sb3.build_balloon(
+ FactoryGirl.attributes_for(:balloon, :system_picture_id => @sp.id, :updated_at => Time.now + 200)
+ )
+ @other_sb3.boost
+ @other_sb3.save!
+ @other_sb4 = FactoryGirl.build :speech_balloon, :panel_id => @other_panel.id, :t => 3, :speech_balloon_template_id => @speech_balloon_template.id, :updated_at => Time.now + 300
+ @other_sb4.build_speech(
+ FactoryGirl.attributes_for(:speech, :writing_format_id => @writing_format.id)
+ )
+ @other_sb4.build_balloon(
+ FactoryGirl.attributes_for(:balloon, :system_picture_id => @sp.id, :updated_at => Time.now + 300)
+ )
+ @other_sb4.boost
+ @other_sb4.save!
+ @other_sb5 = FactoryGirl.build :speech_balloon, :panel_id => @other_panel.id, :t => 4, :speech_balloon_template_id => @speech_balloon_template.id, :updated_at => Time.now + 400
+ @other_sb5.build_speech(
+ FactoryGirl.attributes_for(:speech, :writing_format_id => @writing_format.id)
+ )
+ @other_sb5.build_balloon(
+ FactoryGirl.attributes_for(:balloon, :system_picture_id => @sp.id, :updated_at => Time.now + 400)
+ )
+ @other_sb5.boost
+ @other_sb5.save!
+ end
+ it '通常は2件を返す' do
+ r = SpeechBalloon.himlist @other_author, 1, 2
+ r.should have(2).items
+ end
+ it 'page=1なら末尾2件を返す' do
+ #時系列で並んでいる
+ r = SpeechBalloon.himlist @other_author, 1, 2
+ r.should eq [@other_sb5, @other_sb4]
+ end
+ it 'page=2なら中間2件を返す' do
+ r = SpeechBalloon.himlist @other_author, 2, 2
+ r.should eq [@other_sb3, @other_sb2]
+ end
+ it 'page=3なら先頭1件を返す' do
+ r = SpeechBalloon.himlist @other_author, 3, 2
+ r.should eq [@other_sb]
+ end
+ end
+ end
+
+ describe 'フキダシ一覧ページ制御に於いて' do
+ before do
+ SpeechBalloon.stub(:count).with(any_args).and_return(100)
+ end
+ it 'ページ制御を返す' do
+ r = SpeechBalloon.list_paginate
+ r.is_a?(Kaminari::PaginatableArray).should be_true
+ end
+ it 'フキダシ一覧の取得条件を利用している' do
+ SpeechBalloon.stub(:list_where).with(any_args).and_return('')
+ SpeechBalloon.should_receive(:list_where).with(any_args).exactly(1)
+ r = SpeechBalloon.list_paginate
+ end
+ it 'ページ件数10のとき、3ページ目のオフセットは20から始まる' do
+ r = SpeechBalloon.list_paginate 3, 10
+ r.limit_value.should eq 10
+ r.offset_value.should eq 20
+ end
+ end
+
+ describe '自分のフキダシ一覧ページ制御に於いて' do
+ before do
+ SpeechBalloon.stub(:count).with(any_args).and_return(100)
end
+ it 'ページ制御を返す' do
+ r = SpeechBalloon.mylist_paginate @author
+ r.is_a?(Kaminari::PaginatableArray).should be_true
+ end
+ it '自分のフキダシ一覧の取得条件を利用している' do
+ SpeechBalloon.stub(:mylist_where).with(any_args).and_return('')
+ SpeechBalloon.should_receive(:mylist_where).with(any_args).exactly(1)
+ r = SpeechBalloon.mylist_paginate @author
+ end
+ it 'ページ件数10のとき、3ページ目のオフセットは20から始まる' do
+ r = SpeechBalloon.mylist_paginate @author, 3, 10
+ r.limit_value.should eq 10
+ r.offset_value.should eq 20
+ end
+ end
+
+ describe '他作家のフキダシ一覧ページ制御に於いて' do
+ before do
+ SpeechBalloon.stub(:count).with(any_args).and_return(100)
+ end
+ it 'ページ制御を返す' do
+ r = SpeechBalloon.himlist_paginate @other_author
+ r.is_a?(Kaminari::PaginatableArray).should be_true
+ end
+ it '他作家のフキダシ一覧の取得条件を利用している' do
+ SpeechBalloon.stub(:himlist_where).with(any_args).and_return('')
+ SpeechBalloon.should_receive(:himlist_where).with(any_args).exactly(1)
+ r = SpeechBalloon.himlist_paginate @other_author
+ end
+ it 'ページ件数10のとき、3ページ目のオフセットは20から始まる' do
+ r = SpeechBalloon.himlist_paginate @other_author, 3, 10
+ r.limit_value.should eq 10
+ r.offset_value.should eq 20
+ end
+ end
+
+ describe '一覧取得オプションに於いて' do
it '4つの項目を含んでいる' do
- r = SpeechBalloon.list_opt[:include]
+ r = SpeechBalloon.list_opt
r.should have(4).items
end
it 'コマを含んでいる' do
- r = SpeechBalloon.list_opt[:include]
+ r = SpeechBalloon.list_opt
r.has_key?(:panel).should be_true
end
it 'コマは作家を含んでいる' do
- r = SpeechBalloon.list_opt[:include]
+ r = SpeechBalloon.list_opt
r[:panel].has_key?(:author).should be_true
end
it 'フキダシ枠を含んでいる' do
- r = SpeechBalloon.list_opt[:include]
+ r = SpeechBalloon.list_opt
r.has_key?(:balloon).should be_true
end
it 'セリフを含んでいる' do
- r = SpeechBalloon.list_opt[:include]
+ r = SpeechBalloon.list_opt
r.has_key?(:speech).should be_true
end
it 'フキダシテンプレートを含んでいる' do
- r = SpeechBalloon.list_opt[:include]
+ r = SpeechBalloon.list_opt
r.has_key?(:speech_balloon_template).should be_true
end
end
describe 'json一覧出力オプションに於いて' do
before do
@panel = FactoryGirl.create :panel, :author_id => @author.id, :publish => 1
- @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
+ @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!
end
it 'コマを含んでいる' do
r = SpeechBalloon.list.to_json SpeechBalloon.list_json_opt
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
+ @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!
end
context 'つつがなく終わるとき' do
it '単体取得オプションを利用している' do
describe 'json単体出力オプションに於いて' do
before do
@panel = FactoryGirl.create :panel, :author_id => @author.id, :publish => 1
- @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
+ @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!
end
it 'コマを含んでいる' do
r = SpeechBalloon.show(@sb.id, @author).to_json SpeechBalloon.show_json_opt