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

Update ResourceGroup type for Azure #131

Merged
merged 1 commit into from
Nov 20, 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
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