File tree Expand file tree Collapse file tree 2 files changed +20
-1
lines changed
Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -219,7 +219,11 @@ def message_verifier(verifier_name)
219219 # config.middleware.use ExceptionNotifier, config_for(:exception_notification)
220220 # end
221221 def config_for ( name , env : Rails . env )
222- yaml = Pathname . new ( "#{ paths [ "config" ] . existent . first } /#{ name } .yml" )
222+ if name . is_a? ( Pathname )
223+ yaml = name
224+ else
225+ yaml = Pathname . new ( "#{ paths [ "config" ] . existent . first } /#{ name } .yml" )
226+ end
223227
224228 if yaml . exist?
225229 require "erb"
Original file line number Diff line number Diff line change @@ -1306,6 +1306,21 @@ def index
13061306 assert_equal 'custom key' , Rails . application . config . my_custom_config [ 'key' ]
13071307 end
13081308
1309+ test "config_for use the Pathname object if it is provided" do
1310+ app_file 'config/custom.yml' , <<-RUBY
1311+ development:
1312+ key: 'custom key'
1313+ RUBY
1314+
1315+ add_to_config <<-RUBY
1316+ config.my_custom_config = config_for(Pathname.new(Rails.root.join("config/custom.yml")))
1317+ RUBY
1318+
1319+ app 'development'
1320+
1321+ assert_equal 'custom key' , Rails . application . config . my_custom_config [ 'key' ]
1322+ end
1323+
13091324 test "config_for raises an exception if the file does not exist" do
13101325 add_to_config <<-RUBY
13111326 config.my_custom_config = config_for('custom')
You can’t perform that action at this time.
0 commit comments