Permalink
Browse files

Added a request spec

  • Loading branch information...
1 parent fce512f commit c760924bc4abac0e905a7e6d915a52b9c4058813 @LBRapid LBRapid committed Jan 5, 2012
@@ -1,6 +1,6 @@
<% if get_recently_viewed_products.any? %>
<h3><%= t :recently_viewed_products %></h3>
- <ul>
+ <ul id="recently_viewed_products">
<% get_recently_viewed_products.each do |p| %>
<li><%= link_to p.name, p %></li>
<% end -%>
@@ -7,13 +7,13 @@
describe "Spree::Product.find_by_array_of_ids" do
it "should return the products specified in the array of product ids" do
- product_ids = [1,2,3]
+ product_ids = Spree::Product.limit(2).map(&:id)
products = Spree::Product.find_by_array_of_ids(product_ids)
- products.size.should == 3
+ products.size.should == 2
end
it "should ignore nonexistant product ids and still return correctly specified products" do
- product_ids = [1,2,200]
+ product_ids = Spree::Product.limit(2).map(&:id) << 200
products = Spree::Product.find_by_array_of_ids(product_ids)
products.size.should == 2
end
@@ -0,0 +1,21 @@
+require 'spec_helper'
+
+describe "Recently Viewed Products" do
+ before(:each) do
+ product1 = Factory(:product, :name => "Mug")
+ product2 = Factory(:product, :name => "Shirt")
+ product3 = Factory(:product, :name => "Jersey")
+ end
+
+ it "should keep track of recently viewed products" do
+ visit root_path
+ click_link "Mug"
+ click_link "Home"
+ click_link "Jersey"
+ click_link "Home"
+ within(:css, "ul#recently_viewed_products") do
+ page.should have_content "Mug"
+ page.should have_content "Jersey"
+ end
+ end
+end
View
@@ -11,6 +11,7 @@
require 'spree/core/testing_support/factories'
RSpec.configure do |config|
+ config.include Spree::Core::Engine.routes.url_helpers
# If you're not using ActiveRecord, or you'd prefer not to run each of your
# examples within a transaction, remove the following line or assign false
# instead of true.

0 comments on commit c760924

Please sign in to comment.