\r
describe Speech do\r
before do\r
+ SpeechBalloonTemplate.delete_all\r
@admin = FactoryGirl.create :admin\r
@user = FactoryGirl.create( :user_yas)\r
@author = FactoryGirl.create :author, :user_id => @user.id\r
@license = FactoryGirl.create :license, :license_group_id => @lg.id, :system_picture_id => @sp.id\r
\r
@writing_format = FactoryGirl.create :writing_format\r
+ SpeechBalloonTemplate.delete_all\r
@speech_balloon_template = FactoryGirl.create :speech_balloon_template, "name" => "circle@pettan.com", "classname" => "CircleSpeechBalloon", "caption" => "cc", "system_picture_id" => @sp.id, "settings" => '{}'\r
@panel = FactoryGirl.create :panel, :author_id => @author.id\r
end\r
\r
context 'オーソドックスなデータのとき' do\r
it '下限データが通る' do\r
+ @speech.font_size = 1.0\r
+ @speech.text_align = 0\r
+ @speech.fore_color = 0\r
@speech.x = 0\r
@speech.y = 0\r
@speech.width = 1\r
@speech.should be_valid\r
end\r
it '上限データが通る' do\r
+ @speech.font_size = 99999.0\r
+ @speech.text_align = 3\r
+ @speech.fore_color = 0xffffff\r
@speech.x = 99999\r
@speech.y = 99999\r
@speech.width = 99999\r
end\r
context 'contentを検証するとき' do\r
end\r
+ context 'font_sizeを検証するとき' do\r
+ it 'nullなら失敗する' do\r
+ @speech.font_size = nil\r
+ @speech.should_not be_valid\r
+ end\r
+ it '数値でなければ失敗する' do\r
+ @speech.font_size = 'a'\r
+ @speech.should_not be_valid\r
+ end\r
+ it '0なら通る' do\r
+ @speech.font_size = '0'\r
+ @speech.should be_valid\r
+ end\r
+ it '10.5なら通る' do\r
+ @speech.font_size = '0'\r
+ @speech.should be_valid\r
+ end\r
+ it '負なら失敗する' do\r
+ @speech.font_size = 10.5\r
+ @speech.should be_valid\r
+ end\r
+ end\r
+ context 'text_alignを検証するとき' do\r
+ it 'nullなら失敗する' do\r
+ @speech.text_align = nil\r
+ @speech.should_not be_valid\r
+ end\r
+ it '数値でなければ失敗する' do\r
+ @speech.text_align = 'a'\r
+ @speech.should_not be_valid\r
+ end\r
+ it '0なら通る' do\r
+ @speech.text_align = '0'\r
+ @speech.should be_valid\r
+ end\r
+ it '負なら失敗する' do\r
+ @speech.text_align = -1\r
+ @speech.should_not be_valid\r
+ end\r
+ it '4なら失敗する' do\r
+ @speech.text_align = 4\r
+ @speech.should_not be_valid\r
+ end\r
+ end\r
+ context 'fore_colorを検証するとき' do\r
+ it 'nullなら失敗する' do\r
+ @speech.fore_color = nil\r
+ @speech.should_not be_valid\r
+ end\r
+ it '数値でなければ失敗する' do\r
+ @speech.fore_color = 'a'\r
+ @speech.should_not be_valid\r
+ end\r
+ it '0なら通る' do\r
+ @speech.fore_color = '0'\r
+ @speech.should be_valid\r
+ end\r
+ it '負なら失敗する' do\r
+ @speech.fore_color = -1\r
+ @speech.should_not be_valid\r
+ end\r
+ it '24bit colorでなければ失敗する' do\r
+ @speech.fore_color = 0x1000000\r
+ @speech.should_not be_valid\r
+ end\r
+ end\r
context 'xを検証するとき' do\r
it 'nullなら失敗する' do\r
@speech.x = nil\r
before do\r
@sb2 = FactoryGirl.build :speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @speech_balloon_template.id\r
@speech2 = @sb2.build_speech(\r
- FactoryGirl.attributes_for(:speech, :writing_format_id => @writing_format.id)\r
+ FactoryGirl.attributes_for(:speech, :writing_format_id => @writing_format.id, :updated_at => Time.now + 100)\r
)\r
@balloon2 = @sb2.build_balloon(\r
- FactoryGirl.attributes_for(:balloon, :system_picture_id => @sp.id, :updated_at => Time.now + 100)\r
+ FactoryGirl.attributes_for(:balloon, :system_picture_id => @sp.id)\r
)\r
@sb2.boost\r
@sb2.save!\r
@sb3 = FactoryGirl.build :speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @speech_balloon_template.id\r
@speech3 = @sb3.build_speech(\r
- FactoryGirl.attributes_for(:speech, :writing_format_id => @writing_format.id)\r
+ FactoryGirl.attributes_for(:speech, :writing_format_id => @writing_format.id, :updated_at => Time.now + 200)\r
)\r
@balloon3 = @sb3.build_balloon(\r
- FactoryGirl.attributes_for(:balloon, :system_picture_id => @sp.id, :updated_at => Time.now + 200)\r
+ FactoryGirl.attributes_for(:balloon, :system_picture_id => @sp.id)\r
)\r
@sb3.boost\r
@sb3.save!\r
@sb4 = FactoryGirl.build :speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @speech_balloon_template.id\r
@speech4 = @sb4.build_speech(\r
- FactoryGirl.attributes_for(:speech, :writing_format_id => @writing_format.id)\r
+ FactoryGirl.attributes_for(:speech, :writing_format_id => @writing_format.id, :updated_at => Time.now + 300)\r
)\r
@balloon4 = @sb4.build_balloon(\r
- FactoryGirl.attributes_for(:balloon, :system_picture_id => @sp.id, :updated_at => Time.now + 300)\r
+ FactoryGirl.attributes_for(:balloon, :system_picture_id => @sp.id)\r
)\r
@sb4.boost\r
@sb4.save!\r
@sb5 = FactoryGirl.build :speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @speech_balloon_template.id\r
@speech5 = @sb5.build_speech(\r
- FactoryGirl.attributes_for(:speech, :writing_format_id => @writing_format.id)\r
+ FactoryGirl.attributes_for(:speech, :writing_format_id => @writing_format.id, :updated_at => Time.now + 400)\r
)\r
@balloon5 = @sb5.build_balloon(\r
- FactoryGirl.attributes_for(:balloon, :system_picture_id => @sp.id, :updated_at => Time.now + 400)\r
+ FactoryGirl.attributes_for(:balloon, :system_picture_id => @sp.id)\r
)\r
@sb5.boost\r
@sb5.save!\r
before do\r
@sb2 = FactoryGirl.build :speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @speech_balloon_template.id\r
@speech2 = @sb2.build_speech(\r
- FactoryGirl.attributes_for(:speech, :writing_format_id => @writing_format.id)\r
+ FactoryGirl.attributes_for(:speech, :writing_format_id => @writing_format.id, :updated_at => Time.now + 100)\r
)\r
@balloon2 = @sb2.build_balloon(\r
- FactoryGirl.attributes_for(:balloon, :system_picture_id => @sp.id, :updated_at => Time.now + 100)\r
+ FactoryGirl.attributes_for(:balloon, :system_picture_id => @sp.id)\r
)\r
@sb2.boost\r
@sb2.save!\r
@sb3 = FactoryGirl.build :speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @speech_balloon_template.id\r
@speech3 = @sb3.build_speech(\r
- FactoryGirl.attributes_for(:speech, :writing_format_id => @writing_format.id)\r
+ FactoryGirl.attributes_for(:speech, :writing_format_id => @writing_format.id, :updated_at => Time.now + 200)\r
)\r
@balloon3 = @sb3.build_balloon(\r
- FactoryGirl.attributes_for(:balloon, :system_picture_id => @sp.id, :updated_at => Time.now + 200)\r
+ FactoryGirl.attributes_for(:balloon, :system_picture_id => @sp.id)\r
)\r
@sb3.boost\r
@sb3.save!\r
@sb4 = FactoryGirl.build :speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @speech_balloon_template.id\r
@speech4 = @sb4.build_speech(\r
- FactoryGirl.attributes_for(:speech, :writing_format_id => @writing_format.id)\r
+ FactoryGirl.attributes_for(:speech, :writing_format_id => @writing_format.id, :updated_at => Time.now + 300)\r
)\r
@balloon4 = @sb4.build_balloon(\r
- FactoryGirl.attributes_for(:balloon, :system_picture_id => @sp.id, :updated_at => Time.now + 300)\r
+ FactoryGirl.attributes_for(:balloon, :system_picture_id => @sp.id)\r
)\r
@sb4.boost\r
@sb4.save!\r
@sb5 = FactoryGirl.build :speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @speech_balloon_template.id\r
@speech5 = @sb5.build_speech(\r
- FactoryGirl.attributes_for(:speech, :writing_format_id => @writing_format.id)\r
+ FactoryGirl.attributes_for(:speech, :writing_format_id => @writing_format.id, :updated_at => Time.now + 400)\r
)\r
@balloon5 = @sb5.build_balloon(\r
- FactoryGirl.attributes_for(:balloon, :system_picture_id => @sp.id, :updated_at => Time.now + 400)\r
+ FactoryGirl.attributes_for(:balloon, :system_picture_id => @sp.id)\r
)\r
@sb5.boost\r
@sb5.save!\r