diff --git a/app/models/spree/feed_product.rb b/app/models/spree/feed_product.rb index 9103932..127e507 100644 --- a/app/models/spree/feed_product.rb +++ b/app/models/spree/feed_product.rb @@ -10,30 +10,30 @@ def id product.id end - # FIXME: Must be "new", "refurbished", or "used". - def condition - "retail" + def title + product.name end - def price - product.price.to_s + def description + product.description end - def image_link - return unless product.images.any? - product.images.first.attachment.url(:large) + # Must be selected from https://support.google.com/merchants/answer/1705911 + def category end - def published_at - (product.available_on || product.created_at).strftime("%a, %d %b %Y %H:%M:%S %z") + # Must be "new", "refurbished", or "used". + def condition + "new" end - def description - product.description + def price + Spree::Money.new(product.price) end - def title - product.name + def image_link + return unless product.images.any? + product.images.first.attachment.url(:large) end end end diff --git a/app/views/spree/products/index.rss.builder b/app/views/spree/products/index.rss.builder index e53cc93..90feff0 100644 --- a/app/views/spree/products/index.rss.builder +++ b/app/views/spree/products/index.rss.builder @@ -9,17 +9,14 @@ xml.rss version: "2.0", "xmlns:g" => "http://base.google.com/ns/1.0" do @feed_products.each do |feed_product| xml.item do - xml.link product_url(feed_product.product) - xml.author current_store.url - + xml.tag! 'g:id', feed_product.id xml.title feed_product.title xml.description feed_product.description - xml.pubDate feed_product.published_at - xml.guid feed_product.id - xml.tag! 'g:id', feed_product.id + xml.category feed_product.category if feed_product.category + xml.link product_url(feed_product.product) xml.tag! 'g:image_link', feed_product.image_link - xml.tag! 'g:price', feed_product.price xml.tag! 'g:condition', feed_product.condition + xml.tag! 'g:price', feed_product.price.money.format(symbol: false, with_currency: true) end end end diff --git a/spec/models/spree/feed_product_spec.rb b/spec/models/spree/feed_product_spec.rb index 5535b79..ee40b9d 100644 --- a/spec/models/spree/feed_product_spec.rb +++ b/spec/models/spree/feed_product_spec.rb @@ -16,14 +16,19 @@ end end + describe "#category" do + subject { feed_product.category } + it { is_expected.to be_nil } + end + describe "#condition" do subject { feed_product.condition } - it { is_expected.to eq "retail" } + it { is_expected.to eq "new" } end describe "#price" do subject { feed_product.price } - it { is_expected.to eq "19.99" } + it { is_expected.to eq Spree::Money.new(19.99, currency: 'USD') } end describe "#image_link" do @@ -38,12 +43,6 @@ end end - describe "#published_at" do - subject { feed_product.published_at } - before { product.update_column :available_on, DateTime.new(0) } - it { is_expected.to eq "Thu, 01 Jan 0000 00:00:00 +0000" } - end - describe "#description" do subject { feed_product.description } it { is_expected.to eq "As seen on TV!" }