OSDN Git Service

t#:add r on balloon ... and drop color
authoryasushiito <yas@pen-chan.jp>
Wed, 29 May 2013 09:43:12 +0000 (18:43 +0900)
committeryasushiito <yas@pen-chan.jp>
Wed, 29 May 2013 09:43:12 +0000 (18:43 +0900)
app/models/balloon.rb
app/views/balloons/browse.html.erb
app/views/balloons/list.html.erb
app/views/layouts/system.html.erb
app/views/system/browse.html.erb
config/locales/pettanr.ja.yml
db/migrate/20130529090246_add_r_on_balloons.rb [new file with mode: 0644]
spec/models/balloon_spec.rb

index 94e325b..9db6622 100644 (file)
@@ -8,6 +8,7 @@ class Balloon < ActiveRecord::Base
   validates :y, :presence => true, :numericality => true
   validates :width, :presence => true, :numericality => true, :natural_number => true
   validates :height, :presence => true, :numericality => true, :natural_number => true
+  validates :r, :presence => true, :numericality => true
 #  validates :caption, :presence => true
 #  validates :settings, :presence => true
 
index de39dec..d34d61c 100644 (file)
 </p>
 
 <p>
+  <b><%= t_m 'Balloon.r' -%>:</b>
+  <%= @balloon.r %>
+</p>
+
+<p>
   <b><%= t_m 'Balloon.caption' -%>:</b>
   <%= h @balloon.caption %>
 </p>
index c981422..2486573 100644 (file)
@@ -9,6 +9,7 @@
     <th><%= t_m 'Balloon.y' -%></th>
     <th><%= t_m 'Balloon.width' -%></th>
     <th><%= t_m 'Balloon.height' -%></th>
+    <th><%= t_m 'Balloon.r' -%></th>
     <th><%= t_m 'Balloon.caption' -%></th>
     <th><%= t_m 'Balloon.settings' -%></th>
     <th><%= t_m 'Balloon.created_at' -%></th>
@@ -24,6 +25,7 @@
       <td><%= balloon.y %></td>
       <td><%= balloon.width %></td>
       <td><%= balloon.height %></td>
+      <td><%= balloon.r %></td>
       <td><%= h(truncate(balloon.caption, :length => 12)) %></td>
       <td><%= h(truncate(balloon.settings, :length => 12)) %></td>
       <td><%= l balloon.created_at %></td>
index a016ec9..eb14d8f 100644 (file)
@@ -56,7 +56,6 @@
   <%= link_to 'speech_balloon_templates', main_app.speech_balloon_templates_path %>
   <%= link_to 'license_groups', main_app.license_groups_path %>
   <%= link_to 'licenses', main_app.licenses_path %>
-  <%= link_to 'colors', main_app.colors_path %>
   <%= link_to 'system_pictures', main_app.system_pictures_path %>
 </div>
 <%= yield %>
index 7dc3f2e..f336f5a 100644 (file)
       <%= link_to 'speeches', :controller => 'speeches', :action => :list %>
     </td>
   </tr>
-  <tr>
-    <td>
-      <%= link_to 'colors', :controller => 'colors' %>
-    </td>
-  </tr>
 </table>
 フキダシテンプレート関連
 <table>
       <%= link_to 'system_pictures', :controller => 'system_pictures', :action => :list %>
     </td>
   </tr>
-  <tr>
-    <td>
-      <%= link_to 'colors', :controller => 'colors', :action => :list %>
-    </td>
-  </tr>
 </table>
 </div>
index dc9314c..8663e32 100644 (file)
@@ -129,6 +129,7 @@ ja:
         y: Y
         width: 幅
         height: 高さ
+        r: 角度
         caption: 様子
         settings: 拡張データ
         created_at: 作成
diff --git a/db/migrate/20130529090246_add_r_on_balloons.rb b/db/migrate/20130529090246_add_r_on_balloons.rb
new file mode 100644 (file)
index 0000000..b0747e8
--- /dev/null
@@ -0,0 +1,9 @@
+class AddROnBalloons < ActiveRecord::Migration
+  def up
+    add_column :balloons, :r, :integer, :null => false, :default => 0
+  end
+
+  def down
+    remove_column :balloons, :r
+  end
+end
index 7cc9e83..96f3be2 100644 (file)
@@ -30,6 +30,7 @@ describe Balloon do
         @balloon.y = 0\r
         @balloon.width = 1\r
         @balloon.height = 1\r
+        @balloon.r = 0\r
         @balloon.should be_valid\r
       end\r
       it '上限データが通る' do\r
@@ -37,6 +38,7 @@ describe Balloon do
         @balloon.y = 99999\r
         @balloon.width = 99999\r
         @balloon.height = 99999\r
+        @balloon.r = 99999\r
         @balloon.should be_valid\r
       end\r
     end\r
@@ -138,6 +140,24 @@ describe Balloon do
         @balloon.should_not be_valid\r
       end\r
     end\r
+    context 'rを検証するとき' do\r
+      it 'nullなら失敗する' do\r
+        @balloon.r = nil\r
+        @balloon.should_not be_valid\r
+      end\r
+      it '数値でなければ失敗する' do\r
+        @balloon.r = 'a'\r
+        @balloon.should_not be_valid\r
+      end\r
+      it '0なら通る' do\r
+        @balloon.r = '0'\r
+        @balloon.should be_valid\r
+      end\r
+      it '負でも通る' do\r
+        @balloon.r = -1\r
+        @balloon.should be_valid\r
+      end\r
+    end\r
     context 'settingsを検証するとき' do\r
     end\r
   end\r