solidus_backend 2.8.2 → 2.9.2

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 (110) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/spree/backend/components/sortable_table.js +1 -0
  3. data/app/assets/javascripts/spree/backend/components/tabs.js +1 -0
  4. data/app/assets/javascripts/spree/backend/shipments.js +1 -0
  5. data/app/assets/javascripts/spree/backend/stock_management.js +9 -0
  6. data/app/assets/javascripts/spree/backend/templates/orders/line_item.hbs +1 -1
  7. data/app/assets/javascripts/spree/backend/views/stock/edit_stock_item_row.js +18 -2
  8. data/app/assets/stylesheets/spree/backend/_bootstrap_custom.scss +24 -16
  9. data/app/assets/stylesheets/spree/backend/components/_breadcrumb.scss +12 -0
  10. data/app/assets/stylesheets/spree/backend/components/_buttons.scss +18 -0
  11. data/app/assets/stylesheets/spree/backend/components/_image_placeholder.scss +2 -2
  12. data/app/assets/stylesheets/spree/backend/components/_list_group.scss +2 -2
  13. data/app/assets/stylesheets/spree/backend/components/_messages.scss +20 -12
  14. data/app/assets/stylesheets/spree/backend/components/_navigation.scss +45 -11
  15. data/app/assets/stylesheets/spree/backend/components/_progress.scss +3 -3
  16. data/app/assets/stylesheets/spree/backend/components/_sidebar.scss +1 -2
  17. data/app/assets/stylesheets/spree/backend/components/_tabs.scss +14 -13
  18. data/app/assets/stylesheets/spree/backend/globals/_deprecated_variables.scss +24 -0
  19. data/app/assets/stylesheets/spree/backend/globals/_deprecation.scss +10 -1
  20. data/app/assets/stylesheets/spree/backend/globals/_functions.scss +4 -1
  21. data/app/assets/stylesheets/spree/backend/globals/_variables.scss +88 -57
  22. data/app/assets/stylesheets/spree/backend/globals/_variables_override.scss +1 -0
  23. data/app/assets/stylesheets/spree/backend/globals/mixins/_caret.scss +1 -1
  24. data/app/assets/stylesheets/spree/backend/globals/mixins/_line_through.scss +1 -1
  25. data/app/assets/stylesheets/spree/backend/sections/_log_entries.scss +8 -2
  26. data/app/assets/stylesheets/spree/backend/sections/_orders.scss +17 -6
  27. data/app/assets/stylesheets/spree/backend/sections/_products.scss +3 -1
  28. data/app/assets/stylesheets/spree/backend/sections/_promotions.scss +5 -5
  29. data/app/assets/stylesheets/spree/backend/sections/_style_guide.scss +4 -4
  30. data/app/assets/stylesheets/spree/backend/sections/_taxonomies.scss +1 -1
  31. data/app/assets/stylesheets/spree/backend/shared/_fonts.scss +15 -0
  32. data/app/assets/stylesheets/spree/backend/shared/_forms.scss +27 -7
  33. data/app/assets/stylesheets/spree/backend/shared/_header.scss +2 -2
  34. data/app/assets/stylesheets/spree/backend/shared/_icons.scss +5 -1
  35. data/app/assets/stylesheets/spree/backend/shared/_layout.scss +5 -4
  36. data/app/assets/stylesheets/spree/backend/shared/_tables.scss +11 -6
  37. data/app/assets/stylesheets/spree/backend/shared/_typography.scss +10 -6
  38. data/app/assets/stylesheets/spree/backend/spree_admin.scss +3 -0
  39. data/app/controllers/spree/admin/customer_returns_controller.rb +8 -1
  40. data/app/controllers/spree/admin/log_entries_controller.rb +3 -0
  41. data/app/controllers/spree/admin/orders_controller.rb +0 -1
  42. data/app/controllers/spree/admin/users_controller.rb +4 -2
  43. data/app/helpers/spree/admin/base_helper.rb +9 -3
  44. data/app/helpers/spree/admin/promotions_helper.rb +15 -0
  45. data/app/views/spree/admin/images/index.html.erb +1 -1
  46. data/app/views/spree/admin/log_entries/index.html.erb +1 -19
  47. data/app/views/spree/admin/option_types/edit.html.erb +1 -1
  48. data/app/views/spree/admin/orders/_line_items_edit_form.html.erb +1 -1
  49. data/app/views/spree/admin/payments/_capture_events.html.erb +15 -18
  50. data/app/views/spree/admin/payments/_list.html.erb +1 -1
  51. data/app/views/spree/admin/payments/_log_entries.html.erb +29 -0
  52. data/app/views/spree/admin/payments/show.html.erb +13 -6
  53. data/app/views/spree/admin/payments/source_forms/{_storecredit.html.erb → _store_credit.html.erb} +0 -0
  54. data/app/views/spree/admin/payments/source_views/{_storecredit.html.erb → _store_credit.html.erb} +0 -0
  55. data/app/views/spree/admin/prices/_form.html.erb +1 -1
  56. data/app/views/spree/admin/product_properties/index.html.erb +1 -1
  57. data/app/views/spree/admin/products/_form.html.erb +16 -5
  58. data/app/views/spree/admin/products/edit.html.erb +1 -1
  59. data/app/views/spree/admin/promotions/_form.html.erb +2 -2
  60. data/app/views/spree/admin/promotions/index.html.erb +4 -4
  61. data/app/views/spree/admin/reimbursements/edit.html.erb +2 -2
  62. data/app/views/spree/admin/shared/_head.html.erb +0 -3
  63. data/app/views/spree/admin/shared/_modal.html.erb +1 -1
  64. data/app/views/spree/admin/shipping_methods/_form.html.erb +10 -10
  65. data/app/views/spree/admin/stock_items/_stock_management.html.erb +1 -1
  66. data/app/views/spree/admin/store_credits/edit_validity.html.erb +1 -1
  67. data/app/views/spree/admin/store_credits/index.html.erb +1 -1
  68. data/app/views/spree/admin/store_credits/show.html.erb +1 -1
  69. data/app/views/spree/admin/stores/_form.html.erb +1 -0
  70. data/app/views/spree/admin/style_guide/topics/typography/_colors.html.erb +30 -20
  71. data/app/views/spree/admin/style_guide/topics/typography/_fonts.html.erb +1 -1
  72. data/app/views/spree/admin/taxonomies/edit.html.erb +1 -1
  73. data/app/views/spree/admin/taxons/_form.html.erb +1 -1
  74. data/app/views/spree/admin/taxons/edit.html.erb +2 -2
  75. data/app/views/spree/admin/users/edit.html.erb +2 -2
  76. data/app/views/spree/admin/users/index.html.erb +2 -2
  77. data/app/views/spree/admin/variants/_form.html.erb +1 -1
  78. data/app/views/spree/admin/variants/index.html.erb +1 -1
  79. data/app/views/spree/admin/zones/_state_members.html.erb +1 -1
  80. data/spec/controllers/spree/admin/locale_controller_spec.rb +45 -0
  81. data/spec/controllers/spree/admin/orders/customer_details_controller_spec.rb +3 -3
  82. data/spec/controllers/spree/admin/orders_controller_spec.rb +2 -2
  83. data/spec/controllers/spree/admin/stock_locations_controller_spec.rb +1 -1
  84. data/spec/features/admin/locale_spec.rb +1 -2
  85. data/spec/features/admin/orders/adjustments_spec.rb +1 -1
  86. data/spec/features/admin/orders/customer_details_spec.rb +5 -7
  87. data/spec/features/admin/orders/customer_returns_spec.rb +28 -0
  88. data/spec/features/admin/orders/listing_spec.rb +1 -6
  89. data/spec/features/admin/orders/log_entries_spec.rb +2 -2
  90. data/spec/features/admin/orders/new_order_spec.rb +3 -3
  91. data/spec/features/admin/orders/order_details_spec.rb +8 -3
  92. data/spec/features/admin/orders/payments_spec.rb +80 -39
  93. data/spec/features/admin/products/edit/products_spec.rb +25 -0
  94. data/spec/features/admin/products/edit/taxons_spec.rb +4 -0
  95. data/spec/features/admin/products/pricing_spec.rb +24 -6
  96. data/spec/features/admin/products/products_spec.rb +4 -4
  97. data/spec/features/admin/products/stock_management_spec.rb +17 -0
  98. data/spec/features/admin/products/variant_spec.rb +1 -1
  99. data/spec/features/admin/promotions/promotion_spec.rb +52 -0
  100. data/spec/features/admin/store_credits_spec.rb +3 -3
  101. data/spec/features/admin/users_spec.rb +22 -0
  102. data/spec/spec_helper.rb +1 -2
  103. data/spec/support/appear_before_matcher.rb +1 -1
  104. data/vendor/assets/fonts/inter/Inter-Regular.woff +0 -0
  105. data/vendor/assets/fonts/inter/Inter-Regular.woff2 +0 -0
  106. data/vendor/assets/fonts/inter/Inter-SemiBold.woff +0 -0
  107. data/vendor/assets/fonts/inter/Inter-SemiBold.woff2 +0 -0
  108. data/vendor/assets/stylesheets/solidus_admin/bootstrap/_pagination.scss +4 -0
  109. metadata +21 -11
  110. data/.eslintrc +0 -21
@@ -9,39 +9,49 @@
9
9
  <%-
10
10
  colors = [
11
11
  {
12
- name: '$color-1',
12
+ name: '$color-white',
13
13
  value: '#FFFFFF',
14
- used_for: 'Backgrounds.'
14
+ used_for: 'Body background color.'
15
15
  },
16
16
  {
17
- name: '$color-2',
18
- value: '#9FC820',
19
- used_for: 'Active states.'
17
+ name: '$color-light',
18
+ value: '#F9FAFB',
19
+ used_for: 'Sidebar and header background color.'
20
20
  },
21
21
  {
22
- name: '$color-3',
23
- value: '#5498DA',
24
- used_for: 'Buttons, links, form text.'
22
+ name: '$color-light-dark',
23
+ value: '#E5E7EB',
24
+ used_for: 'Borders color.'
25
25
  },
26
26
  {
27
- name: '$color-4',
28
- value: '#6788A2',
29
- used_for: 'Non-interactive text outside of form fields.'
27
+ name: '$color-dark',
28
+ value: '#24282F',
29
+ used_for: 'Text and headings color.'
30
30
  },
31
31
  {
32
- name: '$color-5',
33
- value: '#C60F13',
34
- used_for: 'Errors, destructive action warnings.'
32
+ name: '$color-dark-light',
33
+ value: '#808C9E',
34
+ used_for: 'Main text color for navigation, tabs, breadcrumb.'
35
+ },
36
+ {
37
+ name: '$color-primary',
38
+ value: '#3D76F1',
39
+ used_for: 'Buttons primary actions, links, active states.'
35
40
  },
36
41
  {
37
- name: '$color-6',
38
- value: '#FF9300',
39
- used_for: 'Warnings'
42
+ name: '$color-success',
43
+ value: '#52B73B',
44
+ used_for: 'Success actions.'
45
+ },
46
+ {
47
+ name: '$color-error',
48
+ value: '#CE452A',
49
+ used_for: 'Errors, destructive action warnings.'
40
50
  },
41
51
  {
42
- name: '$color-7',
43
- value: '#F4F4F4',
44
- used_for: 'Disabled states'
52
+ name: '$color-notice',
53
+ value: '#FFDD59',
54
+ used_for: 'Warnings actions.'
45
55
  }
46
56
  ]
47
57
 
@@ -1,6 +1,6 @@
1
1
  <div class="half">
2
2
  <p>
3
- The typography base is "Open Sans" and Helvetica which we leave to the browser to provide.
3
+ The typography base is "Inter" and Helvetica which we load by stylesheet with @font-face rule.
4
4
  Set at 13px with no specified line-height.
5
5
  </p>
6
6
 
@@ -14,7 +14,7 @@
14
14
  <%= render partial: 'form', locals: { f: f } %>
15
15
  <div class="filter-actions actions">
16
16
  <%= button_tag t('spree.actions.update'), class: 'btn btn-primary' %>
17
- <%= link_to t('spree.actions.cancel'), admin_taxonomies_path, class: 'btn btn-primary' %>
17
+ <%= link_to t('spree.actions.cancel'), admin_taxonomies_path, class: 'btn btn-default' %>
18
18
  </div>
19
19
  </fieldset>
20
20
 
@@ -23,7 +23,7 @@
23
23
  <%= f.field_container :icon do %>
24
24
  <%= f.label :icon %><br />
25
25
  <%= f.file_field :icon %>
26
- <%= image_tag f.object.icon(:mini) if f.object.icon.present? %>
26
+ <%= image_tag f.object.icon(:mini) if f.object.icon_present? %>
27
27
  <% end %>
28
28
  </div>
29
29
 
@@ -3,7 +3,7 @@
3
3
 
4
4
  <% content_for :page_actions do %>
5
5
  <li>
6
- <%= link_to t('spree.back_to_taxonomies_list'), spree.admin_taxonomies_path, class: 'btn btn-primary' %>
6
+ <%= link_to t('spree.back_to_taxonomies_list'), spree.admin_taxonomies_path, class: 'btn btn-default' %>
7
7
  </li>
8
8
  <% end %>
9
9
 
@@ -14,6 +14,6 @@
14
14
 
15
15
  <div class="form-buttons filter-actions" data-hook="buttons">
16
16
  <%= button_tag t('spree.actions.update'), class: 'btn btn-primary' %>
17
- <%= link_to t('spree.actions.cancel'), edit_admin_taxonomy_url(@taxonomy), class: 'btn btn-primary' %>
17
+ <%= link_to t('spree.actions.cancel'), edit_admin_taxonomy_url(@taxonomy), class: 'btn btn-default' %>
18
18
  </div>
19
19
  <% end %>
@@ -41,8 +41,8 @@
41
41
 
42
42
  </div>
43
43
  <div class="filter-actions actions">
44
- <%= button_to t('.clear_key'), spree.clear_api_key_admin_user_path(@user), method: :put, data: { confirm: t('.confirm_clear_key') }, class: 'btn btn-primary' %>
45
- <%= button_to t('.regenerate_key'), spree.generate_api_key_admin_user_path(@user), method: :put, data: { confirm: t('.confirm_regenerate_key') }, class: 'btn btn-primary' %>
44
+ <%= button_to t('.clear_key'), spree.clear_api_key_admin_user_path(@user), method: :put, data: { confirm: t('.confirm_clear_key') }, class: 'btn btn-default' %>
45
+ <%= button_to t('.regenerate_key'), spree.generate_api_key_admin_user_path(@user), method: :put, data: { confirm: t('.confirm_regenerate_key') }, class: 'btn btn-default' %>
46
46
  </div>
47
47
 
48
48
  <% else %>
@@ -82,14 +82,14 @@
82
82
  <tr id="<%= spree_dom_id user %>" data-hook="admin_users_index_rows">
83
83
  <td class='user_email'><%=link_to user.email, edit_admin_user_url(user) %></td>
84
84
  <td><%= user.spree_roles.map(&:name).to_sentence %></td>
85
- <td class="align-center"><%= link_to user.orders.count, spree.orders_admin_user_path(user) %></td>
85
+ <td class="align-center"><%= link_to user.order_count, spree.orders_admin_user_path(user) %></td>
86
86
  <td class="align-center"><%= link_to user.display_lifetime_value, spree.items_admin_user_path(user) %></td>
87
87
  <td class="align-center"><%= l user.created_at.to_date %></td>
88
88
  <td data-hook="admin_users_index_row_actions" class="actions">
89
89
  <% if can?(:edit, user) %>
90
90
  <%= link_to_edit user, no_text: true %>
91
91
  <% end %>
92
- <% if can?(:destroy, user) %>
92
+ <% if can?(:destroy, user) && user.orders.count.zero? %>
93
93
  <%= link_to_delete user, no_text: true %>
94
94
  <% end %>
95
95
  </td>
@@ -65,7 +65,7 @@
65
65
  <div class="col-3">
66
66
  <div class="field" data-hook="price">
67
67
  <%= f.label :price %>
68
- <%= render "spree/admin/shared/number_with_currency", f: f, amount_attr: :price, currency: @variant.default_price.currency %>
68
+ <%= render "spree/admin/shared/number_with_currency", f: f, amount_attr: :price, currency: @variant.find_or_build_default_price.currency %>
69
69
  </div>
70
70
  </div>
71
71
 
@@ -8,7 +8,7 @@
8
8
  <%= link_to(
9
9
  t('spree.new_variant'),
10
10
  new_admin_product_variant_url(@product),
11
- class: 'button'
11
+ class: 'btn btn-primary'
12
12
  ) %>
13
13
  </li>
14
14
  <% end %>
@@ -4,7 +4,7 @@
4
4
 
5
5
  <%= zone_form.field_container :state_ids do %>
6
6
  <%= zone_form.label :state_ids, plural_resource_name(Spree::State) %><br>
7
- <%= zone_form.collection_select :state_ids, @states, :id, :name, {}, { multiple: true, class: "select2 fullwidth" } %>
7
+ <%= zone_form.collection_select :state_ids, @states, :id, :state_with_country, {}, { multiple: true, class: "select2 fullwidth" } %>
8
8
  <% end %>
9
9
  </fieldset>
10
10
  </div>
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ RSpec.describe Spree::Admin::LocaleController, type: :controller do
6
+ stub_authorization!
7
+
8
+ before { I18n.backend.store_translations(:fr, {}) }
9
+
10
+ after do
11
+ I18n.locale = :en
12
+ I18n.reload!
13
+ end
14
+
15
+ context 'switch_to_locale specified' do
16
+ let(:json_response) { JSON.parse(response.body, symbolize_names: true) }
17
+
18
+ before do
19
+ get :set, params: { switch_to_locale: switch_to_locale, format: :json }
20
+ end
21
+
22
+ context 'available locale' do
23
+ let(:switch_to_locale) { 'fr' }
24
+
25
+ it 'sets locale and returns the location for the redirect' do
26
+ expect(I18n.locale).to eq :fr
27
+ expect(session[:admin_locale]).to eq(switch_to_locale)
28
+ expect(json_response).
29
+ to eq({ locale: switch_to_locale,
30
+ location: spree.admin_url(host: 'test.host') })
31
+ expect(response).to have_http_status(:ok)
32
+ end
33
+ end
34
+
35
+ context 'unavailable locale' do
36
+ let(:switch_to_locale) { 'klingon' }
37
+
38
+ it 'does not change locale and returns 404' do
39
+ expect(I18n.locale).to eq :en
40
+ expect(json_response).to eq({ locale: 'en', })
41
+ expect(response).to have_http_status(:not_found)
42
+ end
43
+ end
44
+ end
45
+ end
@@ -17,12 +17,12 @@ describe Spree::Admin::Orders::CustomerDetailsController, type: :controller do
17
17
  let!(:checkout_zone) { create(:zone, name: "Checkout Zone", countries: [canada]) }
18
18
 
19
19
  before do
20
- Spree::Config.checkout_zone = checkout_zone.name
20
+ stub_spree_preferences(checkout_zone: checkout_zone.name)
21
21
  end
22
22
 
23
23
  context "and default_country_iso of the Canada" do
24
24
  before do
25
- Spree::Config.default_country_iso = Spree::Country.find_by!(iso: "CA").iso
25
+ stub_spree_preferences(default_country_iso: Spree::Country.find_by!(iso: "CA").iso)
26
26
  end
27
27
 
28
28
  it 'defaults the shipping address country to Canada' do
@@ -38,7 +38,7 @@ describe Spree::Admin::Orders::CustomerDetailsController, type: :controller do
38
38
 
39
39
  context "and default_country_iso of the United States" do
40
40
  before do
41
- Spree::Config.default_country_iso = Spree::Country.find_by!(iso: "US").iso
41
+ stub_spree_preferences(default_country_iso: Spree::Country.find_by!(iso: "US").iso)
42
42
  end
43
43
 
44
44
  it 'defaults the shipping address country to nil' do
@@ -140,7 +140,7 @@ describe Spree::Admin::OrdersController, type: :controller do
140
140
  end
141
141
 
142
142
  context 'when order_bill_address_used is true' do
143
- before { Spree::Config[:order_bill_address_used] = true }
143
+ before { stub_spree_preferences(order_bill_address_used: true) }
144
144
 
145
145
  it "should redirect to the customer details page" do
146
146
  get :edit, params: { id: order.number }
@@ -149,7 +149,7 @@ describe Spree::Admin::OrdersController, type: :controller do
149
149
  end
150
150
 
151
151
  context 'when order_bill_address_used is false' do
152
- before { Spree::Config[:order_bill_address_used] = false }
152
+ before { stub_spree_preferences(order_bill_address_used: false) }
153
153
 
154
154
  it "should redirect to the customer details page" do
155
155
  get :edit, params: { id: order.number }
@@ -20,7 +20,7 @@ module Spree
20
20
  let(:country) { create :country, iso: "BR" }
21
21
 
22
22
  before do
23
- Spree::Config[:default_country_iso] = country.iso
23
+ stub_spree_preferences(default_country_iso: country.iso)
24
24
  end
25
25
 
26
26
  it "can create a new stock location" do
@@ -19,12 +19,11 @@ describe "setting locale", type: :feature do
19
19
  },
20
20
  listing_orders: "Ordres"
21
21
  })
22
- Spree::Backend::Config[:locale] = "fr"
22
+ stub_spree_preferences(Spree::Backend::Config, locale: "fr")
23
23
  end
24
24
 
25
25
  after do
26
26
  I18n.locale = I18n.default_locale
27
- Spree::Backend::Config[:locale] = "en"
28
27
  ActionView::Base.raise_on_missing_translations = true
29
28
  end
30
29
 
@@ -124,7 +124,7 @@ describe "Adjustments", type: :feature do
124
124
  end
125
125
  end
126
126
 
127
- expect(page).to have_content(/Total: ?\$170\.00/)
127
+ expect(page).to have_content('Total: $170.00', normalize_ws: true)
128
128
  end
129
129
  end
130
130
  end
@@ -70,10 +70,10 @@ describe "Customer Details", type: :feature, js: true do
70
70
 
71
71
  context "editing an order" do
72
72
  before do
73
- configure_spree_preferences do |config|
74
- config.default_country_iso = country.iso
75
- config.company = true
76
- end
73
+ stub_spree_preferences(
74
+ default_country_iso: country.iso,
75
+ company: true
76
+ )
77
77
 
78
78
  visit spree.admin_path
79
79
  click_link "Orders"
@@ -153,9 +153,7 @@ describe "Customer Details", type: :feature, js: true do
153
153
 
154
154
  before do
155
155
  order.bill_address.country.destroy
156
- configure_spree_preferences do |config|
157
- config.default_country_iso = brazil.iso
158
- end
156
+ stub_spree_preferences(default_country_iso: brazil.iso)
159
157
  end
160
158
 
161
159
  it "sets default country when displaying form" do
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe 'Customer returns', type: :feature do
6
+ stub_authorization!
7
+
8
+ context 'when the order has more than one line item' do
9
+ let(:order) { create :shipped_order, line_items_count: 2 }
10
+
11
+ context 'when creating a return with state "Received"' do
12
+ it 'marks the order as returned', :js do
13
+ visit spree.new_admin_order_customer_return_path(order)
14
+
15
+ find('#select-all').click
16
+ page.execute_script "$('select.add-item').val('receive')"
17
+ select 'NY Warehouse', from: 'Stock Location'
18
+ click_button 'Create'
19
+
20
+ expect(page).to have_content 'Customer Return has been successfully created'
21
+
22
+ within 'dd.order-state' do
23
+ expect(page).to have_content 'Returned'
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -114,12 +114,7 @@ describe "Orders Listing", type: :feature, js: true do
114
114
 
115
115
  context "when pagination is really short" do
116
116
  before do
117
- @old_per_page = Spree::Config[:orders_per_page]
118
- Spree::Config[:orders_per_page] = 1
119
- end
120
-
121
- after do
122
- Spree::Config[:orders_per_page] = @old_per_page
117
+ stub_spree_preferences(orders_per_page: 1)
123
118
  end
124
119
 
125
120
  # Regression test for https://github.com/spree/spree/issues/4004
@@ -23,7 +23,7 @@ describe "Log entries", type: :feature do
23
23
  it "shows a successful attempt" do
24
24
  visit spree.admin_order_payments_path(payment.order)
25
25
  click_on payment.number
26
- click_link "Logs"
26
+
27
27
  within("#listing_log_entries") do
28
28
  expect(page).to have_content("Transaction successful")
29
29
  end
@@ -47,7 +47,7 @@ describe "Log entries", type: :feature do
47
47
  it "shows a failed attempt" do
48
48
  visit spree.admin_order_payments_path(payment.order)
49
49
  click_on payment.number
50
- click_link "Logs"
50
+
51
51
  within("#listing_log_entries") do
52
52
  expect(page).to have_content("Transaction failed")
53
53
  end
@@ -208,12 +208,12 @@ describe "New Order", type: :feature do
208
208
 
209
209
  before do
210
210
  Spree::Country.update_all(states_required: true)
211
- Spree::Config.checkout_zone = checkout_zone.name
211
+ stub_spree_preferences(checkout_zone: checkout_zone.name)
212
212
  end
213
213
 
214
214
  context 'and default_country_iso of the United States' do
215
215
  before do
216
- Spree::Config.default_country_iso = Spree::Country.find_by!(iso: 'US').iso
216
+ stub_spree_preferences(default_country_iso: Spree::Country.find_by!(iso: 'US').iso)
217
217
  end
218
218
 
219
219
  it 'the shipping address country select includes only options for Canada' do
@@ -267,7 +267,7 @@ describe "New Order", type: :feature do
267
267
 
268
268
  context 'and default_country_iso of Canada' do
269
269
  before do
270
- Spree::Config.default_country_iso = Spree::Country.find_by!(iso: 'CA').iso
270
+ stub_spree_preferences(default_country_iso: Spree::Country.find_by!(iso: 'CA').iso)
271
271
  end
272
272
 
273
273
  it 'defaults the shipping address country to Canada' do
@@ -191,9 +191,14 @@ describe "Order Details", type: :feature, js: true do
191
191
  end
192
192
 
193
193
  context 'splitting to location' do
194
- # can not properly implement until poltergeist supports checking alert text
195
- # see https://github.com/teampoltergeist/poltergeist/pull/516
196
- it 'should warn you if you have not selected a location or shipment'
194
+ it 'should warn you if you have not selected a location or shipment' do
195
+ visit spree.edit_admin_order_path(order)
196
+
197
+ within('tr', text: line_item.sku) { click_icon 'arrows-h' }
198
+ accept_alert 'Please select the split destination.' do
199
+ click_icon :ok
200
+ end
201
+ end
197
202
 
198
203
  context 'there is enough stock at the other location' do
199
204
  it 'should allow me to make a split' do
@@ -5,17 +5,24 @@ require 'spec_helper'
5
5
  describe 'Payments', type: :feature do
6
6
  stub_authorization!
7
7
 
8
- context "with a pre-existing payment" do
9
- let!(:payment) do
10
- create(:payment,
11
- order: order,
12
- amount: order.outstanding_balance,
8
+ let(:state) { 'checkout' }
9
+
10
+ def create_payment(opts = {})
11
+ create(
12
+ :payment,
13
+ {
14
+ order: order,
15
+ amount: order.outstanding_balance,
13
16
  payment_method: create(:credit_card_payment_method),
14
- state: state)
15
- end
17
+ state: state
18
+ }.merge(opts)
19
+ )
20
+ end
21
+
22
+ context "with a pre-existing payment" do
23
+ let!(:payment) { create_payment }
16
24
 
17
25
  let(:order) { create(:completed_order_with_totals, number: 'R100', line_items_price: 50) }
18
- let(:state) { 'checkout' }
19
26
 
20
27
  before do
21
28
  visit "/admin/orders/#{order.number}/payments"
@@ -24,12 +31,7 @@ describe 'Payments', type: :feature do
24
31
  # Regression tests for https://github.com/spree/spree/issues/1453
25
32
  context 'with a check payment', js: true do
26
33
  let(:order) { create(:completed_order_with_totals, number: 'R100') }
27
- let!(:payment) do
28
- create(:payment,
29
- order: order,
30
- amount: order.outstanding_balance,
31
- payment_method: create(:check_payment_method, available_to_admin: true)) # Check
32
- end
34
+ let!(:payment) { create_payment(payment_method: create(:check_payment_method, available_to_admin: true)) }
33
35
 
34
36
  it 'capturing a check payment from a new order' do
35
37
  click_icon(:capture)
@@ -49,11 +51,9 @@ describe 'Payments', type: :feature do
49
51
 
50
52
  visit spree.admin_order_payment_path(order, payment)
51
53
  expect(page).to have_content 'Capture Events'
52
- # within '#capture_events' do
53
- within_row(1) do
54
+ within '#capture_events' do
54
55
  expect(page).to have_content(capture_amount / 100)
55
56
  end
56
- # end
57
57
  end
58
58
 
59
59
  it 'displays the address for a credit card when present' do
@@ -62,6 +62,57 @@ describe 'Payments', type: :feature do
62
62
  expect(page).to have_content 'my cc address'
63
63
  end
64
64
 
65
+ context 'when there are multiple pending payments', :js do
66
+ context 'while marking all payments as void' do
67
+ let(:card_payment_method) { create(:credit_card_payment_method) }
68
+
69
+ let!(:payment) do
70
+ create_payment(
71
+ payment_method: card_payment_method,
72
+ state: :pending
73
+ )
74
+ end
75
+
76
+ let!(:second_payment) do
77
+ create_payment(
78
+ payment_method: card_payment_method,
79
+ state: :pending
80
+ )
81
+ end
82
+
83
+ it 'updates the order payment state correctly at each iteration' do
84
+ visit current_path
85
+ expect(page).to have_css('#payment_status', text: 'Balance due')
86
+
87
+ within '#payments' do
88
+ expect(page).to have_selector('.pill-pending', count: 2)
89
+ within "#payment_#{payment.id}" do
90
+ find('.fa-void').click
91
+ end
92
+ end
93
+
94
+ expect(page).to have_css('#payment_status', text: 'Balance due')
95
+
96
+ within '#payments' do
97
+ expect(page).to have_selector('.pill-pending', count: 1)
98
+ within "#payment_#{payment.id}" do
99
+ expect(page).to have_selector('.pill-void', count: 1)
100
+ end
101
+ end
102
+
103
+ within "#payment_#{second_payment.id}" do
104
+ find('.fa-void').click
105
+ end
106
+
107
+ within '#payments' do
108
+ expect(page).not_to have_selector('.pill-pending')
109
+ expect(page).to have_selector('.pill-void', count: 2)
110
+ end
111
+ expect(page).to have_css('#payment_status', text: 'Failed')
112
+ end
113
+ end
114
+ end
115
+
65
116
  it 'lists, updates and creates payments for an order', js: true do
66
117
  within_row(1) do
67
118
  expect(column_text(3)).to eq('Credit Card')
@@ -70,7 +121,7 @@ describe 'Payments', type: :feature do
70
121
  end
71
122
 
72
123
  click_icon :void
73
- expect(page).to have_css('#payment_status', text: 'Balance due')
124
+ expect(page).to have_css('#payment_status', text: 'Failed')
74
125
  expect(page).to have_content('Payment Updated')
75
126
 
76
127
  within_row(1) do
@@ -105,7 +156,7 @@ describe 'Payments', type: :feature do
105
156
  within_row(1) do
106
157
  click_icon(:edit)
107
158
  fill_in('amount', with: '$1')
108
- click_icon(:save)
159
+ click_icon(:ok)
109
160
  expect(page).to have_selector('td.amount span', text: '$1.00')
110
161
  expect(payment.reload.amount).to eq(1.00)
111
162
  end
@@ -114,12 +165,7 @@ describe 'Payments', type: :feature do
114
165
  it 'allows the amount change to be cancelled by clicking on the cancel button' do
115
166
  within_row(1) do
116
167
  click_icon(:edit)
117
-
118
- # Can't use fill_in here, as under poltergeist that will unfocus (and
119
- # thus submit) the field under poltergeist
120
- find('td.amount input').click
121
- page.execute_script("$('td.amount input').val('$1')")
122
-
168
+ fill_in 'amount', with: '$1'
123
169
  click_icon(:cancel)
124
170
  expect(page).to have_selector('td.amount span', text: '$150.00')
125
171
  expect(payment.reload.amount).to eq(150.00)
@@ -130,7 +176,7 @@ describe 'Payments', type: :feature do
130
176
  within_row(1) do
131
177
  click_icon(:edit)
132
178
  fill_in('amount', with: 'invalid')
133
- click_icon(:save)
179
+ click_icon(:ok)
134
180
  end
135
181
  expect(page).to have_selector('.flash.error', text: 'Invalid resource. Please fix errors and try again.')
136
182
  expect(payment.reload.amount).to eq(150.00)
@@ -159,9 +205,9 @@ describe 'Payments', type: :feature do
159
205
  end
160
206
 
161
207
  it "is able to create a new credit card payment with valid information", js: true do
162
- fill_in "Card Number", with: "4111 1111 1111 1111"
208
+ fill_in_with_force "Card Number", with: "4111 1111 1111 1111"
163
209
  fill_in "Name", with: "Test User"
164
- fill_in "Expiration", with: "09 / #{Time.current.year + 1}"
210
+ fill_in_with_force "Expiration", with: "09 / #{Time.current.year + 1}"
165
211
  fill_in "Card Code", with: "007"
166
212
  # Regression test for https://github.com/spree/spree/issues/4277
167
213
  expect(page).to have_css('.ccType[value="visa"]', visible: false)
@@ -182,7 +228,7 @@ describe 'Payments', type: :feature do
182
228
 
183
229
  context "user existing card" do
184
230
  let!(:cc) do
185
- create(:credit_card, payment_method: payment_method, gateway_customer_profile_id: "BGS-RFRE")
231
+ create(:credit_card, payment_method: payment_method, gateway_customer_profile_id: "BGS-RFRE", user: order.user)
186
232
  end
187
233
 
188
234
  before do
@@ -216,12 +262,7 @@ describe 'Payments', type: :feature do
216
262
  context 'with a soft-deleted payment method' do
217
263
  let(:order) { create(:completed_order_with_totals, line_items_count: 1) }
218
264
  let!(:payment_method) { create(:check_payment_method) }
219
- let!(:payment) do
220
- create(:payment,
221
- order: order,
222
- amount: order.outstanding_balance,
223
- payment_method: payment_method)
224
- end
265
+ let!(:payment) { create_payment(payment_method: payment_method) }
225
266
 
226
267
  before do
227
268
  payment_method.discard
@@ -249,9 +290,9 @@ describe 'Payments', type: :feature do
249
290
 
250
291
  it "is able to create a new payment", js: true do
251
292
  choose payment_method.name
252
- fill_in "Card Number", with: "4111 1111 1111 1111"
293
+ fill_in_with_force "Card Number", with: "4111 1111 1111 1111"
253
294
  fill_in "Name", with: "Test User"
254
- fill_in "Expiration", with: "09 / #{Time.current.year + 1}"
295
+ fill_in_with_force "Expiration", with: "09 / #{Time.current.year + 1}"
255
296
  fill_in "Card Code", with: "007"
256
297
  click_button "Continue"
257
298
  expect(page).to have_content("Payment has been successfully created!")
@@ -278,9 +319,9 @@ describe 'Payments', type: :feature do
278
319
 
279
320
  it "displays an error" do
280
321
  choose payment_method.name
281
- fill_in "Card Number", with: "4111 1111 1111 1111"
322
+ fill_in_with_force "Card Number", with: "4111 1111 1111 1111"
282
323
  fill_in "Name", with: "Test User"
283
- fill_in "Expiration", with: "09 / #{Time.current.year + 1}"
324
+ fill_in_with_force "Expiration", with: "09 / #{Time.current.year + 1}"
284
325
  fill_in "Card Code", with: "007"
285
326
  click_button "Continue"
286
327
  expect(page).to have_content I18n.t('spree.insufficient_stock_for_order')