summaryrefslogtreecommitdiff
path: root/spec/models
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2014-06-07 08:26:53 -0600
committermo khan <mo@mokhan.ca>2014-06-07 08:26:53 -0600
commit532fa71eae4ecc096d30e2fbebcd77305889fcf6 (patch)
tree5ff30d137dba8c96af0755b865fd04c543b15889 /spec/models
parentb3d59861124ece048e34fcb58c1a3ec99ed3feba (diff)
add ability to generate urls for different versions of an image.
Diffstat (limited to 'spec/models')
-rw-r--r--spec/models/photo_spec.rb21
1 files changed, 21 insertions, 0 deletions
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