summaryrefslogtreecommitdiff
path: root/spec/controllers/api
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2015-01-27 22:17:59 -0700
committermo khan <mo@mokhan.ca>2015-01-27 22:17:59 -0700
commit93487c7b6cd8d34186696e4bc30da642528defd2 (patch)
treea8454cbb883e6e3f8923b166a7bb989036b467d3 /spec/controllers/api
parentc182d3ce40a0e5cb22eefecc21992ad643184083 (diff)
add test for uploading a new photo.
Diffstat (limited to 'spec/controllers/api')
-rw-r--r--spec/controllers/api/v1/photos_controller_spec.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/spec/controllers/api/v1/photos_controller_spec.rb b/spec/controllers/api/v1/photos_controller_spec.rb
index 286e32bc..35204e70 100644
--- a/spec/controllers/api/v1/photos_controller_spec.rb
+++ b/spec/controllers/api/v1/photos_controller_spec.rb
@@ -27,6 +27,22 @@ module Api
expect(assigns(:photo)).to eql(photo)
end
end
+
+ describe "#create" do
+ let(:file) { fixture_file_upload('images/example.png', 'image/png') }
+
+ it 'attaches a new photo to a cake' do
+ allow(ProcessPhotoJob).to receive(:perform_later)
+
+ xhr :post, :create, cake_id: cake.id, watermark: 'watery', image: file
+
+ cake.reload
+ expect(cake.photos.count).to eql(1)
+ expect(cake.photos.first.watermark).to eql('watery')
+ expect(cake.photos.first.image_processing).to be_truthy
+ expect(ProcessPhotoJob).to have_received(:perform_later)
+ end
+ end
end
end
end