Getting images working

This commit is contained in:
Will Marshall
2013-12-20 11:49:08 +11:00
parent 751e98443f
commit 0db7eae7f8
4 changed files with 16 additions and 3 deletions

View File

@@ -1,6 +1,10 @@
module Spree
class ImageSerializer < ActiveModel::Serializer
attributes :id, :mini_url, :alt
attributes :id, :small_url, :alt
def small_url
object.attachment.url(:small, false)
end
end
end

View File

@@ -12,7 +12,7 @@
%tbody{"ng-repeat" => "product in data.products "}
%tr.product
%td
-#{{ product.master.images[0].mini_url }}
%img{src: "{{ product.master.images[0].small_url }}"}
-#{{product.master.images[0].alt}}
%td
%h5

View File

@@ -1,7 +1,7 @@
%shop{"ng-app" => "Shop"}
%navigation
%distributor.details.row
%img.left{src: ""}
-#%img.left{src: @distributor.}
%h4
= @distributor.name
%location= @distributor.address.city

View File

@@ -0,0 +1,9 @@
require 'spec_helper'
describe Spree::ImageSerializer do
it "should give us the small url" do
image = Spree::Image.new(attachment: double(:attachment))
image.attachment.should_receive(:url).with(:small, false)
Spree::ImageSerializer.new(image).to_json
end
end