diff --git a/db/migrate/20180626125654_make_maintenance_zone_record.rb b/db/migrate/20180626125655_rename_user_maintenance_zone_record.rb similarity index 69% rename from db/migrate/20180626125654_make_maintenance_zone_record.rb rename to db/migrate/20180626125655_rename_user_maintenance_zone_record.rb index e159f7b8d..7ab7719b5 100644 --- a/db/migrate/20180626125654_make_maintenance_zone_record.rb +++ b/db/migrate/20180626125655_rename_user_maintenance_zone_record.rb @@ -1,4 +1,4 @@ -class MakeMaintenanceZoneRecord < ActiveRecord::Migration[5.0] +class RenameUserMaintenanceZoneRecord < ActiveRecord::Migration[5.0] class Zone < ActiveRecord::Base include ActiveRecord::IdRegions @@ -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 diff --git a/spec/migrations/20180626125654_make_maintenance_zone_record_spec.rb b/spec/migrations/20180626125655_rename_user_maintenance_zone_record_spec.rb similarity index 90% rename from spec/migrations/20180626125654_make_maintenance_zone_record_spec.rb rename to spec/migrations/20180626125655_rename_user_maintenance_zone_record_spec.rb index 310a107dc..e03487431 100644 --- a/spec/migrations/20180626125654_make_maintenance_zone_record_spec.rb +++ b/spec/migrations/20180626125655_rename_user_maintenance_zone_record_spec.rb @@ -1,6 +1,6 @@ require_migration -describe MakeMaintenanceZoneRecord do +describe RenameUserMaintenanceZoneRecord do let(:zone_stub) { migration_stub(:Zone) } let(:remote_region_start) do @@ -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)