aboutsummaryrefslogtreecommitdiffstats
path: root/actionview/test
diff options
context:
space:
mode:
authorRafael Mendonça França <rafael@franca.dev>2019-07-25 22:24:31 -0400
committerRafael Mendonça França <rafael@franca.dev>2019-07-25 22:24:31 -0400
commit64f4d7fcb00bdbdfa20f306f863914bc2c8e292b (patch)
treee0acdbc549fb92e539bdf0fd67dc9e00dab3bbe3 /actionview/test
parent30757a16923e0afaa38388975b195ae7cf119f4c (diff)
parent92af4aba25057850a0d80cf5c1a3d1eb4e2576b9 (diff)
downloadrails-64f4d7fcb00bdbdfa20f306f863914bc2c8e292b.tar.gz
rails-64f4d7fcb00bdbdfa20f306f863914bc2c8e292b.tar.bz2
rails-64f4d7fcb00bdbdfa20f306f863914bc2c8e292b.zip
Merge pull request #36576 from mtsmfm/mtsmfm/fix-fixture-resolver
Support :any variants for ActionView::FixtureResolver
Diffstat (limited to 'actionview/test')
-rw-r--r--actionview/test/template/testing/fixture_resolver_test.rb22
1 files changed, 22 insertions, 0 deletions
diff --git a/actionview/test/template/testing/fixture_resolver_test.rb b/actionview/test/template/testing/fixture_resolver_test.rb
index 6d0317e0c9..a6066e94c6 100644
--- a/actionview/test/template/testing/fixture_resolver_test.rb
+++ b/actionview/test/template/testing/fixture_resolver_test.rb
@@ -27,4 +27,26 @@ class FixtureResolverTest < ActiveSupport::TestCase
assert_equal :html, templates.first.format
assert_equal "variant", templates.first.variant
end
+
+ def test_should_match_locales
+ resolver = ActionView::FixtureResolver.new("arbitrary/path.erb" => "this text", "arbitrary/path.fr.erb" => "ce texte")
+ en = resolver.find_all("path", "arbitrary", false, locale: [:en], formats: [:html], variants: [], handlers: [:erb])
+ fr = resolver.find_all("path", "arbitrary", false, locale: [:fr], formats: [:html], variants: [], handlers: [:erb])
+
+ assert_equal 1, en.size
+ assert_equal 2, fr.size
+
+ assert_equal "this text", en[0].source
+ assert_equal "ce texte", fr[0].source
+ assert_equal "this text", fr[1].source
+ end
+
+ def test_should_return_all_variants_for_any
+ resolver = ActionView::FixtureResolver.new("arbitrary/path.html.erb" => "this html", "arbitrary/path.html+varient.erb" => "this text")
+ templates = resolver.find_all("path", "arbitrary", false, locale: [], formats: [:html], variants: [], handlers: [:erb])
+ assert_equal 1, templates.size, "expected one template"
+ assert_equal "this html", templates.first.source
+ templates = resolver.find_all("path", "arbitrary", false, locale: [], formats: [:html], variants: :any, handlers: [:erb])
+ assert_equal 2, templates.size, "expected all templates"
+ end
end