From e4b3ab63c1c08bde695a01a0274ecd742fb707c5 Mon Sep 17 00:00:00 2001 From: Martin Slemr Date: Wed, 1 Aug 2018 17:11:01 +0200 Subject: [PATCH] Removing Maintenance zone seed from migration Present also in Zone.seed --- ...25655_rename_user_maintenance_zone_record.rb} | 8 +++----- ..._rename_user_maintenance_zone_record_spec.rb} | 16 +--------------- 2 files changed, 4 insertions(+), 20 deletions(-) rename db/migrate/{20180626125654_make_maintenance_zone_record.rb => 20180626125655_rename_user_maintenance_zone_record.rb} (69%) rename spec/migrations/{20180626125654_make_maintenance_zone_record_spec.rb => 20180626125655_rename_user_maintenance_zone_record_spec.rb} (84%) 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 84% 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..4d035a3c0 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 @@ -9,16 +9,6 @@ end migration_context :up do - before(:each) do - 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) @@ -42,10 +32,6 @@ end migration_context :down do - before(:each) do - zone_stub.delete_all - end - it "removes MaintenanceZone" do zone_stub.create!(:name => zone_stub::MAINTENANCE_ZONE_NAME, :description => 'Maintenance Zone',