forked from ManageIQ/manageiq
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request ManageIQ#13800 from imtayadeway/give-service-bools…
…-defaults Make Service bools default to false
- Loading branch information
Showing
6 changed files
with
87 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
db/migrate/20170207173837_set_service_display_and_retired_to_false.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
class SetServiceDisplayAndRetiredToFalse < ActiveRecord::Migration[5.0] | ||
class Service < ActiveRecord::Base | ||
self.inheritance_column = :_type_disabled # disable STI | ||
end | ||
|
||
def up | ||
Service.where(:retired => nil).update_all(:retired => false) | ||
Service.where(:display => nil).update_all(:display => false) | ||
end | ||
|
||
def down | ||
# NOP | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
spec/migrations/20170207173837_set_service_display_and_retired_to_false_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
require_migration | ||
|
||
RSpec.describe SetServiceDisplayAndRetiredToFalse do | ||
migration_context :up do | ||
it "sets any null display values to false" do | ||
service = migration_stub(:Service).create!(:display => nil) | ||
|
||
migrate | ||
|
||
expect(service.reload.display).to be(false) | ||
end | ||
|
||
it "sets any null retired values to false" do | ||
service = migration_stub(:Service).create!(:retired => nil) | ||
|
||
migrate | ||
|
||
expect(service.reload.retired).to be(false) | ||
end | ||
end | ||
|
||
migration_context :down do | ||
it "leaves false display values as false" do | ||
service = migration_stub(:Service).create!(:display => false) | ||
|
||
migrate | ||
|
||
expect(service.reload.display).to be(false) | ||
end | ||
|
||
it "leaves false retired values as false" do | ||
service = migration_stub(:Service).create!(:retired => false) | ||
|
||
migrate | ||
|
||
expect(service.reload.retired).to be(false) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters