Add paperclip configuration to accept thumbnail on Encoded Content

Signed-off-by: marcheing's avatarHeitor Reis <marcheing@gmail.com>
parent bd8d51e1
......@@ -3,10 +3,15 @@ class EncodedContent < ApplicationRecord
storage: :s3,
s3_credentials: AWSSettings.to_h,
s3_region: AWSSettings.aws_region
validates_attachment_content_type :video, content_type: /\Avideo\/.*\Z/
has_attached_file :thumbnail,
storage: :s3,
s3_credentials: AWSSettings.to_h,
s3_region: AWSSettings.aws_region
validates_attachment_content_type :video, content_type: /\Avideo\/.*\Z/
validates_attachment_content_type :thumbnail, content_type: /\Aimage/
validates :content_id, :job_id, presence: true
belongs_to :content
end
......@@ -6,8 +6,19 @@ RSpec.describe EncodedContent, type: :model do
it { is_expected.to validate_presence_of :job_id }
end
describe 'paperclip attachments' do
it { is_expected.to have_attached_file(:video) }
it { is_expected.to validate_attachment_content_type(:video).
allowing('video/mp4', 'video/x-flv', 'video/MP2T', 'video/3gpp', 'video/quicktime', 'video/x-msvideo', 'video/x-ms-wmv').
rejecting('text/plain', 'text/xml', 'image/png', 'image/gif') }
it { is_expected.to have_attached_file(:thumbnail) }
it { is_expected.to validate_attachment_content_type(:thumbnail).
allowing('image/png', 'image/gif', 'image/jpg').
rejecting('text/plain', 'text/xml', 'video/mp4', 'video/x-flv') }
end
describe 'relations' do
it { should belong_to(:content) }
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment