Add budget investment image dimmensions validator.

This commit is contained in:
Senén Rodero Rodríguez
2017-06-23 16:28:08 +02:00
parent d0a5deab5e
commit c914c772c0
11 changed files with 59 additions and 8 deletions

View File

@@ -38,24 +38,38 @@ describe Budget::Investment do
describe "file extension" do
it "should not be valid with '.png' extension" do
investment_with_image.image = File.new("spec/fixtures/files/logo_header.png")
investment_with_image.image = File.new("spec/fixtures/files/clippy.png")
expect(investment_with_image).to_not be_valid
expect(investment_with_image.errors[:image].size).to eq(1)
end
it "should not be valid with '.gif' extension" do
investment_with_image.image = File.new("spec/fixtures/files/logo_header.gif")
investment_with_image.image = File.new("spec/fixtures/files/clippy.gif")
expect(investment_with_image).to_not be_valid
expect(investment_with_image.errors[:image].size).to eq(1)
end
it "should be valid with '.jpg' extension" do
investment_with_image.image = File.new("spec/fixtures/files/logo_header.jpg")
investment_with_image.image = File.new("spec/fixtures/files/clippy.jpg")
expect(investment_with_image).to be_valid
end
end
describe "image dimmessions" do
it "should be valid when image dimmessions are 475X475 at least" do
expect(investment_with_image).to be_valid
end
it "should be valid when image dimmessions are 475X475 at least" do
investment_with_image.image = File.new("spec/fixtures/files/logo_header.jpg")
expect(investment_with_image).not_to be_valid
end
end
describe "description" do
it "should be valid when image and image_title are not defined" do