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

Merge commit 'mainstream/master'

This commit is contained in:
Pratik Naik 2008-05-27 12:24:46 +01:00
commit f8b402c5d8
7 changed files with 13 additions and 19 deletions

View file

@ -1,14 +1,6 @@
require 'active_support/test_case' require 'active_support/test_case'
module ActionView module ActionView
class NonInferrableHelperError < ActionViewError
def initialize(name)
super "Unable to determine the helper to test from #{name}. " +
"You'll need to specify it using tests YourHelper in your " +
"test case definition"
end
end
class TestCase < ActiveSupport::TestCase class TestCase < ActiveSupport::TestCase
class_inheritable_accessor :helper_class class_inheritable_accessor :helper_class
@@helper_class = nil @@helper_class = nil
@ -29,7 +21,7 @@ module ActionView
def determine_default_helper_class(name) def determine_default_helper_class(name)
name.sub(/Test$/, '').constantize name.sub(/Test$/, '').constantize
rescue NameError rescue NameError
raise NonInferrableHelperError.new(name) nil
end end
end end
@ -42,8 +34,10 @@ module ActionView
setup :setup_with_helper_class setup :setup_with_helper_class
def setup_with_helper_class def setup_with_helper_class
if helper_class && !self.class.ancestors.include?(helper_class)
self.class.send(:include, helper_class) self.class.send(:include, helper_class)
end end
end
class TestController < ActionController::Base class TestController < ActionController::Base
attr_accessor :request, :response attr_accessor :request, :response

View file

@ -25,8 +25,6 @@ class Author::Nested < Author; end
class PrototypeHelperBaseTest < ActionView::TestCase class PrototypeHelperBaseTest < ActionView::TestCase
tests ActionView::Helpers::PrototypeHelper
attr_accessor :template_format attr_accessor :template_format
def setup def setup

View file

@ -30,8 +30,8 @@ class PostgresqlDataTypeTest < ActiveRecord::TestCase
@connection.execute("INSERT INTO postgresql_arrays (commission_by_quarter, nicknames) VALUES ( '{35000,21000,18000,17000}', '{foo,bar,baz}' )") @connection.execute("INSERT INTO postgresql_arrays (commission_by_quarter, nicknames) VALUES ( '{35000,21000,18000,17000}', '{foo,bar,baz}' )")
@first_array = PostgresqlArray.find(1) @first_array = PostgresqlArray.find(1)
@connection.execute("INSERT INTO postgresql_moneys (wealth) VALUES ('$567.89')") @connection.execute("INSERT INTO postgresql_moneys (wealth) VALUES ('567.89'::money)")
@connection.execute("INSERT INTO postgresql_moneys (wealth) VALUES ('-$567.89')") @connection.execute("INSERT INTO postgresql_moneys (wealth) VALUES ('-567.89'::money)")
@first_money = PostgresqlMoney.find(1) @first_money = PostgresqlMoney.find(1)
@second_money = PostgresqlMoney.find(2) @second_money = PostgresqlMoney.find(2)
@ -143,11 +143,11 @@ class PostgresqlDataTypeTest < ActiveRecord::TestCase
end end
def test_update_money def test_update_money
new_value = 123.45 new_value = BigDecimal.new('123.45')
assert @first_money.wealth = new_value assert @first_money.wealth = new_value
assert @first_money.save assert @first_money.save
assert @first_money.reload assert @first_money.reload
assert_equal @first_money.wealth, new_value assert_equal new_value, @first_money.wealth
end end
def test_update_number def test_update_number

View file

@ -867,7 +867,7 @@ class FinderTest < ActiveRecord::TestCase
end end
def test_with_limiting_with_custom_select def test_with_limiting_with_custom_select
posts = Post.find(:all, :include => :author, :select => ' posts.*, authors.id as "author_id"', :limit => 3) posts = Post.find(:all, :include => :author, :select => ' posts.*, authors.id as "author_id"', :limit => 3, :order => 'posts.id')
assert_equal 3, posts.size assert_equal 3, posts.size
assert_equal [0, 1, 1], posts.map(&:author_id).sort assert_equal [0, 1, 1], posts.map(&:author_id).sort
end end

View file

@ -1,3 +1,5 @@
* TimeZone#to_s shows offset as GMT instead of UTC, because GMT will be more familiar to end users (see time zone selects used by Windows OS, google.com and yahoo.com.) Reverts [8370] [Geoff Buesing]
* Hash.from_xml: datetime xml types overflow to Ruby DateTime class when out of range of Time. Adding tests for utc offsets [Geoff Buesing] * Hash.from_xml: datetime xml types overflow to Ruby DateTime class when out of range of Time. Adding tests for utc offsets [Geoff Buesing]
* TimeWithZone #+ and #- : ensure overflow to DateTime with Numeric arg [Geoff Buesing] * TimeWithZone #+ and #- : ensure overflow to DateTime with Numeric arg [Geoff Buesing]

View file

@ -202,7 +202,7 @@ class TimeZone
# Returns a textual representation of this time zone. # Returns a textual representation of this time zone.
def to_s def to_s
"(UTC#{formatted_offset}) #{name}" "(GMT#{formatted_offset}) #{name}"
end end
# Method for creating new ActiveSupport::TimeWithZone instance in time zone of +self+ from given values. Example: # Method for creating new ActiveSupport::TimeWithZone instance in time zone of +self+ from given values. Example:

View file

@ -252,7 +252,7 @@ class TimeZoneTest < Test::Unit::TestCase
end end
def test_to_s def test_to_s
assert_equal "(UTC+03:00) Moscow", TimeZone['Moscow'].to_s assert_equal "(GMT+03:00) Moscow", TimeZone['Moscow'].to_s
end end
def test_all_sorted def test_all_sorted