Skip to content

Commit

Permalink
Removing Maintenance zone seed from migration
Browse files Browse the repository at this point in the history
Present also in Zone.seed
  • Loading branch information
slemrmartin committed Aug 1, 2018
1 parent 6c36a15 commit e2f4ce1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class MakeMaintenanceZoneRecord < ActiveRecord::Migration[5.0]
class RenameUserMaintenanceZoneRecord < ActiveRecord::Migration[5.0]
class Zone < ActiveRecord::Base
include ActiveRecord::IdRegions

Expand All @@ -8,19 +8,17 @@ class Zone < ActiveRecord::Base
end

def up
say_with_time("Creating Maintenance Zone") do
say_with_time("Renaming user-defined Maintenance Zone") do
zone = Zone.in_my_region.where(:name => Zone::MAINTENANCE_ZONE_NAME).first
if zone.present?
zone.name = "#{zone.name}_0"
zone.save
end

Zone.create_with(:description => "Maintenance Zone", :visible => false).find_or_create_by!(:name => Zone::MAINTENANCE_ZONE_NAME)
end
end

def down
say_with_time("Deleting Maintenance Zone") do
say_with_time("Renaming user-defined Maintenance Zone") do
Zone.in_my_region.where(:name => Zone::MAINTENANCE_ZONE_NAME).where(:visible => false).destroy_all

orig = Zone.in_my_region.where(:name => "#{Zone::MAINTENANCE_ZONE_NAME}_0").first
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require_migration

describe MakeMaintenanceZoneRecord do
describe RenameUserMaintenanceZoneRecord do
let(:zone_stub) { migration_stub(:Zone) }

let(:remote_region_start) do
Expand All @@ -13,12 +13,6 @@
zone_stub.delete_all
end

it "adds MaintenanceZone" do
migrate

expect(zone_stub.where(:name => zone_stub::MAINTENANCE_ZONE_NAME).where(:visible => false).count).to eq(1)
end

it "renames original maintenance zone" do
orig = zone_stub.create!(:name => zone_stub::MAINTENANCE_ZONE_NAME)

Expand Down

0 comments on commit e2f4ce1

Please sign in to comment.