Fixing my modal and the tests

This commit is contained in:
Will Marshall
2014-05-20 12:17:56 +10:00
parent e7f6a9badf
commit 685ba3f63a
11 changed files with 28 additions and 25 deletions

View File

@@ -2,17 +2,14 @@ Darkswarm.directive "ofnModal", ($modal)->
restrict: 'E'
replace: true
transclude: true
scope: {}
template: "<a>{{title}}</a>"
link: (scope, elem, attrs, ctrl, transclude)->
scope.title = attrs.title
contents = null
transclude scope, (clone)->
contents = clone
scope.cancel = ->
scope.modalInstance.dismiss("cancel")
elem.on "click", ->
elem.on "click", =>
scope.modalInstance = $modal.open(controller: ctrl, template: contents)

View File

@@ -2,4 +2,4 @@
%h5 Our food hubs are the point of contact between you and the people who make your food!
%p You can search for a convenient hub by location or name. Some hubs have multiple points where you can pick-up your purchases, and some will also provide delivery options. Each food hub is a sales point with independent business operations and logisitics - so variations between hubs are to be expected.
%p You can only shop one food hub at a time.
%a.close-reveal-modal{"ng-click" => "cancel()"} &#215;
%a.close-reveal-modal{"ng-click" => "$close()"} &#215;

View File

@@ -6,4 +6,4 @@
%h5 Learn more
%p If you want to learn more about the Open Food Network, how it works, and get involved, check out:
%a.button.neutral-btn.dark{:href => "http://www.openfoodnetwork.org" , :target => "_blank" } Open Food Network
%a.close-reveal-modal{"ng-click" => "cancel()"} &#215;
%a.close-reveal-modal{"ng-click" => "$close()"} &#215;

View File

@@ -21,7 +21,7 @@
%span.nav-primary Producers
%li.divider
%li
%a{href: groups_path}
%a{href: main_app.groups_path}
%span.nav-primary Groups
%li.divider
- if spree_current_user.andand.has_spree_role? 'admin'

View File

@@ -43,7 +43,7 @@
%a{href: main_app.producers_path}
%span.nav-primary Producers
%li
%a{href: groups_path}
%a{href: main_app.groups_path}
%span.nav-primary Groups

View File

@@ -26,4 +26,4 @@
.row
.small-12.columns
%input.button.right{type: :submit, value: "Add to Cart"}
%input.button.right.add_to_cart{type: :submit, value: "Add to Cart"}

View File

@@ -12,7 +12,7 @@
.small-5.columns.summary-header
{{ product.supplier.name }}
.small-2.columns.summary-price.text-right
.small-2.columns.summary-price.text-right.price
%span{"ng-if" => "hasVariants"}
%em from
{{ price() | currency }}

View File

@@ -38,5 +38,5 @@
"ng-model" => "variant.max_quantity"}
(max)
.small-2.columns.text-right
.small-2.columns.text-right.price
{{ variant.price | currency }}

View File

@@ -144,6 +144,7 @@ describe ShopController do
it "includes the primary taxon" do
taxon = mock_model(Spree::Taxon, name: "fruitbat")
Spree::Product.any_instance.stub(:primary_taxon).and_return taxon
taxon.stub_chain(:icon, :url).and_return ""
xhr :get, :products
response.body.should have_content "fruitbat"
end

View File

@@ -90,10 +90,6 @@ feature "As a consumer I want to shop with a distributor", js: true do
it "should not show quantity field for product with variants" do
visit shop_path
page.should_not have_selector("#variants_#{product.master.id}", visible: true)
#it "expands variants" do
find(".collapse").trigger "click"
page.should_not have_text variant1.options_text
end
it "uses the adjusted price" do
@@ -104,15 +100,16 @@ feature "As a consumer I want to shop with a distributor", js: true do
visit shop_path
# Page should not have product.price (with or without fee)
page.should_not have_selector 'tr.product > td', text: "from $10.00"
page.should_not have_selector 'tr.product > td', text: "from $33.00"
page.should_not have_price "from $10.00"
page.should_not have_price "from $33.00"
# Page should have variant prices (with fee)
page.should have_selector 'tr.variant > td.price', text: "$43.00"
page.should have_selector 'tr.variant > td.price', text: "$53.00"
page.should have_price "$43.00"
page.should have_price "$53.00"
# Product price should be listed as the lesser of these
page.should have_selector 'tr.product > td', text: "from $43.00"
#page.should have_selector 'tr.product > td', text: "from $43.00"
page.should have_price "from $43.00"
end
end
@@ -131,7 +128,7 @@ feature "As a consumer I want to shop with a distributor", js: true do
it "should save group buy data to ze cart" do
fill_in "variants[#{product.master.id}]", with: 5
fill_in "variant_attributes[#{product.master.id}][max_quantity]", with: 9
first("form.custom > input.button.right").click
add_to_cart
page.should have_content product.name
li = Spree::Order.order(:created_at).last.line_items.order(:created_at).last
li.max_quantity.should == 9
@@ -142,7 +139,7 @@ feature "As a consumer I want to shop with a distributor", js: true do
pending "adding a product with a max quantity less than quantity results in max_quantity==quantity" do
fill_in "variants[#{product.master.id}]", with: 5
fill_in "variant_attributes[#{product.master.id}][max_quantity]", with: 1
first("form.custom > input.button.right").click
add_to_cart
page.should have_content product.name
li = Spree::Order.order(:created_at).last.line_items.order(:created_at).last
li.max_quantity.should == 5
@@ -161,7 +158,7 @@ feature "As a consumer I want to shop with a distributor", js: true do
it "should save group buy data to ze cart" do
fill_in "variants[#{variant.id}]", with: 6
fill_in "variant_attributes[#{variant.id}][max_quantity]", with: 7
first("form.custom > input.button.right").click
add_to_cart
page.should have_content product.name
li = Spree::Order.order(:created_at).last.line_items.order(:created_at).last
li.max_quantity.should == 7
@@ -181,7 +178,7 @@ feature "As a consumer I want to shop with a distributor", js: true do
end
it "should let us add products to our cart" do
fill_in "variants[#{variant.id}]", with: "1"
first("form.custom > input.button.right").click
add_to_cart
current_path.should == "/cart"
page.should have_content product.name
end

View File

@@ -1,4 +1,12 @@
module ShopWorkflow
def add_to_cart
first("input.add_to_cart").click
end
def have_price(price)
have_selector ".price", text: price
end
def set_order(order)
ApplicationController.any_instance.stub(:session).and_return({order_id: order.id, access_token: order.token})
end