Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rails 7 compatibility #48

Open
wants to merge 29 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
d7c0042
start on 4.2 support
tenderlove Nov 14, 2014
bfec473
Merge branch 'master' into 4.2
Jan 27, 2015
305fca4
Fixed deprecation warning "ActionDispatch::Assertions::SelectorAssert…
Mar 11, 2015
0fed929
Merge pull request #36 from Nike0/4.2
rafaelfranca Mar 12, 2015
5965de8
First pass at making this rals 5 compatable
clifff Feb 28, 2017
cb082ce
back to how this was
clifff Mar 1, 2017
6c89a20
bump version
clifff Mar 1, 2017
2e76228
top level reference
clifff Mar 1, 2017
4544108
Merging master into 4.2 branch
clifff Mar 1, 2017
55ccc04
no need to delete anymore
clifff Mar 1, 2017
9b57f62
versyion bump
clifff Mar 1, 2017
af970e9
Replace alias_method_chain to quiet Rails deperecations
clifff Mar 15, 2017
7c4bfb9
Version bump
clifff Mar 15, 2017
6604edb
I am not very smart
clifff Mar 15, 2017
e385756
Don't access MIME types as constants - it is deprecated
clifff Mar 15, 2017
7547c6f
update default fomat to use a symbol
cschiewek Jan 20, 2021
e2e9ae2
update lock file
cschiewek Jan 20, 2021
b0484e8
bump version
cschiewek Jan 20, 2021
127d279
Merge pull request #1 from voxmedia/ccs-rails-6-updates
Jan 20, 2021
0d1dae7
Update template to Rails 6 format
ebinmore May 20, 2021
7c5acd2
Update version
ebinmore May 20, 2021
740f701
Merge pull request #2 from voxmedia/eb-rails-6-upgrade
ebinmore May 20, 2021
9d69583
This version is not rails 6 compatible
jamiemccarthy Jul 26, 2022
d11a049
Merge branch 'jm-correct-rails-gemspec' into jm-call-source-optional
jamiemccarthy Jul 26, 2022
0570892
Allow #call to be invoked differently in Rails 6
jamiemccarthy Jul 26, 2022
9ace425
Note this version is now rails 6 compatible
jamiemccarthy Jul 26, 2022
a679ef3
Merge pull request #4 from voxmedia/jm-call-source-optional
jamiemccarthy Jul 26, 2022
5b10820
added back render :update with a block to rails 7
Nov 23, 2024
333ccc9
update README
Nov 23, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
213 changes: 137 additions & 76 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -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
30 changes: 1 addition & 29 deletions README.md
Original file line number Diff line number Diff line change
@@ -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`.
7 changes: 4 additions & 3 deletions lib/action_view/template/handlers/rjs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions lib/prototype-rails/on_load_action_controller.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
require 'prototype-rails/selector_assertions'
require 'prototype-rails/renderers'
require 'prototype-rails/update_rendering'
4 changes: 2 additions & 2 deletions lib/prototype-rails/renderers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
end
7 changes: 4 additions & 3 deletions lib/prototype-rails/rendering.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

alias_method :render_without_update, :render
alias_method :render, :render_with_update
end
10 changes: 5 additions & 5 deletions lib/prototype-rails/selector_assertions.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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)

Expand All @@ -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)
Expand All @@ -208,3 +207,4 @@ def unescape_rjs(rjs_string)
unescaped
end
end
end
16 changes: 16 additions & 0 deletions lib/prototype-rails/update_rendering.rb
Original file line number Diff line number Diff line change
@@ -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
5 changes: 3 additions & 2 deletions prototype-rails.gemspec
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
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'
spec.email = '[email protected]'

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
Loading