Skip to content

Commit

Permalink
Add service_template copy tests for picture and resource_actions
Browse files Browse the repository at this point in the history
  • Loading branch information
gmcculloug committed Jul 16, 2019
1 parent d898d53 commit 7e176fa
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion spec/models/service_template/copy_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
describe ServiceTemplate do
context "#template_copy" do
describe "#template_copy" do
let(:service_template_ansible_tower) { FactoryBot.create(:service_template_ansible_tower) }
let(:service_template_orchestration) { FactoryBot.create(:service_template_orchestration) }
let(:custom_button) { FactoryBot.create(:custom_button, :applies_to => @st1) }
Expand Down Expand Up @@ -232,5 +232,34 @@
expect(@st1.service_resources.first.resource).not_to be(nil)
end
end

context "picture" do
it "creates a duplicate picture" do
@st1.picture = { :content => 'foobar', :extension => 'jpg' }
new_template = @st1.template_copy

expect(@st1.picture.id).to_not eq(new_template.picture.id)
expect(@st1.picture.content).to eq(new_template.picture.content)
end

it "leave picture nil when source template is nil" do
new_template = @st1.template_copy

expect(@st1.picture).to be_nil
expect(new_template.picture).to be_nil
end
end

context "resource_actions" do
it "duplicates resource_actions" do
@st1.resource_actions << [
FactoryBot.create(:resource_action, :action => "Provision"),
FactoryBot.create(:resource_action, :action => "Retire")
]

new_template = @st1.template_copy
expect(new_template.resource_actions.pluck(:action)).to match_array(%w[Provision Retire])
end
end
end
end

0 comments on commit 7e176fa

Please sign in to comment.