OSDN Git Service

remove unused model
authorokimoto <okimoto@good-day.co.jp>
Mon, 8 Mar 2010 04:01:36 +0000 (13:01 +0900)
committerokimoto <okimoto@good-day.co.jp>
Mon, 8 Mar 2010 04:09:08 +0000 (13:09 +0900)
app/models/factorial_expression_edit_form.rb [deleted file]
app/views/admin/problems/_factorial_expression.html.erb [deleted file]
app/views/admin/problems/_factorial_expression_edit_form.html.erb [deleted file]
spec/models/factorial_expression_edit_form_spec.rb [deleted file]

diff --git a/app/models/factorial_expression_edit_form.rb b/app/models/factorial_expression_edit_form.rb
deleted file mode 100644 (file)
index a91e3d2..0000000
+++ /dev/null
@@ -1,92 +0,0 @@
-# == Schema Information
-# Schema version: 20100224042103
-#
-# Table name: active_forms
-#
-#  unit_id                     :
-#  level                       :integer
-#  amount                      :integer
-#  lock_version                :integer
-#  operators_plus              :boolean
-#  operators_minus             :boolean
-#  operators_times             :boolean
-#  operators_div               :boolean
-#  term_number                 :integer
-#  numerator_term_number_min   :integer
-#  numerator_term_number_max   :integer
-#  denominator_term_number_min :integer
-#  denominator_term_number_max :integer
-#  x                           :
-#  factor_minus                :boolean
-#  factor_min                  :integer
-#  factor_max                  :integer
-#
-
-class FactorialExpressionEditForm < ActiveForm
-  acts_as_problem :operators => true, :term_number => true
-
-  column :numerator_term_number_min, :type => :integer
-  column :numerator_term_number_max, :type => :integer
-  column :denominator_term_number_min, :type => :integer
-  column :denominator_term_number_max, :type => :integer
-  column :x
-  column :factor_minus, :type => :boolean
-  column :factor_min,   :type => :integer
-  column :factor_max,   :type => :integer
-
-  validates_presence_of :numerator_term_number_min
-  validates_presence_of :numerator_term_number_max
-  validates_presence_of :denominator_term_number_min
-  validates_presence_of :denominator_term_number_max
-  with_options :only_integer => true, :allow_nil => true do |problem|
-    problem.validates_numericality_of :numerator_term_number_min, :greater_than_or_equal_to => 0
-    problem.validates_numericality_of :numerator_term_number_max, :greater_than_or_equal_to => 0
-    problem.validates_numericality_of :denominator_term_number_min, :greater_than_or_equal_to => 0
-    problem.validates_numericality_of :denominator_term_number_max, :greater_than_or_equal_to => 0
-  end
-
-  validates_presence_of :x
-  validates_presence_of :factor_min
-  validates_presence_of :factor_max
-  validates_format_of :x, :with => /\A[a-zA-Z](?:,\s*[a-zA-Z])*\z/, :allow_blank => true
-  with_options :only_integer => true, :allow_nil => true do |problem|
-    problem.validates_numericality_of :factor_min, :greater_than_or_equal_to => 0
-    problem.validates_numericality_of :factor_max, :greater_than_or_equal_to => 0
-  end
-
-  def options_hash
-    {
-      :term_number                 => term_number,
-      :operators                   => operators,
-      :numerator_term_number_min   => numerator_term_number_min,
-      :numerator_term_number_max   => numerator_term_number_max,
-      :denominator_term_number_min => denominator_term_number_min,
-      :denominator_term_number_max => denominator_term_number_max,
-      :x                           => split_x(x),
-      :factor_minus                => factor_minus,
-      :factor_min                  => factor_min,
-      :factor_max                  => factor_max,
-    }
-  end
-
-  def set_options(options)
-    hash = ActiveSupport::JSON.decode(options)
-    self.term_number = hash["term_number"]
-    self.operators = hash["operators"] if hash["operators"]
-    self.numerator_term_number_min   = hash["numerator_term_number_min"]
-    self.numerator_term_number_max   = hash["numerator_term_number_max"]
-    self.denominator_term_number_min = hash["denominator_term_number_min"]
-    self.denominator_term_number_max = hash["denominator_term_number_max"]
-    self.x                           = hash["x"]
-    self.factor_minus                = hash["factor_minus"]
-    self.factor_min                  = hash["factor_min"]
-    self.factor_max                  = hash["factor_max"]
-  end
-
-  def validate
-    check_min_max(:numerator_term_number_min, :numerator_term_number_max)
-    check_min_max(:denominator_term_number_min, :denominator_term_number_max)
-    check_min_max(:factor_min, :factor_max)
-    check_operators()
-  end
-end
diff --git a/app/views/admin/problems/_factorial_expression.html.erb b/app/views/admin/problems/_factorial_expression.html.erb
deleted file mode 100644 (file)
index cc77723..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-<table class="problem">
-  <%= render :partial => "common" %>
-  <%= render :partial => "operatos", :locals => { :operators => %w[plus minus times div], :term_number => true } %>
-  <%= render :partial => "minus_min_max", :locals => { :prefix => "numerator_term_number_", :minus => false } %>
-  <%= render :partial => "minus_min_max", :locals => { :prefix => "denominator_term_number_", :minus => false } %>
-  <tr><th><%= _("x") %></th><td><%=h @form.x %></td></tr>
-  <%= render :partial => "minus_min_max", :locals => { :prefix => "factor_", :minus => true } %>
-</table>
diff --git a/app/views/admin/problems/_factorial_expression_edit_form.html.erb b/app/views/admin/problems/_factorial_expression_edit_form.html.erb
deleted file mode 100644 (file)
index f089a88..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-<table class="problem">
-  <%= render :partial => "common_edit_form", :locals => { :f => f } %>
-  <%= render :partial => "operators_edit_form", :locals => { :f => f, :operators => %w[plus minus times div], :term_number => true } %>
-  <%= render :partial => "minus_min_max_edit_form", :locals => { :f => f, :prefix => "numerator_term_number_", :minus => false } %>
-  <%= render :partial => "minus_min_max_edit_form", :locals => { :f => f, :prefix => "denominator_term_number_", :minus => false } %>
-  <tr><th><%= f.label(:x) %></th><td><%= f.text_field(:x) %></td></tr>
-  <%= render :partial => "minus_min_max_edit_form", :locals => {:f => f, :prefix => "factor_", :minus => true } %>
-</table>
diff --git a/spec/models/factorial_expression_edit_form_spec.rb b/spec/models/factorial_expression_edit_form_spec.rb
deleted file mode 100644 (file)
index b7714b9..0000000
+++ /dev/null
@@ -1,394 +0,0 @@
-require 'spec_helper'
-
-describe FactorialExpressionEditForm do
-  before do
-    @valid_attributes = {
-      :unit_id                     => 1,
-      :level                       => 1,
-      :amount                      => 2,
-      :term_number                 => 2,
-      :operators_plus              => true,
-      :operators_minus             => true,
-      :operators_times             => true,
-      :operators_div               => true,
-      :numerator_term_number_min   => 0,
-      :numerator_term_number_max   => 100,
-      :denominator_term_number_min => 0,
-      :denominator_term_number_max => 100,
-      :x                           => "x",
-      :factor_minus                => true,
-      :factor_min                  => 1,
-      :factor_max                  => 10,
-    }
-    @klass = FactorialExpressionEditForm
-    @basic = @klass.new(@valid_attributes)
-  end
-
-  context "basic" do
-    it{ @basic.should be_valid }
-  end
-
-  context "validation" do
-    context "numerator_term_number_min" do
-      context "is string" do
-        subject{ @basic.numerator_term_number_min = "a"; @basic }
-        it{ should_not be_valid }
-      end
-      context "is nil" do
-        subject{ @basic.numerator_term_number_min = nil; @basic }
-        it{ should_not be_valid }
-      end
-      context "is empty" do
-        subject{ @basic.numerator_term_number_min = ""; @basic }
-        it{ should_not be_valid }
-      end
-      context "is float" do
-        subject{ @basic.numerator_term_number_min = 1.5; @basic }
-        it{ should_not be_valid }
-      end
-      context "is -1" do
-        subject{ @basic.numerator_term_number_min = -1; @basic }
-        it{ should_not be_valid }
-      end
-      context "is 0" do
-        subject{ @basic.numerator_term_number_min = 0; @basic }
-        it{ should be_valid }
-      end
-    end
-
-    context "numerator_term_number_max" do
-      context "is string" do
-        subject{ @basic.numerator_term_number_max = "a"; @basic }
-        it{ should_not be_valid }
-      end
-      context "is nil" do
-        subject{ @basic.numerator_term_number_max = nil; @basic }
-        it{ should_not be_valid }
-      end
-      context "is empty" do
-        subject{ @basic.numerator_term_number_max = ""; @basic }
-        it{ should_not be_valid }
-      end
-      context "is float" do
-        subject{ @basic.numerator_term_number_max = 1.5; @basic }
-        it{ should_not be_valid }
-      end
-      context "is -1" do
-        subject{ @basic.numerator_term_number_max = -1; @basic }
-        it{ should_not be_valid }
-      end
-      context "is 0" do
-        subject{ @basic.numerator_term_number_max = 0; @basic }
-        it{ should be_valid }
-      end
-    end
-
-    context "denominator_term_number_min" do
-      context "is string" do
-        subject{ @basic.denominator_term_number_min = "a"; @basic }
-        it{ should_not be_valid }
-      end
-      context "is nil" do
-        subject{ @basic.denominator_term_number_min = nil; @basic }
-        it{ should_not be_valid }
-      end
-      context "is empty" do
-        subject{ @basic.denominator_term_number_min = ""; @basic }
-        it{ should_not be_valid }
-      end
-      context "is float" do
-        subject{ @basic.denominator_term_number_min = 1.5; @basic }
-        it{ should_not be_valid }
-      end
-      context "is -1" do
-        subject{ @basic.denominator_term_number_min = -1; @basic }
-        it{ should_not be_valid }
-      end
-      context "is 0" do
-        subject{ @basic.denominator_term_number_min = 0; @basic }
-        it{ should be_valid }
-      end
-    end
-
-    context "denominator_term_number_max" do
-      context "is string" do
-        subject{ @basic.denominator_term_number_max = "a"; @basic }
-        it{ should_not be_valid }
-      end
-      context "is nil" do
-        subject{ @basic.denominator_term_number_max = nil; @basic }
-        it{ should_not be_valid }
-      end
-      context "is empty" do
-        subject{ @basic.denominator_term_number_max = ""; @basic }
-        it{ should_not be_valid }
-      end
-      context "is float" do
-        subject{ @basic.denominator_term_number_max = 1.5; @basic }
-        it{ should_not be_valid }
-      end
-      context "is -1" do
-        subject{ @basic.denominator_term_number_max = -1; @basic }
-        it{ should_not be_valid }
-      end
-      context "is 0" do
-        subject{ @basic.denominator_term_number_max = 0; @basic }
-        it{ should be_valid }
-      end
-    end
-
-    context "x" do
-      context "is 'a,b,c'" do
-        subject{ @basic.x = 'a,b,c'; @basic }
-        it{ should be_valid }
-      end
-      context "is 'a, b, c'" do
-        subject{ @basic.x = 'a, b, c'; @basic }
-        it{ should be_valid }
-      end
-      context "is '1, 2, 3'" do
-        subject{ @basic.x = '1, 2, 3'; @basic }
-        it{ should_not be_valid }
-      end
-      context "is 'aa, bb, cc'" do
-        subject{ @basic.x = 'aa, bb, cc'; @basic }
-        it{ should_not be_valid }
-      end
-      context "is nil" do
-        subject{ @basic.x = nil; @basic }
-        it{ should_not be_valid }
-      end
-      context "is empty" do
-        subject{ @basic.x = ''; @basic }
-        it{ should_not be_valid }
-      end
-    end
-
-    context "factor_min" do
-      context "is string" do
-        subject{ @basic.factor_min = "a"; @basic }
-        it{ should_not be_valid }
-      end
-      context "is nil" do
-        subject{ @basic.factor_min = nil; @basic }
-        it{ should_not be_valid }
-      end
-      context "is empty" do
-        subject{ @basic.factor_min = ""; @basic }
-        it{ should_not be_valid }
-      end
-      context "is float" do
-        subject{ @basic.factor_min = 1.5; @basic }
-        it{ should_not be_valid }
-      end
-      context "is -1" do
-        subject{ @basic.factor_min = -1; @basic }
-        it{ should_not be_valid }
-      end
-      context "is 0" do
-        subject{ @basic.factor_min = 0; @basic }
-        it{ should be_valid }
-      end
-    end
-
-    context "factor_max" do
-      context "is string" do
-        subject{ @basic.factor_max = "a"; @basic }
-        it{ should_not be_valid }
-      end
-      context "is nil" do
-        subject{ @basic.factor_max = nil; @basic }
-        it{ should_not be_valid }
-      end
-      context "is empty" do
-        subject{ @basic.factor_max = ""; @basic }
-        it{ should_not be_valid }
-      end
-      context "is float" do
-        subject{ @basic.factor_max = 1.5; @basic }
-        it{ should_not be_valid }
-      end
-      context "is -1" do
-        subject{ @basic.factor_max = -1; @basic }
-        it{ should_not be_valid }
-      end
-      context "is 0" do
-        subject{ @basic.factor_min = 0; @basic.factor_max = 0; @basic }
-        it{ should be_valid }
-      end
-    end
-
-    context "relation" do
-      context "numerator_term_number" do
-        context "min < max" do
-          before do
-            @basic.numerator_term_number_min = 10
-            @basic.numerator_term_number_max = 1
-          end
-          it{ @basic.should_not be_valid }
-          it "have a correct message" do
-            @basic.valid?
-            @basic.errors.full_messages.first.should == "Numerator term number min must be greater than Numerator term number max."
-          end
-        end
-        context "min = max" do
-          subject{
-            @basic.numerator_term_number_min = 10
-            @basic.numerator_term_number_max = 10
-            @basic
-          }
-          it{ should be_valid }
-        end
-        context "min = max = nil, empty" do
-          subject{
-            @basic.numerator_term_number_min = nil
-            @basic.numerator_term_number_max = ""
-            @basic
-          }
-          it{ should_not be_valid }
-        end
-      end
-      context "denominator_term_number" do
-        context "min < max" do
-          before do
-            @basic.denominator_term_number_min = 10
-            @basic.denominator_term_number_max = 1
-          end
-          it{ @basic.should_not be_valid }
-          it "have a correct message" do
-            @basic.valid?
-            @basic.errors.full_messages.first.should == "Denominator term number min must be greater than Denominator term number max."
-          end
-        end
-        context "min = max" do
-          subject{
-            @basic.denominator_term_number_min = 10
-            @basic.denominator_term_number_max = 10
-            @basic
-          }
-          it{ should be_valid }
-        end
-        context "min = max = nil, empty" do
-          subject{
-            @basic.denominator_term_number_min = nil
-            @basic.denominator_term_number_max = ""
-            @basic
-          }
-          it{ should_not be_valid }
-        end
-      end
-      context "factor" do
-        context "min < max" do
-          before do
-            @basic.factor_min = 10
-            @basic.factor_max = 2
-          end
-          it{ @basic.should_not be_valid }
-          it "have a correct message" do
-            @basic.valid?
-            @basic.errors.full_messages.first.should == "Factor min must be greater than Factor max."
-          end
-        end
-        context "min = max" do
-          subject{
-            @basic.factor_min = 10
-            @basic.factor_max = 10
-            @basic
-          }
-          it{ should be_valid }
-        end
-        context "min = max = nil, empty" do
-          subject{
-            @basic.factor_min = nil
-            @basic.factor_max = ""
-            @basic
-          }
-          it{ should_not be_valid }
-        end
-      end
-    end
-
-    context "operators" do
-      context "no operators specified" do
-        subject{
-          @basic.operators_plus = false
-          @basic.operators_minus = false
-          @basic.operators_times = false
-          @basic.operators_div = false
-          @basic
-        }
-        it{ should_not be_valid }
-      end
-    end
-  end
-
-  context "options_hash" do
-    subject{ @basic.options_hash }
-    it{
-      should == {
-        :term_number                 => 2,
-        :operators                   => %w[+ - * div],
-        :numerator_term_number_min   => 0,
-        :numerator_term_number_max   => 100,
-        :denominator_term_number_min => 0,
-        :denominator_term_number_max => 100,
-        :x                           => ["x"],
-        :factor_minus                => true,
-        :factor_min                  => 1,
-        :factor_max                  => 10,
-      }
-    }
-  end
-
-  context "attributes_for_model" do
-    subject{ @basic.attributes_for_model }
-    it{
-      should == {
-        :unit_id      => 1,
-        :level        => 1,
-        :amount       => 2,
-        :options      => @basic.options_hash.to_json,
-        :lock_version => 0
-      }
-    }
-  end
-
-  context "set_options" do
-    context "basic" do
-      subject{
-        options = {
-          :term_number                 => 3,
-          :operators                   => %w[+ - * div],
-          :numerator_term_number_min   => 0,
-          :numerator_term_number_max   => 100,
-          :denominator_term_number_min => 0,
-          :denominator_term_number_max => 100,
-          :x                           => %w[a b c],
-          :factor_minus                => true,
-          :factor_min                  => 11,
-          :factor_max                  => 101,
-        }
-        @basic.set_options(options.to_json)
-        @basic
-      }
-      its(:term_number){ should == 3 }
-      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(:numerator_term_number_min){ should == 0 }
-      its(:numerator_term_number_max){ should == 100 }
-      its(:denominator_term_number_min){ should == 0 }
-      its(:denominator_term_number_max){ should == 100 }
-      its(:x){ should == %w[a b c] }
-      its(:factor_minus){ should be_true }
-      its(:factor_min){ should == 11 }
-      its(:factor_max){ should == 101 }
-    end
-    context "set nothing" do
-      it "should not raise Exception" do
-        lambda{ @basic.set_options({}.to_json) }.should_not raise_exception
-      end
-    end
-  end
-end