aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/template/resolver_patterns_test.rb
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2011-03-22 09:34:33 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2011-03-22 09:34:33 -0700
commit2ef6270f8fbbefba8d4f10504497e198d8e7deea (patch)
treea90b640a9e59306e92fc4bcc2ab58d08b0341e23 /actionpack/test/template/resolver_patterns_test.rb
parent6ab65bec611247bbd1dd62da0ee8c4dc44b37ec1 (diff)
parent2ddfdba9a0dab7d8499c3ad0d13583bddbac4f69 (diff)
downloadrails-2ef6270f8fbbefba8d4f10504497e198d8e7deea.tar.gz
rails-2ef6270f8fbbefba8d4f10504497e198d8e7deea.tar.bz2
rails-2ef6270f8fbbefba8d4f10504497e198d8e7deea.zip
Merge branch 'master' into fuuu
* master: Do not show optional (.:format) block for wildcard route [#6605 state:resolved] pushing id insertion and prefetch primary keys down to Relation#insert use prepared statements to fetch the last insert id escaping binary data encoding when inserting to sqlite3. Thanks Naruse! [#6559 state:resolved] schemas set by set_table_name are respected by the mysql adapter. [#5322 state:resolved] Reapply extensions when using except and only SJIS is an alias to Windows-31J in ruby trunk. Use SHIFT_JIS for this test Improved resolver docs a bit [action_view] docs for FileSystemResolver [action_view] added custom patterns to template resolver
Diffstat (limited to 'actionpack/test/template/resolver_patterns_test.rb')
-rw-r--r--actionpack/test/template/resolver_patterns_test.rb31
1 files changed, 31 insertions, 0 deletions
diff --git a/actionpack/test/template/resolver_patterns_test.rb b/actionpack/test/template/resolver_patterns_test.rb
new file mode 100644
index 0000000000..97b1bad055
--- /dev/null
+++ b/actionpack/test/template/resolver_patterns_test.rb
@@ -0,0 +1,31 @@
+require 'abstract_unit'
+
+class ResolverPatternsTest < ActiveSupport::TestCase
+ def setup
+ path = File.expand_path("../../fixtures/", __FILE__)
+ pattern = ":prefix/{:formats/,}:action{.:formats,}{.:handlers,}"
+ @resolver = ActionView::FileSystemResolver.new(path, pattern)
+ end
+
+ def test_should_return_empty_list_for_unknown_path
+ templates = @resolver.find_all("unknown", "custom_pattern", false, {:locale => [], :formats => [:html], :handlers => [:erb]})
+ assert_equal [], templates, "expected an empty list of templates"
+ end
+
+ def test_should_return_template_for_declared_path
+ templates = @resolver.find_all("path", "custom_pattern", false, {:locale => [], :formats => [:html], :handlers => [:erb]})
+ assert_equal 1, templates.size, "expected one template"
+ assert_equal "Hello custom patterns!", templates.first.source
+ assert_equal "custom_pattern/path", templates.first.virtual_path
+ assert_equal [:html], templates.first.formats
+ end
+
+ def test_should_return_all_templates_when_ambigous_pattern
+ templates = @resolver.find_all("another", "custom_pattern", false, {:locale => [], :formats => [:html], :handlers => [:erb]})
+ assert_equal 2, templates.size, "expected two templates"
+ assert_equal "Another template!", templates[0].source
+ assert_equal "custom_pattern/another", templates[0].virtual_path
+ assert_equal "Hello custom patterns!", templates[1].source
+ assert_equal "custom_pattern/another", templates[1].virtual_path
+ end
+end