-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Invalid args on RouteSet#to_rfc6570
The two semi-public methods RouteSet#to_rfc6570 and NamedRouteCollection#to_rfc6570 were using the old, no longer working, kwargs format. Both methods are working again. RouteSet#to_rfc6570 has been adjusted to return a hash with named routes only, since the array before isn't much useful, and it was broken. New specs explicitly test RouteSet#to_rfc6570, and, by indirection, NamedRouteCollection#to_rfc6570.
- Loading branch information
Showing
3 changed files
with
35 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'spec_helper' | ||
|
||
RSpec.describe Rails::RFC6570::Extensions::RouteSet do | ||
subject(:route_set) do | ||
ActionDispatch::Routing::RouteSet.new.tap do |routes| | ||
routes.draw do | ||
get '/path/:id', to: 'controller#action', as: :test1 | ||
end | ||
end | ||
end | ||
|
||
let(:ctx) do | ||
Class.new do | ||
def url_options | ||
{host: 'www.example.org'} | ||
end | ||
end.new | ||
end | ||
|
||
describe '#to_rfc6570' do | ||
it 'returns dictionary of all named routes' do | ||
expect(route_set.to_rfc6570(ctx: ctx)).to eq({ | ||
test1: Addressable::Template.new('http://www.example.org/path/{id}'), | ||
}) | ||
end | ||
end | ||
end |