From 6e65d291704afd169130b76c6345c5cd40ff9792 Mon Sep 17 00:00:00 2001 From: yasushiito Date: Sun, 4 Aug 2013 15:23:59 +0900 Subject: [PATCH] t#31834:new base --- app/assets/javascripts/panels.js.coffee | 15 ++++++++------ app/models/balloon.rb | 8 +++++-- app/models/ground_color.rb | 12 +++++++++++ app/models/ground_picture.rb | 12 +++++++++++ app/models/panel.rb | 10 +++++++++ app/models/panel_picture.rb | 12 +++++++++++ app/models/speech.rb | 8 +++++-- app/models/speech_balloon.rb | 12 +++++++++++ app/views/ground_colors/_form.html.erb | 12 +++++------ app/views/panel_pictures/_element.html.erb | 2 +- app/views/panel_pictures/_form.html.erb | 20 +++++++++--------- app/views/panels/_form.html.erb | 12 +++++------ spec/controllers/balloons_controller_spec.rb | 9 ++++---- spec/controllers/home_controller_spec.rb | 3 ++- spec/controllers/speeches_controller_spec.rb | 9 ++++---- spec/factories.rb | 9 ++++++++ spec/models/balloon_spec.rb | 15 +++++++------- spec/models/panel_spec.rb | 3 ++- spec/models/speech_balloon_spec.rb | 13 ++++++------ spec/models/speech_spec.rb | 31 ++++++++++++++-------------- 20 files changed, 156 insertions(+), 71 deletions(-) diff --git a/app/assets/javascripts/panels.js.coffee b/app/assets/javascripts/panels.js.coffee index fbddfaed..a1a96621 100644 --- a/app/assets/javascripts/panels.js.coffee +++ b/app/assets/javascripts/panels.js.coffee @@ -23,13 +23,16 @@ $ -> else return false is_var = (o) -> - if o.attr('column') - if o.attr('column') == '_destroy' and o.val().length < 1 - return false - else - return true - else + if parseInt(o.attr('no_attr')) > 0 return false + else + if o.attr('column') + if o.attr('column') == '_destroy' and o.val().length < 1 + return false + else + return true + else + return false is_element = (o) -> if o.attr('element_type') return true diff --git a/app/models/balloon.rb b/app/models/balloon.rb index 90f05181..04bc1302 100644 --- a/app/models/balloon.rb +++ b/app/models/balloon.rb @@ -89,8 +89,12 @@ self.system_picture_id = 1 'balloon' end - def field_tree f - 'panels-' + self.tag_panel_id + '-speech_balloons_attributes-' + self.tag_element_id + '-balloon_attributes-' + f.to_s + def tag_new_index + if self.get_speech_balloon == nil + nil + else + self.get_speech_balloon.tag_new_index + end end def self.default_page_size diff --git a/app/models/ground_color.rb b/app/models/ground_color.rb index 690770fc..7117e4bf 100644 --- a/app/models/ground_color.rb +++ b/app/models/ground_color.rb @@ -68,6 +68,14 @@ class GroundColor < ActiveRecord::Base "position: absolute; width:#{self.get_panel.width}px; height:#{self.get_panel.height}px; z-index:#{self.z}; background-color:##{format("%06x", self.code)}; #{o}" end + def new_index + @new_index + end + + def new_index= v + @new_index = v + end + def new_panel @new_panel end @@ -100,6 +108,10 @@ class GroundColor < ActiveRecord::Base 'ground_color' end + def tag_new_index + self.new_index.to_s + end + def self.default_page_size 25 end diff --git a/app/models/ground_picture.rb b/app/models/ground_picture.rb index c2aac21c..b77bc6a7 100644 --- a/app/models/ground_picture.rb +++ b/app/models/ground_picture.rb @@ -83,6 +83,14 @@ class GroundPicture < ActiveRecord::Base {:src => self.picture.url, :width => tw, :height => th, :alt => self.caption} end + def new_index + @new_index + end + + def new_index= v + @new_index = v + end + def new_panel @new_panel end @@ -115,6 +123,10 @@ class GroundPicture < ActiveRecord::Base 'ground_picture' end + def tag_new_index + self.new_index.to_s + end + def repeat_text @@repeat_texts[self.repeat] end diff --git a/app/models/panel.rb b/app/models/panel.rb index 7674df53..0bb2cbb9 100644 --- a/app/models/panel.rb +++ b/app/models/panel.rb @@ -308,6 +308,16 @@ class Panel < ActiveRecord::Base Panel.validate_elements_serial validate_serial_list end + def boost + @new_element_index = 0 + self.panel_elements.each do |elm| + if elm.new_record? + elm.new_index = @new_element_index + @new_element_index += 1 + end + end + end + def store attr, au if attr == false self.errors.add :base, I18n.t('errors.invalid_json') diff --git a/app/models/panel_picture.rb b/app/models/panel_picture.rb index 0667d045..36e7699c 100644 --- a/app/models/panel_picture.rb +++ b/app/models/panel_picture.rb @@ -107,6 +107,14 @@ class PanelPicture < ActiveRecord::Base {:src => self.url, :width => tw, :height => th, :alt => self.caption} end + def new_index + @new_index + end + + def new_index= v + @new_index = v + end + def new_panel @new_panel end @@ -139,6 +147,10 @@ class PanelPicture < ActiveRecord::Base 'panel_picture' end + def tag_new_index + self.new_index.to_s + end + def self.default_page_size 25 end diff --git a/app/models/speech.rb b/app/models/speech.rb index b8fe28da..62720b46 100644 --- a/app/models/speech.rb +++ b/app/models/speech.rb @@ -82,8 +82,12 @@ class Speech < ActiveRecord::Base 'speech' end - def field_tree f - 'panels-' + self.tag_panel_id + '-speech_balloons_attributes-' + self.tag_element_id + '-speech_attributes-' + f.to_s + def tag_new_index + if self.get_speech_balloon == nil + nil + else + self.get_speech_balloon.tag_new_index + end end def self.default_page_size diff --git a/app/models/speech_balloon.rb b/app/models/speech_balloon.rb index c7f160ea..1301c31e 100644 --- a/app/models/speech_balloon.rb +++ b/app/models/speech_balloon.rb @@ -68,6 +68,14 @@ class SpeechBalloon < ActiveRecord::Base self.panel.visible? roles end + def new_index + @new_index + end + + def new_index= v + @new_index = v + end + def new_panel @new_panel end @@ -100,6 +108,10 @@ class SpeechBalloon < ActiveRecord::Base 'speech_balloon' end + def tag_new_index + self.new_index.to_s + end + def self.default_page_size 25 end diff --git a/app/views/ground_colors/_form.html.erb b/app/views/ground_colors/_form.html.erb index a0a5d10b..b8ea0d24 100644 --- a/app/views/ground_colors/_form.html.erb +++ b/app/views/ground_colors/_form.html.erb @@ -3,11 +3,11 @@
<%= f.label :caption %> - <%= f.text_field :caption, :id => ground_color.field_tag_id(:caption), :panel_id => ground_color.tag_panel_id, :element_id => ground_color.tag_element_id, :element_type => ground_color.tag_element_type, :column => :caption %> + <%= f.text_field :caption, :id => ground_color.field_tag_id(:caption), :panel_id => ground_color.tag_panel_id, :element_id => ground_color.tag_element_id, :element_type => ground_color.tag_element_type, :column => :caption, :no_attr => no_attr %>
<%= f.label :code %> - <%= f.text_field :code, :size => 8, :id => ground_color.tag_id(:code), :panel_id => ground_color.tag_panel_id, :element_id => ground_color.tag_element_id, :element_type => ground_color.tag_element_type, :column => :code %> + <%= f.text_field :code, :size => 8, :id => ground_color.tag_id(:code), :panel_id => ground_color.tag_panel_id, :element_id => ground_color.tag_element_id, :element_type => ground_color.tag_element_type, :column => :code, :no_attr => no_attr %>
@@ -26,15 +26,15 @@
<%= f.label :z %> - <%= f.number_field :z, :size => 5, :id => ground_color.field_tag_id(:z), :panel_id => ground_color.tag_panel_id, :element_id => ground_color.tag_element_id, :element_type => ground_color.tag_element_type, :column => :z %> + <%= f.number_field :z, :size => 5, :id => ground_color.field_tag_id(:z), :panel_id => ground_color.tag_panel_id, :element_id => ground_color.tag_element_id, :element_type => ground_color.tag_element_type, :column => :z, :no_attr => no_attr %> <%= f.label :t %> - <%= f.number_field :t, :size => 5, :id => ground_color.field_tag_id(:t), :panel_id => ground_color.tag_panel_id, :element_id => ground_color.tag_element_id, :element_type => ground_color.tag_element_type, :column => :t %> + <%= f.number_field :t, :size => 5, :id => ground_color.field_tag_id(:t), :panel_id => ground_color.tag_panel_id, :element_id => ground_color.tag_element_id, :element_type => ground_color.tag_element_type, :column => :t, :no_attr => no_attr %>
- <%= f.hidden_field :panel_id, :id => ground_color.field_tag_id(:panel_id), :panel_id => ground_color.tag_panel_id, :element_id => ground_color.tag_element_id, :element_type => ground_color.tag_element_type, :column => :panel_id %> + <%= f.hidden_field :panel_id, :id => ground_color.field_tag_id(:panel_id), :panel_id => ground_color.tag_panel_id, :element_id => ground_color.tag_element_id, :element_type => ground_color.tag_element_type, :column => :panel_id, :no_attr => no_attr %> <% unless ground_color.new_record? %> - <%= f.hidden_field :id, :id => ground_color.field_tag_id(:id), :panel_id => ground_color.tag_panel_id, :element_id => ground_color.tag_element_id, :element_type => ground_color.tag_element_type, :column => :id %> + <%= f.hidden_field :id, :id => ground_color.field_tag_id(:id), :panel_id => ground_color.tag_panel_id, :element_id => ground_color.tag_element_id, :element_type => ground_color.tag_element_type, :column => :id, :no_attr => no_attr %> <% end %>
diff --git a/app/views/panel_pictures/_element.html.erb b/app/views/panel_pictures/_element.html.erb index a34edf4b..baa60e96 100644 --- a/app/views/panel_pictures/_element.html.erb +++ b/app/views/panel_pictures/_element.html.erb @@ -1,3 +1,3 @@ -
+
<%= link_to_unless(elm.link.blank?, tag(:img, elm.opt_img_tag(spot)), elm.link) %>
diff --git a/app/views/panel_pictures/_form.html.erb b/app/views/panel_pictures/_form.html.erb index 4fbf1940..b94cc2f1 100644 --- a/app/views/panel_pictures/_form.html.erb +++ b/app/views/panel_pictures/_form.html.erb @@ -3,38 +3,38 @@
<%= f.label :caption %> - <%= f.text_field :caption, :id => panel_picture.field_tag_id(:caption), :panel_id => panel_picture.tag_panel_id, :element_id => panel_picture.tag_element_id, :element_type => panel_picture.tag_element_type, :column => :caption %> + <%= f.text_field :caption, :id => panel_picture.field_tag_id(:caption), :panel_id => panel_picture.tag_panel_id, :element_id => panel_picture.tag_element_id, :element_type => panel_picture.tag_element_type, :column => :caption, :new_index => panel_picture.new_index %>
<%= f.label :x %> - <%= f.number_field :x, :size => 5, :id => panel_picture.field_tag_id(:x), :panel_id => panel_picture.tag_panel_id, :element_id => panel_picture.tag_element_id, :element_type => panel_picture.tag_element_type, :column => :x %> + <%= f.number_field :x, :size => 5, :id => panel_picture.field_tag_id(:x), :panel_id => panel_picture.tag_panel_id, :element_id => panel_picture.tag_element_id, :element_type => panel_picture.tag_element_type, :column => :x, :new_index => panel_picture.new_index %> <%= f.label :y %> - <%= f.number_field :y, :size => 5, :id => panel_picture.field_tag_id(:y), :panel_id => panel_picture.tag_panel_id, :element_id => panel_picture.tag_element_id, :element_type => panel_picture.tag_element_type, :column => :y %> + <%= f.number_field :y, :size => 5, :id => panel_picture.field_tag_id(:y), :panel_id => panel_picture.tag_panel_id, :element_id => panel_picture.tag_element_id, :element_type => panel_picture.tag_element_type, :column => :y, :new_index => panel_picture.new_index %>
<%= f.label :z %> - <%= f.number_field :z, :size => 5, :id => panel_picture.field_tag_id(:z), :panel_id => panel_picture.tag_panel_id, :element_id => panel_picture.tag_element_id, :element_type => panel_picture.tag_element_type, :column => :z %> + <%= f.number_field :z, :size => 5, :id => panel_picture.field_tag_id(:z), :panel_id => panel_picture.tag_panel_id, :element_id => panel_picture.tag_element_id, :element_type => panel_picture.tag_element_type, :column => :z, :new_index => panel_picture.new_index %> <%= f.label :t %> - <%= f.number_field :t, :size => 5, :id => panel_picture.field_tag_id(:t), :panel_id => panel_picture.tag_panel_id, :element_id => panel_picture.tag_element_id, :element_type => panel_picture.tag_element_type, :column => :t %> + <%= f.number_field :t, :size => 5, :id => panel_picture.field_tag_id(:t), :panel_id => panel_picture.tag_panel_id, :element_id => panel_picture.tag_element_id, :element_type => panel_picture.tag_element_type, :column => :t, :new_index => panel_picture.new_index %>
<%= f.label :width %> - <%= f.number_field :width, :size => 5, :id => panel_picture.field_tag_id(:width), :panel_id => panel_picture.tag_panel_id, :element_id => panel_picture.tag_element_id, :element_type => panel_picture.tag_element_type, :column => :width %> + <%= f.number_field :width, :size => 5, :id => panel_picture.field_tag_id(:width), :panel_id => panel_picture.tag_panel_id, :element_id => panel_picture.tag_element_id, :element_type => panel_picture.tag_element_type, :column => :width, :new_index => panel_picture.new_index %> <%= content_tag :span, '', :class => "panel_picture_width_tool", :panel_id => panel_picture.tag_panel_id, :element_id => panel_picture.tag_element_id, :element_type => panel_picture.tag_element_type %>
<%= f.label :height %> - <%= f.number_field :height, :size => 5, :id => panel_picture.field_tag_id(:height), :panel_id => panel_picture.tag_panel_id, :element_id => panel_picture.tag_element_id, :element_type => panel_picture.tag_element_type, :column => :height %> + <%= f.number_field :height, :size => 5, :id => panel_picture.field_tag_id(:height), :panel_id => panel_picture.tag_panel_id, :element_id => panel_picture.tag_element_id, :element_type => panel_picture.tag_element_type, :column => :height, :new_index => panel_picture.new_index %> <%= content_tag :span, '', :class => "panel_picture_height_tool", :panel_id => panel_picture.tag_panel_id, :element_id => panel_picture.tag_element_id, :element_type => panel_picture.tag_element_type %>
<%= f.label :link %> - <%= f.text_field :link, :id => panel_picture.field_tag_id(:link), :panel_id => panel_picture.tag_panel_id, :element_id => panel_picture.tag_element_id, :element_type => panel_picture.tag_element_type, :column => :link %> + <%= f.text_field :link, :id => panel_picture.field_tag_id(:link), :panel_id => panel_picture.tag_panel_id, :element_id => panel_picture.tag_element_id, :element_type => panel_picture.tag_element_type, :column => :link, :new_index => panel_picture.new_index %>
- <%= f.hidden_field :panel_id, :id => panel_picture.field_tag_id(:panel_id), :panel_id => panel_picture.tag_panel_id, :element_id => panel_picture.tag_element_id, :element_type => panel_picture.tag_element_type, :column => :panel_id %> - <%= f.hidden_field :picture_id, :id => panel_picture.field_tag_id(:picture_id), :panel_id => panel_picture.tag_panel_id, :element_id => panel_picture.tag_element_id, :element_type => panel_picture.tag_element_type, :column => :picture_id %> + <%= f.hidden_field :panel_id, :id => panel_picture.field_tag_id(:panel_id), :panel_id => panel_picture.tag_panel_id, :element_id => panel_picture.tag_element_id, :element_type => panel_picture.tag_element_type, :column => :panel_id, :new_index => panel_picture.new_index %> + <%= f.hidden_field :picture_id, :id => panel_picture.field_tag_id(:picture_id), :panel_id => panel_picture.tag_panel_id, :element_id => panel_picture.tag_element_id, :element_type => panel_picture.tag_element_type, :column => :picture_id, :new_index => panel_picture.new_index %> <% unless panel_picture.new_record? %> <%= f.hidden_field :id, :id => panel_picture.field_tag_id(:id), :panel_id => panel_picture.tag_panel_id, :element_id => panel_picture.tag_element_id, :element_type => panel_picture.tag_element_type, :column => :id %> <% end %> diff --git a/app/views/panels/_form.html.erb b/app/views/panels/_form.html.erb index 7949999e..3cf438ec 100644 --- a/app/views/panels/_form.html.erb +++ b/app/views/panels/_form.html.erb @@ -55,7 +55,7 @@
<% case elm.class.to_s %> <% when 'PanelPicture' %> - <%= render 'panel_pictures/form', :panel_picture => elm %> + <%= render 'panel_pictures/form', :panel_picture => elm, :no_attr => 0 %> <% when 'SpeechBalloon' %> <% speech_balloon = elm @@ -67,11 +67,11 @@ balloon_extend = balloon.extend_balloon speech_extend = speech.extend_speech %> - <%= render elm.speech_balloon_template.engine_name + '/speech_balloons/form', :speech_balloon => speech_balloon, :balloon => balloon, :speech => speech, :speech_balloon_extend => speech_balloon_extend, :balloon_extend => balloon_extend, :speech_extend => speech_extend %> + <%= render elm.speech_balloon_template.engine_name + '/speech_balloons/form', :speech_balloon => speech_balloon, :balloon => balloon, :speech => speech, :speech_balloon_extend => speech_balloon_extend, :balloon_extend => balloon_extend, :speech_extend => speech_extend, :no_attr => 0 %> <% when 'GroundPicture' %> - <%= render 'ground_pictures/form', :ground_picture => elm %> + <%= render 'ground_pictures/form', :ground_picture => elm, :no_attr => 0 %> <% when 'GroundColor' %> - <%= render 'ground_colors/form', :ground_color => elm %> + <%= render 'ground_colors/form', :ground_color => elm, :no_attr => 0 %> <% end %> <%= hidden_field_tag '_destroy', '', :id => elm.field_tag_id(:_destroy), :panel_id => elm.tag_panel_id, :element_id => elm.tag_element_id, :element_type => elm.tag_element_type, :column => :_destroy %>
@@ -182,14 +182,14 @@ balloon.supply_default speech.supply_default %> - <%= render elm.speech_balloon_template.engine_name + '/speech_balloons/form', :speech_balloon => speech_balloon, :balloon => balloon, :speech => speech, :speech_balloon_extend => speech_balloon_extend, :balloon_extend => balloon_extend, :speech_extend => speech_extend %> + <%= render elm.speech_balloon_template.engine_name + '/speech_balloons/form', :speech_balloon => speech_balloon, :balloon => balloon, :speech => speech, :speech_balloon_extend => speech_balloon_extend, :balloon_extend => balloon_extend, :speech_extend => speech_extend, :no_attr => 1 %>
<% end %> <% when 'GroundPicture' %> <% when 'GroundColor' %> <% elm = GroundColor.new :panel_id => @panel.id %> <% elm.supply_default %> - <%= render k.to_s.tableize + '/form', :ground_color => elm %> + <%= render k.to_s.tableize + '/form', :ground_color => elm, :no_attr => 1 %> <% end %>
diff --git a/spec/controllers/balloons_controller_spec.rb b/spec/controllers/balloons_controller_spec.rb index 381bc1a3..bd4b70d2 100644 --- a/spec/controllers/balloons_controller_spec.rb +++ b/spec/controllers/balloons_controller_spec.rb @@ -13,6 +13,7 @@ describe BalloonsController do @license = FactoryGirl.create :license, :license_group_id => @lg.id, :system_picture_id => @sp.id @speech_balloon_template = FactoryGirl.create :speech_balloon_template + @writing_format = FactoryGirl.create :writing_format @panel = FactoryGirl.create :panel, :author_id => @author.id end @@ -21,7 +22,7 @@ if MagicNumber['run_mode'] == 1 before do @sb = FactoryGirl.create :speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @speech_balloon_template.id @balloon = FactoryGirl.create :balloon, :speech_balloon_id => @sb.id, :system_picture_id => @sp.id - @speech = FactoryGirl.create :speech, :speech_balloon_id => @sb.id + @speech = FactoryGirl.create :speech, :speech_balloon_id => @sb.id, :writing_format_id => @writing_format.id sign_in @user Balloon.stub(:list).and_return([@balloon, @balloon, @balloon]) end @@ -144,7 +145,7 @@ if MagicNumber['run_mode'] == 1 sign_in @user @sb = FactoryGirl.create :speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @speech_balloon_template.id @balloon = FactoryGirl.create :balloon, :speech_balloon_id => @sb.id, :system_picture_id => @sp.id - @speech = FactoryGirl.create :speech, :speech_balloon_id => @sb.id + @speech = FactoryGirl.create :speech, :speech_balloon_id => @sb.id, :writing_format_id => @writing_format.id Balloon.stub(:show).and_return(@balloon) end context 'つつがなく終わるとき' do @@ -235,7 +236,7 @@ else before do @sb = FactoryGirl.create :speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @speech_balloon_template.id @balloon = FactoryGirl.create :balloon, :speech_balloon_id => @sb.id, :system_picture_id => @sp.id - @speech = FactoryGirl.create :speech, :speech_balloon_id => @sb.id + @speech = FactoryGirl.create :speech, :speech_balloon_id => @sb.id, :writing_format_id => @writing_format.id sign_in @user Balloon.stub(:list).and_return([@balloon, @balloon, @balloon]) end @@ -285,7 +286,7 @@ else sign_in @user @sb = FactoryGirl.create :speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @speech_balloon_template.id @balloon = FactoryGirl.create :balloon, :speech_balloon_id => @sb.id, :system_picture_id => @sp.id - @speech = FactoryGirl.create :speech, :speech_balloon_id => @sb.id + @speech = FactoryGirl.create :speech, :speech_balloon_id => @sb.id, :writing_format_id => @writing_format.id Balloon.stub(:show).and_return(@balloon) end context 'つつがなく終わるとき' do diff --git a/spec/controllers/home_controller_spec.rb b/spec/controllers/home_controller_spec.rb index 85cac711..13030083 100644 --- a/spec/controllers/home_controller_spec.rb +++ b/spec/controllers/home_controller_spec.rb @@ -9,6 +9,7 @@ describe HomeController 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 + @writing_format = FactoryGirl.create :writing_format @user = FactoryGirl.create( :user_yas) @author = FactoryGirl.create :author, :user_id => @user.id @artist = FactoryGirl.create :artist_yas, :author_id => @author.id @@ -339,7 +340,7 @@ if MagicNumber['run_mode'] == 1 before do @sb = FactoryGirl.create :speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @speech_balloon_template.id @balloon = FactoryGirl.create :balloon, :speech_balloon_id => @sb.id, :system_picture_id => @sp.id - @speech = FactoryGirl.create :speech, :speech_balloon_id => @sb.id + @speech = FactoryGirl.create :speech, :speech_balloon_id => @sb.id, :writing_format_id => @writing_format.id sign_in @user SpeechBalloon.stub(:mylist).and_return([@sb, @sb, @sb]) end diff --git a/spec/controllers/speeches_controller_spec.rb b/spec/controllers/speeches_controller_spec.rb index abb4ba24..679c1bf7 100644 --- a/spec/controllers/speeches_controller_spec.rb +++ b/spec/controllers/speeches_controller_spec.rb @@ -13,6 +13,7 @@ describe SpeechesController do @license = FactoryGirl.create :license, :license_group_id => @lg.id, :system_picture_id => @sp.id @speech_balloon_template = FactoryGirl.create :speech_balloon_template + @writing_format = FactoryGirl.create :writing_format @panel = FactoryGirl.create :panel, :author_id => @author.id end @@ -21,7 +22,7 @@ if MagicNumber['run_mode'] == 1 before do @sb = FactoryGirl.create :speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @speech_balloon_template.id @balloon = FactoryGirl.create :balloon, :speech_balloon_id => @sb.id, :system_picture_id => @sp.id - @speech = FactoryGirl.create :speech, :speech_balloon_id => @sb.id + @speech = FactoryGirl.create :speech, :speech_balloon_id => @sb.id, :writing_format_id => @writing_format.id sign_in @user Speech.stub(:list).and_return([@speech, @speech, @speech]) end @@ -144,7 +145,7 @@ if MagicNumber['run_mode'] == 1 sign_in @user @sb = FactoryGirl.create :speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @speech_balloon_template.id @balloon = FactoryGirl.create :balloon, :speech_balloon_id => @sb.id, :system_picture_id => @sp.id - @speech = FactoryGirl.create :speech, :speech_balloon_id => @sb.id + @speech = FactoryGirl.create :speech, :speech_balloon_id => @sb.id, :writing_format_id => @writing_format.id Speech.stub(:show).and_return(@speech) end context 'つつがなく終わるとき' do @@ -235,7 +236,7 @@ else before do @sb = FactoryGirl.create :speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @speech_balloon_template.id @balloon = FactoryGirl.create :balloon, :speech_balloon_id => @sb.id, :system_picture_id => @sp.id - @speech = FactoryGirl.create :speech, :speech_balloon_id => @sb.id + @speech = FactoryGirl.create :speech, :speech_balloon_id => @sb.id, :writing_format_id => @writing_format.id sign_in @user Speech.stub(:list).and_return([@speech, @speech, @speech]) end @@ -285,7 +286,7 @@ else sign_in @user @sb = FactoryGirl.create :speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @speech_balloon_template.id @balloon = FactoryGirl.create :balloon, :speech_balloon_id => @sb.id, :system_picture_id => @sp.id - @speech = FactoryGirl.create :speech, :speech_balloon_id => @sb.id + @speech = FactoryGirl.create :speech, :speech_balloon_id => @sb.id, :writing_format_id => @writing_format.id Speech.stub(:show).and_return(@speech) end context 'つつがなく終わるとき' do diff --git a/spec/factories.rb b/spec/factories.rb index 85008140..b4929dd6 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -61,6 +61,14 @@ FactoryGirl.define do license.system_picture_id 1 end + factory :writing_format, :class => WritingFormat do |writing_format| + writing_format.name 'simple_format@pettan.com' + writing_format.classname 'SimpleFormat' + writing_format.caption 'sl' + writing_format.system_picture_id 1 + writing_format.settings '{}' + end + factory :comic, :class => Comic do |comic| comic.title "comic" comic.description 'comic description' @@ -150,6 +158,7 @@ FactoryGirl.define do factory :speech, :class => Speech do |speech| speech.speech_balloon_id 1 + speech.writing_format_id 1 speech.content 'test' speech.x 10 speech.y 100 diff --git a/spec/models/balloon_spec.rb b/spec/models/balloon_spec.rb index 8ceedb10..bf585669 100644 --- a/spec/models/balloon_spec.rb +++ b/spec/models/balloon_spec.rb @@ -15,13 +15,14 @@ describe Balloon do @license = FactoryGirl.create :license, :license_group_id => @lg.id, :system_picture_id => @sp.id @speech_balloon_template = FactoryGirl.create :speech_balloon_template + @writing_format = FactoryGirl.create :writing_format @panel = FactoryGirl.create :panel, :author_id => @author.id end describe '検証に於いて' do before do @sb = FactoryGirl.create :speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @speech_balloon_template.id - @speech = FactoryGirl.create :speech, :speech_balloon_id => @sb.id + @speech = FactoryGirl.create :speech, :speech_balloon_id => @sb.id, :writing_format_id => @writing_format.id @balloon = FactoryGirl.build :balloon, :speech_balloon_id => @sb.id, :system_picture_id => @sp.id end context 'オーソドックスなデータのとき' do @@ -165,7 +166,7 @@ describe Balloon do describe '文字コード検証に於いて' do before do @sb = FactoryGirl.create :speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @speech_balloon_template.id - @speech = FactoryGirl.create :speech, :speech_balloon_id => @sb.id + @speech = FactoryGirl.create :speech, :speech_balloon_id => @sb.id, :writing_format_id => @writing_format.id @balloon = FactoryGirl.build :balloon, :speech_balloon_id => @sb.id, :system_picture_id => @sp.id end @@ -183,7 +184,7 @@ describe Balloon do before do @sb = FactoryGirl.create :speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @speech_balloon_template.id @balloon = FactoryGirl.create :balloon, :speech_balloon_id => @sb.id, :system_picture_id => @sp.id - @speech = FactoryGirl.create :speech, :speech_balloon_id => @sb.id + @speech = FactoryGirl.create :speech, :speech_balloon_id => @sb.id, :writing_format_id => @writing_format.id end context 'オープンモードのとき' do before do @@ -262,7 +263,7 @@ describe Balloon do before do @sb = FactoryGirl.create :speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @speech_balloon_template.id @balloon = FactoryGirl.create :balloon, :speech_balloon_id => @sb.id, :system_picture_id => @sp.id - @speech = FactoryGirl.create :speech, :speech_balloon_id => @sb.id + @speech = FactoryGirl.create :speech, :speech_balloon_id => @sb.id, :writing_format_id => @writing_format.id end context 'page補正について' do it '文字列から数値に変換される' do @@ -389,7 +390,7 @@ describe Balloon do before do @sb = FactoryGirl.create :speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @speech_balloon_template.id @balloon = FactoryGirl.create :balloon, :speech_balloon_id => @sb.id, :system_picture_id => @sp.id - @speech = FactoryGirl.create :speech, :speech_balloon_id => @sb.id + @speech = FactoryGirl.create :speech, :speech_balloon_id => @sb.id, :writing_format_id => @writing_format.id end it 'フキダシを含んでいる' do r = Balloon.list.to_json Balloon.list_json_opt @@ -431,7 +432,7 @@ describe Balloon do before do @sb = FactoryGirl.create :speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @speech_balloon_template.id @balloon = FactoryGirl.create :balloon, :speech_balloon_id => @sb.id, :system_picture_id => @sp.id - @speech = FactoryGirl.create :speech, :speech_balloon_id => @sb.id + @speech = FactoryGirl.create :speech, :speech_balloon_id => @sb.id, :writing_format_id => @writing_format.id end context 'つつがなく終わるとき' do it '単体取得オプションを利用している' do @@ -500,7 +501,7 @@ describe Balloon do before do @sb = FactoryGirl.create :speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @speech_balloon_template.id @balloon = FactoryGirl.create :balloon, :speech_balloon_id => @sb.id, :system_picture_id => @sp.id - @speech = FactoryGirl.create :speech, :speech_balloon_id => @sb.id + @speech = FactoryGirl.create :speech, :speech_balloon_id => @sb.id, :writing_format_id => @writing_format.id end it 'フキダシを含んでいる' do r = Balloon.show(@balloon.id, @author).to_json Balloon.show_json_opt diff --git a/spec/models/panel_spec.rb b/spec/models/panel_spec.rb index 2c7ba5bd..56e18213 100644 --- a/spec/models/panel_spec.rb +++ b/spec/models/panel_spec.rb @@ -7,6 +7,7 @@ describe Panel do @sp = FactoryGirl.create :system_picture @lg = FactoryGirl.create :license_group @license = FactoryGirl.create :license, :license_group_id => @lg.id, :system_picture_id => @sp.id + @writing_format = FactoryGirl.create :writing_format @user = FactoryGirl.create( :user_yas) @author = FactoryGirl.create :author, :user_id => @user.id @artist = FactoryGirl.create :artist_yas, :author_id => @author.id @@ -945,7 +946,7 @@ describe Panel do FactoryGirl.attributes_for(:balloon, :speech_balloon_id => @sb.id) ) @sb.create_speech( - FactoryGirl.attributes_for(:speech, :speech_balloon_id => @sb.id) + FactoryGirl.attributes_for(:speech, :speech_balloon_id => @sb.id, :writing_format_id => @writing_format.id) ) @gc = @panel.ground_colors.create( FactoryGirl.attributes_for(:ground_color, :panel_id => @panel.id, :t => 2) diff --git a/spec/models/speech_balloon_spec.rb b/spec/models/speech_balloon_spec.rb index 650975c9..9dc4b259 100644 --- a/spec/models/speech_balloon_spec.rb +++ b/spec/models/speech_balloon_spec.rb @@ -16,6 +16,7 @@ describe SpeechBalloon do @license = FactoryGirl.create :license, :license_group_id => @lg.id, :system_picture_id => @sp.id @panel = FactoryGirl.create :panel, :author_id => @author.id + @writing_format = FactoryGirl.create :writing_format @speech_balloon_template = FactoryGirl.create :speech_balloon_template end @@ -203,7 +204,7 @@ describe SpeechBalloon do before do @sb = FactoryGirl.create :speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @speech_balloon_template.id @balloon = FactoryGirl.create :balloon, :speech_balloon_id => @sb.id, :system_picture_id => @sp.id - @speech = FactoryGirl.create :speech, :speech_balloon_id => @sb.id + @speech = FactoryGirl.create :speech, :speech_balloon_id => @sb.id, :writing_format_id => @writing_format.id end context 'page補正について' do it '文字列から数値に変換される' do @@ -286,7 +287,7 @@ describe SpeechBalloon do before do @sb = FactoryGirl.create :speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @speech_balloon_template.id @balloon = FactoryGirl.create :balloon, :speech_balloon_id => @sb.id, :system_picture_id => @sp.id - @speech = FactoryGirl.create :speech, :speech_balloon_id => @sb.id + @speech = FactoryGirl.create :speech, :speech_balloon_id => @sb.id, :writing_format_id => @writing_format.id end context 'つつがなく終わるとき' do it '一覧取得オプションを利用している' do @@ -347,7 +348,7 @@ describe SpeechBalloon do before do @sb = FactoryGirl.create :speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @speech_balloon_template.id @balloon = FactoryGirl.create :balloon, :speech_balloon_id => @sb.id, :system_picture_id => @sp.id - @speech = FactoryGirl.create :speech, :speech_balloon_id => @sb.id + @speech = FactoryGirl.create :speech, :speech_balloon_id => @sb.id, :writing_format_id => @writing_format.id @other_panel = FactoryGirl.create :panel, :author_id => @other_author.id, :publish => 1 @other_sb = FactoryGirl.create :speech_balloon, :panel_id => @other_panel.id, :speech_balloon_template_id => @speech_balloon_template.id end @@ -485,7 +486,7 @@ describe SpeechBalloon do @panel = FactoryGirl.create :panel, :author_id => @author.id, :publish => 1 @sb = FactoryGirl.create :speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @speech_balloon_template.id @balloon = FactoryGirl.create :balloon, :speech_balloon_id => @sb.id, :system_picture_id => @sp.id - @speech = FactoryGirl.create :speech, :speech_balloon_id => @sb.id + @speech = FactoryGirl.create :speech, :speech_balloon_id => @sb.id, :writing_format_id => @writing_format.id end it 'コマを含んでいる' do r = SpeechBalloon.list.to_json SpeechBalloon.list_json_opt @@ -524,7 +525,7 @@ describe SpeechBalloon do before do @sb = FactoryGirl.create :speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @speech_balloon_template.id @balloon = FactoryGirl.create :balloon, :speech_balloon_id => @sb.id, :system_picture_id => @sp.id - @speech = FactoryGirl.create :speech, :speech_balloon_id => @sb.id + @speech = FactoryGirl.create :speech, :speech_balloon_id => @sb.id, :writing_format_id => @writing_format.id end context 'つつがなく終わるとき' do it '単体取得オプションを利用している' do @@ -594,7 +595,7 @@ describe SpeechBalloon do @panel = FactoryGirl.create :panel, :author_id => @author.id, :publish => 1 @sb = FactoryGirl.create :speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @speech_balloon_template.id @balloon = FactoryGirl.create :balloon, :speech_balloon_id => @sb.id, :system_picture_id => @sp.id - @speech = FactoryGirl.create :speech, :speech_balloon_id => @sb.id + @speech = FactoryGirl.create :speech, :speech_balloon_id => @sb.id, :writing_format_id => @writing_format.id end it 'コマを含んでいる' do r = SpeechBalloon.show(@sb.id, @author).to_json SpeechBalloon.show_json_opt diff --git a/spec/models/speech_spec.rb b/spec/models/speech_spec.rb index dfeb35b4..f4f8494a 100644 --- a/spec/models/speech_spec.rb +++ b/spec/models/speech_spec.rb @@ -14,6 +14,7 @@ describe Speech do @lg = FactoryGirl.create :license_group @license = FactoryGirl.create :license, :license_group_id => @lg.id, :system_picture_id => @sp.id + @writing_format = FactoryGirl.create :writing_format @speech_balloon_template = FactoryGirl.create :speech_balloon_template @panel = FactoryGirl.create :panel, :author_id => @author.id end @@ -22,7 +23,7 @@ describe Speech do before do @sb = FactoryGirl.create :speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @speech_balloon_template.id @balloon = FactoryGirl.create :balloon, :speech_balloon_id => @sb.id, :system_picture_id => @sp.id - @speech = FactoryGirl.build :speech, :speech_balloon_id => @sb.id + @speech = FactoryGirl.build :speech, :speech_balloon_id => @sb.id, :writing_format_id => @writing_format.id end context 'オーソドックスなデータのとき' do @@ -147,7 +148,7 @@ describe Speech do before do @sb = FactoryGirl.create :speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @speech_balloon_template.id @balloon = FactoryGirl.create :balloon, :speech_balloon_id => @sb.id, :system_picture_id => @sp.id - @speech = FactoryGirl.build :speech, :speech_balloon_id => @sb.id + @speech = FactoryGirl.build :speech, :speech_balloon_id => @sb.id, :writing_format_id => @writing_format.id end context 'contentを検証するとき' do @@ -182,7 +183,7 @@ describe Speech do before do @sb = FactoryGirl.create :speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @speech_balloon_template.id @balloon = FactoryGirl.create :balloon, :speech_balloon_id => @sb.id, :system_picture_id => @sp.id - @speech = FactoryGirl.create :speech, :speech_balloon_id => @sb.id + @speech = FactoryGirl.create :speech, :speech_balloon_id => @sb.id, :writing_format_id => @writing_format.id end context 'オープンモードのとき' do before do @@ -261,7 +262,7 @@ describe Speech do before do @sb = FactoryGirl.create :speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @speech_balloon_template.id @balloon = FactoryGirl.create :balloon, :speech_balloon_id => @sb.id, :system_picture_id => @sp.id - @speech = FactoryGirl.create :speech, :speech_balloon_id => @sb.id + @speech = FactoryGirl.create :speech, :speech_balloon_id => @sb.id, :writing_format_id => @writing_format.id end context 'page補正について' do it '文字列から数値に変換される' do @@ -316,10 +317,10 @@ describe Speech do end context 'DBに5件あって1ページの件数を2件に変えたとして' do before do - @speech2 = FactoryGirl.create :speech, :speech_balloon_id => @sb.id, :updated_at => Time.now + 100 - @speech3 = FactoryGirl.create :speech, :speech_balloon_id => @sb.id, :updated_at => Time.now + 200 - @speech4 = FactoryGirl.create :speech, :speech_balloon_id => @sb.id, :updated_at => Time.now + 300 - @speech5 = FactoryGirl.create :speech, :speech_balloon_id => @sb.id, :updated_at => Time.now + 400 + @speech2 = FactoryGirl.create :speech, :speech_balloon_id => @sb.id, :writing_format_id => @writing_format.id, :updated_at => Time.now + 100 + @speech3 = FactoryGirl.create :speech, :speech_balloon_id => @sb.id, :writing_format_id => @writing_format.id, :updated_at => Time.now + 200 + @speech4 = FactoryGirl.create :speech, :speech_balloon_id => @sb.id, :writing_format_id => @writing_format.id, :updated_at => Time.now + 300 + @speech5 = FactoryGirl.create :speech, :speech_balloon_id => @sb.id, :writing_format_id => @writing_format.id, :updated_at => Time.now + 400 Speech.stub(:default_page_size).and_return(2) end it '通常は2件を返す' do @@ -342,10 +343,10 @@ describe Speech do end context 'DBに5件あって1ページの件数を0件に変えたとして' do before do - @speech2 = FactoryGirl.create :speech, :speech_balloon_id => @sb.id, :updated_at => Time.now + 100 - @speech3 = FactoryGirl.create :speech, :speech_balloon_id => @sb.id, :updated_at => Time.now + 200 - @speech4 = FactoryGirl.create :speech, :speech_balloon_id => @sb.id, :updated_at => Time.now + 300 - @speech5 = FactoryGirl.create :speech, :speech_balloon_id => @sb.id, :updated_at => Time.now + 400 + @speech2 = FactoryGirl.create :speech, :speech_balloon_id => @sb.id, :writing_format_id => @writing_format.id, :updated_at => Time.now + 100 + @speech3 = FactoryGirl.create :speech, :speech_balloon_id => @sb.id, :writing_format_id => @writing_format.id, :updated_at => Time.now + 200 + @speech4 = FactoryGirl.create :speech, :speech_balloon_id => @sb.id, :writing_format_id => @writing_format.id, :updated_at => Time.now + 300 + @speech5 = FactoryGirl.create :speech, :speech_balloon_id => @sb.id, :writing_format_id => @writing_format.id, :updated_at => Time.now + 400 Speech.stub(:default_page_size).and_return(2) end it '通常は全件(5件)を返す' do @@ -388,7 +389,7 @@ describe Speech do before do @sb = FactoryGirl.create :speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @speech_balloon_template.id @balloon = FactoryGirl.create :balloon, :speech_balloon_id => @sb.id, :system_picture_id => @sp.id - @speech = FactoryGirl.create :speech, :speech_balloon_id => @sb.id + @speech = FactoryGirl.create :speech, :speech_balloon_id => @sb.id, :writing_format_id => @writing_format.id end it 'フキダシを含んでいる' do r = Speech.list.to_json Speech.list_json_opt @@ -430,7 +431,7 @@ describe Speech do before do @sb = FactoryGirl.create :speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @speech_balloon_template.id @balloon = FactoryGirl.create :balloon, :speech_balloon_id => @sb.id, :system_picture_id => @sp.id - @speech = FactoryGirl.create :speech, :speech_balloon_id => @sb.id + @speech = FactoryGirl.create :speech, :speech_balloon_id => @sb.id, :writing_format_id => @writing_format.id end context 'つつがなく終わるとき' do it '単体取得オプションを利用している' do @@ -499,7 +500,7 @@ describe Speech do before do @sb = FactoryGirl.create :speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @speech_balloon_template.id @balloon = FactoryGirl.create :balloon, :speech_balloon_id => @sb.id, :system_picture_id => @sp.id - @speech = FactoryGirl.create :speech, :speech_balloon_id => @sb.id + @speech = FactoryGirl.create :speech, :speech_balloon_id => @sb.id, :writing_format_id => @writing_format.id end it 'フキダシを含んでいる' do r = Speech.show(@speech.id, @author).to_json Speech.show_json_opt -- 2.11.0