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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ This project adheres to [Semantic Versioning](http://semver.org/) and [Keep a Ch

### Fixes

- Fix up `*_rfc6570` to support a Hash argument. Required when calling template from Rails Engine in the main app.

### Breaks

## 3.5.0 - (2025-09-26)
Expand Down
6 changes: 3 additions & 3 deletions lib/rails/rfc6570.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,15 @@ def define_rfc6570_helpers(name, route, mod, set)
end

mod.module_eval do
define_method(rfc6570_name) do |**opts|
define_method(rfc6570_name) do |opts = {}|
route.to_rfc6570(**opts, ctx: self)
end

define_method(rfc6570_url_name) do |**opts|
define_method(rfc6570_url_name) do |opts = {}|
route.to_rfc6570(**opts, ctx: self, path_only: false)
end

define_method(rfc6570_path_name) do |**opts|
define_method(rfc6570_path_name) do |opts = {}|
route.to_rfc6570(**opts, ctx: self, path_only: true)
end
end
Expand Down
15 changes: 15 additions & 0 deletions spec/rails/rfc6570_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ def action
partial: test6_rfc6570.partial_expand(title: 'TITLE'),
ignore: test6_rfc6570(ignore: %w[title]),
expand: test6_rfc6570.expand(capture: %w[a b], title: 'TITLE'),
engine_template: dummy_engine.action_rfc6570,
engine_template_url: dummy_engine.action_url_rfc6570,
engine_template_path: dummy_engine.action_path_rfc6570,
}
end

Expand Down Expand Up @@ -149,6 +152,18 @@ def default_url_options
expect(json['expand']).to eq "#{host}/path/a/b/TITLE"
end

it 'allows to return and render a rails engines templates' do
expect(json['engine_template']).to eq "#{host}/dummy_engine/action{?param3}"
end

it 'allows to return and render a rails engines url templates' do
expect(json['engine_template_url']).to eq "#{host}/dummy_engine/action{?param3}"
end

it 'allows to return and render a rails engines path templates' do
expect(json['engine_template_path']).to eq '/dummy_engine/action{?param3}'
end

context 'with origin_script_name' do
let(:headers) { {'__OSN' => '/fuubar'} }

Expand Down