aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--actionview/CHANGELOG.md14
-rw-r--r--actionview/lib/action_view/helpers/asset_tag_helper.rb9
-rw-r--r--actionview/lib/action_view/helpers/url_helper.rb4
-rw-r--r--actionview/test/template/javascript_helper_test.rb7
-rw-r--r--activerecord/lib/active_record/associations/preloader/association.rb2
-rw-r--r--activerecord/test/cases/adapters/postgresql/datatype_test.rb2
-rw-r--r--activerecord/test/models/column_name.rb4
-rw-r--r--activesupport/test/inflector_test.rb7
-rw-r--r--guides/rails_guides/helpers.rb2
9 files changed, 38 insertions, 13 deletions
diff --git a/actionview/CHANGELOG.md b/actionview/CHANGELOG.md
index adbe8ac389..98b78a7114 100644
--- a/actionview/CHANGELOG.md
+++ b/actionview/CHANGELOG.md
@@ -1,3 +1,17 @@
+* Added an `extname` hash option for `javascript_include_tag` method.
+
+ Before:
+
+ javascript_include_tag('templates.jst')
+ # => <script src="/javascripts/templates.jst.js"></script>
+
+ After:
+
+ javascript_include_tag('templates.jst', extname: false )
+ # => <script src="/javascripts/templates.jst"></script>
+
+ *Nathan Stitt*
+
* Fix `current_page?` when the URL contains escaped characters and the
original URL is using the hexadecimal lowercased.
diff --git a/actionview/lib/action_view/helpers/asset_tag_helper.rb b/actionview/lib/action_view/helpers/asset_tag_helper.rb
index 2b3a3c6a29..a13d0021ea 100644
--- a/actionview/lib/action_view/helpers/asset_tag_helper.rb
+++ b/actionview/lib/action_view/helpers/asset_tag_helper.rb
@@ -26,7 +26,8 @@ module ActionView
# to <tt>assets/javascripts</tt>, full paths are assumed to be relative to the document
# root. Relative paths are idiomatic, use absolute paths only when needed.
#
- # When passing paths, the ".js" extension is optional.
+ # When passing paths, the ".js" extension is optional. If you do not want ".js"
+ # appended to the path <tt>extname: false</tt> can be set on the options.
#
# You can modify the HTML attributes of the script tag by passing a hash as the
# last argument.
@@ -37,6 +38,9 @@ module ActionView
# javascript_include_tag "xmlhr"
# # => <script src="/assets/xmlhr.js?1284139606"></script>
#
+ # javascript_include_tag "template.jst", extname: false
+ # # => <script src="/assets/template.jst?1284139606"></script>
+ #
# javascript_include_tag "xmlhr.js"
# # => <script src="/assets/xmlhr.js?1284139606"></script>
#
@@ -51,8 +55,7 @@ module ActionView
# # => <script src="http://www.example.com/xmlhr.js"></script>
def javascript_include_tag(*sources)
options = sources.extract_options!.stringify_keys
- path_options = options.extract!('protocol').symbolize_keys
-
+ path_options = options.extract!('protocol', 'extname').symbolize_keys
sources.uniq.map { |source|
tag_options = {
"src" => path_to_javascript(source, path_options)
diff --git a/actionview/lib/action_view/helpers/url_helper.rb b/actionview/lib/action_view/helpers/url_helper.rb
index db0fb40336..1920a94567 100644
--- a/actionview/lib/action_view/helpers/url_helper.rb
+++ b/actionview/lib/action_view/helpers/url_helper.rb
@@ -528,13 +528,13 @@ module ActionView
return false unless request.get? || request.head?
- url_string = URI.unescape(url_for(options)).force_encoding(Encoding::BINARY)
+ url_string = URI.parser.unescape(url_for(options)).force_encoding(Encoding::BINARY)
# We ignore any extra parameters in the request_uri if the
# submitted url doesn't have any either. This lets the function
# work with things like ?order=asc
request_uri = url_string.index("?") ? request.fullpath : request.path
- request_uri = URI.unescape(request_uri).force_encoding(Encoding::BINARY)
+ request_uri = URI.parser.unescape(request_uri).force_encoding(Encoding::BINARY)
if url_string =~ /^\w+:\/\//
url_string == "#{request.protocol}#{request.host_with_port}#{request_uri}"
diff --git a/actionview/test/template/javascript_helper_test.rb b/actionview/test/template/javascript_helper_test.rb
index de6a6eaab3..4703111741 100644
--- a/actionview/test/template/javascript_helper_test.rb
+++ b/actionview/test/template/javascript_helper_test.rb
@@ -51,6 +51,13 @@ class JavaScriptHelperTest < ActionView::TestCase
assert_equal 'foo', output_buffer, 'javascript_tag without a block should not concat to output_buffer'
end
+ # Setting the :extname option will control what extension (if any) is appended to the url for assets
+ def test_javascript_include_tag
+ assert_dom_equal "<script src='/foo.js'></script>", javascript_include_tag('/foo')
+ assert_dom_equal "<script src='/foo'></script>", javascript_include_tag('/foo', extname: false )
+ assert_dom_equal "<script src='/foo.bar'></script>", javascript_include_tag('/foo', extname: '.bar' )
+ end
+
def test_javascript_tag_with_options
assert_dom_equal "<script id=\"the_js_tag\">\n//<![CDATA[\nalert('hello')\n//]]>\n</script>",
javascript_tag("alert('hello')", :id => "the_js_tag")
diff --git a/activerecord/lib/active_record/associations/preloader/association.rb b/activerecord/lib/active_record/associations/preloader/association.rb
index d31f7432cd..0cc836f991 100644
--- a/activerecord/lib/active_record/associations/preloader/association.rb
+++ b/activerecord/lib/active_record/associations/preloader/association.rb
@@ -77,7 +77,7 @@ module ActiveRecord
# Some databases impose a limit on the number of ids in a list (in Oracle it's 1000)
# Make several smaller queries if necessary or make one query if the adapter supports it
sliced = owner_keys.each_slice(klass.connection.in_clause_length || owner_keys.size)
- records = sliced.map { |slice| records_for(slice).to_a }.flatten
+ records = sliced.flat_map { |slice| records_for(slice).to_a }
end
# Each record may have multiple owners, and vice-versa
diff --git a/activerecord/test/cases/adapters/postgresql/datatype_test.rb b/activerecord/test/cases/adapters/postgresql/datatype_test.rb
index 36d7294bc8..e946b8bb22 100644
--- a/activerecord/test/cases/adapters/postgresql/datatype_test.rb
+++ b/activerecord/test/cases/adapters/postgresql/datatype_test.rb
@@ -594,7 +594,7 @@ _SQL
@connection.reconnect!
@first_timestamp_with_zone = PostgresqlTimestampWithZone.find(1)
- assert_equal Time.utc(2010,1,1, 11,0,0), @first_timestamp_with_zone.time
+ assert_equal Time.local(2010,1,1, 11,0,0), @first_timestamp_with_zone.time
assert_instance_of Time, @first_timestamp_with_zone.time
ensure
ActiveRecord::Base.default_timezone = old_default_tz
diff --git a/activerecord/test/models/column_name.rb b/activerecord/test/models/column_name.rb
index ec07205a3a..460eb4fe20 100644
--- a/activerecord/test/models/column_name.rb
+++ b/activerecord/test/models/column_name.rb
@@ -1,3 +1,3 @@
class ColumnName < ActiveRecord::Base
- def self.table_name () "colnametests" end
-end \ No newline at end of file
+ self.table_name = "colnametests"
+end
diff --git a/activesupport/test/inflector_test.rb b/activesupport/test/inflector_test.rb
index f3bf29881c..1bb2d7e920 100644
--- a/activesupport/test/inflector_test.rb
+++ b/activesupport/test/inflector_test.rb
@@ -76,9 +76,10 @@ class InflectorTest < ActiveSupport::TestCase
ActiveSupport::Inflector.inflections.uncountable "series" # Return to normal
end
- MixtureToTitleCase.each do |before, titleized|
- define_method "test_titleize_#{before}" do
- assert_equal(titleized, ActiveSupport::Inflector.titleize(before))
+ MixtureToTitleCase.each_with_index do |(before, titleized), index|
+ define_method "test_titleize_mixture_to_title_case_#{index}" do
+ assert_equal(titleized, ActiveSupport::Inflector.titleize(before), "mixture \
+ to TitleCase failed for #{before}")
end
end
diff --git a/guides/rails_guides/helpers.rb b/guides/rails_guides/helpers.rb
index a288d0f0f4..760b196abd 100644
--- a/guides/rails_guides/helpers.rb
+++ b/guides/rails_guides/helpers.rb
@@ -17,7 +17,7 @@ module RailsGuides
end
def documents_flat
- documents_by_section.map {|section| section['documents']}.flatten
+ documents_by_section.flat_map {|section| section['documents']}
end
def finished_documents(documents)