Add tests for paperclip configuration on Content

Signed-off-by: marcheing's avatarHeitor Reis <marcheing@gmail.com>
parent bb2d5d03
......@@ -5,5 +5,14 @@ RSpec.describe Content, type: :model do
%i(title user_id soundtrack director).each do |field|
it { is_expected.to validate_presence_of field }
end
it { is_expected.to validate_acceptance_of :terms_of_service }
end
describe 'paperclip attachments' do
it { is_expected.to have_attached_file(:video) }
it { is_expected.to validate_attachment_presence(: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') }
end
end
require 'factory_girl'
require 'factory_girl'
require 'paperclip/matchers'
# This file was generated by the `rails generate rspec:install` command. Conventionally, all
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
# The generated `.rspec` file contains `--require spec_helper` which will cause
......@@ -104,4 +105,7 @@ RSpec.configure do |config|
config.before(:suite) do
FactoryGirl.find_definitions
end
# Provides RSpec-compatible & Test::Unit-compatible matchers for testing Paperclip attachments.
config.include Paperclip::Shoulda::Matchers
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