Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
11 changes: 2 additions & 9 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ jobs:
gemfile:
- Gemfile
- gemfiles/Gemfile-rails-main
- gemfiles/Gemfile-rails-8-1
- gemfiles/Gemfile-rails-8-0
- gemfiles/Gemfile-rails-7-2
- gemfiles/Gemfile-rails-7-1
Expand All @@ -30,6 +29,8 @@ jobs:
- '3.0'
- '2.7'
exclude:
- gemfile: Gemfile
ruby: '3.2'
- gemfile: Gemfile
ruby: '3.1'
- gemfile: Gemfile
Expand All @@ -44,14 +45,6 @@ jobs:
ruby: '3.0'
- gemfile: gemfiles/Gemfile-rails-main
ruby: '2.7'
- gemfile: gemfiles/Gemfile-rails-8-1
ruby: '3.2'
- gemfile: gemfiles/Gemfile-rails-8-1
ruby: '3.1'
- gemfile: gemfiles/Gemfile-rails-8-1
ruby: '3.0'
- gemfile: gemfiles/Gemfile-rails-8-1
ruby: '2.7'
- gemfile: gemfiles/Gemfile-rails-8-0
ruby: '3.1'
- gemfile: gemfiles/Gemfile-rails-8-0
Expand Down
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
## Unreleased
## 3.2.1

* Make default_render failures not set an error cause (#257)
* Use public renderer API when available for better Rails 8.2 integration (#256)
* Support `allow_other_host` option in `respond_with`, forwarded to `redirect_to` (#255)
* Ruby 4.0 support (no changes required)

Expand Down
102 changes: 51 additions & 51 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,25 @@ PATH
GEM
remote: https://rubygems.org/
specs:
actionpack (8.1.3)
actionview (= 8.1.3)
activesupport (= 8.1.3)
actionpack (8.1.4)
actionview (= 8.1.4)
activesupport (= 8.1.4)
nokogiri (>= 1.8.5)
rack (>= 2.2.4)
rack-session (>= 1.0.1)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.2)
rails-html-sanitizer (~> 1.6)
useragent (~> 0.16)
actionview (8.1.3)
activesupport (= 8.1.3)
actionview (8.1.4)
activesupport (= 8.1.4)
builder (~> 3.1)
erubi (~> 1.11)
rails-dom-testing (~> 2.2)
rails-html-sanitizer (~> 1.6)
activemodel (8.1.3)
activesupport (= 8.1.3)
activesupport (8.1.3)
activemodel (8.1.4)
activesupport (= 8.1.4)
activesupport (8.1.4)
base64
bigdecimal
concurrent-ruby (~> 1.0, >= 1.3.1)
Expand All @@ -41,53 +41,49 @@ GEM
uri (>= 0.13.1)
ast (2.4.3)
base64 (0.3.0)
bigdecimal (4.0.1)
bigdecimal (4.1.3)
builder (3.3.0)
concurrent-ruby (1.3.6)
concurrent-ruby (1.3.8)
connection_pool (3.0.2)
crass (1.0.6)
date (3.5.1)
crass (1.0.7)
drb (2.2.3)
erb (6.0.2)
erb (6.0.7)
erubi (1.13.1)
i18n (1.14.8)
i18n (1.15.2)
concurrent-ruby (~> 1.0)
io-console (0.8.2)
irb (1.17.0)
io-console (0.9.4)
irb (1.18.0)
pp (>= 0.6.0)
prism (>= 1.3.0)
rdoc (>= 4.0.0)
reline (>= 0.4.2)
json (2.19.3)
language_server-protocol (3.17.0.5)
json (3.0.2)
language_server-protocol (3.17.0.6)
lint_roller (1.1.0)
logger (1.7.0)
loofah (2.25.1)
loofah (2.25.2)
crass (~> 1.0.2)
nokogiri (>= 1.12.0)
mini_portile2 (2.8.9)
minitest (6.0.2)
minitest (6.0.6)
drb (~> 2.0)
prism (~> 1.5)
mocha (3.1.0)
ruby2_keywords (>= 0.0.5)
nokogiri (1.19.2)
nokogiri (1.19.4)
mini_portile2 (~> 2.8.2)
racc (~> 1.4)
parallel (1.27.0)
parser (3.3.11.1)
parallel (2.3.0)
parser (3.3.12.0)
ast (~> 2.4.1)
racc
pp (0.6.3)
pp (0.6.4)
prettyprint
prettyprint (0.2.0)
prism (1.9.0)
psych (5.3.1)
date
stringio
racc (1.8.1)
rack (3.2.5)
rack-session (2.1.1)
rack (3.2.7)
rack-session (2.1.2)
base64 (>= 0.1.0)
rack (>= 3.0.0)
rack-test (2.2.0)
Expand All @@ -102,59 +98,63 @@ GEM
activesupport (>= 5.0.0)
minitest
nokogiri (>= 1.6)
rails-html-sanitizer (1.7.0)
loofah (~> 2.25)
rails-html-sanitizer (1.7.1)
loofah (~> 2.25, >= 2.25.2)
nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
railties (8.1.3)
actionpack (= 8.1.3)
activesupport (= 8.1.3)
railties (8.1.4)
actionpack (= 8.1.4)
activesupport (= 8.1.4)
irb (~> 1.13)
rackup (>= 1.0.0)
rake (>= 12.2)
thor (~> 1.0, >= 1.2.2)
tsort (>= 0.2)
zeitwerk (~> 2.6)
rainbow (3.1.1)
rake (13.3.1)
rdoc (7.2.0)
rake (13.4.2)
rbs (4.2.0)
logger
prism (>= 1.6.0)
tsort
rdoc (8.1.0)
erb
psych (>= 4.0.0)
prism (>= 1.6.0)
rbs (>= 4.0.0)
tsort
regexp_parser (2.11.3)
reline (0.6.3)
regexp_parser (2.13.1)
reline (0.7.0)
io-console (~> 0.5)
rubocop (1.86.0)
json (~> 2.3)
rubocop (1.91.0)
json (>= 2.3)
language_server-protocol (~> 3.17.0.2)
lint_roller (~> 1.1.0)
parallel (~> 1.10)
parallel (>= 1.10)
parser (>= 3.3.0.2)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 2.9.3, < 3.0)
rubocop-ast (>= 1.49.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 4.0)
rubocop-ast (1.49.1)
rubocop-ast (1.50.0)
parser (>= 3.3.7.2)
prism (~> 1.7)
rubocop-performance (1.26.1)
rubocop-performance (1.27.0)
lint_roller (~> 1.1)
rubocop (>= 1.75.0, < 2.0)
rubocop (>= 1.89.0, < 2.0)
rubocop-ast (>= 1.47.1, < 2.0)
ruby-progressbar (1.13.0)
ruby2_keywords (0.0.5)
securerandom (0.4.1)
stringio (3.2.0)
thor (1.5.0)
tsort (0.2.0)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unicode-display_width (3.2.0)
unicode-emoji (~> 4.1)
unicode-emoji (4.2.0)
unicode-display_width (3.3.0)
unicode-emoji (~> 4.3)
unicode-emoji (4.3.0)
uri (1.1.1)
useragent (0.16.11)
zeitwerk (2.7.5)
zeitwerk (2.8.3)

PLATFORMS
ruby
Expand All @@ -171,4 +171,4 @@ DEPENDENCIES
rubocop-performance

BUNDLED WITH
4.0.3
4.0.16
7 changes: 0 additions & 7 deletions gemfiles/Gemfile-rails-8-1

This file was deleted.

1 change: 0 additions & 1 deletion gemfiles/Gemfile-rails-main
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@ gemspec path: ".."

gem "activemodel", github: "rails/rails", branch: "main"
gem "railties", github: "rails/rails", branch: "main"

22 changes: 12 additions & 10 deletions test/action_controller/respond_with_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -624,23 +624,23 @@ def test_respond_as_responder_entry_point
end

def test_clear_respond_to
@controller = InheritedRespondWithController.new
use_controller InheritedRespondWithController
@request.accept = "text/html"
assert_raises(ActionController::UnknownFormat) do
get :index
end
end

def test_first_in_respond_to_has_higher_priority
@controller = InheritedRespondWithController.new
use_controller InheritedRespondWithController
@request.accept = "*/*"
get :index
assert_equal "application/xml", @response.media_type
assert_equal "<name>david</name>", @response.body
end

def test_block_inside_respond_with_is_rendered
@controller = InheritedRespondWithController.new
use_controller InheritedRespondWithController
@request.accept = "application/json"
get :index
assert_equal "JSON", @response.body
Expand Down Expand Up @@ -726,22 +726,22 @@ def test_using_resource_with_set_responder
end

def test_raises_missing_renderer_if_an_api_behavior_with_no_renderer
@controller = CsvRespondWithController.new
use_controller CsvRespondWithController
assert_raise ActionController::MissingRenderer do
get :index, format: "csv"
end
end

def test_api_behavior_error_is_not_caused_by_missing_template
@controller = CsvRespondWithController.new
use_controller CsvRespondWithController
error = assert_raise ActionController::MissingRenderer do
get :index, format: "csv"
end
assert_nil error.cause
end

def test_error_is_raised_if_no_respond_to_is_declared_and_respond_with_is_called
@controller = EmptyRespondWithController.new
use_controller EmptyRespondWithController
@request.accept = "*/*"
assert_raise RuntimeError do
get :index
Expand Down Expand Up @@ -777,16 +777,18 @@ def test_using_resource_with_allow_other_host

private

def use_controller(controller_class)
@controller = controller_class.new
draw_test_routes(@routes)
end

def with_test_route_set
with_routing do |set|
set.draw do
draw_test_routes(set) do
resources :customers
resources :quiz_stores do
resources :customers
end
(ActionDispatch.try(:deprecator) || ActiveSupport::Deprecation).silence do
get ":controller/:action"
end
end
yield
end
Expand Down
30 changes: 23 additions & 7 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,6 @@
I18n.reload!

Responders::Routes = ActionDispatch::Routing::RouteSet.new
Responders::Routes.draw do
resources :news
(ActionDispatch.try(:deprecator) || ActiveSupport::Deprecation).silence do
get "/admin/:action", controller: "admin/addresses"
get "/:controller(/:action(/:id))"
end
end

class ApplicationController < ActionController::Base
include Responders::Routes.url_helpers
Expand Down Expand Up @@ -94,3 +87,26 @@ class Business < Rails::Engine
extend ActiveModel::Naming
end
end

class ActionController::TestCase
setup do
draw_test_routes(@routes)
end

private

# Dynamic :controller/:action segments are not supported by Rails anymore,
# so we declare routes for the actions of the controller under test.
def draw_test_routes(routes, &block)
controller = @controller.class

routes.draw do
resources :news
instance_exec(&block) if block

controller.action_methods.each do |action|
match "#{controller.controller_path}/#{action}", controller: controller.controller_path, action: action, via: :all
end
end
end
end
Loading