Skip to content

Instantly share code, notes, and snippets.

@assembler
Created August 13, 2012 11:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save assembler/3339549 to your computer and use it in GitHub Desktop.
Save assembler/3339549 to your computer and use it in GitHub Desktop.
with attachment
context 'with attachment' do
let(:file) {
Rack::Test::UploadedFile.new(Rails.root.join('spec/support/image.jpg'), 'image/jpeg')
}
let(:cloudinary_response) {
{ public_id: "rqdrdaexlgjy5j1hoabig", version: 1338884873, format: 'jpg', resource_type: 'image' }
}
before do
stub_request(:post, %r{api.cloudinary.com}).
to_return(:status => 200, :body => cloudinary_response.to_json, :headers => {})
post "/api/households/#{household.id}/notes", { note: { body: 'Voila', photo_file: file } },
api_headers(1, current_user.api_token)
end
it 'creates new note with attachment' do
json['body'].should == 'Voila'
json['photo'].should include(cloudinary_response[:public_id])
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment