OSDN Git Service

fix: any
[pettanr/pettanr.git] / spec / controllers / speech_balloons_controller_spec.rb
index f204513..bb98036 100644 (file)
@@ -3,6 +3,7 @@
 require 'spec_helper'
 describe SpeechBalloonsController do
   before do
+    SpeechBalloonTemplate.delete_all
     @admin = FactoryGirl.create :admin
     @user = FactoryGirl.create( :user_yas)
     @author = FactoryGirl.create :author, :user_id => @user.id
@@ -11,14 +12,23 @@ describe SpeechBalloonsController do
     @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
+    @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
     @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
+      @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!
       sign_in @user
       SpeechBalloon.stub(:list).and_return([@sb, @sb, @sb])
     end
@@ -143,7 +153,15 @@ if MagicNumber['run_mode'] == 1
   describe '単体表示に於いて' do
     before do
       sign_in @user
-      @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!
       SpeechBalloon.stub(:show).and_return(@sb)
     end
     context 'つつがなく終わるとき' do
@@ -232,7 +250,15 @@ if MagicNumber['run_mode'] == 1
 else
   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!
       sign_in @user
       SpeechBalloon.stub(:list).and_return([@sb, @sb, @sb])
     end
@@ -280,7 +306,15 @@ else
   describe '単体表示に於いて' do
     before do
       sign_in @user
-      @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!
       SpeechBalloon.stub(:show).and_return(@sb)
     end
     context 'つつがなく終わるとき' do