Sha256: 810f85b4e4793cdb3bd5f065eaa996c6298c8a57d5d19687629465750424cb4f

Contents?: true

Size: 964 Bytes

Versions: 29

Compression:

Stored size: 964 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

29 entries across 29 versions & 1 rubygems

Version Path
lolita-file-upload-0.7.3 spec/models/file_spec.rb
lolita-file-upload-0.7.2 spec/models/file_spec.rb
lolita-file-upload-0.7.1 spec/models/file_spec.rb
lolita-file-upload-0.6.2 spec/models/file_spec.rb
lolita-file-upload-0.6.1 spec/models/file_spec.rb
lolita-file-upload-0.6.0 spec/models/file_spec.rb
lolita-file-upload-0.5.0 spec/models/file_spec.rb
lolita-file-upload-0.4.13 spec/models/file_spec.rb
lolita-file-upload-0.4.12 spec/models/file_spec.rb
lolita-file-upload-0.4.11 spec/models/file_spec.rb
lolita-file-upload-0.3.0.2 spec/models/file_spec.rb
lolita-file-upload-0.3.0.1 spec/models/file_spec.rb
lolita-file-upload-0.4.10 spec/models/file_spec.rb
lolita-file-upload-0.4.9 spec/models/file_spec.rb
lolita-file-upload-0.4.8 spec/models/file_spec.rb
lolita-file-upload-0.4.7 spec/models/file_spec.rb
lolita-file-upload-0.4.2 spec/models/file_spec.rb
lolita-file-upload-0.4.1 spec/models/file_spec.rb
lolita-file-upload-0.4.0 spec/models/file_spec.rb
lolita-file-upload-0.3.0 spec/models/file_spec.rb