diff options
Diffstat (limited to 'actionview')
-rw-r--r-- | actionview/CHANGELOG.md | 35 | ||||
-rw-r--r-- | actionview/lib/action_view/gem_version.rb | 2 | ||||
-rw-r--r-- | actionview/lib/action_view/helpers/translation_helper.rb | 10 | ||||
-rw-r--r-- | actionview/lib/action_view/railtie.rb | 1 | ||||
-rw-r--r-- | actionview/lib/action_view/record_identifier.rb | 17 | ||||
-rw-r--r-- | actionview/test/template/asset_tag_helper_test.rb | 2 | ||||
-rw-r--r-- | actionview/test/template/translation_helper_test.rb | 10 | ||||
-rw-r--r-- | actionview/test/template/url_helper_test.rb | 9 |
8 files changed, 56 insertions, 30 deletions
diff --git a/actionview/CHANGELOG.md b/actionview/CHANGELOG.md index 0981d47d7a..a43d9039db 100644 --- a/actionview/CHANGELOG.md +++ b/actionview/CHANGELOG.md @@ -1,3 +1,14 @@ +## Rails 5.0.0.beta1 (December 18, 2015) ## + +* `I18n.translate` helper will wrap the missing translation keys + in a <span> tag only if `debug_missing_translation` configuration + be true. Default value is `true`. For example in `application.rb`: + + # in order to turn off missing key wrapping + config.action_view.debug_missing_translation = false + + *Sameer Rahmani* + * Respect value of `:object` if `:object` is false when rendering. Fixes #22260. @@ -35,16 +46,16 @@ *Bernerd Schaefer* -* `number_to_currency` and `number_with_delimiter` now accept custom `delimiter_pattern` option - to handle placement of delimiter, to support currency formats like INR - - Example: - +* `number_to_currency` and `number_with_delimiter` now accept a custom `delimiter_pattern` option + to handle placement of delimiter, to support currency formats like INR. + + Example: + number_to_currency(1230000, delimiter_pattern: /(\d+?)(?=(\d\d)+(\d)(?!\d))/, unit: '₹', format: "%u %n") - # => '₹ 12,30,000.00' - + # => '₹ 12,30,000.00' + *Vipul A M* - + * Make `disable_with` the default behavior for submit tags. Disables the button on submit to prevent double submits. @@ -86,7 +97,7 @@ Which could happen if the rendering was done directly in the controller and not in a template. - Fixes #20535 + Fixes #20535. *Roque Pinel* @@ -95,7 +106,7 @@ *Dov Murik* -* Raise an ArgumentError when a false value for `include_blank` is passed to a +* Raise an `ArgumentError` when a false value for `include_blank` is passed to a required select field (to comply with the HTML5 spec). *Grey Baker* @@ -113,7 +124,7 @@ * `translate` should handle `raise` flag correctly in case of both main and default translation is missing. - Fixes #19967 + Fixes #19967. *Bernard Potocki* @@ -135,7 +146,7 @@ * `translate` should accept nils as members of the `:default` parameter without raising a translation missing error. - Fixes #19419 + Fixes #19419. *Justin Coyne* diff --git a/actionview/lib/action_view/gem_version.rb b/actionview/lib/action_view/gem_version.rb index 4f45f5b8c8..20d408741e 100644 --- a/actionview/lib/action_view/gem_version.rb +++ b/actionview/lib/action_view/gem_version.rb @@ -8,7 +8,7 @@ module ActionView MAJOR = 5 MINOR = 0 TINY = 0 - PRE = "alpha" + PRE = "beta1" STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".") end diff --git a/actionview/lib/action_view/helpers/translation_helper.rb b/actionview/lib/action_view/helpers/translation_helper.rb index 4c4d2c4457..152e1b1211 100644 --- a/actionview/lib/action_view/helpers/translation_helper.rb +++ b/actionview/lib/action_view/helpers/translation_helper.rb @@ -6,7 +6,15 @@ module ActionView # = Action View Translation Helpers module Helpers module TranslationHelper + extend ActiveSupport::Concern + include TagHelper + + included do + mattr_accessor :debug_missing_translation + self.debug_missing_translation = true + end + # Delegates to <tt>I18n#translate</tt> but also performs three additional # functions. # @@ -95,6 +103,8 @@ module ActionView title << ", " << interpolations.map { |k, v| "#{k}: #{ERB::Util.html_escape(v)}" }.join(', ') end + return title unless ActionView::Base.debug_missing_translation + content_tag('span', keys.last.to_s.titleize, class: 'translation_missing', title: title) end end diff --git a/actionview/lib/action_view/railtie.rb b/actionview/lib/action_view/railtie.rb index e829d86c99..59d869d92d 100644 --- a/actionview/lib/action_view/railtie.rb +++ b/actionview/lib/action_view/railtie.rb @@ -6,6 +6,7 @@ module ActionView class Railtie < Rails::Railtie # :nodoc: config.action_view = ActiveSupport::OrderedOptions.new config.action_view.embed_authenticity_token_in_remote_forms = false + config.action_view.debug_missing_translation = true config.eager_load_namespaces << ActionView diff --git a/actionview/lib/action_view/record_identifier.rb b/actionview/lib/action_view/record_identifier.rb index 4b44eb5520..4a2547b0fb 100644 --- a/actionview/lib/action_view/record_identifier.rb +++ b/actionview/lib/action_view/record_identifier.rb @@ -5,24 +5,25 @@ module ActionView # RecordIdentifier encapsulates methods used by various ActionView helpers # to associate records with DOM elements. # - # Consider for example the following code that displays the body of a post: + # Consider for example the following code that form of post: # - # <%= div_for(post) do %> - # <%= post.body %> + # <%= form_for(post) do |f| %> + # <%= f.text_field :body %> # <% end %> # # When +post+ is a new, unsaved ActiveRecord::Base instance, the resulting HTML # is: # - # <div id="new_post" class="post"> - # </div> + # <form class="new_post" id="new_post" action="/posts" accept-charset="UTF-8" method="post"> + # <input type="text" name="post[body]" id="post_body" /> + # </form> # # When +post+ is a persisted ActiveRecord::Base instance, the resulting HTML # is: # - # <div id="post_42" class="post"> - # What a wonderful world! - # </div> + # <form class="edit_post" id="edit_post_42" action="/posts/42" accept-charset="UTF-8" method="post"> + # <input type="text" value="What a wonderful world!" name="post[body]" id="post_body" /> + # </form> # # In both cases, the +id+ and +class+ of the wrapping DOM element are # automatically generated, following naming conventions encapsulated by the diff --git a/actionview/test/template/asset_tag_helper_test.rb b/actionview/test/template/asset_tag_helper_test.rb index fe40010528..8592a2a083 100644 --- a/actionview/test/template/asset_tag_helper_test.rb +++ b/actionview/test/template/asset_tag_helper_test.rb @@ -27,6 +27,8 @@ class AssetTagHelperTest < ActionView::TestCase end AssetPathToTag = { + %(asset_path("")) => %(), + %(asset_path(" ")) => %(), %(asset_path("foo")) => %(/foo), %(asset_path("style.css")) => %(/style.css), %(asset_path("xmlhr.js")) => %(/xmlhr.js), diff --git a/actionview/test/template/translation_helper_test.rb b/actionview/test/template/translation_helper_test.rb index 631bceadd8..597936d7ae 100644 --- a/actionview/test/template/translation_helper_test.rb +++ b/actionview/test/template/translation_helper_test.rb @@ -54,6 +54,16 @@ class TranslationHelperTest < ActiveSupport::TestCase end end + def test_returns_missing_tranlation_message_without_span_wrap + old_value = ActionView::Base.debug_missing_translation + ActionView::Base.debug_missing_translation = false + + expected = 'translation missing: en.translations.missing' + assert_equal expected, translate(:"translations.missing") + ensure + ActionView::Base.debug_missing_translation = old_value + end + def test_returns_missing_translation_message_wrapped_into_span expected = '<span class="translation_missing" title="translation missing: en.translations.missing">Missing</span>' assert_equal expected, translate(:"translations.missing") diff --git a/actionview/test/template/url_helper_test.rb b/actionview/test/template/url_helper_test.rb index 62fa75bc63..784a48ed8d 100644 --- a/actionview/test/template/url_helper_test.rb +++ b/actionview/test/template/url_helper_test.rb @@ -636,10 +636,6 @@ class UrlHelperControllerTest < ActionController::TestCase render inline: "<%= url_for controller: 'url_helper_controller_test/url_helper', action: 'show_url_for' %>" end - def show_overridden_url_for - render inline: "<%= url_for params.merge(controller: 'url_helper_controller_test/url_helper', action: 'show_url_for') %>" - end - def show_named_route render inline: "<%= show_named_route_#{params[:kind]} %>" end @@ -673,11 +669,6 @@ class UrlHelperControllerTest < ActionController::TestCase assert_equal '/url_helper_controller_test/url_helper/show_url_for', @response.body end - def test_overridden_url_for_shows_only_path - get :show_overridden_url_for - assert_equal '/url_helper_controller_test/url_helper/show_url_for', @response.body - end - def test_named_route_url_shows_host_and_path get :show_named_route, params: { kind: 'url' } assert_equal 'http://test.host/url_helper_controller_test/url_helper/show_named_route', |