mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-15 23:57:48 +00:00
Add distributor show page, redirect here after selecting distributor
This commit is contained in:
@@ -128,6 +128,13 @@ ul.product-listing {
|
||||
}
|
||||
|
||||
|
||||
/* Supplier and distributor description */
|
||||
.supplier-description, .distributor-description {
|
||||
margin-bottom: 2em;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Highlight local products in distributor-split product listings */
|
||||
#products-local ul {
|
||||
margin-bottom: 1em;
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
module Spree
|
||||
class DistributorsController < BaseController
|
||||
helper 'spree/products'
|
||||
|
||||
def show
|
||||
options = {:distributor_id => params[:id]}
|
||||
options.merge(params.reject { |k,v| k == :id })
|
||||
|
||||
@distributor = Distributor.find params[:id]
|
||||
|
||||
@searcher = Config.searcher_class.new(options)
|
||||
@products = @searcher.retrieve_products
|
||||
render :template => 'spree/products/index'
|
||||
end
|
||||
|
||||
def select
|
||||
@@ -19,7 +22,7 @@ module Spree
|
||||
order.save!
|
||||
end
|
||||
|
||||
redirect_to root_path
|
||||
redirect_to distributor
|
||||
end
|
||||
|
||||
def deselect
|
||||
|
||||
7
app/views/spree/distributors/show.html.haml
Normal file
7
app/views/spree/distributors/show.html.haml
Normal file
@@ -0,0 +1,7 @@
|
||||
%h2= @distributor.name
|
||||
|
||||
.distributor-description= @distributor.long_description.andand.html_safe
|
||||
|
||||
%h3 Available Now
|
||||
|
||||
= render :template => 'spree/products/index'
|
||||
@@ -12,7 +12,7 @@
|
||||
- if order.nil? || order.can_change_distributor?
|
||||
= link_to distributor.name, select_distributor_path(distributor)
|
||||
- elsif order.distributor == distributor
|
||||
= link_to distributor.name, root_path
|
||||
= link_to distributor.name, distributor
|
||||
- else
|
||||
%span.inactive= distributor.name
|
||||
- if current_distributor && order.can_change_distributor?
|
||||
|
||||
@@ -15,6 +15,7 @@ FactoryGirl.define do
|
||||
contact 'Mr Turing'
|
||||
phone '1000100100'
|
||||
description 'The creator'
|
||||
long_description '<p>Hello, world!</p><p>This is a paragraph.</p>'
|
||||
email 'alan@somewhere.com'
|
||||
url 'http://example.com'
|
||||
pickup_times "Whenever you're free"
|
||||
|
||||
@@ -26,19 +26,36 @@ feature %q{
|
||||
page.should_not have_selector 'a', :text => d3.name
|
||||
end
|
||||
|
||||
|
||||
context "when a distributor is selected" do
|
||||
it "displays the distributor's name" do
|
||||
it "displays the distributor's details" do
|
||||
# Given a distributor with a product
|
||||
d = create(:distributor, :name => 'Melb Uni Co-op')
|
||||
d = create(:distributor, :name => 'Melb Uni Co-op', :description => '<p>Hello, world!</p>')
|
||||
create(:product, :distributors => [d])
|
||||
|
||||
# When I select the distributor
|
||||
visit spree.root_path
|
||||
click_link d.name
|
||||
|
||||
# Then I should see the name of the distributor that I've selected
|
||||
page.should have_selector 'h2', :text => 'Melb Uni Co-op'
|
||||
|
||||
# And I should see the distributor's long description
|
||||
page.should have_selector 'div.distributor-description', :text => 'Hello, world!'
|
||||
end
|
||||
|
||||
it "displays the distributor's name on the home page" do
|
||||
# Given a distributor with a product
|
||||
d = create(:distributor, :name => 'Melb Uni Co-op', :description => '<p>Hello, world!</p>')
|
||||
create(:product, :distributors => [d])
|
||||
|
||||
# When I select the distributor
|
||||
visit spree.root_path
|
||||
click_link d.name
|
||||
visit spree.root_path
|
||||
|
||||
# Then I should see the name of the distributor that I've selected
|
||||
page.should have_content 'You are shopping at Melb Uni Co-op'
|
||||
page.should_not have_selector 'div.distributor-description'
|
||||
end
|
||||
|
||||
it "splits the product listing by local/remote distributor" do
|
||||
@@ -54,6 +71,7 @@ feature %q{
|
||||
# When I select the first distributor
|
||||
visit spree.root_path
|
||||
click_link d1.name
|
||||
visit spree.root_path
|
||||
|
||||
# Then I should see products split by local/remote distributor
|
||||
# on the home page, the products page, the search results page and the taxon page
|
||||
|
||||
Reference in New Issue
Block a user