Removing all the old order populator stuff

This commit is contained in:
Will Marshall
2014-01-06 15:23:21 +11:00
parent 49c2cc3696
commit dd1b3311d7
8 changed files with 65 additions and 4 deletions

BIN
app/assets/images/matte.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@@ -0,0 +1,20 @@
Foundation.libs.section.toggle_active = (e)->
$this = $(this)
self = Foundation.libs.section
region = $this.parent()
content = $this.siblings(self.settings.content_selector)
section = region.parent()
settings = $.extend({}, self.settings, self.data_options(section))
prev_active_region = section.children(self.settings.region_selector).filter("." + self.settings.active_class)
#for anchors inside [data-section-title]
e.preventDefault() if not settings.deep_linking and content.length > 0
e.stopPropagation() #do not catch same click again on parent
unless region.hasClass(self.settings.active_class)
prev_active_region.removeClass self.settings.active_class
region.addClass self.settings.active_class
#force resize for better performance (do not wait timer)
self.resize region.find(self.settings.section_selector).not("[" + self.settings.resized_data_attr + "]"), true
else if not settings.one_up# and (self.small(section) or self.is_vertical_nav(section) or self.is_horizontal_nav(section) or self.is_accordion(section))
region.removeClass self.settings.active_class
settings.callback section

View File

@@ -5,6 +5,8 @@ class ShopController < BaseController
before_filter :set_order_cycles
def show
# All suppliers of all our products
@producers = Exchange.where(receiver_id: @distributor.id).map{ |ex| ex.variants.map {|v| v.product.supplier }}.flatten.uniq
end
def products

View File

@@ -2,4 +2,4 @@ class SuburbsController < ActionController::Base
def index
@suburbs = Suburb.matching(params[:term]).order(:name).limit(8)
end
end
end

View File

@@ -12,7 +12,7 @@
%tbody{"ng-repeat" => "product in data.products "}
%tr.product
%td
%img{src: "{{ product.master.images[0].small_url }}"}
-#%img{src: "{{ product.master.images[0].small_url }}"}
-#{{product.master.images[0].alt}}
%td
%h5

View File

@@ -5,7 +5,8 @@
%h4
= @distributor.name
%location= @distributor.address.city
%small Change location
%small
%a{href: "/"} Change location
= render partial: "shop/order_cycles"
-#%description
@@ -23,7 +24,9 @@
%p.title.avenir{"data-section-title" => ""}
%a{href: "#producers"} Our Producers
.content{"data-section-content" => ""}
%p Content of section 2.
%ul
- for producer in @producers
%li= producer.name
%section
%p.title.avenir{"data-section-title" => ""}

View File

@@ -8,6 +8,7 @@ describe ShopController do
response.should redirect_to root_path
end
describe "with a distributor in place" do
before do
controller.stub(:current_distributor).and_return d
@@ -56,6 +57,22 @@ describe ShopController do
end
describe "producers/suppliers" do
let(:supplier) { create(:supplier_enterprise) }
let(:product) { create(:product, supplier: supplier) }
let(:order_cycle) { create(:order_cycle, distributors: [d], coordinator: create(:distributor_enterprise)) }
before do
exchange = Exchange.find(order_cycle.exchanges.to_enterprises(d).outgoing.first.id)
exchange.variants << product.master
end
it "builds a list of producers/suppliers" do
spree_get :show
assigns[:producers].should == [supplier]
end
end
describe "returning products" do
let(:product) { create(:product) }
let(:order_cycle) { create(:order_cycle, distributors: [d], coordinator: create(:distributor_enterprise)) }

View File

@@ -17,6 +17,25 @@ feature "As a consumer I want to shop with a distributor", js: true do
page.should have_text distributor.name
end
describe "With products in order cycles" do
let(:supplier) { create(:supplier_enterprise) }
let(:product) { create(:product, supplier: supplier) }
let(:order_cycle) { create(:order_cycle, distributors: [distributor], coordinator: create(:distributor_enterprise)) }
before do
exchange = Exchange.find(order_cycle.exchanges.to_enterprises(distributor).outgoing.first.id)
exchange.variants << product.master
end
it "shows the suppliers/producers for a distributor" do
visit shop_path
click_link "Our Producers"
page.should have_content supplier.name
end
end
describe "selecting an order cycle" do
it "selects an order cycle if only one is open" do
# create order cycle