aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--actionpack/lib/action_view/helpers/active_record_helper.rb2
-rwxr-xr-xactionpack/lib/action_view/helpers/date_helper.rb4
-rw-r--r--actionpack/lib/action_view/helpers/number_helper.rb2
-rw-r--r--actionpack/test/template/active_record_helper_i18n_test.rb6
-rw-r--r--actionpack/test/template/date_helper_i18n_test.rb8
-rw-r--r--actionpack/test/template/number_helper_i18n_test.rb6
6 files changed, 14 insertions, 14 deletions
diff --git a/actionpack/lib/action_view/helpers/active_record_helper.rb b/actionpack/lib/action_view/helpers/active_record_helper.rb
index 5ad9d5f76d..716e303a5d 100644
--- a/actionpack/lib/action_view/helpers/active_record_helper.rb
+++ b/actionpack/lib/action_view/helpers/active_record_helper.rb
@@ -160,7 +160,7 @@ module ActionView
count = objects.inject(0) {|sum, object| sum + object.errors.count }
locale = options[:locale]
- locale ||= request.locale if respond_to?(:request)
+ locale ||= self.locale if respond_to?(:locale)
unless count.zero?
html = {}
diff --git a/actionpack/lib/action_view/helpers/date_helper.rb b/actionpack/lib/action_view/helpers/date_helper.rb
index 0337be0744..dbb5d458bf 100755
--- a/actionpack/lib/action_view/helpers/date_helper.rb
+++ b/actionpack/lib/action_view/helpers/date_helper.rb
@@ -60,7 +60,7 @@ module ActionView
#
def distance_of_time_in_words(from_time, to_time = 0, include_seconds = false, options = {})
locale = options[:locale]
- locale ||= request.locale if respond_to?(:request)
+ locale ||= self.locale if respond_to?(:locale)
from_time = from_time.to_time if from_time.respond_to?(:to_time)
to_time = to_time.to_time if to_time.respond_to?(:to_time)
@@ -507,7 +507,7 @@ module ActionView
#
def select_month(date, options = {}, html_options = {})
locale = options[:locale]
- locale ||= request.locale if respond_to?(:request)
+ locale ||= self.locale if respond_to?(:locale)
val = date ? (date.kind_of?(Fixnum) ? date : date.month) : ''
if options[:use_hidden]
diff --git a/actionpack/lib/action_view/helpers/number_helper.rb b/actionpack/lib/action_view/helpers/number_helper.rb
index 9d98036f2d..dc56817c12 100644
--- a/actionpack/lib/action_view/helpers/number_helper.rb
+++ b/actionpack/lib/action_view/helpers/number_helper.rb
@@ -72,7 +72,7 @@ module ActionView
options = options.symbolize_keys
locale = options[:locale]
- locale ||= request.locale if respond_to?(:request)
+ locale ||= self.locale if respond_to?(:locale)
defaults = :'currency.format'.t(locale) || {}
precision = options[:precision] || defaults[:precision]
diff --git a/actionpack/test/template/active_record_helper_i18n_test.rb b/actionpack/test/template/active_record_helper_i18n_test.rb
index 057fb9bd1a..3a2197ac93 100644
--- a/actionpack/test/template/active_record_helper_i18n_test.rb
+++ b/actionpack/test/template/active_record_helper_i18n_test.rb
@@ -5,22 +5,22 @@ class ActiveRecordHelperI18nTest < Test::Unit::TestCase
attr_reader :request
def setup
- @request = mock
@object = stub :errors => stub(:count => 1, :full_messages => ['full_messages'])
stubs(:content_tag).returns 'content_tag'
+ stubs(:locale)
I18n.stubs(:t).with(:'header_message', :locale => 'en-US', :scope => [:active_record, :error], :count => 1, :object_name => '').returns "1 error prohibited this from being saved"
I18n.stubs(:t).with(:'message', :locale => 'en-US', :scope => [:active_record, :error]).returns 'There were problems with the following fields:'
end
def test_error_messages_for_given_a_locale_it_does_not_check_request_for_locale
- request.expects(:locale).never
+ expects(:locale).never
@object.errors.stubs(:count).returns 0
error_messages_for(:object => @object, :locale => 'en-US')
end
def test_error_messages_for_given_no_locale_it_checks_request_for_locale
- request.expects(:locale).returns 'en-US'
+ expects(:locale).returns 'en-US'
@object.errors.stubs(:count).returns 0
error_messages_for(:object => @object)
end
diff --git a/actionpack/test/template/date_helper_i18n_test.rb b/actionpack/test/template/date_helper_i18n_test.rb
index 9b7c03a400..f245ca1fc8 100644
--- a/actionpack/test/template/date_helper_i18n_test.rb
+++ b/actionpack/test/template/date_helper_i18n_test.rb
@@ -5,19 +5,19 @@ class DateHelperDistanceOfTimeInWordsI18nTests < Test::Unit::TestCase
attr_reader :request
def setup
- @request = mock
+ stubs(:locale)
@from = Time.mktime(2004, 6, 6, 21, 45, 0)
end
# distance_of_time_in_words
def test_distance_of_time_in_words_given_a_locale_it_does_not_check_request_for_locale
- request.expects(:locale).never
+ expects(:locale).never
distance_of_time_in_words @from, @from + 1.second, false, :locale => 'en-US'
end
def test_distance_of_time_in_words_given_no_locale_it_checks_request_for_locale
- request.expects(:locale).returns 'en-US'
+ expects(:locale).returns 'en-US'
distance_of_time_in_words @from, @from + 1.second
end
@@ -64,7 +64,7 @@ class DateHelperSelectTagsI18nTests < Test::Unit::TestCase
attr_reader :request
def setup
- @request = mock
+ # stubs(:locale)
I18n.stubs(:translate).with(:'date.month_names', 'en-US').returns Date::MONTHNAMES
end
diff --git a/actionpack/test/template/number_helper_i18n_test.rb b/actionpack/test/template/number_helper_i18n_test.rb
index b75af03378..5db60ece04 100644
--- a/actionpack/test/template/number_helper_i18n_test.rb
+++ b/actionpack/test/template/number_helper_i18n_test.rb
@@ -5,18 +5,18 @@ class NumberHelperI18nTests < Test::Unit::TestCase
attr_reader :request
def setup
- @request = mock
+ stubs(:locale)
@defaults = {:separator => ".", :unit => "$", :format => "%u%n", :delimiter => ",", :precision => 2}
I18n.backend.store_translations 'en-US', :currency => {:format => @defaults}
end
def test_number_to_currency_given_a_locale_it_does_not_check_request_for_locale
- request.expects(:locale).never
+ expects(:locale).never
number_to_currency(1, :locale => 'en-US')
end
def test_number_to_currency_given_no_locale_it_checks_request_for_locale
- request.expects(:locale).returns 'en-US'
+ expects(:locale).returns 'en-US'
number_to_currency(1)
end