Skip to content

Commit

Permalink
Fixes #13968 - Fail to save proxy if feature is missing
Browse files Browse the repository at this point in the history
  • Loading branch information
shlomizadok committed Sep 28, 2016
1 parent 10bceb1 commit 436b79a
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions app/models/smart_proxy.rb
Expand Up @@ -115,16 +115,20 @@ def associate_features

begin
reply = ProxyAPI::Features.new(:url => url).features
if reply.is_a?(Array) && reply.any?
if reply.is_a?(Array) && reply.any? && validate_features(reply)
self.features = Feature.where(:name => reply.map{|f| Feature.name_map[f]})
else
self.features.clear
errors.add :base, _('No features found on this proxy, please make sure you enable at least one feature')
errors.add :base, _('No matching features found on this proxy, please make sure you enable at least one feature')
end
rescue => e
errors.add(:base, _('Unable to communicate with the proxy: %s') % e)
errors.add(:base, _('Please check the proxy is configured and running on the host.'))
end
features.any?
end

def validate_features(features)
features.map{|f| Feature.name_map[f]} == nil
end
end

0 comments on commit 436b79a

Please sign in to comment.