Sha256: 33794fd7e83291e859d86e4e78290d061d16e75ee60c5e2ff3e64549c0f41280
Contents?: true
Size: 1.52 KB
Versions: 1
Compression:
Stored size: 1.52 KB
Contents
require 'test_helper' require 'lupca/carrierwave_image_validation' class User::Test < ActiveSupport::TestCase test 'aspect ratio valid' do e = User.new e.avatar = fixture_file_upload("image_150x150.png") assert_equal e.valid?, true end test 'aspect ratio invalid width 600 x 800' do e = User.new e.avatar = fixture_file_upload('image_600x800.png') assert !e.valid? assert_equal e.errors.full_messages, ["Avatar must have an aspect ratio of 1x1"] end test 'aspect ratio invalid width 800 x 600' do u = User.new u.avatar = fixture_file_upload('image_800x600.png') assert !u.valid? assert_equal u.errors.full_messages, ["Avatar must have an aspect ratio of 1x1"] end # test 'aspect ratio invalid: not is image' do # e = User.new # e.avatar = fixture_file_upload('test.html') # assert !e.valid? # assert_equal e.errors.full_messages, ["Avatar is not a valid image"] # end end def image_150x150_file { io: File.open(Rails.root.join('public', 'image_150x150.png')), filename: 'image_150x150_file.png', content_type: 'image/png' } end def image_800x600_file { io: File.open(Rails.root.join('public', 'image_800x600.png')), filename: 'image_800x600_file.png', content_type: 'image/png' } end def image_600x800_file { io: File.open(Rails.root.join('public', 'image_600x800.png')), filename: 'image_600x800_file.png', content_type: 'image/png' } end def html_file { io: File.open(Rails.root.join('public', 'test.html')), filename: 'test.html', content_type: 'text/html' } end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
carrierwave_image_validate-0.0.1 | test/test_carrierwave_image_ratio_validation.rb |