X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=spec%2Fmodels%2Fground_picture_spec.rb;h=886982ae1f4756f2d7ac4758bc0f7b07b4ab73a9;hb=eb397c27a98c59c856b91a5b09d1316b1135a15c;hp=c293ba111cfcff8102fe17040a75b4f2a3e5a503;hpb=e6ae2d4d0e9cec1828ef7e4bec617d7f925d8133;p=pettanr%2Fpettanr.git diff --git a/spec/models/ground_picture_spec.rb b/spec/models/ground_picture_spec.rb index c293ba11..886982ae 100644 --- a/spec/models/ground_picture_spec.rb +++ b/spec/models/ground_picture_spec.rb @@ -4,6 +4,7 @@ require 'spec_helper' describe GroundPicture do before do + SpeechBalloonTemplate.delete_all @admin = FactoryGirl.create :admin @user = FactoryGirl.create( :user_yas) @author = FactoryGirl.create :author, :user_id => @user.id @@ -31,6 +32,7 @@ describe GroundPicture do @gp.x = -99999 @gp.y = -99999 @gp.z = 1 + @gp.t = 0 @gp.should be_valid end it '上限データが通る' do @@ -38,6 +40,7 @@ describe GroundPicture do @gp.x = 99999 @gp.y = 99999 @gp.z = 99999 + @gp.t = 99999 @gp.should be_valid end end @@ -119,6 +122,35 @@ describe GroundPicture do @gp.should_not be_valid end end + context 'tを検証するとき' do + it 'nullなら失敗する' do + @gp.t = nil + @gp.should_not be_valid + end + it '数値でなければ失敗する' do + @gp.t = 'a' + @gp.should_not be_valid + end + it '負なら失敗する' do + @gp.t = -1 + @gp.should_not be_valid + end + end + end + + describe '文字コード検証に於いて' do + before do + @gp = FactoryGirl.create :ground_picture, :panel_id => @panel.id, :picture_id => @p.id + end + + context 'captionを検証するとき' do + it 'Shift JISなら失敗する' do + @gp.caption = "\x83G\x83r\x83]\x83D" + lambda{ + @gp.valid_encode + }.should raise_error(Pettanr::BadRequest) + end + end end describe 'デフォルト値補充に於いて' do @@ -140,9 +172,10 @@ describe GroundPicture do end describe '上書き補充に於いて' do - it 'defined' do + it 'panel_idが設定されている' do @gp = FactoryGirl.build :ground_picture, :panel_id => @panel.id, :picture_id => @p.id - @gp.overwrite + @gp.overwrite @panel.id + @gp.panel_id.should eq @panel.id end end @@ -504,9 +537,9 @@ describe GroundPicture 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 @gp = FactoryGirl.create :ground_picture, :panel_id => @panel.id, :picture_id => @p.id end it 'コマを含んでいる' do