aboutsummaryrefslogtreecommitdiffstats
path: root/activestorage/test
diff options
context:
space:
mode:
authorclaudiob <claudiob@users.noreply.github.com>2017-08-01 09:06:39 -0700
committerclaudiob <claudiob@users.noreply.github.com>2017-08-01 09:06:39 -0700
commit8b20789cfcc1f3e99742fd20f2e6079b231a9eae (patch)
treeded7dfdc29950be9b50428eb3e8022d9be0da7ef /activestorage/test
parenta9cb1968b6a01572a472a3df3aa750ebc022e076 (diff)
downloadrails-8b20789cfcc1f3e99742fd20f2e6079b231a9eae.tar.gz
rails-8b20789cfcc1f3e99742fd20f2e6079b231a9eae.tar.bz2
rails-8b20789cfcc1f3e99742fd20f2e6079b231a9eae.zip
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 `<top (required)>': 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.
Diffstat (limited to 'activestorage/test')
-rw-r--r--activestorage/test/test_helper.rb4
1 files changed, 3 insertions, 1 deletions
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"
{}