OSDN Git Service

fix bugs
authorokimoto <okimoto@good-day.co.jp>
Thu, 4 Mar 2010 04:57:21 +0000 (13:57 +0900)
committerokimoto <okimoto@good-day.co.jp>
Thu, 4 Mar 2010 04:57:21 +0000 (13:57 +0900)
app/models/complex_number_arithmetic_edit_form.rb
spec/models/complex_number_arithmetic_edit_form_spec.rb

index 32f5d41..ce16ca2 100644 (file)
@@ -1,5 +1,5 @@
 class ComplexNumberArithmeticEditForm < ActiveForm
-  acts_as_problem :operators => %w[+ - * /], :term_number => true
+  acts_as_problem :operators => %w[plus minus times fraction], :term_number => true
 
   column :min, :type => :integer
   column :max, :type => :integer
@@ -15,7 +15,6 @@ class ComplexNumberArithmeticEditForm < ActiveForm
 
   def options_hash
     {
-      :minus           => minus,
       :min             => min,
       :max             => max,
       :fractional_mode => fractional_mode,
@@ -26,7 +25,6 @@ class ComplexNumberArithmeticEditForm < ActiveForm
 
   def set_options(options)
     hash = ActiveSupport::JSON.decode(options)
-    self.minus           = hash["minus"]
     self.min             = hash["min"]
     self.max             = hash["max"]
     self.fractional_mode = hash["fractional_mode"]
index 452aa6b..9340e7c 100644 (file)
@@ -3,17 +3,17 @@ require 'spec_helper'
 describe ComplexNumberArithmeticEditForm do
   before do
     @valid_attributes = {
-      :unit_id         => 1,
-      :level           => 1,
-      :amount          => 2,
-      :min             => 0,
-      :max             => 100,
-      :fractional_mode => false,
-      :term_number     => 2,
-      :operators_plus  => true,
-      :operators_minus => true,
-      :operators_times => true,
-#      :operators_div   => true,
+      :unit_id            => 1,
+      :level              => 1,
+      :amount             => 2,
+      :min                => 0,
+      :max                => 100,
+      :fractional_mode    => false,
+      :term_number        => 2,
+      :operators_plus     => true,
+      :operators_minus    => true,
+      :operators_times    => true,
+      :operators_fraction => true,
     }
     @klass = ComplexNumberArithmeticEditForm
     @basic = @klass.new(@valid_attributes)
@@ -107,7 +107,7 @@ describe ComplexNumberArithmeticEditForm do
           @basic.operators_plus = false
           @basic.operators_minus = false
           @basic.operators_times = false
-          # @basic.operators_div = false
+          @basic.operators_fraction = false
           @basic
         }
         it{ should_not be_valid }
@@ -147,7 +147,7 @@ describe ComplexNumberArithmeticEditForm do
           :min => 1, :max => 99,
           :fractional_mode => true,
           :term_number => 3,
-          :operators => %w[+ - * div]
+          :operators => %w[+ - * /]
         }
         @basic.set_options(options.to_json)
         @basic
@@ -159,7 +159,7 @@ describe ComplexNumberArithmeticEditForm do
       its(:operators_plus){ should be_true }
       its(:operators_minus){ should be_true }
       its(:operators_times){ should be_true }
-      its(:operators_div){ should be_true }
+      its(:operators_fraction){ should be_true }
     end
     context "set nothing" do
       it "should not raise Exception" do