spec/upload_spec.rb in carrierwave-aliyun-0.1.2 vs spec/upload_spec.rb in carrierwave-aliyun-0.1.3
- old
+ new
@@ -1,8 +1,9 @@
require File.dirname(__FILE__) + '/spec_helper'
require "open-uri"
+require "net/http"
ActiveRecord::Base.establish_connection(:adapter => 'sqlite3', :database => ':memory:')
describe "Upload" do
def setup_db
ActiveRecord::Schema.define(:version => 1) do
@@ -99,8 +100,14 @@
it "should get uploaded file" do
attach = open(@attachment.file.url)
attach.size.should == @file.size
end
+ it "should delete old file when upload a new file again" do
+ old_url = @attachment.file.url
+ @attachment.file = load_file("foo.gif")
+ @attachment.save
+ Net::HTTP.get_response(URI.parse(old_url)).code.should == "404"
+ end
end
end
end
\ No newline at end of file