aboutsummaryrefslogtreecommitdiffstats
path: root/actionview/test
diff options
context:
space:
mode:
Diffstat (limited to 'actionview/test')
-rw-r--r--actionview/test/template/form_helper/form_with_test.rb3
-rw-r--r--actionview/test/template/form_helper_test.rb10
-rw-r--r--actionview/test/template/form_tag_helper_test.rb17
-rw-r--r--actionview/test/ujs/config.ru4
-rw-r--r--actionview/test/ujs/server.rb26
5 files changed, 34 insertions, 26 deletions
diff --git a/actionview/test/template/form_helper/form_with_test.rb b/actionview/test/template/form_helper/form_with_test.rb
index 08c685b00f..3a91c7dce7 100644
--- a/actionview/test/template/form_helper/form_with_test.rb
+++ b/actionview/test/template/form_helper/form_with_test.rb
@@ -339,7 +339,7 @@ class FormWithActsLikeFormForTest < FormWithTest
def test_form_with_only_url_on_update
form_with(url: "/posts/123") do |f|
- concat f.label :title, 'Label me'
+ concat f.label :title, "Label me"
concat f.text_field :title
end
@@ -965,7 +965,6 @@ class FormWithActsLikeFormForTest < FormWithTest
assert_dom_equal expected, output_buffer
end
-
def test_nested_fields
@comment.body = "Hello World"
form_with(model: @post) do |f|
diff --git a/actionview/test/template/form_helper_test.rb b/actionview/test/template/form_helper_test.rb
index 4850bc390b..2bc0434771 100644
--- a/actionview/test/template/form_helper_test.rb
+++ b/actionview/test/template/form_helper_test.rb
@@ -1829,9 +1829,9 @@ class FormHelperTest < ActionView::TestCase
obj = Class.new do
private
- def private_property
- raise "This method should not be called."
- end
+ def private_property
+ raise "This method should not be called."
+ end
end.new
form_for(obj, as: "other_name", url: "/", html: { id: "edit-other-name" }) do |f|
@@ -2262,11 +2262,13 @@ class FormHelperTest < ActionView::TestCase
concat f.fields_for("comment[]", @comment) { |c|
concat c.text_field(:name)
}
+ concat f.text_field(:body)
end
expected = whole_form("/posts/123", "edit_post[]", "edit_post[]", method: "patch") do
"<input name='post[123][title]' type='text' id='post_123_title' value='Hello World' />" +
- "<input name='post[123][comment][][name]' type='text' id='post_123_comment__name' value='new comment' />"
+ "<input name='post[123][comment][][name]' type='text' id='post_123_comment__name' value='new comment' />" +
+ "<input name='post[123][body]' type='text' id='post_123_body' value='Back to the hill and over it again!' />"
end
assert_dom_equal expected, output_buffer
diff --git a/actionview/test/template/form_tag_helper_test.rb b/actionview/test/template/form_tag_helper_test.rb
index 088f5ae122..084c540139 100644
--- a/actionview/test/template/form_tag_helper_test.rb
+++ b/actionview/test/template/form_tag_helper_test.rb
@@ -510,6 +510,13 @@ class FormTagHelperTest < ActionView::TestCase
)
end
+ def test_submit_tag_doesnt_have_data_disable_with_twice_with_hash
+ assert_equal(
+ %(<input type="submit" name="commit" value="Save" data-disable-with="Processing..." />),
+ submit_tag("Save", data: { disable_with: "Processing..." })
+ )
+ end
+
def test_submit_tag_with_symbol_value
assert_dom_equal(
%(<input data-disable-with="Save" name='commit' type="submit" value="Save" />),
@@ -694,31 +701,31 @@ class FormTagHelperTest < ActionView::TestCase
def test_text_area_tag_options_symbolize_keys_side_effects
options = { option: "random_option" }
text_area_tag "body", "hello world", options
- assert_equal({option: "random_option"}, options)
+ assert_equal({ option: "random_option" }, options)
end
def test_submit_tag_options_symbolize_keys_side_effects
options = { option: "random_option" }
submit_tag "submit value", options
- assert_equal({option: "random_option"}, options)
+ assert_equal({ option: "random_option" }, options)
end
def test_button_tag_options_symbolize_keys_side_effects
options = { option: "random_option" }
button_tag "button value", options
- assert_equal({option: "random_option"}, options)
+ assert_equal({ option: "random_option" }, options)
end
def test_image_submit_tag_options_symbolize_keys_side_effects
options = { option: "random_option" }
image_submit_tag "submit source", options
- assert_equal({option: "random_option"}, options)
+ assert_equal({ option: "random_option" }, options)
end
def test_image_label_tag_options_symbolize_keys_side_effects
options = { option: "random_option" }
label_tag "submit source", "title", options
- assert_equal({option: "random_option"}, options)
+ assert_equal({ option: "random_option" }, options)
end
def protect_against_forgery?
diff --git a/actionview/test/ujs/config.ru b/actionview/test/ujs/config.ru
index cb961dc140..414c2063c3 100644
--- a/actionview/test/ujs/config.ru
+++ b/actionview/test/ujs/config.ru
@@ -1,3 +1,3 @@
-$LOAD_PATH.unshift File.expand_path('..', __FILE__)
-require 'server'
+$LOAD_PATH.unshift File.expand_path("..", __FILE__)
+require "server"
run UJS::Server
diff --git a/actionview/test/ujs/server.rb b/actionview/test/ujs/server.rb
index cc02cd8419..25f70baf5f 100644
--- a/actionview/test/ujs/server.rb
+++ b/actionview/test/ujs/server.rb
@@ -12,7 +12,7 @@ module UJS
get "/rails-ujs.js" => Blade::Assets.environment
get "/" => "tests#index"
match "/echo" => "tests#echo", via: :all
- get "/error" => proc {|env| [403, {}, []] }
+ get "/error" => proc { |env| [403, {}, []] }
end
config.cache_classes = false
@@ -26,7 +26,7 @@ module UJS
end
module TestsHelper
- def jquery_link version
+ def jquery_link(version)
if params[:version] == version
"[#{version}]"
else
@@ -34,7 +34,7 @@ module TestsHelper
end
end
- def cdn_link cdn
+ def cdn_link(cdn)
if params[:cdn] == cdn
"[#{cdn}]"
else
@@ -43,22 +43,22 @@ module TestsHelper
end
def jquery_src
- if params[:version] == 'edge'
+ if params[:version] == "edge"
"/vendor/jquery.js"
- elsif params[:cdn] && params[:cdn] == 'googleapis'
+ elsif params[:cdn] && params[:cdn] == "googleapis"
"https://ajax.googleapis.com/ajax/libs/jquery/#{params[:version]}/jquery.min.js"
else
"http://code.jquery.com/jquery-#{params[:version]}.js"
end
end
- def test_to *names
+ def test_to(*names)
names = ["/vendor/qunit.js", "settings"] + names
names.map { |name| script_tag name }.join("\n").html_safe
end
- def script_tag src
- src = "/test/#{src}.js" unless src.index('/')
+ def script_tag(src)
+ src = "/test/#{src}.js" unless src.index("/")
%(<script src="#{src}" type="text/javascript"></script>).html_safe
end
@@ -72,20 +72,20 @@ class TestsController < ActionController::Base
layout "application"
def index
- params[:version] ||= ENV['JQUERY_VERSION'] || '1.11.0'
- params[:cdn] ||= 'jquery'
+ params[:version] ||= ENV["JQUERY_VERSION"] || "1.11.0"
+ params[:cdn] ||= "jquery"
render :index
end
def echo
- data = { :params => params.to_unsafe_h }.update(request.env)
+ data = { params: params.to_unsafe_h }.update(request.env)
- if params[:content_type] and params[:content]
+ if params[:content_type] && params[:content]
render inline: params[:content], content_type: params[:content_type]
elsif request.xhr?
render json: JSON.generate(data)
elsif params[:iframe]
- payload = JSON.generate(data).gsub('<', '&lt;').gsub('>', '&gt;')
+ payload = JSON.generate(data).gsub("<", "&lt;").gsub(">", "&gt;")
html = <<-HTML
<script>
if (window.top && window.top !== window)