Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

put back search spec

  • Loading branch information...
commit b07a747711a7b36620aaadb196088f75574f31c1 1 parent d4066e5
@sbounmy sbounmy authored
Showing with 57 additions and 0 deletions.
  1. +57 −0 spec/lib/search/base_spec.rb
View
57 spec/lib/search/base_spec.rb
@@ -0,0 +1,57 @@
+require 'spec_helper'
+
+describe Spree::Core::Search::Base do
+
+ before do
+ include ::Spree::ProductFilters
+ @product1 = create(:product, :name => "RoR Shirt", :name_fr => "RoR Chemise", :name_es => "RoR Camisa", :price => 9.00, :on_hand => 1, :available_on => 2.days.ago)
+ @product2 = create(:product, :name => "Trouser", :name_fr => "Pantalon", :name_es => "Pantalones", :price => 9.00, :on_hand => 1)
+ end
+
+ it "returns all products by default" do
+ params = { :per_page => "" }
+ searcher = Spree::Core::Search::Base.new(params)
+ searcher.retrieve_products.count.should == 2
+ end
+
+ it 'return all product for default i18n' do
+ params = { :per_page => "",
+ :keywords => 'Shirt' }
+ I18n.locale = :en
+ searcher = Spree::Core::Search::Base.new(params)
+ searcher.retrieve_products.should == [@product1]
+ end
+
+ it 'can return translated product name with correct i18n' do
+ params = { :per_page => "",
+ :keywords => 'Camisa' }
+ I18n.locale = :es
+ searcher = Spree::Core::Search::Base.new(params)
+ searcher.retrieve_products.should == [@product1]
+ end
+
+ it 'should not return with incorrect i18n' do
+ params = { :per_page => "",
+ :keywords => 'Camisa' }
+ I18n.locale = :fr
+ searcher = Spree::Core::Search::Base.new(params)
+ searcher.retrieve_products.should == []
+ end
+
+ it 'should not return product base attribute name' do
+ params = { :per_page => "",
+ :keywords => 'Shirt' }
+ I18n.locale = :fr
+ searcher = Spree::Core::Search::Base.new(params)
+ searcher.retrieve_products.should == []
+ end
+
+ it 'should return product without translation' do
+ create(:product, :name => "RoR Shirt", :price => 9.00, :on_hand => 1)
+ params = { :per_page => "" }
+ I18n.locale = :fr
+ searcher = Spree::Core::Search::Base.new(params)
+ searcher.retrieve_products.count.should == 3
+ end
+
+end
Please sign in to comment.
Something went wrong with that request. Please try again.