Sha256: bf072c3fbc0e9af4c05974801ccc7c51d610ef8b3d355976fb2e51fcaf516113

Contents?: true

Size: 1.01 KB

Versions: 16

Compression:

Stored size: 1.01 KB

Contents

require 'spec_helper'

describe Uploader::AttachmentsController do
  include Rack::Test::Methods
  
  def app
    Dummy::Application
  end
  
  it "should create new asset" do
    file = Rack::Test::UploadedFile.new('spec/factories/files/rails.png', "image/png")
    post "/uploader/attachments", {
      :klass => "Picture", 
      :assetable_id => "1",
      :assetable_type => "Article",
      :guid => "SOMESTRING",
      :asset => {:data => file}
    }
    
    last_response.body.should include("assetable_type")
    last_response.body.should include("SOMESTRING")
    last_response.body.should include("data")
  end
  
  it "should destroy asset" do
    @asset = FactoryGirl.create(:picture)
    
    lambda {
      delete "/uploader/attachments/#{@asset.id}", {:klass => "Picture"}
    }.should change { Picture.count }.by(-1)
  end
  
  it "should raise 404 error with wrong class" do
    lambda {
      post "/uploader/attachments", {:klass => "wrong"}
    }.should raise_error(ActionController::RoutingError)
  end
end

Version data entries

16 entries across 16 versions & 3 rubygems

Version Path
glebtv-rails-uploader-0.3.0 spec/requests/attachments_controller_spec.rb
rails-uploader-0.1.4 spec/requests/attachments_controller_spec.rb
glebtv-rails-uploader-0.2.0 spec/requests/attachments_controller_spec.rb
rails-uploader-0.1.3 spec/requests/attachments_controller_spec.rb
rails-uploader-0.1.2 spec/requests/attachments_controller_spec.rb
glebtv-rails-uploader-0.1.3 spec/requests/attachments_controller_spec.rb
glebtv-rails-uploader-0.1.2 spec/requests/attachments_controller_spec.rb
glebtv-rails-uploader-0.1.1 spec/requests/attachments_controller_spec.rb
glebtv-rails-uploader-0.0.8 spec/requests/attachments_controller_spec.rb
rails-uploader-0.1.0 spec/requests/attachments_controller_spec.rb
rails-uploader-0.0.8 spec/requests/attachments_controller_spec.rb
sunrise-cms-0.5.0.rc1 vendor/bundle/ruby/1.9.1/gems/rails-uploader-0.0.7/spec/requests/attachments_controller_spec.rb
rails-uploader-0.0.7 spec/requests/attachments_controller_spec.rb
rails-uploader-0.0.6 spec/requests/attachments_controller_spec.rb
rails-uploader-0.0.5 spec/requests/attachments_controller_spec.rb
rails-uploader-0.0.4 spec/requests/attachments_controller_spec.rb