Skip to content

Commit

Permalink
Update default of internal attribute in service template
Browse files Browse the repository at this point in the history
  • Loading branch information
hsong-rh committed Aug 12, 2018
1 parent 46a826e commit b1bbdbc
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
11 changes: 11 additions & 0 deletions db/migrate/20180810144738_update_default_internal_attribute.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class UpdateDefaultInternalAttribute < ActiveRecord::Migration[5.0]
class ServiceTemplate < ActiveRecord::Base
self.inheritance_column = :_type_disabled
end

def up
say_with_time("Set ServiceTemplate internal") do
ServiceTemplate.where.not(:type => "ServiceTemplateTransformationPlan").update_all(:internal => false)
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
require_migration

describe UpdateDefaultInternalAttribute do
let(:service_template_stub) { migration_stub(:ServiceTemplate) }

migration_context :up do
it "sets internal to false when type is ServiceTemplateTransformationPlan" do
st = service_template_stub.create!(:type => 'ServiceTemplateTransformationPlan', :internal => true)

migrate

expect(st.reload.internal).to be_truthy
end

it "sets internal to false when type is not ServiceTemplateTransformationPlan" do
st = service_template_stub.create!(:type => 'OtherServiceTemplateTransformationPlan')

migrate

expect(st.reload.internal).to be(false)
end
end
end

0 comments on commit b1bbdbc

Please sign in to comment.