-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #131 from djberg96/azure_resource_group_sti
Update ResourceGroup type for Azure (cherry picked from commit bc49956) https://bugzilla.redhat.com/show_bug.cgi?id=1515452
- Loading branch information
Showing
2 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
db/migrate/20171117201519_update_resource_group_type_for_azure.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
class UpdateResourceGroupTypeForAzure < ActiveRecord::Migration[5.0] | ||
class ResourceGroup < ActiveRecord::Base | ||
self.inheritance_column = :_type_disabled | ||
end | ||
|
||
def up | ||
say_with_time("Update Azure resource group type") do | ||
ResourceGroup.update_all(:type => 'ManageIQ::Providers::Azure::ResourceGroup') | ||
end | ||
end | ||
|
||
def down | ||
say_with_time("Set Azure resource group type to base value") do | ||
ResourceGroup.update_all(:type => 'ResourceGroup') | ||
end | ||
end | ||
end |
45 changes: 45 additions & 0 deletions
45
spec/migrations/20171117201519_update_resource_group_type_for_azure_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
require_migration | ||
|
||
describe UpdateResourceGroupTypeForAzure do | ||
let(:resource_group_stub) { migration_stub :ResourceGroup } | ||
let(:expected_type) { 'ManageIQ::Providers::Azure::ResourceGroup' } | ||
let(:base_type) { 'ResourceGroup' } | ||
|
||
migration_context :up do | ||
it 'Sets the type column to the expected value' do | ||
first_group = resource_group_stub.create!(:name => 'foo', :type => 'Alpha') | ||
second_group = resource_group_stub.create!(:name => 'bar', :type => 'ResourceGroup') | ||
third_group = resource_group_stub.create!(:name => 'baz', :type => 'ManageIQ::Providers::Azure::ResourceGroup') | ||
|
||
migrate | ||
|
||
first_group.reload | ||
expect(first_group.type).to eql(expected_type) | ||
|
||
second_group.reload | ||
expect(second_group.type).to eql(expected_type) | ||
|
||
third_group.reload | ||
expect(third_group.type).to eql(expected_type) | ||
end | ||
end | ||
|
||
migration_context :down do | ||
it 'Sets the type column to the base ResourceGroup type' do | ||
first_group = resource_group_stub.create!(:name => 'foo', :type => 'Alpha') | ||
second_group = resource_group_stub.create!(:name => 'bar', :type => 'ResourceGroup') | ||
third_group = resource_group_stub.create!(:name => 'baz', :type => 'ManageIQ::Providers::Azure::ResourceGroup') | ||
|
||
migrate | ||
|
||
first_group.reload | ||
expect(first_group.type).to eql(base_type) | ||
|
||
second_group.reload | ||
expect(second_group.type).to eql(base_type) | ||
|
||
third_group.reload | ||
expect(third_group.type).to eql(base_type) | ||
end | ||
end | ||
end |