added CouchRest::Model#attachment_url for someone to fetch the attachment using other means

This commit is contained in:
Jonathan S. Katz 2008-10-30 00:50:32 -04:00 committed by Chris Anderson
parent a79d9b7f90
commit 3bff23e7c5
2 changed files with 25 additions and 0 deletions

View file

@ -834,4 +834,22 @@ describe CouchRest::Model do
lambda{Basic.get(@obj.id).read_attachment(@attachment_name)}.should raise_error
end
end
describe "#attachment_url" do
before(:each) do
@obj = Basic.new
@file = File.open(FIXTURE_PATH + '/attachments/test.html')
@attachment_name = 'my_attachment'
@obj.create_attachment(:file => @file, :name => @attachment_name)
@obj.save.should == true
end
it 'should return nil if attachment does not exist' do
@obj.attachment_url('bogus').should be_nil
end
it 'should return the attachment URL as specified by CouchDB HttpDocumentApi' do
@obj.attachment_url(@attachment_name).should == "#{Basic.database}/#{@obj.id}/#{@attachment_name}"
end
end
end