Skip to content
This repository
Browse code

Move newly added multiparameter tests to base_test file

All other multiparameter assignment tests are in the same file, so it
makes sense to have all of them here.
  • Loading branch information...
commit 100ad217b80629e78755047e3c87242c64a2fc95 1 parent 4903577
Carlos Antonio da Silva authored
36  activerecord/test/cases/attribute_methods_test.rb
@@ -791,42 +791,8 @@ def title=(val); self.author_name = val; end
791 791
     assert_equal "lol", topic.author_name
792 792
   end
793 793
 
794  
-  def test_setting_time_attribute
795  
-    return skip "Oracle does not have TIME data type" if current_adapter? :OracleAdapter
796  
-
797  
-    topic = Topic.new( "bonus_time(4i)"=> "01", "bonus_time(5i)" => "05" )
798  
-    assert_equal 1, topic.bonus_time.hour
799  
-    assert_equal 5, topic.bonus_time.min
800  
-  end
801  
-
802  
-  def test_setting_date_attribute
803  
-    topic = Topic.new( "written_on(1i)" => "1952", "written_on(2i)" => "3", "written_on(3i)" => "11" )
804  
-    assert_equal 1952, topic.written_on.year
805  
-    assert_equal 3, topic.written_on.month
806  
-    assert_equal 11, topic.written_on.day
807  
-  end
808  
-
809  
-  def test_setting_date_and_time_attribute
810  
-    topic = Topic.new(
811  
-        "written_on(1i)" => "1952",
812  
-        "written_on(2i)" => "3",
813  
-        "written_on(3i)" => "11",
814  
-        "written_on(4i)" => "13",
815  
-        "written_on(5i)" => "55")
816  
-    assert_equal 1952, topic.written_on.year
817  
-    assert_equal 3, topic.written_on.month
818  
-    assert_equal 11, topic.written_on.day
819  
-    assert_equal 13, topic.written_on.hour
820  
-    assert_equal 55, topic.written_on.min
821  
-  end
822  
-
823  
-  def test_setting_time_but_not_date_on_date_field
824  
-    assert_raise( ActiveRecord::MultiparameterAssignmentErrors ) do
825  
-      Topic.new( "written_on(4i)" => "13", "written_on(5i)" => "55" )
826  
-    end
827  
-  end
828  
-
829 794
   private
  795
+
830 796
   def cached_columns
831 797
     Topic.columns.find_all { |column|
832 798
       !Topic.serialized_attributes.include? column.name
35  activerecord/test/cases/base_test.rb
@@ -872,6 +872,41 @@ def test_multiparameter_attributes_on_time_with_empty_seconds
872 872
     assert_equal Time.local(2004, 6, 24, 16, 24, 0), topic.written_on
873 873
   end
874 874
 
  875
+  def test_multiparameter_attributes_setting_time_attribute
  876
+    return skip "Oracle does not have TIME data type" if current_adapter? :OracleAdapter
  877
+
  878
+    topic = Topic.new( "bonus_time(4i)"=> "01", "bonus_time(5i)" => "05" )
  879
+    assert_equal 1, topic.bonus_time.hour
  880
+    assert_equal 5, topic.bonus_time.min
  881
+  end
  882
+
  883
+  def test_multiparameter_attributes_setting_date_attribute
  884
+    topic = Topic.new( "written_on(1i)" => "1952", "written_on(2i)" => "3", "written_on(3i)" => "11" )
  885
+    assert_equal 1952, topic.written_on.year
  886
+    assert_equal 3, topic.written_on.month
  887
+    assert_equal 11, topic.written_on.day
  888
+  end
  889
+
  890
+  def test_multiparameter_attributes_setting_date_and_time_attribute
  891
+    topic = Topic.new(
  892
+        "written_on(1i)" => "1952",
  893
+        "written_on(2i)" => "3",
  894
+        "written_on(3i)" => "11",
  895
+        "written_on(4i)" => "13",
  896
+        "written_on(5i)" => "55")
  897
+    assert_equal 1952, topic.written_on.year
  898
+    assert_equal 3, topic.written_on.month
  899
+    assert_equal 11, topic.written_on.day
  900
+    assert_equal 13, topic.written_on.hour
  901
+    assert_equal 55, topic.written_on.min
  902
+  end
  903
+
  904
+  def test_multiparameter_attributes_setting_time_but_not_date_on_date_field
  905
+    assert_raise( ActiveRecord::MultiparameterAssignmentErrors ) do
  906
+      Topic.new( "written_on(4i)" => "13", "written_on(5i)" => "55" )
  907
+    end
  908
+  end
  909
+
875 910
   def test_multiparameter_assignment_of_aggregation_with_missing_values
876 911
     ex = assert_raise(ActiveRecord::MultiparameterAssignmentErrors) do
877 912
       customer = Customer.new

0 notes on commit 100ad21

Please sign in to comment.
Something went wrong with that request. Please try again.