Skip to content

Admin : can now filter products by taxons #2771

Closed
wants to merge 7 commits into from
View
6 core/app/views/spree/admin/products/index.html.erb
@@ -42,6 +42,12 @@
</label>
</div>
</div>
+ <div class="alpha nine columns">
+ <div class="field">
+ <%= f.label :taxons_id_in, t(:taxon) %>
+ <%= f.grouped_collection_select :taxons_id_in, Spree::Taxonomy.all, :taxons, :name, :id, :name, {}, {:multiple => true, :class => 'select2 fullwidth'} %>
@radar
Spree Commerce member
radar added a note Apr 11, 2013

Is this line supposed to reference Spree::Taxon rather than Spree::Taxonomy?

@sbounmy
sbounmy added a note Apr 13, 2013

this is a grouped_collection_select so it will basically show taxonomy's name aswell

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ </div>
+ </div>
</div>
<div class="clear"></div>
View
5 core/lib/spree/core/testing_support/capybara_ext.rb
@@ -51,14 +51,15 @@ def select2(value, options)
def targetted_select2(value, options)
# find select2 element and click it
- find(options[:from]).find('a').click
+
+ find(options[:from]).find('ul.select2-choices').click
select_select2_result(value)
end
def select_select2_result(value)
#p %Q{$("div.select2-result-label:contains('#{value}')").mouseup()}
sleep(1)
- page.execute_script(%Q{$("div.select2-result-label:contains('#{value}')").mouseup()})
+ find(:xpath, "//div[@class='select2-result-label' and contains(., '#{value}')]").click
end
def find_label_by_text(text)
View
18 core/spec/requests/admin/products/products_spec.rb
@@ -99,6 +99,24 @@
page.should_not have_content("apache baseball cap2")
page.should_not have_content("zomg shirt")
end
+
+ it 'should be able to search products by taxon', :js => true do
+ baseball = create(:taxon, :name => 'baseball')
+ shirt = create(:taxon, :name => 'shirt')
+ create(:product, :name => 'apache baseball cap', :sku => "A100", :taxons => [baseball])
+ create(:product, :name => 'bteam tshirt', :sku => "B100", :taxons => [baseball])
+ create(:product, :name => 'zomg shirt', :taxons => [shirt])
+
+ click_link "Products"
+
+ select2 'shirt', :from => 'Taxon'
+
+ click_icon :search
+ page.should have_content('zomg shirt')
+ page.should_not have_content('bteam tshirt')
+ page.should_not have_content('apache baseball cap')
+ end
+
end
context "creating a new product from a prototype" do
Something went wrong with that request. Please try again.