1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

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.
This commit is contained in:
Carlos Antonio da Silva 2012-06-27 23:50:58 -03:00
parent 4903577b42
commit 100ad217b8
2 changed files with 36 additions and 35 deletions

View file

@ -791,42 +791,8 @@ class AttributeMethodsTest < ActiveRecord::TestCase
assert_equal "lol", topic.author_name
end
def test_setting_time_attribute
return skip "Oracle does not have TIME data type" if current_adapter? :OracleAdapter
topic = Topic.new( "bonus_time(4i)"=> "01", "bonus_time(5i)" => "05" )
assert_equal 1, topic.bonus_time.hour
assert_equal 5, topic.bonus_time.min
end
def test_setting_date_attribute
topic = Topic.new( "written_on(1i)" => "1952", "written_on(2i)" => "3", "written_on(3i)" => "11" )
assert_equal 1952, topic.written_on.year
assert_equal 3, topic.written_on.month
assert_equal 11, topic.written_on.day
end
def test_setting_date_and_time_attribute
topic = Topic.new(
"written_on(1i)" => "1952",
"written_on(2i)" => "3",
"written_on(3i)" => "11",
"written_on(4i)" => "13",
"written_on(5i)" => "55")
assert_equal 1952, topic.written_on.year
assert_equal 3, topic.written_on.month
assert_equal 11, topic.written_on.day
assert_equal 13, topic.written_on.hour
assert_equal 55, topic.written_on.min
end
def test_setting_time_but_not_date_on_date_field
assert_raise( ActiveRecord::MultiparameterAssignmentErrors ) do
Topic.new( "written_on(4i)" => "13", "written_on(5i)" => "55" )
end
end
private
def cached_columns
Topic.columns.find_all { |column|
!Topic.serialized_attributes.include? column.name

View file

@ -872,6 +872,41 @@ class BasicsTest < ActiveRecord::TestCase
assert_equal Time.local(2004, 6, 24, 16, 24, 0), topic.written_on
end
def test_multiparameter_attributes_setting_time_attribute
return skip "Oracle does not have TIME data type" if current_adapter? :OracleAdapter
topic = Topic.new( "bonus_time(4i)"=> "01", "bonus_time(5i)" => "05" )
assert_equal 1, topic.bonus_time.hour
assert_equal 5, topic.bonus_time.min
end
def test_multiparameter_attributes_setting_date_attribute
topic = Topic.new( "written_on(1i)" => "1952", "written_on(2i)" => "3", "written_on(3i)" => "11" )
assert_equal 1952, topic.written_on.year
assert_equal 3, topic.written_on.month
assert_equal 11, topic.written_on.day
end
def test_multiparameter_attributes_setting_date_and_time_attribute
topic = Topic.new(
"written_on(1i)" => "1952",
"written_on(2i)" => "3",
"written_on(3i)" => "11",
"written_on(4i)" => "13",
"written_on(5i)" => "55")
assert_equal 1952, topic.written_on.year
assert_equal 3, topic.written_on.month
assert_equal 11, topic.written_on.day
assert_equal 13, topic.written_on.hour
assert_equal 55, topic.written_on.min
end
def test_multiparameter_attributes_setting_time_but_not_date_on_date_field
assert_raise( ActiveRecord::MultiparameterAssignmentErrors ) do
Topic.new( "written_on(4i)" => "13", "written_on(5i)" => "55" )
end
end
def test_multiparameter_assignment_of_aggregation_with_missing_values
ex = assert_raise(ActiveRecord::MultiparameterAssignmentErrors) do
customer = Customer.new