aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/template/lookup_context_test.rb
diff options
context:
space:
mode:
authorRizwan Reza <rizwanreza@gmail.com>2010-03-28 12:04:00 +0430
committerRizwan Reza <rizwanreza@gmail.com>2010-03-28 12:04:00 +0430
commitb4c91de9462f59d6395c7c871aafa3301afdc383 (patch)
treefadcaf603a6f473e8ccd52070a1f3b4f957c34cb /actionpack/test/template/lookup_context_test.rb
parent4b4f69b9bfbd33556e23262f57cf6d944dfd9f63 (diff)
parent66d57d7ba83df52ff1e0485c89f6192c2f84c6b8 (diff)
downloadrails-b4c91de9462f59d6395c7c871aafa3301afdc383.tar.gz
rails-b4c91de9462f59d6395c7c871aafa3301afdc383.tar.bz2
rails-b4c91de9462f59d6395c7c871aafa3301afdc383.zip
Merge remote branch 'rails/master'
Diffstat (limited to 'actionpack/test/template/lookup_context_test.rb')
-rw-r--r--actionpack/test/template/lookup_context_test.rb45
1 files changed, 29 insertions, 16 deletions
diff --git a/actionpack/test/template/lookup_context_test.rb b/actionpack/test/template/lookup_context_test.rb
index 697ebc694a..df1aa2edb2 100644
--- a/actionpack/test/template/lookup_context_test.rb
+++ b/actionpack/test/template/lookup_context_test.rb
@@ -22,34 +22,35 @@ class LookupContextTest < ActiveSupport::TestCase
end
test "normalizes details on initialization" do
- formats = Mime::SET + [nil]
- locale = [I18n.locale, nil]
- assert_equal Hash[:formats => formats, :locale => locale], @lookup_context.details
- end
-
- test "allows me to set details" do
- @lookup_context.details = { :formats => [:html], :locale => :pt }
- assert_equal Hash[:formats => [:html, nil], :locale => [:pt, nil]], @lookup_context.details
+ assert_equal Mime::SET, @lookup_context.formats
+ assert_equal :en, @lookup_context.locale
end
- test "does not allow details to be modified in place" do
- assert @lookup_context.details.frozen?
+ test "allows me to update details" do
+ @lookup_context.update_details(:formats => [:html], :locale => :pt)
+ assert_equal [:html], @lookup_context.formats
+ assert_equal :pt, @lookup_context.locale
end
test "allows me to update an specific detail" do
@lookup_context.update_details(:locale => :pt)
assert_equal :pt, I18n.locale
- formats = Mime::SET + [nil]
- locale = [I18n.locale, nil]
- assert_equal Hash[:formats => formats, :locale => locale], @lookup_context.details
+ assert_equal :pt, @lookup_context.locale
+ end
+
+ test "allows me to freeze and retrieve frozen formats" do
+ @lookup_context.formats.freeze
+ assert @lookup_context.formats.frozen?
end
test "allows me to change some details to execute an specific block of code" do
- formats = Mime::SET + [nil]
+ formats = Mime::SET
@lookup_context.update_details(:locale => :pt) do
- assert_equal Hash[:formats => formats, :locale => [:pt, nil]], @lookup_context.details
+ assert_equal formats, @lookup_context.formats
+ assert_equal :pt, @lookup_context.locale
end
- assert_equal Hash[:formats => formats, :locale => [:en, nil]], @lookup_context.details
+ assert_equal formats, @lookup_context.formats
+ assert_equal :en, @lookup_context.locale
end
test "provides getters and setters for formats" do
@@ -62,6 +63,11 @@ class LookupContextTest < ActiveSupport::TestCase
assert_equal Mime::SET, @lookup_context.formats
end
+ test "adds :html fallback to :js formats" do
+ @lookup_context.formats = [:js]
+ assert_equal [:js, :html], @lookup_context.formats
+ end
+
test "provides getters and setters for locale" do
@lookup_context.locale = :pt
assert_equal :pt, @lookup_context.locale
@@ -94,6 +100,13 @@ class LookupContextTest < ActiveSupport::TestCase
assert_equal "Hey verden", template.source
end
+ test "found templates respects given formats if one cannot be found from template or handler" do
+ ActionView::Template::Handlers::ERB.expects(:default_format).returns(nil)
+ @lookup_context.formats = [:text]
+ template = @lookup_context.find("hello_world", "test")
+ assert_equal [:text], template.formats
+ end
+
test "adds fallbacks to view paths when required" do
assert_equal 1, @lookup_context.view_paths.size