Add missing image model spec. Add shared specs to check image validations at any imageable model

This commit is contained in:
Senén Rodero Rodríguez
2017-09-15 19:02:49 +02:00
parent bb57c1a7f5
commit c6dabedb4a
13 changed files with 208 additions and 16 deletions

View File

@@ -0,0 +1,19 @@
require 'rails_helper'
describe DirectUpload do
it "should be valid for different kind of combinations when attachment is valid" do
expect(build(:direct_upload, :proposal, :documents)).to be_valid
expect(build(:direct_upload, :proposal, :image)).to be_valid
expect(build(:direct_upload, :budget_investment, :documents)).to be_valid
expect(build(:direct_upload, :budget_investment, :image)).to be_valid
end
it "should not be valid for different kind of combinations when invalid atttachment content types" do
expect(build(:direct_upload, :proposal, :documents, attachment: File.new("spec/fixtures/files/clippy.png"))).not_to be_valid
expect(build(:direct_upload, :proposal, :image, attachment: File.new("spec/fixtures/files/empty.pdf"))).not_to be_valid
expect(build(:direct_upload, :budget_investment, :documents, attachment: File.new("spec/fixtures/files/clippy.png"))).not_to be_valid
expect(build(:direct_upload, :budget_investment, :image, attachment: File.new("spec/fixtures/files/empty.pdf"))).not_to be_valid
end
end