Skip to content

Commit bae044a

Browse files
committed
Fix #323 regression. Configure application inline without proc
1 parent 738451d commit bae044a

File tree

4 files changed

+18
-5
lines changed

4 files changed

+18
-5
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## v2.3.1
44

55
* Add timestamp on when routes where generated into banner
6+
* Fix application specified directly without proc. [#323](https://github.com/railsware/js-routes/issues/323)
67

78
## v2.3.0
89

lib/js_routes/instance.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,8 @@ def wrapper_variable
117117

118118
sig { returns(Application) }
119119
def application
120-
@configuration.application.call
120+
app = @configuration.application
121+
app.is_a?(Proc) ? app.call : app
121122
end
122123

123124
sig { params(value: T.untyped).returns(String) }

lib/js_routes/types.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ module Types
1717
JourneyRoute = T.type_alias{ActionDispatch::Journey::Route}
1818
RouteSpec = T.type_alias {T.untyped}
1919
Application = T.type_alias { T.any(T::Class[Rails::Engine], Rails::Application) }
20-
ApplicationCaller = T.type_alias { T.proc.returns(Application) }
20+
ApplicationCaller = T.type_alias { T.any(Application, T.proc.returns(Application)) }
2121
Clusivity = T.type_alias { T.any(Regexp, T::Array[Regexp]) }
2222
FileName = T.type_alias { T.any(String, Pathname, NilClass) }
2323
ConfigurationBlock = T.type_alias { T.proc.params(arg0: JsRoutes::Configuration).void }

spec/js_routes/options_spec.rb

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -482,10 +482,21 @@
482482
end
483483

484484
describe "when application is specified" do
485-
let(:_options) { {application: -> {BlogEngine::Engine}} }
485+
context "as proc" do
486+
let(:_options) { {application: -> {BlogEngine::Engine}} }
487+
488+
it "should include specified engine route" do
489+
expectjs("Routes.posts_path()").not_to be_nil
490+
end
491+
end
492+
493+
context "directly" do
494+
let(:_options) { {application: BlogEngine::Engine} }
495+
496+
it "should include specified engine route" do
497+
expectjs("Routes.posts_path()").not_to be_nil
498+
end
486499

487-
it "should include specified engine route" do
488-
expectjs("Routes.posts_path()").not_to be_nil
489500
end
490501
end
491502

0 commit comments

Comments
 (0)