aboutsummaryrefslogtreecommitdiffstats
path: root/actionview/test/template/resolver_patterns_test.rb
diff options
context:
space:
mode:
authorPiotr Sarnacki <drogus@gmail.com>2013-04-17 00:06:11 +0200
committerŁukasz Strzałkowski <lukasz.strzalkowski@gmail.com>2013-06-20 17:23:16 +0200
commiteb23754ebbfbf2d465cc0f900720704fb3703633 (patch)
tree5bd1764233b59075341611b1e857d418c794d812 /actionview/test/template/resolver_patterns_test.rb
parent5bcdf4faa6da7acb762dab680372f8520a0533c2 (diff)
downloadrails-eb23754ebbfbf2d465cc0f900720704fb3703633.tar.gz
rails-eb23754ebbfbf2d465cc0f900720704fb3703633.tar.bz2
rails-eb23754ebbfbf2d465cc0f900720704fb3703633.zip
Move template tests from actionpack to actionview
Diffstat (limited to 'actionview/test/template/resolver_patterns_test.rb')
-rw-r--r--actionview/test/template/resolver_patterns_test.rb31
1 files changed, 31 insertions, 0 deletions
diff --git a/actionview/test/template/resolver_patterns_test.rb b/actionview/test/template/resolver_patterns_test.rb
new file mode 100644
index 0000000000..97b1bad055
--- /dev/null
+++ b/actionview/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