Commit 0902b9f3 authored by marcheing's avatar marcheing Committed by Diego de Araújo Martinez Camarinha

Add validations to content fields

Signed-off-by: Diego de Araújo Martinez Camarinha's avatarDiego Araújo <diegoamc@protonmail.ch>
parent 42de1f79
......@@ -2,5 +2,9 @@ class Content < ApplicationRecord
has_attached_file :video
validates_attachment :video, presence: true
validates_attachment_content_type :video, content_type: /\Avideo\/.*\Z/
validates :terms_of_service, acceptance: true
validates :title, :user_id, :soundtrack, :director, presence: true
end
require 'rails_helper'
RSpec.describe Content, type: :model do
pending "add some examples to (or delete) #{__FILE__}"
describe 'validations' do
%i(title user_id soundtrack director).each do |field|
it { is_expected.to validate_presence_of field }
end
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