Fixing up the specs

This commit is contained in:
Will Marshall
2014-03-12 17:17:07 +11:00
parent 35bd1257d9
commit 7c50e1a41d
4 changed files with 10 additions and 12 deletions

View File

@@ -6,7 +6,7 @@ angular.module("Checkout").controller "CheckoutCtrl", ($scope, $rootScope, order
# Our shipping_methods comes through as a hash like so: {id: requires_shipping_address}
# Here we default to the first shipping method if none is selected
$scope.order.shipping_method_id ||= Object.keys(order.shipping_methods)[0]
$scope.order.ship_address_same_as_billing ||= true
$scope.order.ship_address_same_as_billing = true if $scope.order.ship_address_same_as_billing == null
$scope.require_ship_address = $scope.order.shipping_methods[$scope.order.shipping_method_id]
$scope.shippingMethodChanged = ->
@@ -16,3 +16,4 @@ angular.module("Checkout").controller "CheckoutCtrl", ($scope, $rootScope, order
$scope.purchase = (event)->
event.preventDefault()
checkout.submit()

View File

@@ -1,5 +1,8 @@
object current_order
attributes :id, :email, :shipping_method_id, :ship_address_same_as_billing
attributes :id, :email, :shipping_method_id
node :ship_address_same_as_billing do
current_order.ship_address_same_as_billing == "true"
end
child current_order.bill_address => :bill_address do
attributes :phone, :firstname, :lastname, :address1, :address2, :city, :country_id, :state_id, :zipcode

View File

@@ -119,7 +119,7 @@ feature "As a consumer I want to check out my cart", js: true do
fill_in "Customer E-Mail", with: "test@test.com"
fill_in "Phone", with: "0468363090"
fill_in "City", with: "Melbourne"
fill_in "Zip Code", with: "3066"
fill_in "Postcode", with: "3066"
end
click_button "Purchase"
page.should have_content "Your order has been processed successfully"
@@ -137,7 +137,7 @@ feature "As a consumer I want to check out my cart", js: true do
fill_in "Customer E-Mail", with: "test@test.com"
fill_in "Phone", with: "0468363090"
fill_in "City", with: "Melbourne"
fill_in "Zip Code", with: "3066"
fill_in "Postcode", with: "3066"
end
check "Shipping address same as billing address?"
click_button "Purchase"

View File

@@ -134,13 +134,11 @@ feature "As a consumer I want to shop with a distributor", js: true do
page.should_not have_selector("#variants_#{product.master.id}", visible: true)
end
it "collapses variants by default" do
page.should_not have_text variant1.options_text
it "expands variants by default" do
page.should have_text variant1.options_text
end
it "expands variants" do
find(".expand").trigger "click"
page.should have_text variant1.options_text
find(".collapse").trigger "click"
page.should_not have_text variant1.options_text
end
@@ -161,7 +159,6 @@ feature "As a consumer I want to shop with a distributor", js: true do
page.should_not have_selector 'tr.product > td', text: "from $33.00"
# Page should have variant prices (with fee)
find(".expand").trigger 'click'
page.should have_selector 'tr.variant > td.price', text: "$43.00"
page.should have_selector 'tr.variant > td.price', text: "$53.00"
@@ -223,7 +220,6 @@ feature "As a consumer I want to shop with a distributor", js: true do
page.should_not have_content p3.name
# It shows on demand variants
within(".product-#{p4.id}") { find(".expand", visible: true).trigger "click" }
page.should have_content v3.options_text
# It does not show variants that are neither on hand or on demand
@@ -262,7 +258,6 @@ feature "As a consumer I want to shop with a distributor", js: true do
let(:variant) { create(:variant, product: product, on_hand: 10 ) }
before do
build_and_select_order_cycle_with_variants
find(".expand").trigger "click"
end
it "should show group buy input" do
@@ -289,7 +284,6 @@ feature "As a consumer I want to shop with a distributor", js: true do
build_and_select_order_cycle_with_variants
end
it "should let us add products to our cart" do
find(".expand").trigger "click"
fill_in "variants[#{variant.id}]", with: "1"
first("form.custom > input.button.right").click
current_path.should == "/cart"