nimbleshop_core 0.0.5 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. data/app/assets/javascripts/admin.js +6 -4
  2. data/app/assets/javascripts/admin/payment_method.js.coffee +26 -0
  3. data/app/assets/javascripts/{product-group-condition.js.coffee → admin/product-group-condition.js.coffee} +0 -0
  4. data/app/assets/javascripts/admin/products/edit.js.coffee +26 -13
  5. data/app/assets/javascripts/admin/shipit.js.coffee +10 -0
  6. data/app/assets/javascripts/{fadeout_success.js.coffee → admin/utils/fadeout_success.js.coffee} +0 -0
  7. data/app/assets/stylesheets/admin_custom.css +4 -4
  8. data/app/controllers/admin_controller.rb +1 -5
  9. data/app/models/order.rb +11 -6
  10. data/app/{observers/order_observer.rb → models/order/payment_transitions.rb} +7 -4
  11. data/app/views/admin/shipping_zones/_form.html.erb +1 -1
  12. data/app/views/mailer/shipment_notification_to_buyer.text.erb +1 -1
  13. data/config/routes.rb +4 -1
  14. data/db/migrate/{20111107035350_create_creditcard_transactions.rb → 20111107035350_create_payment_transactions.rb} +1 -1
  15. data/lib/generators/nimbleshop/app/install_generator.rb +1 -0
  16. data/lib/generators/nimbleshop/app/templates/config/initializers/001_load_nimbleshop_config.rb +10 -0
  17. data/lib/generators/nimbleshop/app/templates/config/initializers/setup_email.rb +2 -2
  18. data/lib/generators/nimbleshop/app/templates/config/nimbleshop.yml +2 -1
  19. data/lib/nimbleshop/engine.rb +5 -4
  20. data/lib/nimbleshop/nimbleshop/util.rb +63 -0
  21. data/lib/nimbleshop/processor/base.rb +9 -2
  22. data/lib/nimbleshop/sampledata/data.rb +14 -12
  23. data/lib/nimbleshop/version.rb +2 -2
  24. data/lib/nimbleshop_core.rb +3 -0
  25. data/test/factories/address_factory.rb +10 -10
  26. data/test/fixtures/payment_methods.yml +5 -5
  27. data/{config/initializers/001_settings_application.rb → test/myshop/config/initializers/001_load_nimbleshop_config.rb} +1 -1
  28. data/test/myshop/config/initializers/carrierwave.rb +2 -3
  29. data/test/myshop/config/initializers/secret_token.rb +1 -1
  30. data/test/myshop/config/initializers/setup_email.rb +4 -13
  31. data/test/myshop/config/nimbleshop.yml +14 -17
  32. data/test/myshop/db/development.sqlite3 +0 -0
  33. data/test/myshop/db/migrate/{20120707041905_create_product_groups.nimbleshop_core.rb → 20120717095234_create_product_groups.nimbleshop_core.rb} +0 -0
  34. data/test/myshop/db/migrate/{20120707041906_create_products.nimbleshop_core.rb → 20120717095235_create_products.nimbleshop_core.rb} +0 -0
  35. data/test/myshop/db/migrate/{20120707041907_create_orders.nimbleshop_core.rb → 20120717095236_create_orders.nimbleshop_core.rb} +0 -0
  36. data/test/myshop/db/migrate/{20120707041908_create_line_items.nimbleshop_core.rb → 20120717095237_create_line_items.nimbleshop_core.rb} +0 -0
  37. data/test/myshop/db/migrate/{20120707041909_create_shops.nimbleshop_core.rb → 20120717095238_create_shops.nimbleshop_core.rb} +0 -0
  38. data/test/myshop/db/migrate/{20120707041910_create_link_groups.nimbleshop_core.rb → 20120717095239_create_link_groups.nimbleshop_core.rb} +0 -0
  39. data/test/myshop/db/migrate/{20120707041911_create_navigations.nimbleshop_core.rb → 20120717095240_create_navigations.nimbleshop_core.rb} +0 -0
  40. data/test/myshop/db/migrate/{20120707041912_create_links.nimbleshop_core.rb → 20120717095241_create_links.nimbleshop_core.rb} +0 -0
  41. data/test/myshop/db/migrate/{20120707041913_create_custom_fields.nimbleshop_core.rb → 20120717095242_create_custom_fields.nimbleshop_core.rb} +0 -0
  42. data/test/myshop/db/migrate/{20120707041914_create_custom_field_answers.nimbleshop_core.rb → 20120717095243_create_custom_field_answers.nimbleshop_core.rb} +0 -0
  43. data/test/myshop/db/migrate/{20120707041915_create_product_group_conditions.nimbleshop_core.rb → 20120717095244_create_product_group_conditions.nimbleshop_core.rb} +0 -0
  44. data/test/myshop/db/migrate/{20120707041916_create_creditcard_transactions.nimbleshop_core.rb → 20120717095245_create_creditcard_transactions.nimbleshop_core.rb} +0 -0
  45. data/test/myshop/db/migrate/{20120707041917_create_addresses.nimbleshop_core.rb → 20120717095246_create_addresses.nimbleshop_core.rb} +0 -0
  46. data/test/myshop/db/migrate/{20120707041918_create_pictures.nimbleshop_core.rb → 20120717095247_create_pictures.nimbleshop_core.rb} +0 -0
  47. data/test/myshop/db/migrate/{20120707041919_create_shipping_methods.nimbleshop_core.rb → 20120717095248_create_shipping_methods.nimbleshop_core.rb} +0 -0
  48. data/test/myshop/db/migrate/{20120707041920_create_shipping_zones.nimbleshop_core.rb → 20120717095249_create_shipping_zones.nimbleshop_core.rb} +0 -0
  49. data/test/myshop/db/migrate/{20120707041921_create_payment_methods.nimbleshop_core.rb → 20120717095250_create_payment_methods.nimbleshop_core.rb} +0 -0
  50. data/test/myshop/db/migrate/{20120707041922_create_preferences.nimbleshop_core.rb → 20120717095251_create_preferences.nimbleshop_core.rb} +0 -0
  51. data/test/myshop/db/migrate/{20120707041923_create_shipments.nimbleshop_core.rb → 20120717095252_create_shipments.nimbleshop_core.rb} +0 -0
  52. data/test/myshop/db/migrate/{20120707041924_create_shipment_carriers.nimbleshop_core.rb → 20120717095253_create_shipment_carriers.nimbleshop_core.rb} +0 -0
  53. data/test/myshop/db/migrate/{20120707041925_create_delayed_jobs.nimbleshop_core.rb → 20120717095254_create_delayed_jobs.nimbleshop_core.rb} +0 -0
  54. data/test/myshop/db/schema.rb +1 -1
  55. data/test/myshop/db/test.sqlite3 +0 -0
  56. data/test/myshop/log/development.log +3 -0
  57. data/test/support/shipping_method_test_helper.rb +1 -1
  58. data/test/test_helper.rb +1 -1
  59. metadata +85 -136
  60. data/app/assets/javascripts/payment_method.js.coffee +0 -19
  61. data/app/assets/javascripts/remove_deletion_of_product_pictures.js.coffee +0 -5
  62. data/app/assets/javascripts/shipit.js.coffee +0 -10
  63. data/app/mailers/mailer.rb +0 -31
  64. data/config/initializers/strip_and_nullify.rb +0 -13
  65. data/lib/nimbleshop/util.rb +0 -60
  66. data/test/integration/checkout/cart_acceptance_test.rb +0 -113
  67. data/test/integration/checkout/payment_confirmation_acceptance_test.rb +0 -24
  68. data/test/integration/checkout/paypal_acceptance_test.rb +0 -34
  69. data/test/integration/checkout/shipping_address_acceptance_test.rb +0 -91
  70. data/test/integration/checkout/shipping_method_acceptance_test.rb +0 -51
  71. data/test/integration/homepage_acceptance_test.rb +0 -24
  72. data/test/integration/products_acceptance_test.rb +0 -12
  73. data/test/integration/static_pages_acceptance_test.rb +0 -13
  74. data/test/mailers/mailer_test.rb +0 -25
  75. data/test/unit/payment_method/authorizedotnet_test.rb +0 -21
  76. data/test/unit/payment_method/paypalwp_test.rb +0 -17
  77. data/test/unit/payment_method/splitable_test.rb +0 -18
  78. data/test/unit/processor/authorize_net_test.rb +0 -236
  79. data/test/unit/processor/paypal_test.rb +0 -40
  80. data/test/unit/processor/splitable_test.rb +0 -123
  81. data/test/vcr_cassettes/authorize_net/authorize-failure.yml +0 -38
  82. data/test/vcr_cassettes/authorize_net/authorize-success.yml +0 -38
  83. data/test/vcr_cassettes/authorize_net/capture-failure.yml +0 -38
  84. data/test/vcr_cassettes/authorize_net/capture-success.yml +0 -38
  85. data/test/vcr_cassettes/authorize_net/purchase-failure.yml +0 -38
  86. data/test/vcr_cassettes/authorize_net/purchase-success.yml +0 -38
  87. data/test/vcr_cassettes/authorize_net/refund-failure.yml +0 -38
  88. data/test/vcr_cassettes/authorize_net/refund-success.yml +0 -38
  89. data/test/vcr_cassettes/authorize_net/void-authorize.yml +0 -38
  90. data/test/vcr_cassettes/authorize_net/void-failure.yml +0 -38
  91. data/test/vcr_cassettes/authorize_net/void-success.yml +0 -38
  92. data/test/vcr_cassettes/splitable/split-create-failure.yml +0 -48
  93. data/test/vcr_cassettes/splitable/split-create-success.yml +0 -50
  94. data/test/vcr_cassettes/splitable/split-draft-create-failure.yml +0 -50
  95. data/test/vcr_cassettes/splitable/split-draft-create-success.yml +0 -50
@@ -1,19 +0,0 @@
1
- $ ->
2
-
3
- # Handle cancel on payment form
4
- $(".nimbleshop-payment-method-form .cancel").click ->
5
- $this = $(this)
6
- div = $this.closest(".nimbleshop-payment-method-form-well")
7
- div.hide() if div.length
8
- false
9
-
10
- # edit a payment form
11
- $(".nimbleshop-payment-method-edit").click ->
12
- $this = $(this)
13
- well = $this.parent("div").find(".nimbleshop-payment-method-form-well")
14
- if well.length
15
- if well.is(":visible")
16
- well.hide()
17
- else
18
- well.show()
19
- false
@@ -1,5 +0,0 @@
1
- # nested_form generated the link to delete the pictures. However picture deletion
2
- # is handled separately. So here the deletion link is made to hide.
3
-
4
- $ ->
5
- #$('.edit_product .fields').hide()
@@ -1,10 +0,0 @@
1
- $ ->
2
- $("a.ship-items-link").click ->
3
- $(this).hide()
4
- $("#ship_items_action_box").show()
5
- false
6
-
7
-
8
- $("#ship_items_cancel").live "click", ->
9
- $("a.ship-items-link").show()
10
- $("#ship_items_action_box").hide()
@@ -1,31 +0,0 @@
1
- class Mailer < ActionMailer::Base
2
-
3
- helper :application
4
-
5
- layout 'email'
6
-
7
- default from: lambda { Shop.current.from_email }
8
- default_url_options[:host] = Nimbleshop.config.bare_url_with_port
9
- default_url_options[:protocol] = 'http'
10
-
11
- def order_notification_to_buyer(order_number)
12
- subject = "Order confirmation for order ##{order_number}"
13
- @order = Order.find_by_number!(order_number)
14
-
15
- @shop = Shop.current
16
- @payment_date = @order.created_at.to_s(:long) || @order.purchased_at.to_s(:long)
17
-
18
- mail_options = {to: @order.email, subject: subject}
19
- mail(mail_options)
20
- end
21
-
22
- def shipment_notification_to_buyer(order_number)
23
- subject = "Items for order ##{order_number} have been shipped"
24
- @order = Order.find_by_number!(order_number)
25
- @shipment = @order.shipments.first
26
-
27
- mail_options = {to: @order.email, subject: subject}
28
- mail(mail_options)
29
- end
30
-
31
- end
@@ -1,13 +0,0 @@
1
- #
2
- # empty spaces should be saved as NULL in database
3
- # before values are saved string values should undergo strip
4
- #
5
- module ActiveRecord
6
- class Base
7
- before_validation do |record|
8
- record.attributes.each do |attr, value|
9
- record[attr] = value.blank? ? nil : value.strip if value.respond_to?(:strip)
10
- end
11
- end
12
- end
13
- end
@@ -1,60 +0,0 @@
1
- class Util
2
-
3
- # loads a yaml based configuration file and returns hash
4
- def self.config2hash(file)
5
- hash = YAML.load(ERB.new(File.read(file)).result)
6
-
7
- common_hash = hash['common'] || {}
8
- env_hash = hash[Rails.env.to_s] || {}
9
-
10
- final_hash = common_hash.deep_merge(env_hash)
11
- Hashr.new(final_hash)
12
- end
13
-
14
- # Converts the amount in cents and returns an integer.
15
- def self.in_cents(amount)
16
- (BigDecimal(amount.to_s) * 100).round(0).to_i
17
- end
18
-
19
- # returns public url for a given localhost url
20
- #
21
- # Usage: localhost2public_url ( '/nimbleshop_paypal/notify', 'http' )
22
- #
23
- def self.localhost2public_url(url, protocol)
24
- return url unless Nimbleshop.config.use_localhost2public_url
25
-
26
- tunnel = Rails.root.join('config', '.tunnel')
27
- return Nimbleshop.config.default_localhost2public_url unless File.exists?(tunnel)
28
-
29
- path = []
30
-
31
- host = File.open(tunnel, "r").gets.sub("\n", "")
32
- path << "#{protocol}://#{host}"
33
-
34
- path << url
35
- path.join('')
36
- end
37
-
38
- # The output is something like
39
- # ["Timor-Leste", "TL"], ["Turkmenistan", "TM"], ["Tunisia", "TN"], ["Tonga", "TO"], .......
40
- def self.countries_list_with_name_and_code
41
- Carmen::Country.all.map { |t| [t.name, t.alpha_2_code] }
42
- end
43
-
44
- def self.countries_without_shipping_zone
45
- Util.countries_list_with_name_and_code.reject { |_, t| CountryShippingZone.all_country_codes.include?(t) }
46
- end
47
-
48
- def self.disabled_shipping_zone_countries
49
- countries_with_shipping_zone.reduce([]) { |result, element| result << [element[0], element[1], {disabled: :disabled}]}
50
- end
51
-
52
- def self.unconfigured_shipping_zone_countries
53
- (Util.disabled_shipping_zone_countries + Util.countries_without_shipping_zone).sort
54
- end
55
-
56
- def self.countries_with_shipping_zone
57
- Util.countries_list_with_name_and_code.select { |_, t| CountryShippingZone.all_country_codes.include?(t)}
58
- end
59
-
60
- end
@@ -1,113 +0,0 @@
1
- require "test_helper"
2
-
3
- class CartAcceptanceTest < ActionDispatch::IntegrationTest
4
-
5
- include ::ShippingMethodSpecHelper
6
- include ::CheckoutTestHelper
7
-
8
- setup do
9
- create(:product, name: 'Bracelet Set', price: 25)
10
- create(:product, name: 'Necklace Set', price: 14)
11
- create_regional_shipping_method
12
- end
13
-
14
- test "after going all the way to checkout if buyer comes back to cart only line items amount should be shown" do
15
- visit root_path
16
- add_item_to_cart('Bracelet Set')
17
- assert_equal "Total: $25.00", find('.line-items-total').text.chomp.strip
18
-
19
- click_link 'Checkout'
20
-
21
- enter_valid_email_address
22
- enter_valid_shipping_address
23
-
24
- click_button 'Submit'
25
-
26
- choose 'Ground'
27
- click_button 'Submit'
28
-
29
- assert_sanitized_equal 'Total: $29.30', find('.order-total-amount').text
30
- click_link 'edit_cart'
31
-
32
- assert_sanitized_equal "Total: $25.00", find('.line-items-total').text
33
- end
34
-
35
- test "should be able to change the quantity even if product is deleted" do
36
- visit root_path
37
- add_item_to_cart('Bracelet Set')
38
-
39
- p = Product.find_by_name('Bracelet Set')
40
- fill_in "updates_#{p.id}", with: '10'
41
- p.destroy
42
- click_button 'Update'
43
- assert_sanitized_equal "Total: $250.00", find('.line-items-total').text
44
- end
45
-
46
- test "should be able to increase the quantities of items in the cart" do
47
- visit root_path
48
- add_item_to_cart('Bracelet Set')
49
- visit root_path
50
- add_item_to_cart 'Necklace Set'
51
- p1 = Product.find_by_name 'Bracelet Set'
52
- p2 = Product.find_by_name 'Necklace Set'
53
-
54
- fill_in "updates_#{p1.id}", with: '4'
55
- fill_in "updates_#{p2.id}", with: '2'
56
-
57
- click_button 'Update'
58
- assert page.has_content?('$128')
59
- end
60
-
61
- test "when admin has not setup any payment method then there should not be any error" do
62
- PaymentMethod.delete_all
63
- visit root_path
64
- add_item_to_cart('Bracelet Set')
65
- click_link 'Checkout'
66
- enter_valid_email_address
67
- enter_valid_shipping_address
68
- click_button 'Submit'
69
- choose 'Ground'
70
- click_button 'Submit'
71
- assert page.has_content?('No payment method has been setup. Please setup atleast one payment method.')
72
- end
73
-
74
- test "should be able to add 2 items to cart and title should be reflect that" do
75
- visit root_path
76
- add_item_to_cart('Bracelet Set')
77
- visit root_path
78
- add_item_to_cart 'Necklace Set'
79
- assert page.has_content?('2 Items')
80
- assert page.has_content?('$39')
81
- end
82
- end
83
-
84
- class CartWithOrderExpiredAcceptanceTest < ActionDispatch::IntegrationTest
85
-
86
- include ::ShippingMethodSpecHelper
87
- include ::CheckoutTestHelper
88
-
89
- setup do
90
- create(:product, name: 'Bracelet Set', price: 25)
91
- create(:product, name: 'Necklace Set', price: 14)
92
- create(:country_shipping_method)
93
- end
94
-
95
- test 'on cart page' do
96
- visit root_path
97
- add_item_to_cart('Bracelet Set')
98
- click_link 'Checkout'
99
- Order.last.destroy
100
- click_link 'edit_cart'
101
- assert page.has_content?('powered by')
102
- end
103
-
104
- test 'on shipping address page' do
105
- visit root_path
106
- add_item_to_cart('Bracelet Set')
107
- assert page.has_css?('.line-items-total', text: '$25.00')
108
- click_link 'Checkout'
109
- Order.last.destroy
110
- visit current_path
111
- assert page.has_content?('powered by')
112
- end
113
- end
@@ -1,24 +0,0 @@
1
- require 'test_helper'
2
-
3
- class PaymentConfirmationAcceptanceTest < ActionDispatch::IntegrationTest
4
-
5
- test "show order when it was paid using splitable" do
6
- order = create :order_paid_using_splitable
7
- visit nimbleshop_simply.order_path(order)
8
- assert page.has_content?('Purchase is complete')
9
- end
10
-
11
- test "show order when it was paid using paypalwp" do
12
- order = create :order_paid_using_paypalwp
13
- visit nimbleshop_simply.order_path(order)
14
- assert page.has_content?('Purchase is complete')
15
- end
16
-
17
- test "show order when it was paid using authorizedotnet" do
18
- order = create :order_paid_using_authorizedotnet
19
- visit nimbleshop_simply.order_path(order)
20
- assert page.has_content?('Purchase is complete')
21
- assert page.has_content?('In the credit card statement name of the company would appear as Nimbleshop LLC')
22
- end
23
-
24
- end
@@ -1,34 +0,0 @@
1
- require "test_helper"
2
-
3
- class PaypalAcceptanceTest < ActionDispatch::IntegrationTest
4
-
5
- include ::ShippingMethodSpecHelper
6
- include ::CheckoutTestHelper
7
-
8
- setup do
9
- create(:product, name: 'Bracelet Set', price: 25)
10
- create(:product, name: 'Necklace Set', price: 14)
11
- create_regional_shipping_method
12
- end
13
-
14
- test 'paypal variables' do
15
- visit root_path
16
- add_item_to_cart('Bracelet Set')
17
- assert_sanitized_equal "Total: $25.00", find('.line-items-total').text
18
-
19
- click_link 'Checkout'
20
-
21
- enter_valid_email_address
22
- enter_valid_shipping_address
23
-
24
- click_button 'Submit'
25
-
26
- choose 'Ground'
27
- click_button 'Submit'
28
-
29
- assert_sanitized_equal 'Total: $29.30', find('.order-total-amount').text
30
- assert_sanitized_equal "25.0", page.find("#amount_1").value
31
- assert_sanitized_equal "3.99", page.find("#handling_cart").value
32
- assert_sanitized_equal "0.31", page.find("#tax_cart").value
33
- end
34
- end
@@ -1,91 +0,0 @@
1
- require "test_helper"
2
-
3
- class ShippingAddressAcceptanceTest < ActionDispatch::IntegrationTest
4
-
5
- include ::ShippingMethodSpecHelper
6
- include ::CheckoutTestHelper
7
-
8
- setup do
9
- create(:product, name: 'Bracelet Set', price: 25)
10
- create(:product, name: 'Necklace Set', price: 14)
11
- create_regional_shipping_method
12
- end
13
-
14
- test "Billing address is same as shipping address" do
15
- visit root_path
16
- add_item_to_cart('Bracelet Set')
17
- click_link 'Checkout'
18
- assert page.has_content?('Shipping address')
19
- enter_valid_email_address
20
- enter_valid_shipping_address
21
- click_button 'Submit'
22
-
23
- assert_sanitized_equal "Neeaj Singh 100 N Miami Ave Suite 500 Miami Florida 33333 United States", find('.shipping-address').text
24
- assert_sanitized_equal "Same as shipping address", find('.billing-address').text
25
- end
26
-
27
- test "Billing address is not same as shipping address" do
28
- visit root_path
29
- add_item_to_cart('Bracelet Set')
30
- click_link 'Checkout'
31
- enter_valid_email_address
32
- enter_valid_shipping_address
33
- uncheck 'order_shipping_address_attributes_use_for_billing'
34
- enter_valid_billing_address
35
-
36
- click_button 'Submit'
37
-
38
- assert_sanitized_equal "Neeaj Singh 100 N Miami Ave Suite 500 Miami Florida 33333 United States", find('.shipping-address').text
39
- assert_sanitized_equal "Neil Singh 100 N Pines Ave Suite 400 Pembroke Pines Florida 33332 United States", find('.billing-address').text
40
- end
41
-
42
- test 'editing shipping address' do
43
- visit root_path
44
- add_item_to_cart('Bracelet Set')
45
- click_link 'Checkout'
46
- enter_valid_email_address
47
- enter_valid_shipping_address
48
- click_button 'Submit'
49
- choose 'Ground'
50
- click_button 'Submit'
51
- click_link 'edit_shipping_address'
52
- fill_in "order_shipping_address_attributes_first_name", with: 'Neeraj1234'
53
- click_button 'Submit'
54
- assert page.has_content?('Neeraj1234')
55
- end
56
-
57
- test 'shipping_address validations' do
58
- visit root_path
59
- add_item_to_cart('Bracelet Set')
60
- click_link 'Checkout'
61
-
62
- click_button 'Submit'
63
- assert page.has_content?('Email is invalid')
64
-
65
- enter_valid_email_address
66
- click_button 'Submit'
67
-
68
- assert page.has_content?('Shipping address error !')
69
- assert page.has_content?("First name can't be blank")
70
- assert page.has_content?("Last name can't be blank")
71
- assert page.has_content?("Address1 can't be blank")
72
- assert page.has_content?("Zipcode can't be blank")
73
- assert page.has_content?("City can't be blank")
74
-
75
- enter_valid_shipping_address
76
- uncheck 'order_shipping_address_attributes_use_for_billing'
77
- click_button 'Submit'
78
-
79
- assert page.has_content?('Billing address error !')
80
- assert page.has_content?("First name can't be blank")
81
- assert page.has_content?("Last name can't be blank")
82
- assert page.has_content?("Address1 can't be blank")
83
- assert page.has_content?("Zipcode can't be blank")
84
- assert page.has_content?("City can't be blank")
85
-
86
- check 'order_shipping_address_attributes_use_for_billing'
87
- click_button 'Submit'
88
- assert page.has_content?("Pick shipping method")
89
- end
90
- end
91
-
@@ -1,51 +0,0 @@
1
- require "test_helper"
2
-
3
- class ShippingMethodAcceptanceTest < ActionDispatch::IntegrationTest
4
-
5
- include ::CheckoutTestHelper
6
-
7
- setup do
8
- Capybara.current_driver = :selenium
9
- create(:product, name: 'Bracelet Set', price: 25)
10
- create(:product, name: 'Necklace Set', price: 14)
11
- create(:country_shipping_method, name: 'Ground Shipping', base_price: 3.99, minimum_order_amount: 1, maximum_order_amount: 99999)
12
- create(:country_shipping_method, name: 'Express Shipping', base_price: 13.99, minimum_order_amount: 1, maximum_order_amount: 99999)
13
- end
14
-
15
- test "shipping method is required" do
16
- visit root_path
17
- add_item_to_cart('Bracelet Set')
18
- click_link 'Checkout'
19
-
20
- enter_valid_email_address
21
- enter_valid_shipping_address
22
- click_button 'Submit'
23
-
24
- # Submit without choosing a shipping method
25
- click_button 'Submit'
26
-
27
- assert page.has_content?('Please select a shipping method')
28
- end
29
-
30
- test "ability to change shipping method" do
31
- visit root_path
32
- add_item_to_cart('Bracelet Set')
33
- click_link 'Checkout'
34
-
35
- enter_valid_email_address
36
- enter_valid_shipping_address
37
- click_button 'Submit'
38
-
39
- choose 'Ground Shipping'
40
- click_button 'Submit'
41
-
42
- assert_sanitized_equal 'Ground Shipping ( $3.99 )', find('.shipping-method').text
43
- click_link 'edit_shipping_method'
44
-
45
- choose 'Express Shipping'
46
- click_button 'Submit'
47
-
48
- assert_sanitized_equal 'Express Shipping ( $13.99 )', find('.shipping-method').text
49
- end
50
-
51
- end