Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refresh to pick up scm options for Tower Project #14220

Merged
merged 1 commit into from
Mar 9, 2017
Merged
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
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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @Ladas it would be nice if lazy_find would also work with non strings - maybe this is just a small tweak somehwere

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 @@ -103,17 +103,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 @@ -174,6 +181,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