aboutsummaryrefslogtreecommitdiffstats
path: root/actionview/test
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2019-02-25 13:18:44 -0800
committerAaron Patterson <aaron.patterson@gmail.com>2019-02-25 13:18:44 -0800
commitca5e23ed4d8818d81314953aadd422b2cbde63b0 (patch)
treea411836c47d0ac22af072ec580656e983954d131 /actionview/test
parentd1f68b50487ea1a8fc7f822973e2cc46d1288060 (diff)
downloadrails-ca5e23ed4d8818d81314953aadd422b2cbde63b0.tar.gz
rails-ca5e23ed4d8818d81314953aadd422b2cbde63b0.tar.bz2
rails-ca5e23ed4d8818d81314953aadd422b2cbde63b0.zip
Templates have one format
Templates only have one format. Before this commit, templates would be constructed with a single element array that contained the format. This commit eliminates the single element array and just implements a `format` method. This saves one array allocation per template.
Diffstat (limited to 'actionview/test')
-rw-r--r--actionview/test/actionpack/controller/view_paths_test.rb2
-rw-r--r--actionview/test/template/digestor_test.rb2
-rw-r--r--actionview/test/template/html_test.rb6
-rw-r--r--actionview/test/template/lookup_context_test.rb2
-rw-r--r--actionview/test/template/resolver_patterns_test.rb2
-rw-r--r--actionview/test/template/testing/fixture_resolver_test.rb2
-rw-r--r--actionview/test/template/testing/null_resolver_test.rb2
-rw-r--r--actionview/test/template/text_test.rb2
8 files changed, 10 insertions, 10 deletions
diff --git a/actionview/test/actionpack/controller/view_paths_test.rb b/actionview/test/actionpack/controller/view_paths_test.rb
index c5238dd746..a7a58a78cc 100644
--- a/actionview/test/actionpack/controller/view_paths_test.rb
+++ b/actionview/test/actionpack/controller/view_paths_test.rb
@@ -144,7 +144,7 @@ class ViewLoadPathsTest < ActionController::TestCase
template.identifier,
template.handler,
virtual_path: template.virtual_path,
- format: template.formats
+ format: template.format
)
end
end
diff --git a/actionview/test/template/digestor_test.rb b/actionview/test/template/digestor_test.rb
index 91861edf11..7affd3c005 100644
--- a/actionview/test/template/digestor_test.rb
+++ b/actionview/test/template/digestor_test.rb
@@ -361,7 +361,7 @@ class TemplateDigestorTest < ActionView::TestCase
def tree_template_formats(template_name)
tree = ActionView::Digestor.tree(template_name, finder)
- tree.flatten.map(&:template).compact.flat_map(&:formats)
+ tree.flatten.map(&:template).compact.map(&:format)
end
def disable_resolver_caching
diff --git a/actionview/test/template/html_test.rb b/actionview/test/template/html_test.rb
index 5cdff74d60..c5fc8f906c 100644
--- a/actionview/test/template/html_test.rb
+++ b/actionview/test/template/html_test.rb
@@ -4,16 +4,16 @@ require "abstract_unit"
class HTMLTest < ActiveSupport::TestCase
test "formats returns symbol for recognized MIME type" do
- assert_equal [:html], ActionView::Template::HTML.new("", :html).formats
+ assert_equal :html, ActionView::Template::HTML.new("", :html).format
end
test "formats returns string for recognized MIME type when MIME does not have symbol" do
foo = Mime::Type.lookup("foo")
assert_nil foo.to_sym
- assert_equal ["foo"], ActionView::Template::HTML.new("", foo).formats
+ assert_equal "foo", ActionView::Template::HTML.new("", foo).format
end
test "formats returns string for unknown MIME type" do
- assert_equal ["foo"], ActionView::Template::HTML.new("", "foo").formats
+ assert_equal "foo", ActionView::Template::HTML.new("", "foo").format
end
end
diff --git a/actionview/test/template/lookup_context_test.rb b/actionview/test/template/lookup_context_test.rb
index 5298afb694..a763e24226 100644
--- a/actionview/test/template/lookup_context_test.rb
+++ b/actionview/test/template/lookup_context_test.rb
@@ -125,7 +125,7 @@ class LookupContextTest < ActiveSupport::TestCase
assert_called(ActionView::Template::Handlers::Builder, :default_format, returns: nil) do
@lookup_context.formats = [:text]
template = @lookup_context.find("hello", %w(test))
- assert_equal [:text], template.formats
+ assert_equal :text, template.format
end
end
diff --git a/actionview/test/template/resolver_patterns_test.rb b/actionview/test/template/resolver_patterns_test.rb
index 1e1a4c5063..38357aa10b 100644
--- a/actionview/test/template/resolver_patterns_test.rb
+++ b/actionview/test/template/resolver_patterns_test.rb
@@ -19,7 +19,7 @@ class ResolverPatternsTest < ActiveSupport::TestCase
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
+ assert_equal :html, templates.first.format
end
def test_should_return_all_templates_when_ambiguous_pattern
diff --git a/actionview/test/template/testing/fixture_resolver_test.rb b/actionview/test/template/testing/fixture_resolver_test.rb
index 9954e3500d..4361824a71 100644
--- a/actionview/test/template/testing/fixture_resolver_test.rb
+++ b/actionview/test/template/testing/fixture_resolver_test.rb
@@ -15,6 +15,6 @@ class FixtureResolverTest < ActiveSupport::TestCase
assert_equal 1, templates.size, "expected one template"
assert_equal "this text", templates.first.source
assert_equal "arbitrary/path", templates.first.virtual_path
- assert_equal [:html], templates.first.formats
+ assert_equal :html, templates.first.format
end
end
diff --git a/actionview/test/template/testing/null_resolver_test.rb b/actionview/test/template/testing/null_resolver_test.rb
index 53364c1d90..dad8d0966d 100644
--- a/actionview/test/template/testing/null_resolver_test.rb
+++ b/actionview/test/template/testing/null_resolver_test.rb
@@ -9,6 +9,6 @@ class NullResolverTest < ActiveSupport::TestCase
assert_equal 1, templates.size, "expected one template"
assert_equal "Template generated by Null Resolver", templates.first.source
assert_equal "arbitrary/path.erb", templates.first.virtual_path.to_s
- assert_equal [:html], templates.first.formats
+ assert_equal :html, templates.first.format
end
end
diff --git a/actionview/test/template/text_test.rb b/actionview/test/template/text_test.rb
index 0c6470df21..e7e3b6aae8 100644
--- a/actionview/test/template/text_test.rb
+++ b/actionview/test/template/text_test.rb
@@ -4,7 +4,7 @@ require "abstract_unit"
class TextTest < ActiveSupport::TestCase
test "formats always return :text" do
- assert_equal [:text], ActionView::Template::Text.new("").formats
+ assert_equal :text, ActionView::Template::Text.new("").format
end
test "identifier should return 'text template'" do