Sha256: 16ea663fb7ff21bcfa43f88610d354c446d5106185a414b12482045386499d38

Contents?: true

Size: 1.16 KB

Versions: 6

Compression:

Stored size: 1.16 KB

Contents

require 'spec_helper'

describe :has_uploadcare_file, :vcr do
  let(:post) { Post.new(title: 'Post title', file: FILE_CDN_URL) }
  let(:subject) { post }
  let(:method) { 'file' }

  describe 'object with uploadcare_file' do
    it 'creates blank post' do
      Post.create!
    end
    it 'responds to has_uploadcare_file? method' do
      is_expected.to respond_to(:has_file_as_uploadcare_file?)
    end

    it 'responds to has_uploadcare_group? method' do
      is_expected.to respond_to(:has_file_as_uploadcare_group?)
    end

    it 'has Uploadcare::Rails::File' do
      expect(post.file).to be_an(Uploadcare::Rails::File)
    end

    it 'stores file after save' do
      post.save
      expect(post.file).to be_stored
    end

    it 'deletes file after destroy',
      vcr: 'has_upload_care_file_destroy_file' do
      post.save
      post.destroy
      expect(post.file).to be_deleted
    end
  end

  context 'instanse methods' do
    it '#has_uploadcare_file? returns true' do
      expect(post.has_file_as_uploadcare_file?).to be_truthy
    end

    it '#has_uploadcare_group? returns false' do
      expect(post.has_file_as_uploadcare_group?).to be_falsey
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
uploadcare-rails-1.2.1 spec/models/has_file_spec.rb
uploadcare-rails-1.2.0 spec/models/has_file_spec.rb
uploadcare-rails-1.2.0.pre.alpha3 spec/models/has_file_spec.rb
uploadcare-rails-1.2.0.pre.alpha spec/models/has_file_spec.rb
uploadcare-rails-1.1.1 spec/models/has_file_spec.rb
uploadcare-rails-1.1.0 spec/models/has_file_spec.rb