geemus/fog — pull request #581 by newmana (2011-11-02 05:10:44+00:00)
Title: Ninefold implementation missing head_object implementation

I have a class called PlanFile that has the following paperclip configuration:
...
has_attached_file :pdf,
:url => "/:new_file_name",
:path => "/data/survey_plan_files/:parent_directory/:add_pdf_to_file_name_no_ext",
:storage => :fog,
:fog_directory => FOG_DIRECTORY,
:fog_credentials => {
:provider => 'Ninefold',
:ninefold_storage_token => '',
:ninefold_storage_secret => ''
}
...

Trying to either delete or overwrite the file I get the following exceptions:

ruby-1.8.7-p334 :005 > p.pdf.destroy
NoMethodError: undefined method `head_object' for #
from /home/andrew/.rvm/gems/ruby-1.8.7-p334/gems/fog-1.0.0.1/lib/fog/ninefold/models/storage/files.rb:54:in `head'
from /home/andrew/.rvm/gems/ruby-1.8.7-p334/gems/paperclip-2.4.5/lib/paperclip/storage/fog.rb:56:in `exists?'
from /home/andrew/.rvm/gems/ruby-1.8.7-p334/gems/paperclip-2.4.5/lib/paperclip/attachment.rb:445:in `queue_existing_for_delete'
from /home/andrew/.rvm/gems/ruby-1.8.7-p334/gems/paperclip-2.4.5/lib/paperclip/attachment.rb:444:in `map'
from /home/andrew/.rvm/gems/ruby-1.8.7-p334/gems/paperclip-2.4.5/lib/paperclip/attachment.rb:444:in `queue_existing_for_delete'
from /home/andrew/.rvm/gems/ruby-1.8.7-p334/gems/paperclip-2.4.5/lib/paperclip/attachment.rb:187:in `clear'
from /home/andrew/.rvm/gems/ruby-1.8.7-p334/gems/paperclip-2.4.5/lib/paperclip/attachment.rb:197:in `destroy'
from (irb):5
ruby-1.8.7-p334 :006 > p.pdf = File.new(p.filename)
NoMethodError: undefined method `head_object' for #
from /home/andrew/.rvm/gems/ruby-1.8.7-p334/gems/fog-1.0.0.1/lib/fog/ninefold/models/storage/files.rb:54:in `head'
from /home/andrew/.rvm/gems/ruby-1.8.7-p334/gems/paperclip-2.4.5/lib/paperclip/storage/fog.rb:56:in `exists?'
from /home/andrew/.rvm/gems/ruby-1.8.7-p334/gems/paperclip-2.4.5/lib/paperclip/attachment.rb:445:in `queue_existing_for_delete'
from /home/andrew/.rvm/gems/ruby-1.8.7-p334/gems/paperclip-2.4.5/lib/paperclip/attachment.rb:444:in `map'
from /home/andrew/.rvm/gems/ruby-1.8.7-p334/gems/paperclip-2.4.5/lib/paperclip/attachment.rb:444:in `queue_existing_for_delete'
from /home/andrew/.rvm/gems/ruby-1.8.7-p334/gems/paperclip-2.4.5/lib/paperclip/attachment.rb:187:in `clear'
from /home/andrew/.rvm/gems/ruby-1.8.7-p334/gems/paperclip-2.4.5/lib/paperclip/attachment.rb:104:in `assign'
from /home/andrew/.rvm/gems/ruby-1.8.7-p334/gems/paperclip-2.4.5/lib/paperclip.rb:337:in `pdf='
from (irb):6

Fog storage.rb for Ninefold is missing "request :head_object" even though the fog/ninefold/models/storage/files.rb (which looks like a cut and paste from Rackspace) calls it.

It just took a bit of pattern matching to get it going.

It appears that there are no tests covering this code paths. I had a go at adding them to "tests/helpers/collection_helper.rb" but they don't seem to be included. I'd really like to know how the testing is suppose to work - some code has mocks and others don't so I wasn't able to easily work out what to do.