Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add internal column to ServiceTemplate table
- Loading branch information
Showing
2 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
db/migrate/20180719163110_add_internal_to_service_template.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,17 @@ | ||
class AddInternalToServiceTemplate < ActiveRecord::Migration[5.0] | ||
class ServiceTemplate < ActiveRecord::Base | ||
self.inheritance_column = :_type_disabled | ||
end | ||
|
||
def up | ||
add_column :service_templates, :internal, :boolean | ||
|
||
say_with_time("Set ServiceTemplate internal") do | ||
ServiceTemplate.where(:type => "ServiceTemplateTransformationPlan").update_all(:internal => true) | ||
end | ||
end | ||
|
||
def down | ||
remove_column :service_templates, :internal | ||
end | ||
end |
23 changes: 23 additions & 0 deletions
23
spec/migrations/20180719163110_add_internal_to_service_template_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,23 @@ | ||
require_migration | ||
|
||
describe AddInternalToServiceTemplate do | ||
let(:service_template_stub) { migration_stub(:ServiceTemplate) } | ||
|
||
migration_context :up do | ||
it "sets internal to true when type is ServiceTemplateTransformationPlan" do | ||
st = service_template_stub.create!(:type => 'ServiceTemplateTransformationPlan') | ||
|
||
migrate | ||
|
||
expect(st.reload.internal).to be_truthy | ||
end | ||
|
||
it "skip internal for other types" do | ||
st = service_template_stub.create!(:type => 'OtherServiceTemplateType') | ||
|
||
migrate | ||
|
||
expect(st.reload.internal).to be_nil | ||
end | ||
end | ||
end |