Commit 169d8d7e by George Brocklehurst Committed by Mike Burns

(wip) Fix failing cucumber spec

There was a spec that was failing because we removed .attachment_definitions
from models, I expected this to fix it, but apparently it hasn't.
parent 5046dfcb
When /^I attach the file "([^"]*)" to "([^"]*)" on S3$/ do |file_path, field|
definition = User.attachment_definitions[field.downcase.to_sym]
definition = Paperclip::Tasks::Attachments.defintions_for(User)[field.downcase.to_sym]
path = "https://paperclip.s3.amazonaws.com#{definition[:path]}"
path.gsub!(':filename', File.basename(file_path))
path.gsub!(/:([^\/\.]+)/) do |match|
......
......@@ -21,6 +21,10 @@ module Paperclip
instance.each_definition(&block)
end
def self.definitions_for(klass)
instance.definitions_for(klass)
end
def initialize
clear
end
......@@ -46,6 +50,10 @@ module Paperclip
end
end
end
def definitions_for(klass)
@attachments[klass]
end
end
end
end
......@@ -48,6 +48,22 @@ class AttachmentsTest < Test::Unit::TestCase
end
end
context '.definitions_for' do
should 'produce the attachment name and options' do
expected_definitions = {
avatar: { yo: 'greeting' },
greeter: { ciao: 'greeting' }
}
foo = Class.new
Paperclip::Tasks::Attachments.add(foo, :avatar, { yo: 'greeting' })
Paperclip::Tasks::Attachments.add(foo, :greeter, { ciao: 'greeting' })
definitions = Paperclip::Tasks::Attachments.definitions_for(foo)
assert_equal expected_definitions, definitions
end
end
context '.clear' do
should 'remove all of the existing attachment definitions' do
foo = Class.new
......
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