Skip to content

Commit

Permalink
Merge pull request #14220 from jameswnl/project-refresh
Browse files Browse the repository at this point in the history
Refresh to pick up scm options for Tower Project
  • Loading branch information
blomquisg authored Mar 9, 2017
2 parents b608548 + 4a4d0b0 commit c9e9ae1
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ def configuration_script_sources
inventory_object = persister.configuration_script_sources.find_or_build(project.id.to_s)
inventory_object.description = project.description
inventory_object.name = project.name
inventory_object.authentication = persister.credentials.lazy_find(project.credential_id.to_s)
inventory_object.scm_type = project.scm_type
inventory_object.scm_url = project.scm_url
inventory_object.scm_branch = project.scm_branch
inventory_object.scm_clean = project.scm_clean
inventory_object.scm_delete_on_update = project.scm_delete_on_update
inventory_object.scm_update_on_launch = project.scm_update_on_launch

project.playbooks.each do |playbook_name|
inventory_object_playbook = persister.configuration_script_payloads.find_or_build_by(
Expand Down
2 changes: 1 addition & 1 deletion app/models/manager_refresh/inventory/core.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def has_configuration_script_sources(options = {})
has_inventory({
:model_class => ::ConfigurationScriptSource,
:manager_ref => [:manager_ref],
:inventory_object_attributes => %i(name description),
:inventory_object_attributes => %i(name description scm_type scm_url scm_branch scm_clean scm_delete_on_update scm_update_on_launch authentication),
}.merge(options))
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,17 +110,24 @@ def assert_credentials

def assert_playbooks
expect(expected_configuration_script_source.configuration_script_payloads.first).to be_an_instance_of(ManageIQ::Providers::AnsibleTower::AutomationManager::Playbook)
expect(expected_configuration_script_source.configuration_script_payloads.count).to eq(1)
expect(expected_configuration_script_source.configuration_script_payloads.map(&:name)).to include('hello_world.yml')
expect(expected_configuration_script_source.configuration_script_payloads.count).to eq(8)
expect(expected_configuration_script_source.configuration_script_payloads.map(&:name)).to include('start_ec2.yml')
end

def assert_configuration_script_sources
expect(automation_manager.configuration_script_sources.count).to eq(6)
expect(expected_configuration_script_source).to be_an_instance_of(ManageIQ::Providers::AnsibleTower::AutomationManager::ConfigurationScriptSource)
expect(expected_configuration_script_source).to have_attributes(
:name => 'Demo Project',
:description => 'A great demo',
:name => 'DB_Github',
:description => 'DB Playbooks',
:scm_type => 'git',
:scm_url => 'https://github.com/syncrou/playbooks',
:scm_branch => 'master',
:scm_clean => false,
:scm_delete_on_update => false,
:scm_update_on_launch => true
)
expect(expected_configuration_script_source.authentication.name).to eq('db-github')
end

def assert_configured_system
Expand Down Expand Up @@ -181,6 +188,6 @@ def expected_inventory_root_group
end

def expected_configuration_script_source
@expected_configuration_script_source ||= automation_manager.configuration_script_sources.find_by(:name => 'Demo Project')
@expected_configuration_script_source ||= automation_manager.configuration_script_sources.find_by(:name => 'DB_Github')
end
end

0 comments on commit c9e9ae1

Please sign in to comment.