From 8b20789cfcc1f3e99742fd20f2e6079b231a9eae Mon Sep 17 00:00:00 2001 From: claudiob Date: Tue, 1 Aug 2017 09:06:39 -0700 Subject: Let ActiveStorage tests pass only for Disk If you have a "service/configurations.yml" file, but every single line is commented out, then an error occurs when running tests: ``` git:active-storage-import~/code/rails/activestorage$ rake ~/code/rails/activestorage/test/test_helper.rb:17:in `': undefined method `deep_symbolize_keys' for false:FalseClass (NoMethodError) from ~/code/rails/activestorage/test/controllers/direct_uploads_controller_test.rb:1:in `require' ``` The reason is that `YAML.load(..an empty file content..)` simply returns `false`, and not `{}`. This PR fixes this behavior so tests can also run when no remote service is available. --- activestorage/test/test_helper.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'activestorage/test/test_helper.rb') diff --git a/activestorage/test/test_helper.rb b/activestorage/test/test_helper.rb index 7826c1aeba..5b6d3b64c2 100644 --- a/activestorage/test/test_helper.rb +++ b/activestorage/test/test_helper.rb @@ -14,7 +14,9 @@ require "active_storage" require "yaml" SERVICE_CONFIGURATIONS = begin - YAML.load(ERB.new(Pathname.new(File.expand_path("../service/configurations.yml", __FILE__)).read).result).deep_symbolize_keys + erb = ERB.new(Pathname.new(File.expand_path("../service/configurations.yml", __FILE__)).read) + configuration = YAML.load(erb.result) || {} + configuration.deep_symbolize_keys rescue Errno::ENOENT puts "Missing service configuration file in test/service/configurations.yml" {} -- cgit v1.2.3