diff options
Diffstat (limited to 'actionview')
-rw-r--r-- | actionview/Rakefile | 2 | ||||
-rw-r--r-- | actionview/lib/action_view/helpers/tags/base.rb | 2 | ||||
-rw-r--r-- | actionview/lib/action_view/test_case.rb | 2 | ||||
-rw-r--r-- | actionview/package.json | 2 | ||||
-rw-r--r-- | actionview/test/template/form_collections_helper_test.rb | 14 | ||||
-rw-r--r-- | actionview/test/template/test_case_test.rb | 8 | ||||
-rw-r--r-- | actionview/test/ujs/public/test/data-confirm.js | 2 | ||||
-rw-r--r-- | actionview/test/ujs/public/test/data-remote.js | 2 |
8 files changed, 29 insertions, 5 deletions
diff --git a/actionview/Rakefile b/actionview/Rakefile index 0d974cb087..20dfa4e114 100644 --- a/actionview/Rakefile +++ b/actionview/Rakefile @@ -37,7 +37,7 @@ namespace :test do start_time = Time.now loop do - break if system("lsof -i :4567 >/dev/null") + break if system("lsof -i :4567", 1 => File::NULL) if Time.now - start_time > 5 puts "Timed out after 5 seconds" diff --git a/actionview/lib/action_view/helpers/tags/base.rb b/actionview/lib/action_view/helpers/tags/base.rb index bbb8c4d224..922d4c5390 100644 --- a/actionview/lib/action_view/helpers/tags/base.rb +++ b/actionview/lib/action_view/helpers/tags/base.rb @@ -138,7 +138,7 @@ module ActionView end def sanitized_value(value) - value.to_s.gsub(/\s/, "_").gsub(/[^-\w]/, "").downcase + value.to_s.gsub(/\s/, "_").gsub(/[^-[[:word:]]]/, "").mb_chars.downcase.to_s end def select_content_tag(option_tags, options, html_options) diff --git a/actionview/lib/action_view/test_case.rb b/actionview/lib/action_view/test_case.rb index 8542978e34..efe8c87b9b 100644 --- a/actionview/lib/action_view/test_case.rb +++ b/actionview/lib/action_view/test_case.rb @@ -103,6 +103,7 @@ module ActionView def setup_with_controller @controller = ActionView::TestCase::TestController.new @request = @controller.request + @view_flow = ActionView::OutputFlow.new # empty string ensures buffer has UTF-8 encoding as # new without arguments returns ASCII-8BIT encoded buffer like String#new @output_buffer = ActiveSupport::SafeBuffer.new "" @@ -246,6 +247,7 @@ module ActionView :@test_passed, :@view, :@view_context_class, + :@view_flow, :@_subscribers, :@html_document ] diff --git a/actionview/package.json b/actionview/package.json index 85f4ddacbe..4cbf0207e5 100644 --- a/actionview/package.json +++ b/actionview/package.json @@ -12,7 +12,7 @@ "scripts": { "build": "bundle exec blade build", "test": "echo \"See the README: https://github.com/rails/rails/blob/master/actionview/app/assets/javascripts#how-to-run-tests\" && exit 1", - "lint": "coffeelint app/assets/javascripts && eslint test/public/test" + "lint": "coffeelint app/assets/javascripts && eslint test/ujs/public/test" }, "repository": { "type": "git", diff --git a/actionview/test/template/form_collections_helper_test.rb b/actionview/test/template/form_collections_helper_test.rb index aa72621c7d..bba529a98a 100644 --- a/actionview/test/template/form_collections_helper_test.rb +++ b/actionview/test/template/form_collections_helper_test.rb @@ -39,6 +39,13 @@ class FormCollectionsHelperTest < ActionView::TestCase assert_select "label[for=user_active_no]", "No" end + test "collection radio generates labels for non-English values correctly" do + with_collection_radio_buttons :user, :title, ["Господин", "Госпожа"], :to_s, :to_s + + assert_select "input[type=radio]#user_title_господин" + assert_select "label[for=user_title_господин]", "Господин" + end + test "collection radio should sanitize collection values for labels correctly" do with_collection_radio_buttons :user, :name, ["$0.99", "$1.99"], :to_s, :to_s assert_select "label[for=user_name_099]", "$0.99" @@ -299,6 +306,13 @@ class FormCollectionsHelperTest < ActionView::TestCase assert_select "label[for=user_name_199]", "$1.99" end + test "collection check boxes generates labels for non-English values correctly" do + with_collection_check_boxes :user, :title, ["Господин", "Госпожа"], :to_s, :to_s + + assert_select "input[type=checkbox]#user_title_господин" + assert_select "label[for=user_title_господин]", "Господин" + end + test "collection check boxes accepts html options as the last element of array" do collection = [[1, "Category 1", { class: "foo" }], [2, "Category 2", { class: "bar" }]] with_collection_check_boxes :user, :active, collection, :first, :second diff --git a/actionview/test/template/test_case_test.rb b/actionview/test/template/test_case_test.rb index f2f64ffa71..05e5f21ce4 100644 --- a/actionview/test/template/test_case_test.rb +++ b/actionview/test/template/test_case_test.rb @@ -282,6 +282,14 @@ module ActionView @customers = [DeveloperStruct.new("Eloy"), DeveloperStruct.new("Manfred")] assert_match(/Hello: EloyHello: Manfred/, render(file: "test/list")) end + + test "is able to use helpers that depend on the view flow" do + assert_not content_for?(:foo) + + content_for :foo, "bar" + assert content_for?(:foo) + assert_equal "bar", content_for(:foo) + end end class AssertionsTest < ActionView::TestCase diff --git a/actionview/test/ujs/public/test/data-confirm.js b/actionview/test/ujs/public/test/data-confirm.js index 229b9e1466..d1ea82ea7e 100644 --- a/actionview/test/ujs/public/test/data-confirm.js +++ b/actionview/test/ujs/public/test/data-confirm.js @@ -300,7 +300,7 @@ asyncTest('clicking on the children of a disabled button should not trigger a co window.confirm = function(msg) { message = msg; return false } $('button[data-confirm][disabled]') - .html("<strong>Click me</strong>") + .html('<strong>Click me</strong>') .bindNative('confirm', function() { App.assertCallbackNotInvoked('confirm') }) diff --git a/actionview/test/ujs/public/test/data-remote.js b/actionview/test/ujs/public/test/data-remote.js index 161a92ac11..9bbefc18f2 100644 --- a/actionview/test/ujs/public/test/data-remote.js +++ b/actionview/test/ujs/public/test/data-remote.js @@ -411,7 +411,7 @@ asyncTest('form buttons should only be serialized when clicked', 4, function() { asyncTest('changing a select option without "data-url" attribute still fires ajax request to current location', 1, function() { var currentLocation, ajaxLocation - buildSelect({'data-url': ''}); + buildSelect({'data-url': ''}) $('select[data-remote]') .bindNative('ajax:beforeSend', function(e, xhr, settings) { |