Sha256: 36f2bf1b69bcb29719a8fa5d4de320c59d75c9fa9267481f8964d2fb5c3a9251

Contents?: true

Size: 1.03 KB

Versions: 2

Compression:

Stored size: 1.03 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 => "507f1f77bcf86cd799439011",
      :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

2 entries across 2 versions & 1 rubygems

Version Path
glebtv-rails-uploader-0.4.1 spec/requests/attachments_controller_spec.rb
glebtv-rails-uploader-0.4.0 spec/requests/attachments_controller_spec.rb