diff options
-rw-r--r-- | actionview/CHANGELOG.md | 14 | ||||
-rw-r--r-- | actionview/lib/action_view/helpers/asset_tag_helper.rb | 9 | ||||
-rw-r--r-- | actionview/lib/action_view/helpers/text_helper.rb | 10 | ||||
-rw-r--r-- | actionview/lib/action_view/helpers/url_helper.rb | 4 | ||||
-rw-r--r-- | actionview/test/template/javascript_helper_test.rb | 7 | ||||
-rw-r--r-- | activerecord/lib/active_record/associations/preloader/association.rb | 2 | ||||
-rw-r--r-- | activerecord/test/cases/adapters/postgresql/datatype_test.rb | 2 | ||||
-rw-r--r-- | activerecord/test/models/column_name.rb | 4 | ||||
-rw-r--r-- | activesupport/test/inflector_test.rb | 7 | ||||
-rw-r--r-- | guides/rails_guides/helpers.rb | 2 | ||||
-rw-r--r-- | guides/source/association_basics.md | 5 | ||||
-rw-r--r-- | guides/source/i18n.md | 2 |
12 files changed, 48 insertions, 20 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/text_helper.rb b/actionview/lib/action_view/helpers/text_helper.rb index e3d4eb1d74..3fc64fa8a5 100644 --- a/actionview/lib/action_view/helpers/text_helper.rb +++ b/actionview/lib/action_view/helpers/text_helper.rb @@ -157,10 +157,12 @@ module ActionView return unless matches = text.match(regex) phrase = matches[0] - text.split(separator).each do |value| - if value.match(regex) - regex = phrase = value - break + unless separator.empty? + text.split(separator).each do |value| + if value.match(regex) + regex = phrase = value + break + end end end 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) diff --git a/guides/source/association_basics.md b/guides/source/association_basics.md index e6a66f3fa1..9b80a65a44 100644 --- a/guides/source/association_basics.md +++ b/guides/source/association_basics.md @@ -1944,8 +1944,8 @@ While Rails uses intelligent defaults that will work well in most situations, th ```ruby class Parts < ActiveRecord::Base - has_and_belongs_to_many :assemblies, uniq: true, - read_only: true + has_and_belongs_to_many :assemblies, autosave: true, + readonly: true end ``` @@ -1957,6 +1957,7 @@ The `has_and_belongs_to_many` association supports these options: * `:foreign_key` * `:join_table` * `:validate` +* `:readonly` ##### `:association_foreign_key` diff --git a/guides/source/i18n.md b/guides/source/i18n.md index 046c7543f3..facfb96d98 100644 --- a/guides/source/i18n.md +++ b/guides/source/i18n.md @@ -97,7 +97,7 @@ en: hello: "Hello world" ``` -This means, that in the `:en` locale, the key _hello_ will map to the _Hello world_ string. Every string inside Rails is internationalized in this way, see for instance Active Record validation messages in the [`activerecord/lib/active_record/locale/en.yml`](https://github.com/rails/rails/blob/master/activerecord/lib/active_record/locale/en.yml) file or time and date formats in the [`activesupport/lib/active_support/locale/en.yml`](https://github.com/rails/rails/blob/master/activesupport/lib/active_support/locale/en.yml) file. You can use YAML or standard Ruby Hashes to store translations in the default (Simple) backend. +This means, that in the `:en` locale, the key _hello_ will map to the _Hello world_ string. Every string inside Rails is internationalized in this way, see for instance Active Model validation messages in the [`activemodel/lib/active_model/locale/en.yml`](https://github.com/rails/rails/blob/master/activemodel/lib/active_model/locale/en.yml) file or time and date formats in the [`activesupport/lib/active_support/locale/en.yml`](https://github.com/rails/rails/blob/master/activesupport/lib/active_support/locale/en.yml) file. You can use YAML or standard Ruby Hashes to store translations in the default (Simple) backend. The I18n library will use **English** as a **default locale**, i.e. if you don't set a different locale, `:en` will be used for looking up translations. |