OSDN Git Service

t#31834:new base
authoryasushiito <yas@pen-chan.jp>
Sun, 4 Aug 2013 06:23:59 +0000 (15:23 +0900)
committeryasushiito <yas@pen-chan.jp>
Sun, 4 Aug 2013 06:23:59 +0000 (15:23 +0900)
20 files changed:
app/assets/javascripts/panels.js.coffee
app/models/balloon.rb
app/models/ground_color.rb
app/models/ground_picture.rb
app/models/panel.rb
app/models/panel_picture.rb
app/models/speech.rb
app/models/speech_balloon.rb
app/views/ground_colors/_form.html.erb
app/views/panel_pictures/_element.html.erb
app/views/panel_pictures/_form.html.erb
app/views/panels/_form.html.erb
spec/controllers/balloons_controller_spec.rb
spec/controllers/home_controller_spec.rb
spec/controllers/speeches_controller_spec.rb
spec/factories.rb
spec/models/balloon_spec.rb
spec/models/panel_spec.rb
spec/models/speech_balloon_spec.rb
spec/models/speech_spec.rb

index fbddfae..a1a9662 100644 (file)
@@ -23,13 +23,16 @@ $ ->
     else\r
       return false\r
   is_var = (o) ->\r
-    if o.attr('column') \r
-      if o.attr('column') == '_destroy' and o.val().length < 1\r
-        return false\r
-      else\r
-        return true\r
-    else\r
+    if parseInt(o.attr('no_attr')) > 0\r
       return false\r
+    else\r
+      if o.attr('column') \r
+        if o.attr('column') == '_destroy' and o.val().length < 1\r
+          return false\r
+        else\r
+          return true\r
+      else\r
+        return false\r
   is_element = (o) ->\r
     if o.attr('element_type')\r
       return true\r
index 90f0518..04bc130 100644 (file)
@@ -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
index 690770f..7117e4b 100644 (file)
@@ -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
index c2aac21..b77bc6a 100644 (file)
@@ -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
index 7674df5..0bb2cbb 100644 (file)
@@ -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')
index 0667d04..36e7699 100644 (file)
@@ -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
index b8fe28d..62720b4 100644 (file)
@@ -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
index c7f160e..1301c31 100644 (file)
@@ -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
index a0a5d10..b8ea0d2 100644 (file)
@@ -3,11 +3,11 @@
 
   <div class="field">
     <%= 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 %>
   </div>
   <div class="field">
     <%= 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 %>
     <div class="colorpicker-wrap">
       <div class="colorpicker" style="float: left;" id="<%= ground_color.tag_id(:code_picker) -%>" panel_id="<%= ground_color.tag_panel_id -%>" element_id="<%= ground_color.tag_element_id -%>" element_type="<%= ground_color.tag_element_type -%>">
         <div id="<%= ground_color.tag_id(:code_red) -%>" class="colorpicker-red"></div>
   </div>
   <div class="field">
     <%= 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 %>
   </div>
 
-  <%= 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 %>
 
   <div class="actions">
index a34edf4..baa60e9 100644 (file)
@@ -1,3 +1,3 @@
-<div id="<%= elm.tag_id(:div) -%>" panel_id="<%= elm.tag_panel_id -%>" element_id="<%= elm.tag_element_id -%>" element_type="<%= elm.tag_element_type -%>" class="pettanr-panel-picture-wrapper" style="<%= elm.opt_div_style() -%>">
+<div id="<%= elm.tag_id(:div) -%>" panel_id="<%= elm.tag_panel_id -%>" element_id="<%= elm.tag_element_id -%>" element_type="<%= elm.tag_element_type -%>" new_index="<%= elm.new_index -%>" class="pettanr-panel-picture-wrapper" style="<%= elm.opt_div_style() -%>">
   <%= link_to_unless(elm.link.blank?, tag(:img, elm.opt_img_tag(spot)), elm.link) %>
 </div>
index 4fbf194..b94cc2f 100644 (file)
@@ -3,38 +3,38 @@
 
   <div class="field">
     <%= 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 %>
   </div>
   <div class="field">
     <%= 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 %>
   </div>
   <div class="field">
     <%= 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 %>
   </div>
   <div class="field">
     <%= 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 %>
   </div>
   <div class="field">
     <%= 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 %>
   </div>
   <div class="field">
     <%= 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 %>
   </div>
-  <%= 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 %>
index 7949999..3cf438e 100644 (file)
@@ -55,7 +55,7 @@
           <div id="elements-tabs-<%= elm.t -%>">
             <% 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
                 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 %>
           </div>
                       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 %>
                   </div>
                 <% 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 %>
           </div>
         </div>
index 381bc1a..bd4b70d 100644 (file)
@@ -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
index 85cac71..1303008 100644 (file)
@@ -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
index abb4ba2..679c1bf 100644 (file)
@@ -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
index 8500814..b4929dd 100644 (file)
@@ -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
index 8ceedb1..bf58566 100644 (file)
@@ -15,13 +15,14 @@ describe Balloon do
     @license = FactoryGirl.create :license, :license_group_id => @lg.id, :system_picture_id => @sp.id\r
     \r
     @speech_balloon_template = FactoryGirl.create :speech_balloon_template\r
+    @writing_format = FactoryGirl.create :writing_format\r
     @panel = FactoryGirl.create :panel, :author_id => @author.id\r
   end\r
   \r
   describe '検証に於いて' do\r
     before do\r
       @sb = FactoryGirl.create :speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @speech_balloon_template.id\r
-      @speech = FactoryGirl.create :speech, :speech_balloon_id => @sb.id\r
+      @speech = FactoryGirl.create :speech, :speech_balloon_id => @sb.id, :writing_format_id => @writing_format.id\r
       @balloon = FactoryGirl.build :balloon, :speech_balloon_id => @sb.id, :system_picture_id => @sp.id\r
     end\r
     context 'オーソドックスなデータのとき' do\r
@@ -165,7 +166,7 @@ describe Balloon do
   describe '文字コード検証に於いて' do\r
     before do\r
       @sb = FactoryGirl.create :speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @speech_balloon_template.id\r
-      @speech = FactoryGirl.create :speech, :speech_balloon_id => @sb.id\r
+      @speech = FactoryGirl.create :speech, :speech_balloon_id => @sb.id, :writing_format_id => @writing_format.id\r
       @balloon = FactoryGirl.build :balloon, :speech_balloon_id => @sb.id, :system_picture_id => @sp.id\r
     end\r
     \r
@@ -183,7 +184,7 @@ describe Balloon do
     before do\r
       @sb = FactoryGirl.create :speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @speech_balloon_template.id\r
       @balloon = FactoryGirl.create :balloon, :speech_balloon_id => @sb.id, :system_picture_id => @sp.id\r
-      @speech = FactoryGirl.create :speech, :speech_balloon_id => @sb.id\r
+      @speech = FactoryGirl.create :speech, :speech_balloon_id => @sb.id, :writing_format_id => @writing_format.id\r
     end\r
     context 'オープンモードのとき' do\r
       before do\r
@@ -262,7 +263,7 @@ describe Balloon do
     before do\r
       @sb = FactoryGirl.create :speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @speech_balloon_template.id\r
       @balloon = FactoryGirl.create :balloon, :speech_balloon_id => @sb.id, :system_picture_id => @sp.id\r
-      @speech = FactoryGirl.create :speech, :speech_balloon_id => @sb.id\r
+      @speech = FactoryGirl.create :speech, :speech_balloon_id => @sb.id, :writing_format_id => @writing_format.id\r
     end\r
     context 'page補正について' do\r
       it '文字列から数値に変換される' do\r
@@ -389,7 +390,7 @@ describe Balloon do
     before do\r
       @sb = FactoryGirl.create :speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @speech_balloon_template.id\r
       @balloon = FactoryGirl.create :balloon, :speech_balloon_id => @sb.id, :system_picture_id => @sp.id\r
-      @speech = FactoryGirl.create :speech, :speech_balloon_id => @sb.id\r
+      @speech = FactoryGirl.create :speech, :speech_balloon_id => @sb.id, :writing_format_id => @writing_format.id\r
     end\r
     it 'フキダシを含んでいる' do\r
       r = Balloon.list.to_json Balloon.list_json_opt\r
@@ -431,7 +432,7 @@ describe Balloon do
     before do\r
       @sb = FactoryGirl.create :speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @speech_balloon_template.id\r
       @balloon = FactoryGirl.create :balloon, :speech_balloon_id => @sb.id, :system_picture_id => @sp.id\r
-      @speech = FactoryGirl.create :speech, :speech_balloon_id => @sb.id\r
+      @speech = FactoryGirl.create :speech, :speech_balloon_id => @sb.id, :writing_format_id => @writing_format.id\r
     end\r
     context 'つつがなく終わるとき' do\r
       it '単体取得オプションを利用している' do\r
@@ -500,7 +501,7 @@ describe Balloon do
     before do\r
       @sb = FactoryGirl.create :speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @speech_balloon_template.id\r
       @balloon = FactoryGirl.create :balloon, :speech_balloon_id => @sb.id, :system_picture_id => @sp.id\r
-      @speech = FactoryGirl.create :speech, :speech_balloon_id => @sb.id\r
+      @speech = FactoryGirl.create :speech, :speech_balloon_id => @sb.id, :writing_format_id => @writing_format.id\r
     end\r
     it 'フキダシを含んでいる' do\r
       r = Balloon.show(@balloon.id, @author).to_json Balloon.show_json_opt\r
index 2c7ba5b..56e1821 100644 (file)
@@ -7,6 +7,7 @@ describe Panel do
     @sp = FactoryGirl.create :system_picture\r
     @lg = FactoryGirl.create :license_group\r
     @license = FactoryGirl.create :license, :license_group_id => @lg.id, :system_picture_id => @sp.id\r
+    @writing_format = FactoryGirl.create :writing_format\r
     @user = FactoryGirl.create( :user_yas)\r
     @author = FactoryGirl.create :author, :user_id => @user.id\r
     @artist = FactoryGirl.create :artist_yas, :author_id => @author.id\r
@@ -945,7 +946,7 @@ describe Panel do
         FactoryGirl.attributes_for(:balloon, :speech_balloon_id => @sb.id)\r
       )\r
       @sb.create_speech(\r
-        FactoryGirl.attributes_for(:speech, :speech_balloon_id => @sb.id)\r
+        FactoryGirl.attributes_for(:speech, :speech_balloon_id => @sb.id, :writing_format_id => @writing_format.id)\r
       )\r
       @gc = @panel.ground_colors.create(\r
         FactoryGirl.attributes_for(:ground_color, :panel_id => @panel.id, :t => 2)\r
index 650975c..9dc4b25 100644 (file)
@@ -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
index dfeb35b..f4f8494 100644 (file)
@@ -14,6 +14,7 @@ describe Speech do
     @lg = FactoryGirl.create :license_group\r
     @license = FactoryGirl.create :license, :license_group_id => @lg.id, :system_picture_id => @sp.id\r
     \r
+    @writing_format = FactoryGirl.create :writing_format\r
     @speech_balloon_template = FactoryGirl.create :speech_balloon_template\r
     @panel = FactoryGirl.create :panel, :author_id => @author.id\r
   end\r
@@ -22,7 +23,7 @@ describe Speech do
     before do\r
       @sb = FactoryGirl.create :speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @speech_balloon_template.id\r
       @balloon = FactoryGirl.create :balloon, :speech_balloon_id => @sb.id, :system_picture_id => @sp.id\r
-      @speech = FactoryGirl.build :speech, :speech_balloon_id => @sb.id\r
+      @speech = FactoryGirl.build :speech, :speech_balloon_id => @sb.id, :writing_format_id => @writing_format.id\r
     end\r
     \r
     context 'オーソドックスなデータのとき' do\r
@@ -147,7 +148,7 @@ describe Speech do
     before do\r
       @sb = FactoryGirl.create :speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @speech_balloon_template.id\r
       @balloon = FactoryGirl.create :balloon, :speech_balloon_id => @sb.id, :system_picture_id => @sp.id\r
-      @speech = FactoryGirl.build :speech, :speech_balloon_id => @sb.id\r
+      @speech = FactoryGirl.build :speech, :speech_balloon_id => @sb.id, :writing_format_id => @writing_format.id\r
     end\r
     \r
     context 'contentを検証するとき' do\r
@@ -182,7 +183,7 @@ describe Speech do
     before do\r
       @sb = FactoryGirl.create :speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @speech_balloon_template.id\r
       @balloon = FactoryGirl.create :balloon, :speech_balloon_id => @sb.id, :system_picture_id => @sp.id\r
-      @speech = FactoryGirl.create :speech, :speech_balloon_id => @sb.id\r
+      @speech = FactoryGirl.create :speech, :speech_balloon_id => @sb.id, :writing_format_id => @writing_format.id\r
     end\r
     context 'オープンモードのとき' do\r
       before do\r
@@ -261,7 +262,7 @@ describe Speech do
     before do\r
       @sb = FactoryGirl.create :speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @speech_balloon_template.id\r
       @balloon = FactoryGirl.create :balloon, :speech_balloon_id => @sb.id, :system_picture_id => @sp.id\r
-      @speech = FactoryGirl.create :speech, :speech_balloon_id => @sb.id\r
+      @speech = FactoryGirl.create :speech, :speech_balloon_id => @sb.id, :writing_format_id => @writing_format.id\r
     end\r
     context 'page補正について' do\r
       it '文字列から数値に変換される' do\r
@@ -316,10 +317,10 @@ describe Speech do
     end\r
     context 'DBに5件あって1ページの件数を2件に変えたとして' do\r
       before do\r
-        @speech2 = FactoryGirl.create :speech, :speech_balloon_id => @sb.id, :updated_at => Time.now + 100\r
-        @speech3 = FactoryGirl.create :speech, :speech_balloon_id => @sb.id, :updated_at => Time.now + 200\r
-        @speech4 = FactoryGirl.create :speech, :speech_balloon_id => @sb.id, :updated_at => Time.now + 300\r
-        @speech5 = FactoryGirl.create :speech, :speech_balloon_id => @sb.id, :updated_at => Time.now + 400\r
+        @speech2 = FactoryGirl.create :speech, :speech_balloon_id => @sb.id, :writing_format_id => @writing_format.id, :updated_at => Time.now + 100\r
+        @speech3 = FactoryGirl.create :speech, :speech_balloon_id => @sb.id, :writing_format_id => @writing_format.id, :updated_at => Time.now + 200\r
+        @speech4 = FactoryGirl.create :speech, :speech_balloon_id => @sb.id, :writing_format_id => @writing_format.id, :updated_at => Time.now + 300\r
+        @speech5 = FactoryGirl.create :speech, :speech_balloon_id => @sb.id, :writing_format_id => @writing_format.id, :updated_at => Time.now + 400\r
         Speech.stub(:default_page_size).and_return(2)\r
       end\r
       it '通常は2件を返す' do\r
@@ -342,10 +343,10 @@ describe Speech do
     end\r
     context 'DBに5件あって1ページの件数を0件に変えたとして' do\r
       before do\r
-        @speech2 = FactoryGirl.create :speech, :speech_balloon_id => @sb.id, :updated_at => Time.now + 100\r
-        @speech3 = FactoryGirl.create :speech, :speech_balloon_id => @sb.id, :updated_at => Time.now + 200\r
-        @speech4 = FactoryGirl.create :speech, :speech_balloon_id => @sb.id, :updated_at => Time.now + 300\r
-        @speech5 = FactoryGirl.create :speech, :speech_balloon_id => @sb.id, :updated_at => Time.now + 400\r
+        @speech2 = FactoryGirl.create :speech, :speech_balloon_id => @sb.id, :writing_format_id => @writing_format.id, :updated_at => Time.now + 100\r
+        @speech3 = FactoryGirl.create :speech, :speech_balloon_id => @sb.id, :writing_format_id => @writing_format.id, :updated_at => Time.now + 200\r
+        @speech4 = FactoryGirl.create :speech, :speech_balloon_id => @sb.id, :writing_format_id => @writing_format.id, :updated_at => Time.now + 300\r
+        @speech5 = FactoryGirl.create :speech, :speech_balloon_id => @sb.id, :writing_format_id => @writing_format.id, :updated_at => Time.now + 400\r
         Speech.stub(:default_page_size).and_return(2)\r
       end\r
       it '通常は全件(5件)を返す' do\r
@@ -388,7 +389,7 @@ describe Speech do
     before do\r
       @sb = FactoryGirl.create :speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @speech_balloon_template.id\r
       @balloon = FactoryGirl.create :balloon, :speech_balloon_id => @sb.id, :system_picture_id => @sp.id\r
-      @speech = FactoryGirl.create :speech, :speech_balloon_id => @sb.id\r
+      @speech = FactoryGirl.create :speech, :speech_balloon_id => @sb.id, :writing_format_id => @writing_format.id\r
     end\r
     it 'フキダシを含んでいる' do\r
       r = Speech.list.to_json Speech.list_json_opt\r
@@ -430,7 +431,7 @@ describe Speech do
     before do\r
       @sb = FactoryGirl.create :speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @speech_balloon_template.id\r
       @balloon = FactoryGirl.create :balloon, :speech_balloon_id => @sb.id, :system_picture_id => @sp.id\r
-      @speech = FactoryGirl.create :speech, :speech_balloon_id => @sb.id\r
+      @speech = FactoryGirl.create :speech, :speech_balloon_id => @sb.id, :writing_format_id => @writing_format.id\r
     end\r
     context 'つつがなく終わるとき' do\r
       it '単体取得オプションを利用している' do\r
@@ -499,7 +500,7 @@ describe Speech do
     before do\r
       @sb = FactoryGirl.create :speech_balloon, :panel_id => @panel.id, :speech_balloon_template_id => @speech_balloon_template.id\r
       @balloon = FactoryGirl.create :balloon, :speech_balloon_id => @sb.id, :system_picture_id => @sp.id\r
-      @speech = FactoryGirl.create :speech, :speech_balloon_id => @sb.id\r
+      @speech = FactoryGirl.create :speech, :speech_balloon_id => @sb.id, :writing_format_id => @writing_format.id\r
     end\r
     it 'フキダシを含んでいる' do\r
       r = Speech.show(@speech.id, @author).to_json Speech.show_json_opt\r