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

Maintenance zone support for suspending provider #275

Merged
merged 2 commits into from
Sep 24, 2018
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
5 changes: 5 additions & 0 deletions db/migrate/20180618083035_add_visible_to_zone.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddVisibleToZone < ActiveRecord::Migration[5.0]
def change
add_column :zones, :visible, :boolean
end
end
16 changes: 16 additions & 0 deletions db/migrate/20180618084054_init_zones_visibility.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
class InitZonesVisibility < ActiveRecord::Migration[5.0]
class Zone < ActiveRecord::Base
end

def up
say_with_time("Updating all zones to visible") do
Zone.update_all(:visible => true)
end
end

def down
say_with_time("Resetting zone visibility") do
Zone.update_all(:visible => nil)
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddZoneBeforePauseIdToExtManagementSystem < ActiveRecord::Migration[5.0]
def change
add_reference :ext_management_systems, :zone_before_pause, :type => :bigint, :index => true
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddMaintenanceZoneIdToRegion < ActiveRecord::Migration[5.0]
def change
add_column :miq_regions, :maintenance_zone_id, :bigint, :index => true
end
end
26 changes: 26 additions & 0 deletions spec/migrations/20180618084054_init_zones_visibility_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
require_migration
describe InitZonesVisibility do
let(:zone_stub) { migration_stub(:Zone) }

migration_context :up do
it "makes zones visible" do
zone = zone_stub.create!(:name => 'zone1')

migrate
zone.reload

expect(zone.visible).to be_truthy
end
end

migration_context :down do
it 'resets zone visibility' do
zone = zone_stub.create!(:name => 'zone_visible', :visible => true)

migrate
zone.reload

expect(zone.visible).to be_nil
end
end
end