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

WIP: testing dependent-destroy #52

Closed
wants to merge 1 commit into from
Closed
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
40 changes: 40 additions & 0 deletions spec/support/ansible_shared/provider.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,46 @@
expect(OperatingSystem.count).to eq(0)
expect(Hardware.count).to eq(0)
end

it "thru automation_manager will remove all child objects" do
subject.automation_manager.configured_systems = [
FactoryGirl.create(:configured_system, :computer_system =>
Copy link
Contributor

Choose a reason for hiding this comment

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

you should use different factory https://github.com/Ladas/manageiq/blob/2f0ef1a90758f2b5c37e93a0ed2f586a916dad64/spec/factories/configured_system.rb#L10

or the default factory should contain valid base class STI, in this case ManageIQ::Providers::AutomationManager::ConfiguredSystem


None of factories should be producing a record that can't be created in real life, e.g. ConfiguredSystem with type nil is not valid, refresh always set :type

Copy link
Member

Choose a reason for hiding this comment

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

Thanks @Ladas !

FactoryGirl.create(:computer_system,
:operating_system => FactoryGirl.create(:operating_system),
:hardware => FactoryGirl.create(:hardware)))
]

expect(ExtManagementSystem.count).to eq(1)
expect(subject.automation_manager.class.name).to eq("ManageIQ::Providers::AnsibleTower::AutomationManager")
subject.automation_manager.destroy

expect(Provider.count).to eq(1)
expect(ExtManagementSystem.count).to eq(0)
expect(ConfiguredSystem.count).to eq(0)
expect(ComputerSystem.count).to eq(0)
expect(OperatingSystem.count).to eq(0)
expect(Hardware.count).to eq(0)
end

it "thru ems will NOT remove all child objects" do
subject.automation_manager.configured_systems = [
FactoryGirl.create(:configured_system, :computer_system =>
FactoryGirl.create(:computer_system,
:operating_system => FactoryGirl.create(:operating_system),
:hardware => FactoryGirl.create(:hardware)))
]

expect(ExtManagementSystem.count).to eq(1)
expect(ExtManagementSystem.first.class.name).to eq("ManageIQ::Providers::AnsibleTower::AutomationManager")
ExtManagementSystem.first.destroy

expect(Provider.count).to eq(1)
expect(ExtManagementSystem.count).to eq(0)
expect(ConfiguredSystem.count).to eq(1)
expect(ComputerSystem.count).to eq(1)
expect(OperatingSystem.count).to eq(1)
expect(Hardware.count).to eq(1)
end
end

context "#url=" do
Expand Down