Commit 9578ba12 by Isaac Betesh Committed by Jon Yurek

Cucumber needs to tell FakeWeb the s3_domain_url path for uploading a file, and…

Cucumber needs to tell FakeWeb the s3_domain_url path for uploading a file, and FakeWeb needs to return XML
parent 7b3d2bb2
When /^I attach the file "([^"]*)" to "([^"]*)" on S3$/ do |file_path, field| When /^I attach the file "([^"]*)" to "([^"]*)" on S3$/ do |file_path, field|
definition = Paperclip::AttachmentRegistry.definitions_for(User)[field.downcase.to_sym] definition = Paperclip::AttachmentRegistry.definitions_for(User)[field.downcase.to_sym]
path = "https://paperclip.s3.amazonaws.com#{definition[:path]}" path = if defined?(::AWS)
"https://paperclip.s3.amazonaws.com#{definition[:path]}"
else
"https://paperclip.s3-us-west-2.amazonaws.com#{definition[:path]}"
end
path.gsub!(':filename', File.basename(file_path)) path.gsub!(':filename', File.basename(file_path))
path.gsub!(/:([^\/\.]+)/) do |match| path.gsub!(/:([^\/\.]+)/) do |match|
"([^\/\.]+)" "([^\/\.]+)"
end end
FakeWeb.register_uri(:put, Regexp.new(path), :body => "OK") FakeWeb.register_uri(:put, Regexp.new(path), :body => defined?(::AWS) ? "OK" : "<xml></xml>")
step "I attach the file \"#{file_path}\" to \"#{field}\"" step "I attach the file \"#{file_path}\" to \"#{field}\""
end end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment