diff --git a/controllers/agents_controller.rb b/controllers/agents_controller.rb index 87572e99..1bf86321 100644 --- a/controllers/agents_controller.rb +++ b/controllers/agents_controller.rb @@ -14,6 +14,11 @@ class AgentsController < ApplicationController else agents = query.to_a end + + if includes_param.include?(:all) || includes_param.include?(:usages) + LinkedData::Models::Agent.load_agents_usages(agents) + end + reply agents end diff --git a/test/controllers/test_agents_controller.rb b/test/controllers/test_agents_controller.rb index e7521b37..de36bc36 100644 --- a/test/controllers/test_agents_controller.rb +++ b/test/controllers/test_agents_controller.rb @@ -28,12 +28,12 @@ def teardown end def test_all_agents - get '/agents?display=all' + get '/agents?display=all&page=1' assert last_response.ok? created_agents = MultiJson.load(last_response.body) @agents.each do |agent| - created_agent = created_agents.select{|x| x["name"].eql?(agent[:name])}.first + created_agent = created_agents["collection"].select{|x| x["name"].eql?(agent[:name])}.first refute_nil created_agent refute_nil created_agent["usages"] assert_equal agent[:name], created_agent["name"]