Sha256: fac398ec62408aa74c40e3e17f99c20dc69a8e239ada6096591bc0e3ab44c9e6

Contents?: true

Size: 1.17 KB

Versions: 2

Compression:

Stored size: 1.17 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('thumb_url')
    last_response.body.should include('name')
  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 not destroy asset with not exists guid" do
    @asset = FactoryGirl.create(:picture)

    lambda {
      delete "/uploader/attachments/wrong", {:klass => "Picture"}
    }.should raise_error(ActionController::RoutingError)
  end

  it "should raise 404 error with wrong class" do
    lambda {
      post "/uploader/attachments", {:klass => "wrong"}
    }.should raise_error(ActionController::ParameterMissing)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rails-uploader-0.4.5 spec/requests/attachments_controller_spec.rb
rails-uploader-0.4.4 spec/requests/attachments_controller_spec.rb