Skip to content

Commit

Permalink
Merge pull request #131 from djberg96/azure_resource_group_sti
Browse files Browse the repository at this point in the history
Update ResourceGroup type for Azure
(cherry picked from commit bc49956)

https://bugzilla.redhat.com/show_bug.cgi?id=1515452
  • Loading branch information
Fryguy authored and simaishi committed Nov 20, 2017
1 parent ecd0641 commit 1b9189c
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
17 changes: 17 additions & 0 deletions db/migrate/20171117201519_update_resource_group_type_for_azure.rb
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
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

0 comments on commit 1b9189c

Please sign in to comment.