solidus_backend 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of solidus_backend might be problematic. Click here for more details.

Files changed (92) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +6 -0
  3. data/Rakefile +15 -0
  4. data/script/rails +9 -0
  5. data/solidus_backend.gemspec +30 -0
  6. data/spec/controllers/spree/admin/base_controller_spec.rb +24 -0
  7. data/spec/controllers/spree/admin/cancellations_controller_spec.rb +77 -0
  8. data/spec/controllers/spree/admin/customer_returns_controller_spec.rb +234 -0
  9. data/spec/controllers/spree/admin/general_settings_controller_spec.rb +41 -0
  10. data/spec/controllers/spree/admin/missing_products_controller_spec.rb +18 -0
  11. data/spec/controllers/spree/admin/orders/customer_details_controller_spec.rb +80 -0
  12. data/spec/controllers/spree/admin/orders_controller_spec.rb +460 -0
  13. data/spec/controllers/spree/admin/payment_methods_controller_spec.rb +49 -0
  14. data/spec/controllers/spree/admin/payments_controller_spec.rb +175 -0
  15. data/spec/controllers/spree/admin/product_properties_controller_spec.rb +69 -0
  16. data/spec/controllers/spree/admin/products_controller_spec.rb +162 -0
  17. data/spec/controllers/spree/admin/promotion_actions_controller_spec.rb +21 -0
  18. data/spec/controllers/spree/admin/promotion_codes_controller_spec.rb +18 -0
  19. data/spec/controllers/spree/admin/promotion_rules_controller_spec.rb +21 -0
  20. data/spec/controllers/spree/admin/promotions_controller_spec.rb +122 -0
  21. data/spec/controllers/spree/admin/refunds_controller_spec.rb +32 -0
  22. data/spec/controllers/spree/admin/reimbursements_controller_spec.rb +124 -0
  23. data/spec/controllers/spree/admin/reports_controller_spec.rb +134 -0
  24. data/spec/controllers/spree/admin/resource_controller_spec.rb +166 -0
  25. data/spec/controllers/spree/admin/return_authorizations_controller_spec.rb +240 -0
  26. data/spec/controllers/spree/admin/return_items_controller_spec.rb +27 -0
  27. data/spec/controllers/spree/admin/root_controller_spec.rb +41 -0
  28. data/spec/controllers/spree/admin/search_controller_spec.rb +104 -0
  29. data/spec/controllers/spree/admin/shipping_methods_controller_spec.rb +14 -0
  30. data/spec/controllers/spree/admin/stock_items_controller_spec.rb +50 -0
  31. data/spec/controllers/spree/admin/stock_locations_controller_spec.rb +41 -0
  32. data/spec/controllers/spree/admin/stock_transfers_controller_spec.rb +351 -0
  33. data/spec/controllers/spree/admin/store_credits_controller_spec.rb +309 -0
  34. data/spec/controllers/spree/admin/users_controller_spec.rb +257 -0
  35. data/spec/controllers/spree/admin/variants_controller_spec.rb +32 -0
  36. data/spec/features/admin/configuration/analytics_tracker_spec.rb +50 -0
  37. data/spec/features/admin/configuration/countries_spec.rb +22 -0
  38. data/spec/features/admin/configuration/general_settings_spec.rb +45 -0
  39. data/spec/features/admin/configuration/payment_methods_spec.rb +124 -0
  40. data/spec/features/admin/configuration/shipping_methods_spec.rb +64 -0
  41. data/spec/features/admin/configuration/states_spec.rb +64 -0
  42. data/spec/features/admin/configuration/stock_locations_spec.rb +50 -0
  43. data/spec/features/admin/configuration/tax_categories_spec.rb +56 -0
  44. data/spec/features/admin/configuration/tax_rates_spec.rb +30 -0
  45. data/spec/features/admin/configuration/taxonomies_spec.rb +52 -0
  46. data/spec/features/admin/configuration/zones_spec.rb +39 -0
  47. data/spec/features/admin/homepage_spec.rb +78 -0
  48. data/spec/features/admin/locale_spec.rb +30 -0
  49. data/spec/features/admin/orders/adjustments_promotions_spec.rb +53 -0
  50. data/spec/features/admin/orders/adjustments_spec.rb +126 -0
  51. data/spec/features/admin/orders/cancelling_and_resuming_spec.rb +48 -0
  52. data/spec/features/admin/orders/cancelling_inventory_spec.rb +48 -0
  53. data/spec/features/admin/orders/customer_details_spec.rb +163 -0
  54. data/spec/features/admin/orders/line_items_spec.rb +50 -0
  55. data/spec/features/admin/orders/listing_spec.rb +130 -0
  56. data/spec/features/admin/orders/log_entries_spec.rb +55 -0
  57. data/spec/features/admin/orders/new_order_spec.rb +185 -0
  58. data/spec/features/admin/orders/order_details_spec.rb +533 -0
  59. data/spec/features/admin/orders/payments_spec.rb +234 -0
  60. data/spec/features/admin/orders/risk_analysis_spec.rb +47 -0
  61. data/spec/features/admin/orders/shipments_spec.rb +65 -0
  62. data/spec/features/admin/payments/store_credits_spec.rb +21 -0
  63. data/spec/features/admin/products/edit/images_spec.rb +87 -0
  64. data/spec/features/admin/products/edit/products_spec.rb +66 -0
  65. data/spec/features/admin/products/edit/taxons_spec.rb +43 -0
  66. data/spec/features/admin/products/edit/variants_spec.rb +61 -0
  67. data/spec/features/admin/products/option_types_spec.rb +114 -0
  68. data/spec/features/admin/products/products_spec.rb +395 -0
  69. data/spec/features/admin/products/properties_spec.rb +139 -0
  70. data/spec/features/admin/products/prototypes_spec.rb +110 -0
  71. data/spec/features/admin/products/stock_management_spec.rb +82 -0
  72. data/spec/features/admin/products/variant_spec.rb +51 -0
  73. data/spec/features/admin/promotion_adjustments_spec.rb +220 -0
  74. data/spec/features/admin/promotions/option_value_rule_spec.rb +65 -0
  75. data/spec/features/admin/promotions/tiered_calculator_spec.rb +69 -0
  76. data/spec/features/admin/reports_spec.rb +61 -0
  77. data/spec/features/admin/stock_transfer_spec.rb +104 -0
  78. data/spec/features/admin/store_credits_spec.rb +82 -0
  79. data/spec/features/admin/taxons_spec.rb +31 -0
  80. data/spec/features/admin/users_spec.rb +275 -0
  81. data/spec/helpers/admin/base_helper_spec.rb +18 -0
  82. data/spec/helpers/admin/navigation_helper_spec.rb +73 -0
  83. data/spec/helpers/admin/reimbursements_helper_spec.rb +34 -0
  84. data/spec/helpers/admin/stock_movements_helper_spec.rb +29 -0
  85. data/spec/helpers/admin/store_credit_events_helper_spec.rb +95 -0
  86. data/spec/helpers/promotion_rules_helper_spec.rb +12 -0
  87. data/spec/spec_helper.rb +116 -0
  88. data/spec/support/appear_before_matcher.rb +8 -0
  89. data/spec/support/ror_ringer.jpeg +0 -0
  90. data/spec/test_views/spree/admin/widgets/edit.html.erb +1 -0
  91. data/spec/test_views/spree/admin/widgets/new.html.erb +1 -0
  92. metadata +96 -6
@@ -0,0 +1,53 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Adjustments Promotions", :type => :feature do
4
+ stub_authorization!
5
+
6
+ before(:each) do
7
+ promotion = create(:promotion_with_item_adjustment,
8
+ :name => "$10 off",
9
+ :path => 'test',
10
+ :code => "10_off",
11
+ :starts_at => 1.day.ago,
12
+ :expires_at => 1.day.from_now,
13
+ :adjustment_rate => 10)
14
+
15
+ order = create(:order_with_totals)
16
+ line_item = order.line_items.first
17
+ # so we can be sure of a determinate price in our assertions
18
+ line_item.update_column(:price, 10)
19
+
20
+ visit spree.admin_order_adjustments_path(order)
21
+ end
22
+
23
+ context "admin adding a promotion" do
24
+ context "successfully" do
25
+ it "should create a new adjustment", :js => true do
26
+ fill_in "coupon_code", :with => "10_off"
27
+ click_button "Add Coupon Code"
28
+ expect(page).to have_content("$10 off")
29
+ expect(page).to have_content("-$10.00")
30
+ end
31
+ end
32
+
33
+ context "for non-existing promotion" do
34
+ it "should show an error message", :js => true do
35
+ fill_in "coupon_code", :with => "does_not_exist"
36
+ click_button "Add Coupon Code"
37
+ expect(page).to have_content("doesn't exist.")
38
+ end
39
+ end
40
+
41
+ context "for already applied promotion" do
42
+ it "should show an error message", :js => true do
43
+ fill_in "coupon_code", :with => "10_off"
44
+ click_button "Add Coupon Code"
45
+ expect(page).to have_content('-$10.00')
46
+
47
+ fill_in "coupon_code", :with => "10_off"
48
+ click_button "Add Coupon Code"
49
+ expect(page).to have_content("already been applied")
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,126 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Adjustments", :type => :feature do
4
+ stub_authorization!
5
+
6
+ let!(:order) { create(:completed_order_with_totals, line_items_count: 5) }
7
+ let!(:line_item) do
8
+ line_item = order.line_items.first
9
+ # so we can be sure of a determinate price in our assertions
10
+ line_item.update_column(:price, 10)
11
+ line_item
12
+ end
13
+
14
+ let!(:tax_adjustment) do
15
+ create(:tax_adjustment,
16
+ :adjustable => line_item,
17
+ :finalized => true,
18
+ :order => order,
19
+ :label => "VAT 5%",
20
+ :amount => 10)
21
+ end
22
+
23
+ let!(:adjustment) { order.adjustments.create!(order: order, label: 'Rebate', amount: 10) }
24
+
25
+ before(:each) do
26
+ # To ensure the order totals are correct
27
+ order.update_totals
28
+ order.persist_totals
29
+
30
+ visit spree.admin_path
31
+ click_link "Orders"
32
+ within_row(1) { click_icon :edit }
33
+ click_link "Adjustments"
34
+ end
35
+
36
+ context "admin managing adjustments" do
37
+ it "should display the correct values for existing order adjustments" do
38
+ within_row(1) do
39
+ expect(column_text(2)).to eq("VAT 5%")
40
+ expect(column_text(3)).to eq("$10.00")
41
+ end
42
+ end
43
+
44
+ it "only shows eligible adjustments" do
45
+ expect(page).not_to have_content("ineligible")
46
+ end
47
+ end
48
+
49
+ context "admin creating a new adjustment" do
50
+ before(:each) do
51
+ click_link "New Adjustment"
52
+ end
53
+
54
+ context "successfully" do
55
+ it "should create a new adjustment" do
56
+ fill_in "adjustment_amount", :with => "10"
57
+ fill_in "adjustment_label", :with => "rebate"
58
+ click_button "Continue"
59
+
60
+ order.reload.all_adjustments.each do |adjustment|
61
+ expect(adjustment.order_id).to equal(order.id)
62
+ end
63
+ end
64
+ end
65
+
66
+ context "with validation errors" do
67
+ it "should not create a new adjustment" do
68
+ fill_in "adjustment_amount", :with => ""
69
+ fill_in "adjustment_label", :with => ""
70
+ click_button "Continue"
71
+ expect(page).to have_content("Label can't be blank")
72
+ expect(page).to have_content("Amount is not a number")
73
+ end
74
+ end
75
+ end
76
+
77
+ context "admin editing an adjustment" do
78
+
79
+ before(:each) do
80
+ within_row(2) { click_icon :edit }
81
+ end
82
+
83
+ context "successfully" do
84
+ it "should update the adjustment" do
85
+ fill_in "adjustment_amount", :with => "99"
86
+ fill_in "adjustment_label", :with => "rebate 99"
87
+ click_button "Continue"
88
+ expect(page).to have_content("successfully updated!")
89
+ expect(page).to have_content("rebate 99")
90
+ within(".adjustments") do
91
+ expect(page).to have_content("$99.00")
92
+ end
93
+
94
+ expect(page).to have_content("Total: $259.00")
95
+ end
96
+ end
97
+
98
+ context "with validation errors" do
99
+ it "should not update the adjustment" do
100
+ fill_in "adjustment_amount", :with => ""
101
+ fill_in "adjustment_label", :with => ""
102
+ click_button "Continue"
103
+ expect(page).to have_content("Label can't be blank")
104
+ expect(page).to have_content("Amount is not a number")
105
+ end
106
+ end
107
+ end
108
+
109
+ context "deleting an adjustment" do
110
+ it "should not be possible if adjustment is closed" do
111
+ within_row(1) do
112
+ expect(page).not_to have_css('.fa-trash')
113
+ end
114
+ end
115
+
116
+ it "should update the total", :js => true do
117
+ accept_alert do
118
+ within_row(2) do
119
+ click_icon(:trash)
120
+ end
121
+ end
122
+
123
+ expect(page).to have_content(/TOTAL: ?\$170\.00/)
124
+ end
125
+ end
126
+ end
@@ -0,0 +1,48 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Cancelling + Resuming", :type => :feature do
4
+
5
+ stub_authorization!
6
+
7
+ let(:user) { build_stubbed(:user, id: 123, spree_api_key: 'fake') }
8
+
9
+ before do
10
+ allow(user).to receive(:has_spree_role?).and_return(true)
11
+ allow_any_instance_of(Spree::Admin::BaseController).to receive(:try_spree_current_user).and_return(user)
12
+ end
13
+
14
+ let(:order) do
15
+ order = create(:order)
16
+ order.update_columns({
17
+ :state => 'complete',
18
+ :completed_at => Time.now
19
+ })
20
+ order
21
+ end
22
+
23
+ it "can cancel an order" do
24
+ visit spree.edit_admin_order_path(order.number)
25
+ click_button 'cancel'
26
+ within(".additional-info") do
27
+ within(".state") do
28
+ expect(page).to have_content("canceled")
29
+ end
30
+ end
31
+ end
32
+
33
+ context "with a cancelled order" do
34
+ before do
35
+ order.update_column(:state, 'canceled')
36
+ end
37
+
38
+ it "can resume an order" do
39
+ visit spree.edit_admin_order_path(order.number)
40
+ click_button 'resume'
41
+ within(".additional-info") do
42
+ within(".state") do
43
+ expect(page).to have_content("resumed")
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,48 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Cancelling inventory" do
4
+ stub_authorization!
5
+
6
+ let!(:order) do
7
+ create(
8
+ :order_ready_to_ship,
9
+ number: "R100",
10
+ state: "complete",
11
+ line_items_count: 1,
12
+ )
13
+ end
14
+
15
+ def visit_order
16
+ visit spree.admin_path
17
+ click_link "Orders"
18
+ within_row(1) do
19
+ click_link "R100"
20
+ end
21
+ end
22
+
23
+ context "when some inventory is cancelable" do
24
+ it "can cancel the inventory" do
25
+ visit_order
26
+
27
+ click_link 'Cancel Inventory'
28
+
29
+ within_row(1) do
30
+ check 'inventory_unit_ids[]'
31
+ end
32
+
33
+ click_button "Cancel Inventory"
34
+ expect(page).to have_content("Inventory canceled")
35
+ expect(page).to have_content("1 x canceled")
36
+ end
37
+ end
38
+
39
+ context "when all inventory is not cancelable" do
40
+ before { order.inventory_units.each(&:cancel!) }
41
+
42
+ it "does not display the link to cancel inventory" do
43
+ visit_order
44
+
45
+ expect(page).to have_no_content('Cancel Inventory')
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,163 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Customer Details", type: :feature, js: true do
4
+ stub_authorization!
5
+
6
+ let(:country) { create(:country, name: "Kangaland") }
7
+ let(:state) { create(:state, name: "Alabama", country: country) }
8
+ let!(:shipping_method) { create(:shipping_method, display_on: "front_end") }
9
+ let!(:order) { create(:order, state: 'complete', completed_at: "2011-02-01 12:36:15") }
10
+ let!(:product) { create(:product_in_stock) }
11
+
12
+ # We need a unique name that will appear for the customer dropdown
13
+ let!(:ship_address) { create(:address, country: country, state: state, first_name: "Rumpelstiltskin") }
14
+ let!(:bill_address) { create(:address, country: country, state: state, first_name: "Rumpelstiltskin") }
15
+
16
+ let!(:user) { create(:user, email: 'foobar@example.com', ship_address: ship_address, bill_address: bill_address) }
17
+
18
+ context "brand new order" do
19
+ # Regression test for #3335 & #5317
20
+ it "associates a user when not using guest checkout" do
21
+ visit spree.admin_path
22
+ click_link "Orders"
23
+ click_link "New Order"
24
+ click_on 'Cart'
25
+ select2_search product.name, from: Spree.t(:name_or_sku)
26
+ within("table.stock-levels") do
27
+ find('.variant_quantity').set(1)
28
+ end
29
+ click_icon :plus
30
+ expect(page).to have_css('.line-item')
31
+ click_link "Customer Details"
32
+ targetted_select2 "foobar@example.com", from: "#s2id_customer_search"
33
+ # 5317 - Address prefills using user's default.
34
+ expect(page).to have_field('First Name', with: user.bill_address.firstname)
35
+ expect(page).to have_field('Last Name', with: user.bill_address.lastname)
36
+ expect(page).to have_field('Street Address', with: user.bill_address.address1)
37
+ expect(page).to have_field("Street Address (cont'd)", with: user.bill_address.address2)
38
+ expect(page).to have_field('City', with: user.bill_address.city)
39
+ expect(page).to have_field('Zip', with: user.bill_address.zipcode)
40
+ expect(page).to have_field('Country', with: user.bill_address.country_id)
41
+ expect(page).to have_field('State', with: user.bill_address.state_id)
42
+ expect(page).to have_field('Phone', with: user.bill_address.phone)
43
+ click_button "Update"
44
+ expect(Spree::Order.last.user).not_to be_nil
45
+ end
46
+ end
47
+
48
+ context "editing an order" do
49
+ before do
50
+ configure_spree_preferences do |config|
51
+ config.default_country_id = country.id
52
+ config.company = true
53
+ end
54
+
55
+ visit spree.admin_path
56
+ click_link "Orders"
57
+ within('table#listing_orders') { click_icon(:edit) }
58
+ end
59
+
60
+ context "selected country has no state" do
61
+ before { create(:country, iso: "BRA", name: "Brazil") }
62
+
63
+ it "changes state field to text input" do
64
+ click_link "Customer Details"
65
+
66
+ within("#billing") do
67
+ targetted_select2 "Brazil", from: "#s2id_order_bill_address_attributes_country_id"
68
+ fill_in "order_bill_address_attributes_state_name", with: "Piaui"
69
+ end
70
+
71
+ click_button "Update"
72
+ click_link "Customer Details"
73
+ expect(find_field("order_bill_address_attributes_state_name").value).to eq("Piaui")
74
+ end
75
+ end
76
+
77
+ it "should be able to update customer details for an existing order" do
78
+ order.ship_address = create(:address)
79
+ order.save!
80
+
81
+ click_link "Customer Details"
82
+ within("#shipping") { fill_in_address "ship" }
83
+ within("#billing") { fill_in_address "bill" }
84
+
85
+ click_button "Update"
86
+ click_link "Customer Details"
87
+
88
+ # Regression test for #2950 + #2433
89
+ # This act should transition the state of the order as far as it will go too
90
+ within("#order_tab_summary") do
91
+ expect(find(".state").text).to eq("COMPLETE")
92
+ end
93
+ end
94
+
95
+ it "should show validation errors" do
96
+ order.update_attributes!(ship_address_id: nil)
97
+ click_link "Customer Details"
98
+ click_button "Update"
99
+ expect(page).to have_content("Shipping address first name can't be blank")
100
+ end
101
+
102
+ it "updates order email for an existing order with a user" do
103
+ order.update_columns(ship_address_id: ship_address.id, bill_address_id: bill_address.id, state: "confirm", completed_at: nil)
104
+ previous_user = order.user
105
+ click_link "Customer Details"
106
+ fill_in "order_email", with: "newemail@example.com"
107
+ expect { click_button "Update" }.to change { order.reload.email }.to "newemail@example.com"
108
+ expect(order.user_id).to eq previous_user.id
109
+ expect(order.user.email).to eq previous_user.email
110
+ end
111
+
112
+ context "country associated was removed" do
113
+ let(:brazil) { create(:country, iso: "BRA", name: "Brazil") }
114
+
115
+ before do
116
+ order.bill_address.country.destroy
117
+ configure_spree_preferences do |config|
118
+ config.default_country_id = brazil.id
119
+ end
120
+ end
121
+
122
+ it "sets default country when displaying form" do
123
+ click_link "Customer Details"
124
+ expect(find_field("order_bill_address_attributes_country_id").value.to_i).to eq brazil.id
125
+ end
126
+ end
127
+
128
+ # Regression test for #942
129
+ context "errors when no shipping methods are available" do
130
+ before do
131
+ Spree::ShippingMethod.delete_all
132
+ end
133
+
134
+ specify do
135
+ click_link "Customer Details"
136
+ # Need to fill in valid information so it passes validations
137
+ fill_in "order_ship_address_attributes_firstname", with: "John 99"
138
+ fill_in "order_ship_address_attributes_lastname", with: "Doe"
139
+ fill_in "order_ship_address_attributes_lastname", with: "Company"
140
+ fill_in "order_ship_address_attributes_address1", with: "100 first lane"
141
+ fill_in "order_ship_address_attributes_address2", with: "#101"
142
+ fill_in "order_ship_address_attributes_city", with: "Bethesda"
143
+ fill_in "order_ship_address_attributes_zipcode", with: "20170"
144
+
145
+ page.select('Alabama', from: 'order_ship_address_attributes_state_id')
146
+ fill_in "order_ship_address_attributes_phone", with: "123-456-7890"
147
+ expect { click_button "Update" }.not_to raise_error
148
+ end
149
+ end
150
+ end
151
+
152
+ def fill_in_address(kind = "bill")
153
+ fill_in "First Name", with: "John 99"
154
+ fill_in "Last Name", with: "Doe"
155
+ fill_in "Company", with: "Company"
156
+ fill_in "Street Address", with: "100 first lane"
157
+ fill_in "Street Address (cont'd)", with: "#101"
158
+ fill_in "City", with: "Bethesda"
159
+ fill_in "Zip", with: "20170"
160
+ targetted_select2 "Alabama", from: "#s2id_order_#{kind}_address_attributes_state_id"
161
+ fill_in "Phone", with: "123-456-7890"
162
+ end
163
+ end
@@ -0,0 +1,50 @@
1
+ require 'spec_helper'
2
+
3
+ # Tests for #3958's features
4
+ describe "Order Line Items", type: :feature, js: true do
5
+ stub_authorization!
6
+
7
+ before do
8
+ # Removing the delivery step causes the order page to render a different
9
+ # partial, called _line_items, which shows line items rather than shipments
10
+ allow(Spree::Order).to receive_messages :checkout_step_names => [:address, :payment, :confirm, :complete]
11
+ end
12
+
13
+ let!(:order) do
14
+ order = create(:order_with_line_items, :line_items_count => 1)
15
+ order.shipments.destroy_all
16
+ order
17
+ end
18
+
19
+ it "can edit a line item's quantity" do
20
+ visit spree.edit_admin_order_path(order)
21
+ within(".line-items") do
22
+ find(".edit-line-item").click
23
+ fill_in "quantity", :with => 10
24
+ find(".save-line-item").click
25
+ end
26
+ within '.line-item-qty-show' do
27
+ expect(page).to have_content("10")
28
+ end
29
+ within '.line-item-total' do
30
+ expect(page).to have_content("$100.00")
31
+ end
32
+ end
33
+
34
+ it "can delete a line item" do
35
+ visit spree.edit_admin_order_path(order)
36
+
37
+ product_name = find(".line-items tr:nth-child(1) .line-item-name").text
38
+
39
+ within(".line-items") do
40
+ within_row(1) do
41
+ accept_alert do
42
+ find(".delete-line-item").click
43
+ end
44
+ end
45
+ end
46
+
47
+ expect(find('#order_total')).to have_content("$0.00")
48
+ expect(page).not_to have_content(product_name)
49
+ end
50
+ end
@@ -0,0 +1,130 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Orders Listing", type: :feature, js: true do
4
+ stub_authorization!
5
+
6
+ let!(:promotion) { create(:promotion_with_item_adjustment, code: "vnskseiw") }
7
+ let(:promotion_code) { promotion.codes.first }
8
+
9
+ before(:each) do
10
+ allow_any_instance_of(Spree::OrderInventory).to receive(:add_to_shipment)
11
+ @order1 = create(:order_with_line_items, created_at: 1.day.from_now, completed_at: 1.day.from_now, number: "R100")
12
+ @order2 = create(:order, created_at: 1.day.ago, completed_at: 1.day.ago, number: "R200")
13
+ visit spree.admin_orders_path
14
+ end
15
+
16
+ context "listing orders" do
17
+ it "should list existing orders" do
18
+ within_row(1) do
19
+ expect(column_text(2)).to eq "R100"
20
+ expect(column_text(3)).to eq "CART"
21
+ end
22
+
23
+ within_row(2) do
24
+ expect(column_text(2)).to eq "R200"
25
+ end
26
+ end
27
+
28
+ it "should be able to sort the orders listing" do
29
+ # default is completed_at desc
30
+ within_row(1) { expect(page).to have_content("R100") }
31
+ within_row(2) { expect(page).to have_content("R200") }
32
+
33
+ click_link "Completed At"
34
+
35
+ # Completed at desc
36
+ within_row(1) { expect(page).to have_content("R200") }
37
+ within_row(2) { expect(page).to have_content("R100") }
38
+
39
+ within('table#listing_orders thead') { click_link "Number" }
40
+
41
+ # number asc
42
+ within_row(1) { expect(page).to have_content("R100") }
43
+ within_row(2) { expect(page).to have_content("R200") }
44
+ end
45
+ end
46
+
47
+ context "searching orders" do
48
+ it "should be able to search orders" do
49
+ click_on 'Filter'
50
+ fill_in "q_number_cont", with: "R200"
51
+ click_on 'Filter Results'
52
+ within_row(1) do
53
+ expect(page).to have_content("R200")
54
+ end
55
+
56
+ # Ensure that the other order doesn't show up
57
+ within("table#listing_orders") { expect(page).not_to have_content("R100") }
58
+ end
59
+
60
+ it "should be able to filter on variant_id" do
61
+ click_on 'Filter'
62
+ select2_search @order1.products.first.sku, from: Spree.t(:variant)
63
+ click_on 'Filter Results'
64
+
65
+ within_row(1) do
66
+ expect(page).to have_content(@order1.number)
67
+ end
68
+
69
+ expect(page).not_to have_content(@order2.number)
70
+ end
71
+
72
+ context "when pagination is really short" do
73
+ before do
74
+ @old_per_page = Spree::Config[:orders_per_page]
75
+ Spree::Config[:orders_per_page] = 1
76
+ end
77
+
78
+ after do
79
+ Spree::Config[:orders_per_page] = @old_per_page
80
+ end
81
+
82
+ # Regression test for #4004
83
+ it "should be able to go from page to page for incomplete orders" do
84
+ 10.times { Spree::Order.create email: "incomplete@example.com" }
85
+ click_on 'Filter'
86
+ uncheck "q_completed_at_not_null"
87
+ click_on 'Filter Results'
88
+ within(".pagination") do
89
+ click_link "2"
90
+ end
91
+ expect(page).to have_content("incomplete@example.com")
92
+ click_on 'Filter'
93
+ expect(find("#q_completed_at_not_null")).not_to be_checked
94
+ end
95
+ end
96
+
97
+ it "should be able to search orders using only completed at input" do
98
+ click_on 'Filter'
99
+ fill_in "q_created_at_gt", with: Date.current
100
+
101
+ # Just so the datepicker gets out of poltergeists way.
102
+ page.execute_script("$('#q_created_at_gt').datepicker('widget').hide();")
103
+
104
+ click_on 'Filter Results'
105
+ within_row(1) { expect(page).to have_content("R100") }
106
+
107
+ # Ensure that the other order doesn't show up
108
+ within("table#listing_orders") { expect(page).not_to have_content("R200") }
109
+ end
110
+
111
+ context "filter on promotions" do
112
+ before(:each) do
113
+ @order1.order_promotions.build(
114
+ promotion: promotion,
115
+ promotion_code: promotion_code,
116
+ )
117
+ @order1.save
118
+ visit spree.admin_orders_path
119
+ end
120
+
121
+ it "only shows the orders with the selected promotion" do
122
+ click_on 'Filter'
123
+ fill_in "q_promotions_codes_value_cont", with: promotion.codes.first.value
124
+ click_on 'Filter Results'
125
+ within_row(1) { expect(page).to have_content("R100") }
126
+ within("table#listing_orders") { expect(page).not_to have_content("R200") }
127
+ end
128
+ end
129
+ end
130
+ end
@@ -0,0 +1,55 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Log entries", :type => :feature do
4
+ stub_authorization!
5
+
6
+ let!(:payment) { create(:payment) }
7
+
8
+ context "with a successful log entry" do
9
+ before do
10
+ response = ActiveMerchant::Billing::Response.new(
11
+ true,
12
+ "Transaction successful",
13
+ :transid => "ABCD1234"
14
+ )
15
+
16
+ payment.log_entries.create(
17
+ :source => payment.source,
18
+ :details => response.to_yaml
19
+ )
20
+ end
21
+
22
+ it "shows a successful attempt" do
23
+ visit spree.admin_order_payments_path(payment.order)
24
+ find("#payment_#{payment.id} a").click
25
+ click_link "Logs"
26
+ within("#listing_log_entries") do
27
+ expect(page).to have_content("Transaction successful")
28
+ end
29
+ end
30
+ end
31
+
32
+ context "with a failed log entry" do
33
+ before do
34
+ response = ActiveMerchant::Billing::Response.new(
35
+ false,
36
+ "Transaction failed",
37
+ :transid => "ABCD1234"
38
+ )
39
+
40
+ payment.log_entries.create(
41
+ :source => payment.source,
42
+ :details => response.to_yaml
43
+ )
44
+ end
45
+
46
+ it "shows a failed attempt" do
47
+ visit spree.admin_order_payments_path(payment.order)
48
+ find("#payment_#{payment.id} a").click
49
+ click_link "Logs"
50
+ within("#listing_log_entries") do
51
+ expect(page).to have_content("Transaction failed")
52
+ end
53
+ end
54
+ end
55
+ end