Skip to content
This repository has been archived by the owner on Jul 25, 2023. It is now read-only.

Commit

Permalink
Merge pull request #10 from jarednorman/make-correct
Browse files Browse the repository at this point in the history
Bring the feed more in line with the spec
  • Loading branch information
jhawthorn committed May 10, 2016
2 parents 9f936b3 + 265c5f6 commit f5c16da
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 29 deletions.
28 changes: 14 additions & 14 deletions app/models/spree/feed_product.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
11 changes: 4 additions & 7 deletions app/views/spree/products/index.rss.builder
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 7 additions & 8 deletions spec/models/spree/feed_product_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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!" }
Expand Down

0 comments on commit f5c16da

Please sign in to comment.