diff --git a/Gemfile.lock b/Gemfile.lock index 92b8540..907d0d8 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,90 +1,151 @@ PATH remote: . specs: - prototype-rails (4.0.0) - rails (~> 4.0) + prototype-rails (4.1.3) + rails (>= 4.2) GEM remote: https://rubygems.org/ specs: - actionmailer (4.0.0) - actionpack (= 4.0.0) - mail (~> 2.5.3) - actionpack (4.0.0) - activesupport (= 4.0.0) - builder (~> 3.1.0) - erubis (~> 2.7.0) - rack (~> 1.5.2) - rack-test (~> 0.6.2) - activemodel (4.0.0) - activesupport (= 4.0.0) - builder (~> 3.1.0) - activerecord (4.0.0) - activemodel (= 4.0.0) - activerecord-deprecated_finders (~> 1.0.2) - activesupport (= 4.0.0) - arel (~> 4.0.0) - activerecord-deprecated_finders (1.0.3) - activesupport (4.0.0) - i18n (~> 0.6, >= 0.6.4) - minitest (~> 4.2) - multi_json (~> 1.3) - thread_safe (~> 0.1) - tzinfo (~> 0.3.37) - arel (4.0.0) - atomic (1.1.13) - builder (3.1.4) - erubis (2.7.0) - hike (1.2.3) - i18n (0.6.5) - mail (2.5.4) - mime-types (~> 1.16) - treetop (~> 1.4.8) - metaclass (0.0.1) - mime-types (1.24) - minitest (4.7.5) - mocha (0.10.3) - metaclass (~> 0.0.1) - multi_json (1.7.9) - polyglot (0.3.3) - rack (1.5.2) - rack-test (0.6.2) - rack (>= 1.0) - rails (4.0.0) - actionmailer (= 4.0.0) - actionpack (= 4.0.0) - activerecord (= 4.0.0) - activesupport (= 4.0.0) - bundler (>= 1.3.0, < 2.0) - railties (= 4.0.0) - sprockets-rails (~> 2.0.0) - railties (4.0.0) - actionpack (= 4.0.0) - activesupport (= 4.0.0) + actioncable (6.1.1) + actionpack (= 6.1.1) + activesupport (= 6.1.1) + nio4r (~> 2.0) + websocket-driver (>= 0.6.1) + actionmailbox (6.1.1) + actionpack (= 6.1.1) + activejob (= 6.1.1) + activerecord (= 6.1.1) + activestorage (= 6.1.1) + activesupport (= 6.1.1) + mail (>= 2.7.1) + actionmailer (6.1.1) + actionpack (= 6.1.1) + actionview (= 6.1.1) + activejob (= 6.1.1) + activesupport (= 6.1.1) + mail (~> 2.5, >= 2.5.4) + rails-dom-testing (~> 2.0) + actionpack (6.1.1) + actionview (= 6.1.1) + activesupport (= 6.1.1) + rack (~> 2.0, >= 2.0.9) + rack-test (>= 0.6.3) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.2.0) + actiontext (6.1.1) + actionpack (= 6.1.1) + activerecord (= 6.1.1) + activestorage (= 6.1.1) + activesupport (= 6.1.1) + nokogiri (>= 1.8.5) + actionview (6.1.1) + activesupport (= 6.1.1) + builder (~> 3.1) + erubi (~> 1.4) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.1, >= 1.2.0) + activejob (6.1.1) + activesupport (= 6.1.1) + globalid (>= 0.3.6) + activemodel (6.1.1) + activesupport (= 6.1.1) + activerecord (6.1.1) + activemodel (= 6.1.1) + activesupport (= 6.1.1) + activestorage (6.1.1) + actionpack (= 6.1.1) + activejob (= 6.1.1) + activerecord (= 6.1.1) + activesupport (= 6.1.1) + marcel (~> 0.3.1) + mimemagic (~> 0.3.2) + activesupport (6.1.1) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (>= 1.6, < 2) + minitest (>= 5.1) + tzinfo (~> 2.0) + zeitwerk (~> 2.3) + builder (3.2.4) + concurrent-ruby (1.1.8) + crass (1.0.6) + erubi (1.10.0) + globalid (0.4.2) + activesupport (>= 4.2.0) + i18n (1.8.7) + concurrent-ruby (~> 1.0) + loofah (2.9.0) + crass (~> 1.0.2) + nokogiri (>= 1.5.9) + mail (2.7.1) + mini_mime (>= 0.1.1) + marcel (0.3.3) + mimemagic (~> 0.3.2) + method_source (1.0.0) + mimemagic (0.3.5) + mini_mime (1.0.2) + minitest (5.14.3) + mocha (1.12.0) + nio4r (2.5.4) + nokogiri (1.11.1-x86_64-linux) + racc (~> 1.4) + racc (1.5.2) + rack (2.2.3) + rack-test (1.1.0) + rack (>= 1.0, < 3) + rails (6.1.1) + actioncable (= 6.1.1) + actionmailbox (= 6.1.1) + actionmailer (= 6.1.1) + actionpack (= 6.1.1) + actiontext (= 6.1.1) + actionview (= 6.1.1) + activejob (= 6.1.1) + activemodel (= 6.1.1) + activerecord (= 6.1.1) + activestorage (= 6.1.1) + activesupport (= 6.1.1) + bundler (>= 1.15.0) + railties (= 6.1.1) + sprockets-rails (>= 2.0.0) + rails-controller-testing (1.0.5) + actionpack (>= 5.0.1.rc1) + actionview (>= 5.0.1.rc1) + activesupport (>= 5.0.1.rc1) + rails-dom-testing (2.0.3) + activesupport (>= 4.2.0) + nokogiri (>= 1.6) + rails-html-sanitizer (1.3.0) + loofah (~> 2.3) + railties (6.1.1) + actionpack (= 6.1.1) + activesupport (= 6.1.1) + method_source rake (>= 0.8.7) - thor (>= 0.18.1, < 2.0) - rake (10.1.0) - sprockets (2.10.0) - hike (~> 1.2) - multi_json (~> 1.0) - rack (~> 1.0) - tilt (~> 1.1, != 1.3.0) - sprockets-rails (2.0.0) - actionpack (>= 3.0) - activesupport (>= 3.0) - sprockets (~> 2.8) - thor (0.18.1) - thread_safe (0.1.2) - atomic - tilt (1.4.1) - treetop (1.4.14) - polyglot - polyglot (>= 0.3.1) - tzinfo (0.3.37) + thor (~> 1.0) + rake (13.0.3) + sprockets (4.0.2) + concurrent-ruby (~> 1.0) + rack (> 1, < 3) + sprockets-rails (3.2.2) + actionpack (>= 4.0) + activesupport (>= 4.0) + sprockets (>= 3.0.0) + thor (1.0.1) + tzinfo (2.0.4) + concurrent-ruby (~> 1.0) + websocket-driver (0.7.3) + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.5) + zeitwerk (2.4.2) PLATFORMS - ruby + x86_64-linux DEPENDENCIES mocha prototype-rails! + rails-controller-testing + +BUNDLED WITH + 2.3.6 diff --git a/README.md b/README.md index 03ad553..a6b1637 100644 --- a/README.md +++ b/README.md @@ -1,29 +1 @@ -prototype-rails provides Prototype, Scriptaculous, and RJS on Rails 3.1 -and later. - -Prototype and Scriptaculous are pulled in by the asset pipeline, so you don't -need to copy the source files into your app. You may reference them in your -s app/assets/javascripts/application.js: - - //= require prototype - //= require prototype_ujs - //= require effects - //= require dragdrop - //= require controls - -prototype-rails supports RJS debugging. RJS responses are wrapped to catch -exceptions, alert() them, and re-raise the exception. Debugging is disabled by -default. To enable in development, set `config.action_view.debug_rjs = true` -in config/environments/development.rb. - ---- - -## Support for Rails 4.1 and above - -Unfortunately, due to limited manpower and resources, the Rails core team has -not been able to confirm if this gem currently works with Rails 4.1 and above. -If you have found any problems while upgrading your application, please report -them at the [issue tracker](https://github.com/rails/prototype-rails/issues), -or better yet, submit patches by sending a [pull request](https://github.com/rails/prototype-rails/pulls). - -In any case, this gem will *NOT* be officially supported on Rails 5.0 and above. +This fork provides thoroughly untested and unsupport Rails 7 compatability for `prototype-rails`. diff --git a/lib/action_view/template/handlers/rjs.rb b/lib/action_view/template/handlers/rjs.rb index 0855959..89f415a 100644 --- a/lib/action_view/template/handlers/rjs.rb +++ b/lib/action_view/template/handlers/rjs.rb @@ -3,10 +3,11 @@ module Template::Handlers class RJS # Default format used by RJS. class_attribute :default_format - self.default_format = Mime::JS + self.default_format = :js - def call(template) - "update_page do |page|;#{template.source}\nend" + def call(template, source=nil) + block_source = Rails.version >= "6" ? source : template.source + "update_page do |page|;#{block_source}\nend" end end end diff --git a/lib/prototype-rails/on_load_action_controller.rb b/lib/prototype-rails/on_load_action_controller.rb index 92302e7..d5542c7 100644 --- a/lib/prototype-rails/on_load_action_controller.rb +++ b/lib/prototype-rails/on_load_action_controller.rb @@ -1,2 +1,3 @@ require 'prototype-rails/selector_assertions' require 'prototype-rails/renderers' +require 'prototype-rails/update_rendering' diff --git a/lib/prototype-rails/renderers.rb b/lib/prototype-rails/renderers.rb index a514adc..e03347e 100644 --- a/lib/prototype-rails/renderers.rb +++ b/lib/prototype-rails/renderers.rb @@ -5,8 +5,8 @@ module Renderers add :update do |proc, options| view_context = self.view_context generator = ActionView::Helpers::PrototypeHelper::JavaScriptGenerator.new(view_context, &proc) - self.content_type = Mime::JS + self.content_type = Mime[:js] self.response_body = generator.to_s end end -end \ No newline at end of file +end diff --git a/lib/prototype-rails/rendering.rb b/lib/prototype-rails/rendering.rb index e2350d8..0b42a74 100644 --- a/lib/prototype-rails/rendering.rb +++ b/lib/prototype-rails/rendering.rb @@ -8,6 +8,7 @@ def render_with_update(options = {}, locals = {}, &block) render_without_update(options, locals, &block) end end - - alias_method_chain :render, :update -end \ No newline at end of file + + alias_method :render_without_update, :render + alias_method :render, :render_with_update +end diff --git a/lib/prototype-rails/selector_assertions.rb b/lib/prototype-rails/selector_assertions.rb index bdbe918..c1e2419 100644 --- a/lib/prototype-rails/selector_assertions.rb +++ b/lib/prototype-rails/selector_assertions.rb @@ -1,14 +1,14 @@ require 'active_support/core_ext/module/aliasing' -require 'action_view/vendor/html-scanner' require 'action_dispatch/testing/assertions' -require 'action_dispatch/testing/assertions/selector' +require 'rails/dom/testing/assertions/selector_assertions' #-- # Copyright (c) 2006 Assaf Arkin (http://labnotes.org) # Under MIT and/or CC By license. #++ -ActionDispatch::Assertions::SelectorAssertions.module_eval do +module PrototypeRails + module SelectorAssertions # Selects content from the RJS response. # # === Narrowing down @@ -174,7 +174,7 @@ def assert_select_rjs(*args, &block) def response_from_page_with_rjs content_type = @response.content_type - if content_type && Mime::JS =~ content_type + if content_type && Mime[:js] =~ content_type body = @response.body.dup root = HTML::Node.new(nil) @@ -193,7 +193,6 @@ def response_from_page_with_rjs response_from_page_without_rjs end end - alias_method_chain :response_from_page, :rjs # Unescapes a RJS string. def unescape_rjs(rjs_string) @@ -208,3 +207,4 @@ def unescape_rjs(rjs_string) unescaped end end +end diff --git a/lib/prototype-rails/update_rendering.rb b/lib/prototype-rails/update_rendering.rb new file mode 100644 index 0000000..5cdea94 --- /dev/null +++ b/lib/prototype-rails/update_rendering.rb @@ -0,0 +1,16 @@ +require 'action_controller/metal/rendering' + +module ActionController::Rendering::UpdateRendering + + private + + # Normalize arguments by catching blocks and setting them on :update. + # Copied from rails 6 + def _normalize_args(action = nil, options = {}, &blk) + options = super + options[:update] = blk if block_given? + options + end +end + +ActionController::Rendering.include ActionController::Rendering::UpdateRendering diff --git a/prototype-rails.gemspec b/prototype-rails.gemspec index 512ae58..05938f3 100644 --- a/prototype-rails.gemspec +++ b/prototype-rails.gemspec @@ -1,6 +1,6 @@ Gem::Specification.new do |spec| spec.name = 'prototype-rails' - spec.version = '4.0.1' + spec.version = '4.2.1' spec.summary = 'Prototype, Scriptaculous, and RJS for Ruby on Rails' spec.homepage = 'http://github.com/rails/prototype-rails' spec.author = 'Xavier Noria' @@ -8,7 +8,8 @@ Gem::Specification.new do |spec| spec.files = %w(README.md Rakefile Gemfile MIT-LICENSE) + Dir['lib/**/*', 'vendor/**/*'] - spec.add_dependency('rails', '~> 4.0') + spec.add_dependency('rails', '>= 4.2') spec.add_development_dependency('mocha') + spec.add_development_dependency('rails-controller-testing') spec.license = "MIT" end diff --git a/test/assert_select_test.rb b/test/assert_select_test.rb deleted file mode 100644 index f627f17..0000000 --- a/test/assert_select_test.rb +++ /dev/null @@ -1,457 +0,0 @@ -# coding: utf-8 - -require 'abstract_unit' - -class AssertSelectTest < ActionController::TestCase - Assertion = ActiveSupport::TestCase::Assertion - - class AssertSelectController < ActionController::Base - def response_with=(content) - @content = content - end - - def response_with(&block) - @update = block - end - - def rjs - render :update do |page| - @update.call page - end - @update = nil - end - - def rescue_action(e) - raise e - end - end - - tests AssertSelectController - - def assert_failure(message, &block) - e = assert_raise(Assertion, &block) - assert_match(message, e.message) if Regexp === message - assert_equal(message, e.message) if String === message - end - - # With single result. - def test_assert_select_from_rjs_with_single_result - render_rjs do |page| - page.replace_html "test", "
foo
\n
foo
" - end - assert_select "div" do |elements| - assert elements.size == 2 - assert_select "#1" - assert_select "#2" - end - assert_select "div#?", /\d+/ do |elements| - assert_select "#1" - assert_select "#2" - end - end - - # With multiple results. - def test_assert_select_from_rjs_with_multiple_results - render_rjs do |page| - page.replace_html "test", "
foo
" - page.replace_html "test2", "
foo
" - end - assert_select "div" do |elements| - assert elements.size == 2 - assert_select "#1" - assert_select "#2" - end - end - - # With one result. - def test_css_select_from_rjs_with_single_result - render_rjs do |page| - page.replace_html "test", "
foo
\n
foo
" - end - assert_equal 2, css_select("div").size - assert_equal 1, css_select("#1").size - assert_equal 1, css_select("#2").size - end - - # With multiple results. - def test_css_select_from_rjs_with_multiple_results - render_rjs do |page| - page.replace_html "test", "
foo
" - page.replace_html "test2", "
foo
" - end - - assert_equal 2, css_select("div").size - assert_equal 1, css_select("#1").size - assert_equal 1, css_select("#2").size - end - - # - # Test assert_select_rjs. - # - - def test_assert_select_rjs_for_positioned_insert_should_fail_when_mixing_arguments - render_rjs do |page| - page.insert_html :top, "test1", "
foo
" - page.insert_html :bottom, "test2", "
foo
" - end - assert_raise(Assertion) {assert_select_rjs :insert, :top, "test2"} - end - - # Test that we can pick up all statements in the result. - def test_assert_select_rjs_picks_up_all_statements - render_rjs do |page| - page.replace "test", "
foo
" - page.replace_html "test2", "
foo
" - page.insert_html :top, "test3", "
foo
" - end - - found = false - assert_select_rjs do - assert_select "#1" - assert_select "#2" - assert_select "#3" - found = true - end - assert found - end - - # Test that we fail if there is nothing to pick. - def test_assert_select_rjs_fails_if_nothing_to_pick - render_rjs { } - assert_raise(Assertion) { assert_select_rjs } - end - - def test_assert_select_rjs_with_unicode - # Test that non-ascii characters (which are converted into \uXXXX in RJS) are decoded correctly. - - unicode = "\343\203\201\343\202\261\343\203\203\343\203\210" - render_rjs do |page| - page.replace "test", %(
#{unicode}
) - end - - assert_select_rjs do - str = "#1" - assert_select str, :text => unicode - assert_select str, unicode - if str.respond_to?(:force_encoding) - assert_select str, /\343\203\201..\343\203\210/u - assert_raise(Assertion) { assert_select str, /\343\203\201.\343\203\210/u } - else - assert_select str, Regexp.new("\343\203\201..\343\203\210", 0, 'U') - assert_raise(Assertion) { assert_select str, Regexp.new("\343\203\201.\343\203\210", 0, 'U') } - end - end - end - - def test_assert_select_rjs_with_id - # Test that we can pick up all statements in the result. - render_rjs do |page| - page.replace "test1", "
foo
" - page.replace_html "test2", "
foo
" - page.insert_html :top, "test3", "
foo
" - end - assert_select_rjs "test1" do - assert_select "div", 1 - assert_select "#1" - end - assert_select_rjs "test2" do - assert_select "div", 1 - assert_select "#2" - end - assert_select_rjs "test3" do - assert_select "div", 1 - assert_select "#3" - end - assert_raise(Assertion) { assert_select_rjs "test4" } - end - - def test_assert_select_rjs_for_replace - render_rjs do |page| - page.replace "test1", "
foo
" - page.replace_html "test2", "
foo
" - page.insert_html :top, "test3", "
foo
" - end - # Replace. - assert_select_rjs :replace do - assert_select "div", 1 - assert_select "#1" - end - assert_select_rjs :replace, "test1" do - assert_select "div", 1 - assert_select "#1" - end - assert_raise(Assertion) { assert_select_rjs :replace, "test2" } - # Replace HTML. - assert_select_rjs :replace_html do - assert_select "div", 1 - assert_select "#2" - end - assert_select_rjs :replace_html, "test2" do - assert_select "div", 1 - assert_select "#2" - end - assert_raise(Assertion) { assert_select_rjs :replace_html, "test1" } - end - - def test_assert_select_rjs_for_chained_replace - render_rjs do |page| - page['test1'].replace "
foo
" - page['test2'].replace_html "
foo
" - page.insert_html :top, "test3", "
foo
" - end - # Replace. - assert_select_rjs :chained_replace do - assert_select "div", 1 - assert_select "#1" - end - assert_select_rjs :chained_replace, "test1" do - assert_select "div", 1 - assert_select "#1" - end - assert_raise(Assertion) { assert_select_rjs :chained_replace, "test2" } - # Replace HTML. - assert_select_rjs :chained_replace_html do - assert_select "div", 1 - assert_select "#2" - end - assert_select_rjs :chained_replace_html, "test2" do - assert_select "div", 1 - assert_select "#2" - end - assert_raise(Assertion) { assert_select_rjs :replace_html, "test1" } - end - - # Simple remove - def test_assert_select_rjs_for_remove - render_rjs do |page| - page.remove "test1" - end - - assert_select_rjs :remove, "test1" - end - - def test_assert_select_rjs_for_remove_offers_useful_error_when_assertion_fails - render_rjs do |page| - page.remove "test_with_typo" - end - - assert_select_rjs :remove, "test1" - - rescue Assertion => e - assert_equal "No RJS statement that removes 'test1' was rendered.", e.message - end - - def test_assert_select_rjs_for_remove_ignores_block - render_rjs do |page| - page.remove "test1" - end - - assert_nothing_raised do - assert_select_rjs :remove, "test1" do - assert_select "p" - end - end - end - - # Simple show - def test_assert_select_rjs_for_show - render_rjs do |page| - page.show "test1" - end - - assert_select_rjs :show, "test1" - end - - def test_assert_select_rjs_for_show_offers_useful_error_when_assertion_fails - render_rjs do |page| - page.show "test_with_typo" - end - - assert_select_rjs :show, "test1" - - rescue Assertion => e - assert_equal "No RJS statement that shows 'test1' was rendered.", e.message - end - - def test_assert_select_rjs_for_show_ignores_block - render_rjs do |page| - page.show "test1" - end - - assert_nothing_raised do - assert_select_rjs :show, "test1" do - assert_select "p" - end - end - end - - # Simple hide - def test_assert_select_rjs_for_hide - render_rjs do |page| - page.hide "test1" - end - - assert_select_rjs :hide, "test1" - end - - def test_assert_select_rjs_for_hide_offers_useful_error_when_assertion_fails - render_rjs do |page| - page.hide "test_with_typo" - end - - assert_select_rjs :hide, "test1" - - rescue Assertion => e - assert_equal "No RJS statement that hides 'test1' was rendered.", e.message - end - - def test_assert_select_rjs_for_hide_ignores_block - render_rjs do |page| - page.hide "test1" - end - - assert_nothing_raised do - assert_select_rjs :hide, "test1" do - assert_select "p" - end - end - end - - # Simple toggle - def test_assert_select_rjs_for_toggle - render_rjs do |page| - page.toggle "test1" - end - - assert_select_rjs :toggle, "test1" - end - - def test_assert_select_rjs_for_toggle_offers_useful_error_when_assertion_fails - render_rjs do |page| - page.toggle "test_with_typo" - end - - assert_select_rjs :toggle, "test1" - - rescue Assertion => e - assert_equal "No RJS statement that toggles 'test1' was rendered.", e.message - end - - def test_assert_select_rjs_for_toggle_ignores_block - render_rjs do |page| - page.toggle "test1" - end - - assert_nothing_raised do - assert_select_rjs :toggle, "test1" do - assert_select "p" - end - end - end - - # Non-positioned insert. - def test_assert_select_rjs_for_nonpositioned_insert - render_rjs do |page| - page.replace "test1", "
foo
" - page.replace_html "test2", "
foo
" - page.insert_html :top, "test3", "
foo
" - end - assert_select_rjs :insert_html do - assert_select "div", 1 - assert_select "#3" - end - assert_select_rjs :insert_html, "test3" do - assert_select "div", 1 - assert_select "#3" - end - assert_raise(Assertion) { assert_select_rjs :insert_html, "test1" } - end - - # Positioned insert. - def test_assert_select_rjs_for_positioned_insert - render_rjs do |page| - page.insert_html :top, "test1", "
foo
" - page.insert_html :bottom, "test2", "
foo
" - page.insert_html :before, "test3", "
foo
" - page.insert_html :after, "test4", "
foo
" - end - assert_select_rjs :insert, :top do - assert_select "div", 1 - assert_select "#1" - end - assert_select_rjs :insert, :bottom do - assert_select "div", 1 - assert_select "#2" - end - assert_select_rjs :insert, :before do - assert_select "div", 1 - assert_select "#3" - end - assert_select_rjs :insert, :after do - assert_select "div", 1 - assert_select "#4" - end - assert_select_rjs :insert_html do - assert_select "div", 4 - end - end - - def test_assert_select_rjs_raise_errors - assert_raise(ArgumentError) { assert_select_rjs(:destroy) } - assert_raise(ArgumentError) { assert_select_rjs(:insert, :left) } - end - - # Simple selection from a single result. - def test_nested_assert_select_rjs_with_single_result - render_rjs do |page| - page.replace_html "test", "
foo
\n
foo
" - end - - assert_select_rjs "test" do |elements| - assert_equal 2, elements.size - assert_select "#1" - assert_select "#2" - end - end - - # Deal with two results. - def test_nested_assert_select_rjs_with_two_results - render_rjs do |page| - page.replace_html "test", "
foo
" - page.replace_html "test2", "
foo
" - end - - assert_select_rjs "test" do |elements| - assert_equal 1, elements.size - assert_select "#1" - end - - assert_select_rjs "test2" do |elements| - assert_equal 1, elements.size - assert_select "#2" - end - end - - def test_assert_select_rjs_for_redirect_to - render_rjs do |page| - page.redirect_to '/' - end - assert_select_rjs :redirect, '/' - end - - protected - def render_html(html) - @controller.response_with = html - get :html - end - - def render_rjs(&block) - @controller.response_with(&block) - get :rjs - end - - def render_xml(xml) - @controller.response_with = xml - get :xml - end -end diff --git a/test/controller/caching_test.rb b/test/controller/caching_test.rb index 5bc1617..20ce6c8 100644 --- a/test/controller/caching_test.rb +++ b/test/controller/caching_test.rb @@ -30,7 +30,7 @@ def setup @controller = FunctionalCachingController.new @controller.perform_caching = true @controller.cache_store = @store - @request = ActionController::TestRequest.new + @request = ActionController::TestRequest.create @response = ActionController::TestResponse.new end diff --git a/test/controller/content_type_test.rb b/test/controller/content_type_test.rb index db32e11..ca6a882 100644 --- a/test/controller/content_type_test.rb +++ b/test/controller/content_type_test.rb @@ -10,7 +10,7 @@ class ContentTypeTest < ActionController::TestCase def test_default_for_rjs xhr :post, :render_default_for_rjs - assert_equal Mime::JS, @response.content_type + assert_equal Mime[:js], @response.content_type assert_equal "utf-8", @response.charset end end diff --git a/test/controller/mime_responds_test.rb b/test/controller/mime_responds_test.rb index 280b4b7..262e45c 100644 --- a/test/controller/mime_responds_test.rb +++ b/test/controller/mime_responds_test.rb @@ -184,10 +184,13 @@ def test_xhr end class RespondWithController < ActionController::Base - respond_to :html, :json, :js def using_resource - respond_with(resource) + respond_to do |format| + format.html { render html: resource } + format.json { render json: resource } + format.js { render js: resource } + end end protected @@ -196,7 +199,7 @@ def resource end def _render_js(js, options) - self.content_type ||= Mime::JS + self.content_type ||= Mime[:js] self.response_body = js.respond_to?(:to_js) ? js.to_js : js end end diff --git a/test/controller/render_js_test.rb b/test/controller/render_js_test.rb index 5b9c550..59e0a3e 100644 --- a/test/controller/render_js_test.rb +++ b/test/controller/render_js_test.rb @@ -2,7 +2,6 @@ class RenderJSTest < ActionController::TestCase class TestController < ActionController::Base - protect_from_forgery def self.controller_path 'test' diff --git a/test/javascript_helper_test.rb b/test/javascript_helper_test.rb index c79b067..daad92d 100644 --- a/test/javascript_helper_test.rb +++ b/test/javascript_helper_test.rb @@ -26,14 +26,14 @@ def test_link_to_function_with_rjs_block html = link_to_function( "Greet me!" ) do |page| page.replace_html 'header', "

Greetings

" end - assert_dom_equal %(Greet me!), html + assert_dom_equal %(Greet me!), html end def test_link_to_function_with_rjs_block_and_options html = link_to_function( "Greet me!", :class => "updater" ) do |page| page.replace_html 'header', "

Greetings

" end - assert_dom_equal %(Greet me!), html + assert_dom_equal %(Greet me!), html end def test_link_to_function_with_inner_block_does_not_raise_exception @@ -42,20 +42,20 @@ def test_link_to_function_with_inner_block_does_not_raise_exception 'Greetings' end) end - assert_dom_equal %(Greet me!), html + assert_dom_equal %(Greet me!), html end def test_button_to_function_with_rjs_block html = button_to_function( "Greet me!" ) do |page| page.replace_html 'header', "

Greetings

" end - assert_dom_equal %(), html + assert_dom_equal %(), html end def test_button_to_function_with_rjs_block_and_options html = button_to_function( "Greet me!", :class => "greeter" ) do |page| page.replace_html 'header', "

Greetings

" end - assert_dom_equal %(), html + assert_dom_equal %(), html end -end \ No newline at end of file +end diff --git a/test/render_other_test.rb b/test/render_other_test.rb index 27a533e..e72ba43 100644 --- a/test/render_other_test.rb +++ b/test/render_other_test.rb @@ -3,13 +3,12 @@ require 'securerandom' ActionController.add_renderer :simon do |says, options| - self.content_type = Mime::TEXT + self.content_type = Mime[:text] self.response_body = "Simon says: #{says}" end class RenderOtherTest < ActionController::TestCase class TestController < ActionController::Base - protect_from_forgery def self.controller_path 'test' diff --git a/test/template/prototype_helper_test.rb b/test/template/prototype_helper_test.rb index a6aa848..685bb67 100644 --- a/test/template/prototype_helper_test.rb +++ b/test/template/prototype_helper_test.rb @@ -142,23 +142,23 @@ def teardown def _evaluate_assigns_and_ivars() end def test_insert_html_with_string - assert_equal 'Element.insert("element", { top: "\\u003Cp\\u003EThis is a test\\u003C/p\\u003E" });', + assert_equal 'Element.insert("element", { top: "\\u003cp\\u003eThis is a test\\u003c/p\\u003e" });', @generator.insert_html(:top, 'element', '

This is a test

') - assert_equal 'Element.insert("element", { bottom: "\\u003Cp\u003EThis is a test\\u003C/p\u003E" });', + assert_equal 'Element.insert("element", { bottom: "\\u003cp\u003eThis is a test\\u003c/p\u003e" });', @generator.insert_html(:bottom, 'element', '

This is a test

') - assert_equal 'Element.insert("element", { before: "\\u003Cp\u003EThis is a test\\u003C/p\u003E" });', + assert_equal 'Element.insert("element", { before: "\\u003cp\u003eThis is a test\\u003c/p\u003e" });', @generator.insert_html(:before, 'element', '

This is a test

') - assert_equal 'Element.insert("element", { after: "\\u003Cp\u003EThis is a test\\u003C/p\u003E" });', + assert_equal 'Element.insert("element", { after: "\\u003cp\u003eThis is a test\\u003c/p\u003e" });', @generator.insert_html(:after, 'element', '

This is a test

') end def test_replace_html_with_string - assert_equal 'Element.update("element", "\\u003Cp\\u003EThis is a test\\u003C/p\\u003E");', + assert_equal 'Element.update("element", "\\u003cp\\u003eThis is a test\\u003c/p\\u003e");', @generator.replace_html('element', '

This is a test

') end def test_replace_element_with_string - assert_equal 'Element.replace("element", "\\u003Cdiv id=\"element\"\\u003E\\u003Cp\\u003EThis is a test\\u003C/p\\u003E\\u003C/div\\u003E");', + assert_equal 'Element.replace("element", "\\u003cdiv id=\"element\"\\u003e\\u003cp\\u003eThis is a test\\u003c/p\\u003e\\u003c/div\\u003e");', @generator.replace('element', '

This is a test

') end @@ -221,10 +221,10 @@ def test_to_s @generator.replace_html('baz', '

This is a test

') assert_equal <<-EOS.chomp, @generator.to_s -Element.insert("element", { top: "\\u003Cp\\u003EThis is a test\\u003C/p\\u003E" }); -Element.insert("element", { bottom: "\\u003Cp\\u003EThis is a test\\u003C/p\\u003E" }); +Element.insert("element", { top: "\\u003cp\\u003eThis is a test\\u003c/p\\u003e" }); +Element.insert("element", { bottom: "\\u003cp\\u003eThis is a test\\u003c/p\\u003e" }); ["foo","bar"].each(Element.remove); -Element.update("baz", "\\u003Cp\\u003EThis is a test\\u003C/p\\u003E"); +Element.update("baz", "\\u003cp\\u003eThis is a test\\u003c/p\\u003e"); EOS end