def find_objects_for_index
# all users can list all keep services
- @objects = from_config_or_db
+ @objects = KeepService.all
super
end
def accessible
if request.headers['X-External-Client'] == '1'
- @objects = from_config_or_db.where('service_type=?', 'proxy')
+ @objects = KeepService.where('service_type=?', 'proxy')
else
- @objects = from_config_or_db.where('service_type<>?', 'proxy')
+ @objects = KeepService.where('service_type<>?', 'proxy')
end
render_list
end
-
- private
-
- # return the set of keep services from the database (if this is an
- # older installation or test system where entries have been added
- # manually) or, preferably, the cluster config file.
- def from_config_or_db
- if KeepService.all.count == 0
- KeepService.from_config
- else
- KeepService.all
- end
- end
end
api_accessible :superuser, :extend => :user do |t|
end
+ # return the set of keep services from the database (if this is an
+ # older installation or test system where entries have been added
+ # manually) or, preferably, the cluster config file.
+ def self.all *args
+ if super.count == 0
+ from_config
+ else
+ super
+ end
+ end
+
+ def self.where *args
+ all.where *args
+ end
+
protected
def permission_to_create
end
if values.length == 0
# return empty set as AR relation
- return where('1=0')
+ return unscoped.where('1=0')
else
sql = "(values #{values.join(", ")}) as keep_services (id, uuid, service_host, service_port, service_ssl_flag, service_type, read_only, created_at, modified_at, owner_uuid, modified_by_user_uuid, modified_by_client_uuid)"
- return KeepService.from(sql)
+ return unscoped.from(sql)
end
end
end
test "report configured servers if db is empty" do
- KeepService.all.delete_all
+ KeepService.unscoped.all.delete_all
expect_rvz = {}
n = 0
Rails.configuration.Services.Keepstore.InternalURLs.each do |k,v|
get :index,
params: {:format => :json},
headers: auth(:active)
+ assert_response :success
json_response['items'].each do |svc|
url = "#{svc['service_ssl_flag'] ? 'https' : 'http'}://#{svc['service_host']}:#{svc['service_port']}"
assert_equal true, expect_rvz.has_key?(url), "#{url} does not match any configured service: expecting #{expect_rvz}"