diff options
| author | mo khan <mo@mokhan.ca> | 2014-06-07 08:26:53 -0600 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2014-06-07 08:26:53 -0600 |
| commit | 532fa71eae4ecc096d30e2fbebcd77305889fcf6 (patch) | |
| tree | 5ff30d137dba8c96af0755b865fd04c543b15889 /spec | |
| parent | b3d59861124ece048e34fcb58c1a3ec99ed3feba (diff) | |
add ability to generate urls for different versions of an image.
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/controllers/creations_controller_spec.rb | 5 | ||||
| -rw-r--r-- | spec/controllers/my/photos_controller_spec.rb | 7 | ||||
| -rw-r--r-- | spec/factories/photo.rb | 2 | ||||
| -rw-r--r-- | spec/models/photo_spec.rb | 21 |
4 files changed, 26 insertions, 9 deletions
diff --git a/spec/controllers/creations_controller_spec.rb b/spec/controllers/creations_controller_spec.rb index 692d6495..e8c9583d 100644 --- a/spec/controllers/creations_controller_spec.rb +++ b/spec/controllers/creations_controller_spec.rb @@ -5,9 +5,8 @@ describe CreationsController do let(:creation){ create(:creation, :user => user) } before(:each) do - photo = File.new(File.join(Rails.root, 'spec/fixtures/images/example.png')) - creation.add_photo(photo) - creation.photos.first.update_attribute(:image_processing, nil) + photo = 'spec/fixtures/images/example.png' + creation.photos.create(image: photo, image_processing: nil) end describe :index do diff --git a/spec/controllers/my/photos_controller_spec.rb b/spec/controllers/my/photos_controller_spec.rb index fc917f4f..75d85381 100644 --- a/spec/controllers/my/photos_controller_spec.rb +++ b/spec/controllers/my/photos_controller_spec.rb @@ -32,13 +32,10 @@ module My end describe :delete do - let!(:photo) { create(:photo) } + let!(:photo) { create(:photo, creation_id: cake.id, image_processing: nil) } before :each do - cake.photos << photo - cake.save! - photo.update_attribute(:image_processing, nil) - delete :destroy, :cake_id => cake.id, :id => photo.id + delete :destroy, cake_id: cake.id, id: photo.id end it "returns http success" do diff --git a/spec/factories/photo.rb b/spec/factories/photo.rb index 95763112..71dea1a1 100644 --- a/spec/factories/photo.rb +++ b/spec/factories/photo.rb @@ -1,5 +1,5 @@ FactoryGirl.define do factory :photo, class: Photo do - image { File.new(File.join(Rails.root, 'spec/fixtures/images/example.png')) } + image { 'example.png' } end end diff --git a/spec/models/photo_spec.rb b/spec/models/photo_spec.rb index 0fa2900b..e807fc34 100644 --- a/spec/models/photo_spec.rb +++ b/spec/models/photo_spec.rb @@ -36,4 +36,25 @@ describe Photo do "uploads/photo/image/#{subject.id}/#{prefix}gps.jpg" end end + + describe "#url_for" do + let(:asset_host) { ENV['ASSET_HOST'] } + + before :each do + subject.id = rand(100) + subject.image = "blah.png" + end + + it "returns the url to the large version" do + expect(subject.url_for(:large)).to eql("#{asset_host}/uploads/photo/image/#{subject.id}/large_blah.png") + end + + it "returns the url for the thumbnail version" do + expect(subject.url_for(:thumb)).to eql("#{asset_host}/uploads/photo/image/#{subject.id}/thumb_blah.png") + end + + it "returns the url for the original version" do + expect(subject.url_for(:original)).to eql("#{asset_host}/uploads/photo/image/#{subject.id}/blah.png") + end + end end |
