diff --git a/app/assets/javascripts/darkswarm/directives/modal.js.coffee b/app/assets/javascripts/darkswarm/directives/modal.js.coffee index 0eed6e93c5..73217b3812 100644 --- a/app/assets/javascripts/darkswarm/directives/modal.js.coffee +++ b/app/assets/javascripts/darkswarm/directives/modal.js.coffee @@ -2,17 +2,14 @@ Darkswarm.directive "ofnModal", ($modal)-> restrict: 'E' replace: true transclude: true + scope: {} template: "{{title}}" 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) diff --git a/app/views/modals/_food_hub.html.haml b/app/views/modals/_food_hub.html.haml index e80ffe3745..9b559d26cc 100644 --- a/app/views/modals/_food_hub.html.haml +++ b/app/views/modals/_food_hub.html.haml @@ -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()"} × \ No newline at end of file +%a.close-reveal-modal{"ng-click" => "$close()"} × diff --git a/app/views/modals/_learn_more.html.haml b/app/views/modals/_learn_more.html.haml index 870d5fe0bc..4cb0534c6e 100644 --- a/app/views/modals/_learn_more.html.haml +++ b/app/views/modals/_learn_more.html.haml @@ -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()"} × +%a.close-reveal-modal{"ng-click" => "$close()"} × diff --git a/app/views/shared/menu/_large_menu.html.haml b/app/views/shared/menu/_large_menu.html.haml index a5c6180150..6f9bae4488 100644 --- a/app/views/shared/menu/_large_menu.html.haml +++ b/app/views/shared/menu/_large_menu.html.haml @@ -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' diff --git a/app/views/shared/menu/_mobile_menu.html.haml b/app/views/shared/menu/_mobile_menu.html.haml index 43096c34b6..5478436eb8 100644 --- a/app/views/shared/menu/_mobile_menu.html.haml +++ b/app/views/shared/menu/_mobile_menu.html.haml @@ -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 diff --git a/app/views/shop/products/_form.html.haml b/app/views/shop/products/_form.html.haml index 07dd7c8e1a..8c70f76188 100644 --- a/app/views/shop/products/_form.html.haml +++ b/app/views/shop/products/_form.html.haml @@ -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"} diff --git a/app/views/shop/products/_summary.html.haml b/app/views/shop/products/_summary.html.haml index ebf2a8104c..5e777a5dbb 100644 --- a/app/views/shop/products/_summary.html.haml +++ b/app/views/shop/products/_summary.html.haml @@ -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 }} diff --git a/app/views/shop/products/_variants.html.haml b/app/views/shop/products/_variants.html.haml index 40a4371337..14ff8eff24 100644 --- a/app/views/shop/products/_variants.html.haml +++ b/app/views/shop/products/_variants.html.haml @@ -38,5 +38,5 @@ "ng-model" => "variant.max_quantity"} (max) - .small-2.columns.text-right + .small-2.columns.text-right.price {{ variant.price | currency }} diff --git a/spec/controllers/shop_controller_spec.rb b/spec/controllers/shop_controller_spec.rb index 3683137b79..f0857f54bc 100644 --- a/spec/controllers/shop_controller_spec.rb +++ b/spec/controllers/shop_controller_spec.rb @@ -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 diff --git a/spec/features/consumer/shopping/shopping_spec.rb b/spec/features/consumer/shopping/shopping_spec.rb index 19fcb5a44b..9946be2f5b 100644 --- a/spec/features/consumer/shopping/shopping_spec.rb +++ b/spec/features/consumer/shopping/shopping_spec.rb @@ -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 diff --git a/spec/support/request/shop_workflow.rb b/spec/support/request/shop_workflow.rb index bdad9e5d49..c87d33149a 100644 --- a/spec/support/request/shop_workflow.rb +++ b/spec/support/request/shop_workflow.rb @@ -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