Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fixed tests for the s3 storage

  • Loading branch information...
commit 1f93b89b1cf5bda64a3be9af70c7ba276c3f916c 1 parent 5f5369d
Trevor Rowe trevorrowe authored
1  features/basic_integration.feature
View
@@ -22,6 +22,7 @@ Feature: Rails integration
And I should see an image with a path of "/system/attachments/1/original/5k.png"
And the file at "/system/attachments/1/original/5k.png" should be the same as "test/fixtures/5k.png"
+ @s3
Scenario: S3 Integration test
Given I add this snippet to the User model:
"""
2  features/step_definitions/rails_steps.rb
View
@@ -10,7 +10,7 @@
gem "sqlite3"
gem "capybara"
gem "gherkin"
- gem "aws-s3"
+ gem "aws-sdk"
"""
And I configure the application to use "paperclip" from this project
And I reset Bundler environment variable
2  lib/paperclip/storage/s3.rb
View
@@ -292,7 +292,7 @@ def flush_deletes #:nodoc:
@queued_for_delete.each do |path|
begin
log("deleting #{path}")
- s3_bucket.objects[path].delete
+ s3_bucket.objects[path.sub(%r{^/},'')].delete
rescue AWS::Errors::Base => e
# Ignore this.
end
17 test/storage/s3_test.rb
View
@@ -1,6 +1,7 @@
require 'aws'
-AWS.config(:access_key_id => "TESTKEY",
- :secret_access_key => "TESTSECRET")
+
+AWS.stub!
+AWS.config(:access_key_id => "TESTKEY", :secret_access_key => "TESTSECRET")
require './test/helper'
@@ -159,7 +160,6 @@ def rails_env(env)
context "An attachment that uses S3 for storage and has spaces in file name" do
setup do
- AWS::S3::Base.stubs(:establish_connection!)
rebuild_model :styles => { :large => ['500x500#', :jpg] },
:storage => :s3,
:bucket => "bucket",
@@ -425,12 +425,13 @@ def counter
end
should "delete tempfiles" do
- AWS::S3::S3Object.stubs(:store).with(@dummy.avatar.path, anything, 'testing', :content_type => 'image/png', :access => :public_read)
+
File.stubs(:exist?).returns(true)
Paperclip::Tempfile.any_instance.expects(:close).at_least_once()
Paperclip::Tempfile.any_instance.expects(:unlink).at_least_once()
@dummy.save!
+
end
context "and saved without a bucket" do
@@ -531,7 +532,7 @@ def counter
context "when assigned" do
setup do
- @file = File.new(File.join(File.dirname(__FILE__), 'fixtures', '5k.png'), 'rb')
+ @file = File.new(File.join(File.dirname(__FILE__), '..', 'fixtures', '5k.png'), 'rb')
@dummy = Dummy.new
@dummy.avatar = @file
end
@@ -570,7 +571,7 @@ def counter
context "when assigned" do
setup do
- @file = File.new(File.join(File.dirname(__FILE__), 'fixtures', '5k.png'), 'rb')
+ @file = File.new(File.join(File.dirname(__FILE__), '..', 'fixtures', '5k.png'), 'rb')
@dummy = Dummy.new
@dummy.avatar = @file
end
@@ -609,7 +610,7 @@ def counter
context "when assigned" do
setup do
- @file = File.new(File.join(File.dirname(__FILE__), 'fixtures', '5k.png'), 'rb')
+ @file = File.new(File.join(File.dirname(__FILE__), '..', 'fixtures', '5k.png'), 'rb')
@dummy = Dummy.new
@dummy.avatar = @file
end
@@ -648,7 +649,7 @@ def counter
context "when assigned" do
setup do
- @file = File.new(File.join(File.dirname(__FILE__), 'fixtures', '5k.png'), 'rb')
+ @file = File.new(File.join(File.dirname(__FILE__), '..', 'fixtures', '5k.png'), 'rb')
@dummy = Dummy.new
@dummy.avatar = @file
end
Please sign in to comment.
Something went wrong with that request. Please try again.