#コマ\r
describe Panel do\r
before do\r
+ SpeechBalloonTemplate.delete_all\r
@admin = FactoryGirl.create :admin\r
@sp = FactoryGirl.create :system_picture\r
@lg = FactoryGirl.create :license_group\r
@op = FactoryGirl.create :original_picture, :artist_id => @artist.id\r
@p = FactoryGirl.create :picture, :original_picture_id => @op.id, :license_id => @license.id, :artist_id => @artist.id\r
@rp = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op.id, :picture_id => @p.id\r
- @sbt = FactoryGirl.create :speech_balloon_template\r
+ @sbt = FactoryGirl.create :speech_balloon_template, "name" => "circle@pettan.com", "classname" => "CircleSpeechBalloon", "caption" => "cc", "system_picture_id" => @sp.id, "settings" => '{}'\r
end\r
\r
describe '検証に於いて' do\r
\r
describe '閲覧許可に於いて' do\r
before do\r
- @comic = FactoryGirl.create :comic, :author_id => @author.id\r
+ @scroll = FactoryGirl.create :scroll, :author_id => @author.id\r
@panel = FactoryGirl.create :panel, :author_id => @author.id\r
- @story = FactoryGirl.create :story, :author_id => @author.id, :comic_id => @comic.id, :panel_id => @panel.id\r
+ @scroll_panel = FactoryGirl.create :scroll_panel, :author_id => @author.id, :scroll_id => @scroll.id, :panel_id => @panel.id\r
end\r
context 'オープンモードのとき' do\r
before do\r
#コマを作成しておく。\r
@panel = FactoryGirl.create :panel, :author_id => @author.id\r
@pp = FactoryGirl.create :panel_picture, :panel_id => @panel.id, :t => 1, :width => @p.width, :height => @p.height\r
- @sb = @panel.speech_balloons.create(\r
+ @sb = @panel.speech_balloons.build(\r
FactoryGirl.attributes_for(:speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @sbt.id, :t => 0)\r
)\r
+ @sb.build_balloon(\r
+ FactoryGirl.attributes_for(:balloon, :system_picture_id => @sp.id)\r
+ )\r
+ @sb.build_speech(\r
+ FactoryGirl.attributes_for(:speech, :writing_format_id => @writing_format.id)\r
+ )\r
+ @sb.boost\r
+ @sb.save!\r
@gc = @panel.ground_colors.create(\r
FactoryGirl.attributes_for(:ground_color, :panel_id => @panel.id, :t => 2)\r
)\r
#コマを作成しておく。\r
@panel = FactoryGirl.create :panel, :author_id => @author.id\r
@pp = FactoryGirl.create :panel_picture, :panel_id => @panel.id, :t => 0, :z => 2, :width => @p.width, :height => @p.height\r
- @sb = @panel.speech_balloons.create(\r
+ @sb = @panel.speech_balloons.build(\r
FactoryGirl.attributes_for(:speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @sbt.id, :t => 1, :z => 1)\r
)\r
+ @sb.build_balloon(\r
+ FactoryGirl.attributes_for(:balloon, :system_picture_id => @sp.id)\r
+ )\r
+ @sb.build_speech(\r
+ FactoryGirl.attributes_for(:speech, :writing_format_id => @writing_format.id)\r
+ )\r
+ @sb.boost\r
+ @sb.save!\r
@gc = @panel.ground_colors.create(\r
FactoryGirl.attributes_for(:ground_color, :panel_id => @panel.id, :t => 2, :z => 3)\r
)\r
end\r
context 'さらに末尾にフキダシを追加したとき' do\r
before do\r
- @sb2 = @panel.speech_balloons.create(\r
+ @sb2 = @panel.speech_balloons.build(\r
FactoryGirl.attributes_for(:speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @sbt.id, :t => 4, :z => 5)\r
)\r
+ @sb2.build_balloon(\r
+ FactoryGirl.attributes_for(:balloon, :system_picture_id => @sp.id)\r
+ )\r
+ @sb2.build_speech(\r
+ FactoryGirl.attributes_for(:speech, :writing_format_id => @writing_format.id)\r
+ )\r
+ @sb2.boost\r
+ @sb2.save!\r
@panel.reload\r
end\r
it 'zでソートしている' do\r
#コマを作成しておく。\r
@panel = FactoryGirl.create :panel, :author_id => @author.id\r
@pp = FactoryGirl.create :panel_picture, :panel_id => @panel.id, :t => 1, :width => @p.width, :height => @p.height\r
- @sb = @panel.speech_balloons.create(\r
+ @sb = @panel.speech_balloons.build(\r
FactoryGirl.attributes_for(:speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @sbt.id, :t => 0)\r
)\r
+ @sb.build_balloon(\r
+ FactoryGirl.attributes_for(:balloon, :system_picture_id => @sp.id)\r
+ )\r
+ @sb.build_speech(\r
+ FactoryGirl.attributes_for(:speech, :writing_format_id => @writing_format.id)\r
+ )\r
+ @sb.boost\r
+ @sb.save!\r
@gc = @panel.ground_colors.create(\r
FactoryGirl.attributes_for(:ground_color, :panel_id => @panel.id, :t => 2)\r
)\r
end\r
context 'さらに末尾にフキダシを追加したとき' do\r
before do\r
- @sb2 = @panel.speech_balloons.create(\r
+ @sb2 = @panel.speech_balloons.build(\r
FactoryGirl.attributes_for(:speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @sbt.id, :t => 4)\r
)\r
+ @sb2.build_balloon(\r
+ FactoryGirl.attributes_for(:balloon, :system_picture_id => @sp.id)\r
+ )\r
+ @sb2.build_speech(\r
+ FactoryGirl.attributes_for(:speech, :writing_format_id => @writing_format.id)\r
+ )\r
+ @sb2.boost\r
+ @sb2.save!\r
@panel.reload\r
end\r
it 'tでソートしている' do\r
#コマを作成しておく。\r
@panel = FactoryGirl.create :panel, :author_id => @author.id\r
@pp = FactoryGirl.create :panel_picture, :panel_id => @panel.id, :t => 1, :width => @p.width, :height => @p.height\r
- @sb = @panel.speech_balloons.create(\r
+ @sb = @panel.speech_balloons.build(\r
FactoryGirl.attributes_for(:speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @sbt.id, :t => 0)\r
)\r
+ @sb.build_balloon(\r
+ FactoryGirl.attributes_for(:balloon, :system_picture_id => @sp.id)\r
+ )\r
+ @sb.build_speech(\r
+ FactoryGirl.attributes_for(:speech, :writing_format_id => @writing_format.id)\r
+ )\r
+ @sb.boost\r
+ @sb.save!\r
@gc = @panel.ground_colors.create(\r
FactoryGirl.attributes_for(:ground_color, :panel_id => @panel.id, :t => 2)\r
)\r
#コマを作成しておく。\r
@panel = FactoryGirl.create :panel, :author_id => @author.id\r
@pp = FactoryGirl.create :panel_picture, :panel_id => @panel.id, :t => 1, :width => @p.width, :height => @p.height\r
- @sb = @panel.speech_balloons.create(\r
+ @sb = @panel.speech_balloons.build(\r
FactoryGirl.attributes_for(:speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @sbt.id, :t => 0)\r
)\r
- @sb.create_balloon(\r
- FactoryGirl.attributes_for(:balloon, :speech_balloon_id => @sb.id)\r
+ @sb.build_balloon(\r
+ FactoryGirl.attributes_for(:balloon, :system_picture_id => @sp.id)\r
)\r
- @sb.create_speech(\r
- FactoryGirl.attributes_for(:speech, :speech_balloon_id => @sb.id, :writing_format_id => @writing_format.id)\r
+ @sb.build_speech(\r
+ FactoryGirl.attributes_for(:speech, :writing_format_id => @writing_format.id)\r
)\r
+ @sb.boost\r
+ @sb.save!\r
@gc = @panel.ground_colors.create(\r
FactoryGirl.attributes_for(:ground_color, :panel_id => @panel.id, :t => 2)\r
)\r
@rp2 = FactoryGirl.create :resource_picture, :artist_id => @artist.id, :license_id => @license.id, :original_picture_id => @op2.id, :picture_id => @p2.id\r
@panel = FactoryGirl.create :panel, :author_id => @author.id\r
@pp = FactoryGirl.create :panel_picture, :panel_id => @panel.id, :t => 1, :width => @p.width, :height => @p.height, :picture_id => @p.id\r
- @sb = @panel.speech_balloons.create(\r
+ @sb = @panel.speech_balloons.build(\r
FactoryGirl.attributes_for(:speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @sbt.id, :t => 0)\r
)\r
+ @sb.build_balloon(\r
+ FactoryGirl.attributes_for(:balloon, :system_picture_id => @sp.id)\r
+ )\r
+ @sb.build_speech(\r
+ FactoryGirl.attributes_for(:speech, :writing_format_id => @writing_format.id)\r
+ )\r
+ @sb.boost\r
+ @sb.save!\r
@gc = @panel.ground_colors.create(\r
FactoryGirl.attributes_for(:ground_color, :panel_id => @panel.id, :t => 2)\r
)\r
FactoryGirl.attributes_for(:panel_picture, :panel_id => @panel.id, :picture_id => @p.id, :t => 1, :z => 1+1)\r
)\r
sb1 = @panel.speech_balloons.build(\r
- FactoryGirl.attributes_for(:speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @sbt.id, :t => 2, :z => 2+1)\r
+ FactoryGirl.attributes_for(:speech_balloon, :speech_balloon_template_id => @sbt.id, :t => 2, :z => 2+1)\r
)\r
sb1.build_balloon(\r
- FactoryGirl.attributes_for(:balloon, :speech_balloon_id => sb1.id)\r
+ FactoryGirl.attributes_for(:balloon, :system_picture_id => @sp.id)\r
)\r
sb1.build_speech(\r
- FactoryGirl.attributes_for(:speech, :speech_balloon_id => sb1.id)\r
+ FactoryGirl.attributes_for(:speech, :writing_format_id => @writing_format.id)\r
)\r
+ sb1.boost\r
+ sb1.save!\r
sb2 = @panel.speech_balloons.build(\r
- FactoryGirl.attributes_for(:speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @sbt.id, :t => 3, :z => 3+1)\r
+ FactoryGirl.attributes_for(:speech_balloon, :speech_balloon_template_id => @sbt.id, :t => 3, :z => 3+1)\r
)\r
sb2.build_balloon(\r
- FactoryGirl.attributes_for(:balloon, :speech_balloon_id => sb2.id)\r
+ FactoryGirl.attributes_for(:balloon, :system_picture_id => @sp.id)\r
)\r
sb2.build_speech(\r
- FactoryGirl.attributes_for(:speech, :speech_balloon_id => sb2.id)\r
+ FactoryGirl.attributes_for(:speech, :writing_format_id => @writing_format.id)\r
)\r
+ sb2.boost\r
+ sb2.save!\r
@gc = @panel.ground_colors.build(\r
FactoryGirl.attributes_for(:ground_color, :panel_id => @panel.id, :t => 4, :z => 4+1)\r
)\r
FactoryGirl.attributes_for(:panel_picture, :panel_id => @panel.id, :picture_id => @p.id, :t => 1, :z => 1+1)\r
)\r
sb1 = @panel.speech_balloons.build(\r
- FactoryGirl.attributes_for(:speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @sbt.id, :t => 2, :z => 2+1)\r
+ FactoryGirl.attributes_for(:speech_balloon, :speech_balloon_template_id => @sbt.id, :t => 2, :z => 2+1)\r
)\r
sb1.build_balloon(\r
- FactoryGirl.attributes_for(:balloon, :speech_balloon_id => sb1.id)\r
+ FactoryGirl.attributes_for(:balloon, :system_picture_id => @sp.id)\r
)\r
sb1.build_speech(\r
- FactoryGirl.attributes_for(:speech, :speech_balloon_id => sb1.id)\r
+ FactoryGirl.attributes_for(:speech, :writing_format_id => @writing_format.id)\r
)\r
+ sb1.boost\r
+ sb1.save!\r
sb2 = @panel.speech_balloons.build(\r
- FactoryGirl.attributes_for(:speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @sbt.id, :t => 4, :z => 3+1)\r
+ FactoryGirl.attributes_for(:speech_balloon, :speech_balloon_template_id => @sbt.id, :t => 4, :z => 3+1)\r
)\r
sb2.build_balloon(\r
- FactoryGirl.attributes_for(:balloon, :speech_balloon_id => sb2.id)\r
+ FactoryGirl.attributes_for(:balloon, :system_picture_id => @sp.id)\r
)\r
sb2.build_speech(\r
- FactoryGirl.attributes_for(:speech, :speech_balloon_id => sb2.id)\r
+ FactoryGirl.attributes_for(:speech, :writing_format_id => @writing_format.id)\r
)\r
+ sb2.boost\r
+ sb2.save!\r
@gc = @panel.ground_colors.build(\r
FactoryGirl.attributes_for(:ground_color, :panel_id => @panel.id, :t => 4, :z => 4+1)\r
)\r
FactoryGirl.attributes_for(:panel_picture, :panel_id => @panel.id, :picture_id => @p.id, :t => 1, :z => 0+1)\r
)\r
sb1 = @panel.speech_balloons.build(\r
- FactoryGirl.attributes_for(:speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @sbt.id, :t => 2, :z => 2+1)\r
+ FactoryGirl.attributes_for(:speech_balloon, :speech_balloon_template_id => @sbt.id, :t => 2, :z => 2+1)\r
)\r
sb1.build_balloon(\r
- FactoryGirl.attributes_for(:balloon, :speech_balloon_id => sb1.id)\r
+ FactoryGirl.attributes_for(:balloon, :system_picture_id => @sp.id)\r
)\r
sb1.build_speech(\r
- FactoryGirl.attributes_for(:speech, :speech_balloon_id => sb1.id)\r
+ FactoryGirl.attributes_for(:speech, :writing_format_id => @writing_format.id)\r
)\r
+ sb1.boost\r
+ sb1.save!\r
sb2 = @panel.speech_balloons.build(\r
- FactoryGirl.attributes_for(:speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @sbt.id, :t => 3, :z => 3+1)\r
+ FactoryGirl.attributes_for(:speech_balloon, :speech_balloon_template_id => @sbt.id, :t => 3, :z => 3+1)\r
)\r
sb2.build_balloon(\r
- FactoryGirl.attributes_for(:balloon, :speech_balloon_id => sb2.id)\r
+ FactoryGirl.attributes_for(:balloon, :system_picture_id => @sp.id)\r
)\r
sb2.build_speech(\r
- FactoryGirl.attributes_for(:speech, :speech_balloon_id => sb2.id)\r
+ FactoryGirl.attributes_for(:speech, :writing_format_id => @writing_format.id)\r
)\r
+ sb2.boost\r
+ sb2.save!\r
@gc = @panel.ground_colors.build(\r
FactoryGirl.attributes_for(:ground_color, :panel_id => @panel.id, :t => 4, :z => 4+1)\r
)\r
end\r
end\r
\r
+ describe '要素の検証に於いて' do\r
+ before do\r
+ @panel = Panel.new\r
+ @panel.supply_default\r
+ @attr = FactoryGirl.attributes_for :panel\r
+@sbattr = {\r
+ "speech_balloons_attributes" => {\r
+ "0" => {\r
+ "caption" => "大きな文字で","z" => "1","t" => "0",\r
+ "classname" => "CircleSpeechBalloon","speech_balloon_template_id" => @sbt.id,\r
+ "speech_attributes" => {\r
+ "content" => "カギッコ","x" => "20","y" => "20","width" => "-60","height" => "60",\r
+ "settings" => "","writing_format_id" => @writing_format.id\r
+ },\r
+ "balloon_attributes" => {\r
+ "r" => "247","x" => "293","y" => "-2","width" => "200","height" => "200",\r
+ "system_picture_id" => @sp.id,"settings" => ""\r
+ }\r
+ }\r
+ },\r
+ "publish" => "0"\r
+}\r
+@ppattr = {\r
+ "panel_pictures_attributes" => {\r
+ "4" => {\r
+ "caption" => "司会","x" => "a","y" => "99","z" => "1","t" => "0",\r
+ "width" => "156","height" => "245","link" => "","picture_id" => @p.id\r
+ }\r
+ },\r
+ "publish" => "0"\r
+}\r
+ end\r
+ context 'フキダシの幅がマイナスで検証に失敗したとき' do\r
+ before do\r
+ @attr.merge!(@sbattr)\r
+ end\r
+ it 'エラーメッセージがセットされている' do\r
+ r = @panel.store @attr, @author\r
+ r.should be_false\r
+ @panel.errors.should_not be_empty\r
+ end\r
+ end\r
+ context 'コマ絵の横軸はアルファベットのため検証に失敗したとき' do\r
+ before do\r
+ @attr.merge!(@ppattr)\r
+ end\r
+ it 'エラーメッセージがセットされている' do\r
+ r = @panel.store @attr, @author\r
+ r.should be_false\r
+ @panel.errors.should_not be_empty\r
+ end\r
+ end\r
+ end\r
+ \r
describe '削除に於いて' do\r
before do\r
- @comic = FactoryGirl.create :comic, :author_id => @author.id\r
+ @scroll = FactoryGirl.create :scroll, :author_id => @author.id\r
@panel = FactoryGirl.create :panel, :author_id => @author.id, :publish => 1\r
@pp = FactoryGirl.create :panel_picture, :panel_id => @panel.id, :t => 1, :width => @p.width, :height => @p.height\r
- @sb = @panel.speech_balloons.create(\r
+ @sb = @panel.speech_balloons.build(\r
FactoryGirl.attributes_for(:speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @sbt.id, :t => 0)\r
)\r
+ @sb.build_balloon(\r
+ FactoryGirl.attributes_for(:balloon, :system_picture_id => @sp.id)\r
+ )\r
+ @sb.build_speech(\r
+ FactoryGirl.attributes_for(:speech, :writing_format_id => @writing_format.id)\r
+ )\r
+ @sb.boost\r
+ @sb.save!\r
@gc = @panel.ground_colors.create(\r
FactoryGirl.attributes_for(:ground_color, :panel_id => @panel.id)\r
)\r