Sha256: 5140fa6560c3b05fb245fb34e6c7e11e1744b9354498845f52530b4b1f7613fe

Contents?: true

Size: 912 Bytes

Versions: 22

Compression:

Stored size: 912 Bytes

Contents

require 'spec_helper'

class MongoidArticle
  include Mongoid::Document
  include Uploader::Fileuploads

  has_one :mongoid_picture, :as => :assetable

  fileuploads :mongoid_picture
end

class MongoidPicture
  include Mongoid::Document
  include Uploader::Asset::Mongoid

  belongs_to :assetable, polymorphic: true
end

describe Uploader::Asset::Mongoid do
  before do
    @guid = 'guid'
    @picture = MongoidPicture.create!(:guid => @guid, :assetable_type => 'MongoidArticle')
  end

  it 'should find asset by guid' do
    asset = MongoidArticle.fileupload_find("mongoid_picture", @picture.guid)
    asset.should == @picture
  end

  it "should update asset target_id by guid" do
    MongoidArticle.fileupload_update(1000, @picture.guid, :mongoid_picture)
    @picture.reload
    @picture.assetable_id.should == 1000
    @picture.guid.should be_nil
  end

  after do
    MongoidPicture.destroy_all
  end
end

Version data entries

22 entries across 22 versions & 2 rubygems

Version Path
glebtv-rails-uploader-0.12.0 spec/mongoid_spec.rb
glebtv-rails-uploader-0.11.1 spec/mongoid_spec.rb
glebtv-rails-uploader-0.11.0 spec/mongoid_spec.rb
glebtv-rails-uploader-0.10.1 spec/mongoid_spec.rb
glebtv-rails-uploader-0.10.0 spec/mongoid_spec.rb
rails-uploader-0.2.7 spec/mongoid_spec.rb
rails-uploader-0.2.6 spec/mongoid_spec.rb
glebtv-rails-uploader-0.9.0 spec/mongoid_spec.rb
glebtv-rails-uploader-0.8.0 spec/mongoid_spec.rb
glebtv-rails-uploader-0.7.1 spec/mongoid_spec.rb
glebtv-rails-uploader-0.7.0 spec/mongoid_spec.rb
glebtv-rails-uploader-0.6.1 spec/mongoid_spec.rb
glebtv-rails-uploader-0.6.0 spec/mongoid_spec.rb
rails-uploader-0.2.5 spec/mongoid_spec.rb
glebtv-rails-uploader-0.5.1 spec/mongoid_spec.rb
glebtv-rails-uploader-0.5.0 spec/mongoid_spec.rb
rails-uploader-0.2.4 spec/mongoid_spec.rb
rails-uploader-0.2.3 spec/mongoid_spec.rb
rails-uploader-0.2.0 spec/mongoid_spec.rb
rails-uploader-0.1.4 spec/mongoid_spec.rb