Skip to content

Commit

Permalink
Add additional_tenant info to copy
Browse files Browse the repository at this point in the history
  • Loading branch information
d-m-u committed Jul 16, 2019
1 parent 2b9bba0 commit 0ecc0bf
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
5 changes: 4 additions & 1 deletion app/models/service_template/copy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ def template_copy(new_name = "Copy of " + name + Time.zone.now.to_s)
private

def additional_tenant_copy(template)
template.class.with_additional_tenants.deep_clone
template.additional_tenants << additional_tenants.each do |tenant|
tenant.name = "Copy of " + tenant.name + Time.zone.now.to_s
tenant.subdomain = "Copy of " + tenant.subdomain + Time.zone.now.to_s
end
end

def custom_button_copy(custom_button, template)
Expand Down
12 changes: 12 additions & 0 deletions spec/models/service_template/copy_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -261,5 +261,17 @@
expect(new_template.resource_actions.pluck(:action)).to match_array(%w[Provision Retire])
end
end

context "additional tenants" do
it "duplicates additional tenants" do
@st1.additional_tenants << [
FactoryBot.create(:tenant),
FactoryBot.create(:tenant)
]
expect(@st1.additional_tenants.count).to eq(2)
new_template = @st1.template_copy
expect(new_template.additional_tenants.count).to eq(2)
end
end
end
end

0 comments on commit 0ecc0bf

Please sign in to comment.