Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# frozen_string_literal: true

require 'foreman_ansible_director_test_helper'

module ForemanAnsibleDirectorTests
module Controllers
module Api
module V2
class StatusControllerTest < ForemanAnsibleDirectorControllerTestCase
tests ::ForemanAnsibleDirector::Api::V2::StatusController

test 'content exposes global content counts' do
::ForemanAnsibleDirector::AnsibleRole.stub(:count, 2) do
::ForemanAnsibleDirector::AnsibleCollection.stub(:count, 3) do
::ForemanAnsibleDirector::ExecutionEnvironment.stub(:count, 4) do
as_admin do
get :content, params: { organization_id: @organization.id, format: :json }
end
end
end
end

assert_response :success
assert_equal(
{
'roles' => 2,
'collections' => 3,
'execution_environments' => 4,
},
ActiveSupport::JSON.decode(@response.body)
)
end

test 'context exposes ansible director settings' do
as_admin do
get :context, params: { format: :json }
end

assert_response :success
assert_equal(
{
'settings' => {
'ad_default_galaxy_url' => Setting[:ad_default_galaxy_url],
'ad_default_ansible_core_version' => Setting[:ad_default_ansible_core_version],
},
},
ActiveSupport::JSON.decode(@response.body)
)
end
end
end
end
end
end
10 changes: 9 additions & 1 deletion test/foreman_ansible_director_test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,12 @@ class ForemanAnsibleDirectorTestCase < ActiveSupport::TestCase
@organization ||= Organization.find_by name: 'Organization 1'
Organization.current = @organization
end
end
end

class ForemanAnsibleDirectorControllerTestCase < ActionController::TestCase
setup do
User.current = User.find_by login: 'admin'
@organization ||= Organization.find_by name: 'Organization 1'
Organization.current = @organization
end
end
Loading