14874: Fixes issue with keys being loaded as symbols from application.yml
authorLucas Di Pentima <ldipentima@veritasgenetics.com>
Fri, 14 Jun 2019 19:10:42 +0000 (16:10 -0300)
committerLucas Di Pentima <ldipentima@veritasgenetics.com>
Fri, 14 Jun 2019 19:10:42 +0000 (16:10 -0300)
Arvados-DCO-1.1-Signed-off-by: Lucas Di Pentima <ldipentima@veritasgenetics.com>

services/api/app/models/collection.rb

index c3bcfce5585c74f9262ffb33623d0a227e7dd8ef..83bb604c46a70613ae1cb99d14512a72ab84f5c7 100644 (file)
@@ -610,7 +610,7 @@ class Collection < ArvadosModel
 
   # Sets default properties at creation time
   def default_properties
-    default_props = Rails.configuration.Collections.DefaultProperties
+    default_props = Rails.configuration.Collections.DefaultProperties.with_indifferent_access
     if default_props.empty?
       return
     end
@@ -687,17 +687,17 @@ class Collection < ArvadosModel
   end
 
   def protected_default_properties_updates
-    if Rails.configuration.Collections.DefaultProperties.empty? || !properties_changed? || current_user.is_admin
+    default_properties = Rails.configuration.Collections.DefaultProperties.with_indifferent_access
+    if default_properties.empty? || !properties_changed? || current_user.is_admin
       return true
     end
-    protected_props = Rails.configuration.Collections.DefaultProperties.keys.select do |p|
+    protected_props = default_properties.keys.select do |p|
       Rails.configuration.Collections.DefaultProperties[p]['protected']
     end
     # Pre-existent protected properties can't be updated
     invalid_updates = properties_was.keys.select{|p| properties_was[p] != properties[p]} & protected_props
     if !invalid_updates.empty?
-      errors.add(:properties, "protected properties cannot be updated: #{invalid_updates.join(', ')}")
-      raise PermissionDeniedError
+      raise PermissionDeniedError.new("protected properties cannot be updated: #{invalid_updates.join(', ')}")
     end
     true
   end