Skip to content

Commit

Permalink
Make Roda.freeze work if already frozen when using the autoload_{hash…
Browse files Browse the repository at this point in the history
…_branches,named_routes} plugins
  • Loading branch information
jeremyevans committed Nov 1, 2024
1 parent 7ba726b commit cd21246
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
= master

* Make Roda.freeze work if already frozen when using the autoload_{hash_branches,named_routes} plugins (jeremyevans)

* Allow response.content_security_plugin = false to avoid setting policy in content_security_policy plugin (jeremyevans)

= 3.85.0 (2024-10-11)
Expand Down
2 changes: 1 addition & 1 deletion lib/roda/plugins/autoload_hash_branches.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def autoload_hash_branch_dir(namespace='', dir)

# Eagerly load all hash branches when freezing the application.
def freeze
opts.delete(:autoload_hash_branch_files).each{|file| require file}
opts.delete(:autoload_hash_branch_files).each{|file| require file} unless opts.frozen?
super
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/roda/plugins/autoload_named_routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def autoload_named_route(namespace=nil, name, file)

# Eagerly load all autoloaded named routes when freezing the application.
def freeze
opts.delete(:autoload_named_route_files).each{|file| require file}
opts.delete(:autoload_named_route_files).each{|file| require file} unless opts.frozen?
super
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/plugin/autoload_hash_branches_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def check_autoload_hash_branches

$roda_app = @app
@app.opts[:loaded] = []
@app.freeze
2.times{@app.freeze}
@app.opts[:loaded].must_equal [:a, :b, :a_c, :a_d, :a_e]
body('/c').must_equal '-'
body('/b').must_equal 'b'
Expand Down
2 changes: 1 addition & 1 deletion spec/plugin/autoload_named_routes_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@

$roda_app = @app
@app.opts[:loaded] = []
@app.freeze
2.times{@app.freeze}
@app.opts[:loaded].must_equal [:a, :b, :a_c, :a_d, :a_e]
body('/c').must_equal '-'
body('/b').must_equal 'b'
Expand Down

0 comments on commit cd21246

Please sign in to comment.