Sha256: cab3a21cbec1b19214931d6902be0ff904070615718d908b293e9cf61ece4912

Contents?: true

Size: 1.43 KB

Versions: 37

Compression:

Stored size: 1.43 KB

Contents

require 'spec_helper'

describe Uploader::Fileuploads do
  before(:all) do
    @picture = FactoryGirl.create(:picture)
  end

  it "should be a Module" do
    Uploader::Fileuploads.should be_a(Module)
  end
  
  it "should return asset class" do
    Article.fileupload_klass("picture").should == Picture
  end
  
  it "should find asset by guid" do
    asset = Article.fileupload_find("picture", @picture.guid)
    asset.should == @picture
  end

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

  context "instance methods" do
    before(:each) do
      @article = FactoryGirl.build(:article)
    end

    it "should generate guid" do
      @article.fileupload_guid.should_not be_blank
    end

    it "should change guid" do
      @article.fileupload_guid = "other guid"
      @article.fileupload_changed?.should be_true
      @article.fileupload_guid.should == "other guid"
    end

    it "should not multiplay upload" do
      @article.fileupload_multiple?("picture").should be_false
    end

    it "should find uploaded asset or build new record" do
      picture = @article.fileupload_asset(:picture)
      picture.should_not be_nil
      picture.should be_new_record
    end

    it "should return fileuploads columns" do
      @article.fileuploads_columns.should include(:picture)
    end
  end
end

Version data entries

37 entries across 37 versions & 3 rubygems

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