Sha256: 54291254b62279964273a1f2b3d179c42b9cb7633becec18e2489c74a86cdc17

Contents?: true

Size: 925 Bytes

Versions: 2

Compression:

Stored size: 925 Bytes

Contents

require File.dirname(__FILE__) + '/../test_helper'

class CmsUploadTest < ActiveSupport::TestCase
  
  def test_validations
    assert_no_difference 'CmsUpload.count' do
      upload = CmsUpload.create
      assert upload.errors.present?
      assert_has_errors_on upload, [:file_file_name]
    end
  end
  
  def test_create
    assert_difference 'CmsUpload.count', 2 do
      upload = CmsUpload.create(:file => fixture_file_upload('files/valid_image.jpg', 'image/jpeg'))
      assert upload.image?
      upload = CmsUpload.create(:uploaded_file => fixture_file_upload('files/valid_image.jpg'))
      assert upload.image?
    end
  end
  
  def test_create_fails_on_invalid_file
    assert_no_difference 'CmsUpload.count' do
      upload = CmsUpload.create(:file => fixture_file_upload('files/invalid_file.gif', 'image/gif'))
      assert upload.errors.present?
      assert_has_errors_on upload, :file
    end
  end
  
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
comfortable_mexican_sofa-1.0.1 test/unit/cms_upload_test.rb
comfortable_mexican_sofa-1.0.0 test/unit/cms_upload_test.rb