Sha256: c4433a51a0b9b1b48149d9a0795ad5826c38f53cc8c303130cdc13532717e800
Contents?: true
Size: 1.04 KB
Versions: 16
Compression:
Stored size: 1.04 KB
Contents
require 'test_helper' module Adminpanel class ImageTest < ActiveSupport::TestCase test "creating an image should store the size and content_type" do uploader = Adminpanel::PhotoUploader.new(model: Adminpanel::Galleryfile) image = Adminpanel::Galleryfile.new(file: uploader) image.file.store! Rack::Test::UploadedFile.new(Rails.root.join('app/assets/images/hipster.jpg'), 'image/jpg') assert image.save assert_equal image.content_type, 'image/jpg' assert_equal image.file_size.to_i, 52196 end test "updating a record with galleries should destroy old unassigned images of the same type" do unassigned_image = adminpanel_images(:unassigned) assert_not unassigned_image.nil? assert_equal 1, Adminpanel::Galleryfile.where(model: nil).count #trigger delete event gallery = adminpanel_galleries(:one).save assert_equal 0, Adminpanel::Galleryfile.where(model: nil).count assert_raise ActiveRecord::RecordNotFound do unassigned_image.reload end end end end
Version data entries
16 entries across 16 versions & 1 rubygems