OSDN Git Service

add: social button
[pettanr/pettanr.git] / spec / models / speech_balloon_spec.rb
index 9dc4b25..da4ea56 100644 (file)
@@ -4,6 +4,7 @@ require 'spec_helper'
 
 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
@@ -17,12 +18,20 @@ describe SpeechBalloon do
     
     @panel = FactoryGirl.create :panel, :author_id => @author.id
     @writing_format = FactoryGirl.create :writing_format
-    @speech_balloon_template = FactoryGirl.create :speech_balloon_template
+    @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
@@ -125,7 +134,15 @@ describe SpeechBalloon 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
@@ -202,9 +219,15 @@ describe SpeechBalloon 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, :writing_format_id => @writing_format.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
@@ -245,22 +268,70 @@ describe SpeechBalloon 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
@@ -285,9 +356,15 @@ describe SpeechBalloon 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, :writing_format_id => @writing_format.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
@@ -301,28 +378,84 @@ describe SpeechBalloon do
       pl.should eq [@sb]
     end
     it '時系列で並んでいる' do
-      npl = FactoryGirl.create :speech_balloon, :panel_id => @panel.id, :t => 1, :speech_balloon_template_id => @speech_balloon_template.id, :updated_at => Time.now + 100
+      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 [npl, @sb]
+      pl.should eq [nsb, @sb]
     end
     it '他人のコマのフキダシは公開コマでも含まない' do
       hpl = FactoryGirl.create :panel, :author_id => @other_author.id, :publish => 1
-      npl = FactoryGirl.create :speech_balloon, :panel_id => hpl.id, :t => 1, :speech_balloon_template_id => @speech_balloon_template.id, :updated_at => Time.now + 100
+      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
-      ni = FactoryGirl.create :speech_balloon, :panel_id => pl.id, :t => 1, :speech_balloon_template_id => @speech_balloon_template.id, :updated_at => Time.now + 100
+      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 [ni, @sb]
+      r.should eq [nsb, @sb]
     end
     context 'DBに5件あって1ページの件数を2件に変えたとして' do
       before do
-        @npl2 = FactoryGirl.create :speech_balloon, :panel_id => @panel.id, :t => 1, :speech_balloon_template_id => @speech_balloon_template.id, :updated_at => Time.now + 100
-        @npl3 = FactoryGirl.create :speech_balloon, :panel_id => @panel.id, :t => 2, :speech_balloon_template_id => @speech_balloon_template.id, :updated_at => Time.now + 200
-        @npl4 = FactoryGirl.create :speech_balloon, :panel_id => @panel.id, :t => 3, :speech_balloon_template_id => @speech_balloon_template.id, :updated_at => Time.now + 300
-        @npl5 = FactoryGirl.create :speech_balloon, :panel_id => @panel.id, :t => 4, :speech_balloon_template_id => @speech_balloon_template.id, :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!
       end
       it '通常は2件を返す' do
         r = SpeechBalloon.mylist @author, 1, 2
@@ -331,11 +464,11 @@ describe SpeechBalloon do
       it 'page=1なら末尾2件を返す' do
         #時系列で並んでいる
         r = SpeechBalloon.mylist(@author, 1, 2)
-        r.should eq [@npl5, @npl4]
+        r.should eq [@sb5, @sb4]
       end
       it 'page=2なら中間2件を返す' do
         r = SpeechBalloon.mylist(@author, 2, 2)
-        r.should eq [@npl3, @npl2]
+        r.should eq [@sb3, @sb2]
       end
       it 'page=3なら先頭1件を返す' do
         r = SpeechBalloon.mylist(@author, 3, 2)
@@ -346,11 +479,25 @@ describe SpeechBalloon 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, :writing_format_id => @writing_format.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!
       @other_panel = FactoryGirl.create :panel, :author_id => @other_author.id, :publish => 1
-      @other_sb = FactoryGirl.create :speech_balloon, :panel_id => @other_panel.id, :speech_balloon_template_id => @speech_balloon_template.id
+      @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
@@ -358,22 +505,70 @@ describe SpeechBalloon do
     end
     it '時系列で並んでいる' do
       new_panel = FactoryGirl.create :panel, :author_id => @other_author.id, :updated_at => Time.now + 100
-      new_sb = FactoryGirl.create :speech_balloon, :panel_id => new_panel.id, :speech_balloon_template_id => @speech_balloon_template.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.create :speech_balloon, :panel_id => hidden_panel.id, :speech_balloon_template_id => @speech_balloon_template.id
+      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.create :speech_balloon, :panel_id => @other_panel.id, :t => 1, :speech_balloon_template_id => @speech_balloon_template.id, :updated_at => Time.now + 100
-        @other_sb3 = FactoryGirl.create :speech_balloon, :panel_id => @other_panel.id, :t => 2, :speech_balloon_template_id => @speech_balloon_template.id, :updated_at => Time.now + 200
-        @other_sb4 = FactoryGirl.create :speech_balloon, :panel_id => @other_panel.id, :t => 3, :speech_balloon_template_id => @speech_balloon_template.id, :updated_at => Time.now + 300
-        @other_sb5 = FactoryGirl.create :speech_balloon, :panel_id => @other_panel.id, :t => 4, :speech_balloon_template_id => @speech_balloon_template.id, :updated_at => Time.now + 400
+        @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
@@ -484,9 +679,15 @@ describe SpeechBalloon 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, :writing_format_id => @writing_format.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
@@ -523,9 +724,15 @@ describe SpeechBalloon 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, :writing_format_id => @writing_format.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
@@ -593,9 +800,15 @@ describe SpeechBalloon 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, :writing_format_id => @writing_format.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