Sha256: 2f53ea5d6cd5d6c9a522fc2afe8c13aafbfbb308fa38d8abd0319e94720d0b71
Contents?: true
Size: 972 Bytes
Versions: 14
Compression:
Stored size: 972 Bytes
Contents
require 'spec_helper' require 'mongoid' Mongoid.load!('spec/mongoid.yml', ENV['RAILS_ENV']) 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 field :guid, type: String belongs_to :assetable, polymorphic: true end describe Uploader::Asset do before do @guid = 'guid' @article = MongoidArticle.new(fileupload_guid: @guid) @picture = MongoidPicture.create!(guid: @guid, assetable_type: 'MongoidArticle') end it 'should find asset by guid' do asset = @article.fileupload_asset(:mongoid_picture) asset.should == @picture end it "should update asset target_id by guid" do @article.save @picture.reload @picture.assetable_id.should == @article.id @picture.guid.should be_nil end after do MongoidPicture.destroy_all end end
Version data entries
14 entries across 14 versions & 1 rubygems