OSDN Git Service

t#32046:
[pettanr/pettanr.git] / spec / models / ground_color_spec.rb
index 8b979b7..7f0567e 100644 (file)
@@ -4,6 +4,7 @@ require 'spec_helper'
 
 describe GroundColor do
   before do
+    SpeechBalloonTemplate.delete_all
     @admin = FactoryGirl.create :admin
     @user = FactoryGirl.create( :user_yas)
     @author = FactoryGirl.create :author, :user_id => @user.id
@@ -29,11 +30,13 @@ describe GroundColor do
       it '下限データが通る' do
         @gc.code = 0
         @gc.z = 1
+        @gc.t = 0
         @gc.should be_valid
       end
       it '上限データが通る' do
         @gc.code = 99999
         @gc.z = 99999
+        @gc.t = 99999
         @gc.should be_valid
       end
     end
@@ -85,6 +88,20 @@ describe GroundColor do
         @gc.should_not be_valid
       end
     end
+    context 'tを検証するとき' do
+      it 'nullなら失敗する' do
+        @gc.t = nil
+        @gc.should_not be_valid
+      end
+      it '数値でなければ失敗する' do
+        @gc.t = 'a'
+        @gc.should_not be_valid
+      end
+      it '負なら失敗する' do
+        @gc.t = -1
+        @gc.should_not be_valid
+      end
+    end
   end
   
   describe '文字コード検証に於いて' do
@@ -463,9 +480,9 @@ describe GroundColor do
       @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
-      @comic = FactoryGirl.create :comic, :author_id => @author.id, :visible => 1
+      @scroll = FactoryGirl.create :scroll, :author_id => @author.id, :visible => 1
       @panel = FactoryGirl.create :panel, :author_id => @author.id, :publish => 1
-      @story = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id
+      @scroll_panel = FactoryGirl.create :scroll_panel, :author_id => @author.id, :scroll_id => @scroll.id, :panel_id => @panel.id
       @gc = FactoryGirl.create :ground_color, :panel_id => @panel.id
     end
     it 'コマを含んでいる' do