From bd65e7f73d6aba48d4baadba916f1652a6c8aade Mon Sep 17 00:00:00 2001 From: Bob Remeika Date: Wed, 7 Oct 2009 19:51:40 -0700 Subject: Changed data-remote='true' to data-js-type='remote' --- actionpack/lib/action_view/helpers/ajax_helper.rb | 2 +- actionpack/test/javascript/ajax_test.rb | 45 ++++++++++++++--------- 2 files changed, 29 insertions(+), 18 deletions(-) (limited to 'actionpack') diff --git a/actionpack/lib/action_view/helpers/ajax_helper.rb b/actionpack/lib/action_view/helpers/ajax_helper.rb index 92e1d916c9..e4684c4992 100644 --- a/actionpack/lib/action_view/helpers/ajax_helper.rb +++ b/actionpack/lib/action_view/helpers/ajax_helper.rb @@ -25,7 +25,7 @@ module ActionView attributes["data-update-position"] = options.delete(:position) attributes["data-method"] = options.delete(:method) - attributes["data-remote"] = true + attributes["data-js-type"] = "remote" attributes end diff --git a/actionpack/test/javascript/ajax_test.rb b/actionpack/test/javascript/ajax_test.rb index 3004cac97f..fc6928b8c1 100644 --- a/actionpack/test/javascript/ajax_test.rb +++ b/actionpack/test/javascript/ajax_test.rb @@ -74,17 +74,21 @@ class LinkToRemoteTest < AjaxTestCase test "using a url hash" do link = link_to_remote("Delete this post", {:controller => :blog}, :update => "#posts") - assert_html link, %w(href="/blog/destroy/4" data-update-success="#posts") + assert_html link, %w(href="/url/hash" data-update-success="#posts") + end + + test "with no update" do + assert_html link, %w(href="/blog/destroy/4" Delete\ this\ post data-js-type="remote") end test "with :html options" do - expected = %{Delete this post} + expected = %{Delete this post} assert_equal expected, link(:update => "#posts", :html => {"data-custom" => "me"}) end test "with a hash for :update" do link = link(:update => {:success => "#posts", :failure => "#error"}) - assert_html link, %w(data-remote="true" data-update-success="#posts" data-update-failure="#error") + assert_html link, %w(data-js-type="remote" data-update-success="#posts" data-update-failure="#error") end test "with positional parameters" do @@ -105,7 +109,7 @@ class LinkToRemoteTest < AjaxTestCase end test "basic link_to_remote with :url =>" do - expected = %{Delete this post} + expected = %{Delete this post} assert_equal expected, link_to_remote("Delete this post", :url => "/blog/destroy/4", :update => "#posts") end @@ -137,7 +141,7 @@ class FormRemoteTagTest < AjaxTestCase # TODO: Play with using assert_dom_equal test "basic" do assert_html form_remote_tag(:update => "#glass_of_beer", :url => { :action => :fast }), - %w(form action="/url/hash" method="post" data-remote="true" data-update-success="#glass_of_beer") + %w(form action="/url/hash" method="post" data-js-type="remote" data-update-success="#glass_of_beer") end test "when protect_against_forgery? is true" do @@ -145,7 +149,7 @@ class FormRemoteTagTest < AjaxTestCase true end - expected_form_attributes = %w(form action="/url/hash" method="post" data-remote="true" data-update-success="#glass_of_beer") + expected_form_attributes = %w(form action="/url/hash" method="post" data-js-type="remote" data-update-success="#glass_of_beer") expected_patterns = expected_form_attributes + authenticity_input_attributes assert_equal true, protect_against_forgery? @@ -155,14 +159,14 @@ class FormRemoteTagTest < AjaxTestCase test ":action is used when it is present" do html = form_remote_tag(:update => "#glass_of_beer", :action => "foo") - assert_html html, %w(form action="foo" method="post" data-remote="true" data-update-success="#glass_of_beer") + assert_html html, %w(form action="foo" method="post" data-js-type="remote" data-update-success="#glass_of_beer") assert_no_match /url="foo"/, html end test ":url is used when :action is not present" do html = form_remote_tag(:update => "#glass_of_beer", :url => "bar") - assert_html html, %w(form action="bar" method="post" data-remote="true" data-update-success="#glass_of_beer") + assert_html html, %w(form action="bar" method="post" data-js-type="remote" data-update-success="#glass_of_beer") assert_no_match /url="bar"/, html end @@ -174,18 +178,25 @@ class FormRemoteTagTest < AjaxTestCase test "update callbacks" do assert_html form_remote_tag(:update => { :success => "#glass_of_beer" }, :url => { :action => :fast }), - %w(form action="/url/hash" method="post" data-remote="true" data-update-success="#glass_of_beer") + %w(form action="/url/hash" method="post" data-js-type="remote" data-update-success="#glass_of_beer") assert_html form_remote_tag(:update => { :failure => "#glass_of_water" }, :url => { :action => :fast }), - %w(form action="/url/hash" method="post" data-remote="true" data-update-failure="#glass_of_water") + %w(form action="/url/hash" method="post" data-js-type="remote" data-update-failure="#glass_of_water") assert_html form_remote_tag(:update => { :success => "#glass_of_beer", :failure => "#glass_of_water" }, :url => { :action => :fast }), - %w(form action="/url/hash" method="post" data-remote="true" data-update-success="#glass_of_beer" data-update-failure="#glass_of_water") + %w(form action="/url/hash" method="post" data-js-type="remote" data-update-success="#glass_of_beer" data-update-failure="#glass_of_water") end test "using a :method option" do +<<<<<<< HEAD expected_form_attributes = %w(form action="/url/hash" method="post" data-remote="true" data-update-success="#glass_of_beer") # TODO: Ask Katz: Why does rails do this? Some web servers don't allow PUT or DELETE from what I remember... - BR +======= + expected_form_attributes = %w(form action="/url/hash" method="post" data-js-type="remote" data-update-success="#glass_of_beer") + # TODO: Experiment with not using this _method param. Apparently this is done to address browser incompatibilities, but since + # we have a layer between the HTML and the JS libs now, we can probably get away with letting JS the JS libs handle the requirement + # for an extra field if needed. +>>>>>>> 6af9c2f... Changed data-remote='true' to data-js-type='remote' expected_input_attributes = %w(input name="_method" type="hidden" value="put") assert_html form_remote_tag(:update => "#glass_of_beer", :url => { :action => :fast }, :html => { :method => :put }), @@ -207,7 +218,7 @@ class FormRemoteTagTest < AjaxTestCase @buffer << str end - expected_form_attributes = %w(form action="/url/hash" method="post" data-remote="true" data-update-success="#glass_of_beer" /form) + expected_form_attributes = %w(form action="/url/hash" method="post" data-js-type="remote" data-update-success="#glass_of_beer" /form) expected_inner_html = %w(w00t!) form_remote_tag(:update => "#glass_of_beer", :url => { :action => :fast }) { concat expected_inner_html } @@ -251,14 +262,14 @@ class RemoteFormForTest < AjaxTestCase test "remote_form_for with record identification with new record" do remote_form_for(@record, {:html => { :id => 'create-author' }}) {} - expected = %(
) + expected = %(
) assert_dom_equal expected, output_buffer end test "remote_form_for with record identification without html options" do remote_form_for(@record) {} - expected = %(
) + expected = %(
) assert_dom_equal expected, output_buffer end @@ -266,14 +277,14 @@ class RemoteFormForTest < AjaxTestCase @record.save remote_form_for(@record) {} - expected = %(
) + expected = %(
) assert_dom_equal expected, output_buffer end test "remote_form_for with new object in list" do remote_form_for([@author, @article]) {} - expected = %(
) + expected = %(
) assert_dom_equal expected, output_buffer end @@ -282,7 +293,7 @@ class RemoteFormForTest < AjaxTestCase @article.save remote_form_for([@author, @article]) {} - expected = %(
) + expected = %(
) assert_dom_equal expected, output_buffer end -- cgit v1.2.3