Sha256: 068d57ce5016d072aab140e2532f7c7f0e71b063026323ae4a5adefdc4ddbf60

Contents?: true

Size: 997 Bytes

Versions: 2

Compression:

Stored size: 997 Bytes

Contents

require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')

describe Lolita::Upload::File do
  
  let(:dbi){
    Lolita::DBI::Base.new(Post)
  }
  let(:normal_file){
      Lolita::Upload::File.new(:asset=>File.open(Support.get_file("normal_file.txt")))
  }
  let(:tab){
    Lolita::Configuration::Tab::Files.new(dbi)
  }

  context "upload" do
      it "should be allowed" do
        file=Lolita::Upload::File.create(:asset=>File.open(Support.get_file("large_file.txt")))
        file.asset.current_path.should match(/large_file\.txt$/)
      end
  end

  context "configuration" do
    it "should get from parent model lolita file tab" do
      post=Factory.create(:post)
      Post.lolita.tabs.clear # remove all tabs
      file_tab=tab
      file_tab.maxfilesize=5
      Post.lolita.tabs << file_tab
      normal_file.fileable=post
      normal_file.save
      normal_file.errors[:asset].should == ["file too big (max #{5.0} bytes)"]
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
lolita-file-upload-0.2.1 spec/models/file_spec.rb
lolita-file-upload-0.2.0 spec/models/file_spec.rb