Skip to content

Commit

Permalink
Fixes tests
Browse files Browse the repository at this point in the history
  • Loading branch information
d-m-u committed Jan 8, 2018
1 parent 7b80b5b commit 2ad96cd
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions spec/models/customization_template_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,43 @@
context "#name" do
context "two pxe templates" do
it "raises error with non-unique names" do
expect { FactoryGirl.create(:customization_template, :name => "foo") }.to_not raise_error
expect { FactoryGirl.create(:customization_template, :name => "foo") }
.to raise_error(ActiveRecord::RecordInvalid, /Name has already been taken/)
FactoryGirl.create(:customization_template, :name => "foo1")

expect { FactoryGirl.create(:customization_template, :name => "foo1") }.to raise_error(ActiveRecord::RecordInvalid, / Name is not unique within region/)
end

it "doesn't raise error with unique names" do
expect { FactoryGirl.create(:customization_template, :name => "foo") }.to_not raise_error
expect { FactoryGirl.create(:customization_template, :name => "something else", :pxe_image_type => PxeImageType.new(:name => "image1")) }.to_not raise_error
FactoryGirl.create(:customization_template)

expect { FactoryGirl.create(:customization_template) }.to_not raise_error
end
end

context "pxe template and a non pxe template" do
it "raises error with non-unique names" do
expect { FactoryGirl.create(:customization_template_cloud_init, :name => "foo") }.to_not raise_error
expect { FactoryGirl.create(:customization_template, :name => "foo", :system => true, :pxe_image_type => nil) }
.to raise_error(ActiveRecord::RecordInvalid, /Name has already been taken/)
FactoryGirl.create(:customization_template, :name => "foo2")

expect { FactoryGirl.create(:customization_template_sysprep, :name => "foo2") }.to raise_error(ActiveRecord::RecordInvalid, / Name is not unique within region/)
end

it "doesn't raise error with unique names" do
expect { FactoryGirl.create(:customization_template_cloud_init, :name => "foo", :system => true, :pxe_image_type => nil) }.to_not raise_error
expect { FactoryGirl.create(:customization_template, :name => "something else", :pxe_image_type => PxeImageType.new(:name => "image1")) }
.to_not raise_error
FactoryGirl.create(:customization_template)

expect { FactoryGirl.create(:customization_template_sysprep) }.to_not raise_error
end
end

context "two non pxe templates" do
it "raises error with non-unique names" do
expect { FactoryGirl.create(:customization_template_cloud_init, :name => "foo", :system => true) }.to_not raise_error
expect { FactoryGirl.create(:customization_template_cloud_init, :name => "foo", :system => true) }
.to raise_error(ActiveRecord::RecordInvalid, /Name has already been taken/)
FactoryGirl.create(:customization_template_cloud_init, :name => "foo3")

expect { FactoryGirl.create(:customization_template_sysprep, :name => "foo3") }.to raise_error(ActiveRecord::RecordInvalid, / Name is not unique within region/)
end

it "doesn't raise error with unique names" do
expect { FactoryGirl.create(:customization_template_cloud_init, :name => "foo", :system => true, :pxe_image_type => PxeImageType.new(:name => "image1")) }.to_not raise_error
expect { FactoryGirl.create(:customization_template_cloud_init, :name => "other", :system => true, :pxe_image_type => PxeImageType.new(:name => "image2")) }.to_not raise_error
FactoryGirl.create(:customization_template_cloud_init)

expect { FactoryGirl.create(:customization_template_sysprep) }.to_not raise_error
end
end
end
Expand Down

0 comments on commit 2ad96cd

Please sign in to comment.