solidus_backend 2.7.4 → 2.8.0
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.
- checksums.yaml +4 -4
- data/README.md +12 -8
- data/app/assets/images/favicon.ico +0 -0
- data/app/assets/javascripts/spree/backend.js +0 -2
- data/app/assets/javascripts/spree/backend/adjustments.js +1 -1
- data/app/assets/javascripts/spree/backend/components/tooltips.js +21 -17
- data/app/assets/javascripts/spree/backend/option_type_autocomplete.js +1 -1
- data/app/assets/javascripts/spree/backend/product_picker.js +1 -1
- data/app/assets/javascripts/spree/backend/shipments.js +6 -1
- data/app/assets/javascripts/spree/backend/stock_management.js +9 -0
- data/app/assets/javascripts/spree/backend/store_credits.js +18 -2
- data/app/assets/javascripts/spree/backend/taxons.js +1 -1
- data/app/assets/javascripts/spree/backend/templates/stock_items/stock_location_stock_item.hbs +24 -25
- data/app/assets/javascripts/spree/backend/user_picker.js +1 -1
- data/app/assets/javascripts/spree/backend/variant_autocomplete.js +1 -1
- data/app/assets/javascripts/spree/backend/views/order/customer_select.js +1 -1
- data/app/assets/javascripts/spree/backend/views/order/summary.js +2 -2
- data/app/assets/javascripts/spree/backend/views/stock/add_stock_item.js +15 -4
- data/app/assets/javascripts/spree/backend/views/stock/edit_stock_item_row.js +30 -10
- data/app/assets/stylesheets/spree/backend/globals/_functions.scss +1 -2
- data/app/assets/stylesheets/spree/backend/sections/_orders.scss +8 -0
- data/app/assets/stylesheets/spree/backend/sections/_stock_management.scss +77 -2
- data/app/assets/stylesheets/spree/backend/spree_admin.scss +0 -1
- data/app/controllers/spree/admin/cancellations_controller.rb +2 -2
- data/app/controllers/spree/admin/locale_controller.rb +1 -1
- data/app/controllers/spree/admin/orders/customer_details_controller.rb +8 -1
- data/app/controllers/spree/admin/orders_controller.rb +1 -11
- data/app/controllers/spree/admin/products_controller.rb +10 -6
- data/app/controllers/spree/admin/promotion_codes_controller.rb +19 -1
- data/app/controllers/spree/admin/promotions_controller.rb +1 -1
- data/app/controllers/spree/admin/reimbursements_controller.rb +7 -2
- data/app/controllers/spree/admin/resource_controller.rb +1 -0
- data/app/controllers/spree/admin/store_credit_reasons_controller.rb +8 -0
- data/app/controllers/spree/admin/store_credits_controller.rb +11 -11
- data/app/helpers/spree/admin/navigation_helper.rb +1 -1
- data/app/models/spree/backend_configuration.rb +38 -21
- data/app/views/spree/admin/cancellations/index.html.erb +3 -1
- data/app/views/spree/admin/images/_image_row.html.erb +1 -1
- data/app/views/spree/admin/images/edit.html.erb +3 -3
- data/app/views/spree/admin/images/index.html.erb +2 -2
- data/app/views/spree/admin/log_entries/index.html.erb +2 -2
- data/app/views/spree/admin/orders/_carton_manifest.html.erb +3 -1
- data/app/views/spree/admin/orders/_shipment_manifest.html.erb +3 -1
- data/app/views/spree/admin/orders/confirm/_line_items.html.erb +3 -2
- data/app/views/spree/admin/orders/confirm/_shipment_manifest.html.erb +3 -1
- data/app/views/spree/admin/orders/index.html.erb +1 -1
- data/app/views/spree/admin/products/_form.html.erb +7 -7
- data/app/views/spree/admin/products/edit.html.erb +5 -0
- data/app/views/spree/admin/products/index.html.erb +3 -1
- data/app/views/spree/admin/promotion_categories/index.html.erb +1 -1
- data/app/views/spree/admin/promotion_code_batches/index.html.erb +1 -1
- data/app/views/spree/admin/promotion_codes/index.html.erb +5 -1
- data/app/views/spree/admin/promotion_codes/new.html.erb +31 -0
- data/app/views/spree/admin/promotions/_actions.html.erb +1 -1
- data/app/views/spree/admin/promotions/_activations_edit.html.erb +1 -1
- data/app/views/spree/admin/promotions/_form.html.erb +4 -3
- data/app/views/spree/admin/promotions/_rules.html.erb +1 -1
- data/app/views/spree/admin/promotions/edit.html.erb +3 -1
- data/app/views/spree/admin/refunds/new.html.erb +1 -1
- data/app/views/spree/admin/shared/_address_form.html.erb +10 -3
- data/app/views/spree/admin/shared/_edit_resource_links.html.erb +1 -1
- data/app/views/spree/admin/shared/_head.html.erb +1 -0
- data/app/views/spree/admin/shared/_image.html.erb +2 -2
- data/app/views/spree/admin/shared/_product_sub_menu.html.erb +1 -1
- data/app/views/spree/admin/shared/_settings_checkout_tabs.html.erb +4 -0
- data/app/views/spree/admin/shared/_settings_sub_menu.html.erb +3 -3
- data/app/views/spree/admin/shared/_tabs.html.erb +3 -2
- data/app/views/spree/admin/shared/_variant_search.html.erb +1 -1
- data/app/views/spree/admin/stock_items/_stock_management.html.erb +56 -38
- data/app/views/spree/admin/stock_locations/_form.html.erb +133 -121
- data/app/views/spree/admin/stock_locations/edit.html.erb +4 -2
- data/app/views/spree/admin/store_credit_reasons/edit.html.erb +15 -0
- data/app/views/spree/admin/store_credit_reasons/index.html.erb +56 -0
- data/app/views/spree/admin/store_credit_reasons/new.html.erb +18 -0
- data/app/views/spree/admin/store_credit_reasons/shared/_form.html.erb +15 -0
- data/app/views/spree/admin/store_credits/_store_credit_reason_field.html.erb +7 -0
- data/app/views/spree/admin/store_credits/edit_amount.html.erb +1 -1
- data/app/views/spree/admin/store_credits/edit_validity.html.erb +1 -1
- data/app/views/spree/admin/store_credits/show.html.erb +2 -2
- data/app/views/spree/admin/users/items.html.erb +3 -1
- data/app/views/spree/admin/users/orders.html.erb +1 -1
- data/config/routes.rb +2 -8
- data/lib/spree/backend.rb +1 -1
- data/solidus_backend.gemspec +3 -4
- data/spec/controllers/spree/admin/base_controller_spec.rb +1 -1
- data/spec/controllers/spree/admin/cancellations_controller_spec.rb +7 -3
- data/spec/controllers/spree/admin/orders/customer_details_controller_spec.rb +50 -2
- data/spec/controllers/spree/admin/orders_controller_spec.rb +23 -11
- data/spec/controllers/spree/admin/payments_controller_spec.rb +1 -1
- data/spec/controllers/spree/admin/products_controller_spec.rb +72 -0
- data/spec/controllers/spree/admin/promotion_codes_controller_spec.rb +13 -1
- data/spec/controllers/spree/admin/reimbursements_controller_spec.rb +11 -0
- data/spec/controllers/spree/admin/resource_controller_spec.rb +22 -0
- data/spec/controllers/spree/admin/stock_items_controller_spec.rb +1 -1
- data/spec/controllers/spree/admin/store_credits_controller_spec.rb +7 -7
- data/spec/features/admin/configuration/payment_methods_spec.rb +2 -2
- data/spec/features/admin/configuration/shipping_methods_spec.rb +2 -2
- data/spec/features/admin/homepage_spec.rb +1 -6
- data/spec/features/admin/orders/listing_spec.rb +1 -1
- data/spec/features/admin/orders/new_order_spec.rb +117 -0
- data/spec/features/admin/orders/new_refund_spec.rb +35 -0
- data/spec/features/admin/orders/order_details_spec.rb +2 -2
- data/spec/features/admin/orders/payments_spec.rb +2 -2
- data/spec/features/admin/orders/return_payment_state_spec.rb +3 -0
- data/spec/features/admin/orders/shipments_spec.rb +28 -0
- data/spec/features/admin/products/products_spec.rb +1 -1
- data/spec/features/admin/products/stock_management_spec.rb +10 -13
- data/spec/features/admin/promotion_adjustments_spec.rb +12 -12
- data/spec/features/admin/promotions/option_value_rule_spec.rb +2 -2
- data/spec/features/admin/promotions/product_rule_spec.rb +1 -1
- data/spec/features/admin/promotions/tiered_calculator_spec.rb +1 -1
- data/spec/features/admin/promotions/user_rule_spec.rb +2 -2
- data/spec/features/admin/reimbursements_spec.rb +1 -1
- data/spec/features/admin/store_credits_spec.rb +51 -2
- data/spec/features/admin/taxons_spec.rb +35 -0
- data/spec/features/admin/users_spec.rb +22 -11
- data/spec/helpers/admin/navigation_helper_spec.rb +4 -2
- data/spec/helpers/admin/store_credit_events_helper_spec.rb +2 -2
- data/spec/javascripts/spec_helper.js +2 -0
- data/spec/models/spree/backend_configuration/menu_item_spec.rb +17 -0
- data/spec/models/spree/backend_configuration_spec.rb +22 -0
- data/spec/spec_helper.rb +1 -0
- data/spec/support/feature/order_feature_helper.rb +1 -1
- data/spec/views/spree/admin/shared/navigation_footer_spec.rb +1 -1
- data/vendor/assets/javascripts/solidus_admin/select2_locales/select2_locale_en-US.js +10 -0
- metadata +26 -34
- data/app/controllers/spree/admin/reports_controller.rb +0 -82
- data/app/views/spree/admin/reports/index.html.erb +0 -19
- data/app/views/spree/admin/reports/sales_total.html.erb +0 -35
- data/app/views/spree/admin/shared/_report_order_criteria.html.erb +0 -19
- data/app/views/spree/admin/store_credits/_update_reason_field.html.erb +0 -7
- data/spec/controllers/spree/admin/reports_controller_spec.rb +0 -133
- data/spec/features/admin/reports_spec.rb +0 -63
@@ -0,0 +1,18 @@
|
|
1
|
+
<%= render 'spree/admin/shared/settings_checkout_tabs' %>
|
2
|
+
|
3
|
+
<% admin_breadcrumb(t('spree.settings')) %>
|
4
|
+
<% admin_breadcrumb(t('spree.admin.tab.checkout')) %>
|
5
|
+
<% admin_breadcrumb(link_to plural_resource_name(Spree::StoreCreditReason), spree.admin_store_credit_reasons_path) %>
|
6
|
+
<% admin_breadcrumb(t('spree.new_store_credit_reason')) %>
|
7
|
+
|
8
|
+
<% content_for :page_actions do %>
|
9
|
+
<% end %>
|
10
|
+
|
11
|
+
<%= render partial: 'spree/shared/error_messages', locals: { target: @object } %>
|
12
|
+
|
13
|
+
<%= form_for [:admin, @object] do |f| %>
|
14
|
+
<fieldset class='no-border-top'>
|
15
|
+
<%= render partial: 'spree/admin/store_credit_reasons/shared/form', locals: { f: f } %>
|
16
|
+
<%= render partial: 'spree/admin/shared/new_resource_links' %>
|
17
|
+
</fieldset>
|
18
|
+
<% end %>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<div data-hook='admin_named_type_form_fields' class='row'>
|
2
|
+
<div class='col-3'>
|
3
|
+
<%= f.field_container :name do %>
|
4
|
+
<%= f.label :name, class: 'required' %><br />
|
5
|
+
<%= f.text_field :name, class: 'fullwidth' %>
|
6
|
+
<% end %>
|
7
|
+
|
8
|
+
<div class='checkbox'>
|
9
|
+
<label>
|
10
|
+
<%= f.check_box :active %>
|
11
|
+
<%= t('spree.active') %>
|
12
|
+
</label>
|
13
|
+
</div>
|
14
|
+
</div>
|
15
|
+
</div>
|
@@ -0,0 +1,7 @@
|
|
1
|
+
<%= f.field_container :reason do %>
|
2
|
+
<%= f.label :store_credit_reason, t('spree.reason'), class: 'required' %>
|
3
|
+
<%= select_tag :store_credit_reason_id, options_from_collection_for_select(@store_credit_reasons, :id, :name),
|
4
|
+
include_blank: t('spree.choose_reason'), class: 'custom-select fullwidth',
|
5
|
+
placeholder: t('spree.admin.store_credits.select_amount_store_credit_reason') %>
|
6
|
+
<%= f.error_message_on :store_credit_reason %>
|
7
|
+
<% end %>
|
@@ -15,7 +15,7 @@
|
|
15
15
|
<legend align="center"><%= t('spree.admin.store_credits.invalidate_store_credit') %></legend>
|
16
16
|
<div data-hook="admin_store_credit_form_fields" class="row">
|
17
17
|
<div class="col-12">
|
18
|
-
<%= render partial: '
|
18
|
+
<%= render partial: 'store_credit_reason_field', locals: { f: f } %>
|
19
19
|
</div>
|
20
20
|
</div>
|
21
21
|
<div class="form-buttons filter-actions actions" data-hook="buttons">
|
@@ -84,7 +84,7 @@
|
|
84
84
|
<th><%= t('spree.admin.store_credits.created_by') %></th>
|
85
85
|
<th><%= Spree::StoreCreditEvent.human_attribute_name(:user_total_amount) %></th>
|
86
86
|
<th><%= Spree::StoreCreditEvent.human_attribute_name(:amount_remaining) %></th>
|
87
|
-
<th><%= Spree::
|
87
|
+
<th><%= Spree::StoreCreditReason.human_attribute_name(:name) %></th>
|
88
88
|
</tr>
|
89
89
|
</thead>
|
90
90
|
<tbody>
|
@@ -98,7 +98,7 @@
|
|
98
98
|
<td><%= store_credit_event_originator_link(event) %></td>
|
99
99
|
<td><%= event.display_user_total_amount %></td>
|
100
100
|
<td><%= event.display_remaining_amount %></td>
|
101
|
-
<td><%= event.
|
101
|
+
<td><%= event.store_credit_reason.try!(:name) %></td>
|
102
102
|
</tr>
|
103
103
|
<% end %>
|
104
104
|
</tbody>
|
@@ -41,7 +41,9 @@
|
|
41
41
|
<tr class="stock-item" data-item-quantity="<%= item.quantity %>">
|
42
42
|
<td class="order-completed-at"><%= l(order.completed_at.to_date) if order.completed_at %></td>
|
43
43
|
<td class="item-image">
|
44
|
-
<%= render 'spree/admin/shared/image',
|
44
|
+
<%= render 'spree/admin/shared/image',
|
45
|
+
image: (item.variant.gallery.images.first || item.variant.product.gallery.images.first),
|
46
|
+
size: :mini %>
|
45
47
|
</td>
|
46
48
|
<td class="item-name">
|
47
49
|
<%= item.product.name %><br><%= "(" + variant_options(item.variant) + ")" unless item.variant.option_values.empty? %>
|
@@ -74,7 +74,7 @@
|
|
74
74
|
<div class="no-objects-found">
|
75
75
|
<%= render 'spree/admin/shared/no_objects_found',
|
76
76
|
resource: Spree::Order,
|
77
|
-
new_resource_url: spree.new_admin_order_path %>
|
77
|
+
new_resource_url: spree.new_admin_order_path(user_id: @user.id) %>
|
78
78
|
</div>
|
79
79
|
<% end %>
|
80
80
|
|
data/config/routes.rb
CHANGED
@@ -16,7 +16,7 @@ Spree::Core::Engine.routes.draw do
|
|
16
16
|
resources :promotions do
|
17
17
|
resources :promotion_rules
|
18
18
|
resources :promotion_actions
|
19
|
-
resources :promotion_codes, only: [:index]
|
19
|
+
resources :promotion_codes, only: [:index, :new, :create]
|
20
20
|
resources :promotion_code_batches, only: [:index, :new, :create] do
|
21
21
|
get '/download', to: "promotion_code_batches#download", defaults: { format: "csv" }
|
22
22
|
end
|
@@ -141,17 +141,11 @@ Spree::Core::Engine.routes.draw do
|
|
141
141
|
end
|
142
142
|
end
|
143
143
|
|
144
|
-
resources :reports, only: [:index] do
|
145
|
-
collection do
|
146
|
-
get :sales_total
|
147
|
-
post :sales_total
|
148
|
-
end
|
149
|
-
end
|
150
|
-
|
151
144
|
resources :reimbursement_types, only: [:index]
|
152
145
|
resources :adjustment_reasons, except: [:show, :destroy]
|
153
146
|
resources :refund_reasons, except: [:show, :destroy]
|
154
147
|
resources :return_reasons, except: [:show, :destroy]
|
148
|
+
resources :store_credit_reasons, except: [:show]
|
155
149
|
|
156
150
|
resources :shipping_methods
|
157
151
|
resources :shipping_categories
|
data/lib/spree/backend.rb
CHANGED
data/solidus_backend.gemspec
CHANGED
@@ -26,12 +26,11 @@ Gem::Specification.new do |s|
|
|
26
26
|
|
27
27
|
s.add_dependency 'coffee-rails'
|
28
28
|
s.add_dependency 'font-awesome-rails', '~> 4.0'
|
29
|
-
s.add_dependency 'jbuilder', '~> 2.
|
29
|
+
s.add_dependency 'jbuilder', '~> 2.8'
|
30
30
|
s.add_dependency 'jquery-rails'
|
31
31
|
s.add_dependency 'kaminari', '~> 1.1'
|
32
|
-
s.add_dependency '
|
33
|
-
s.add_dependency 'sass', '>= 3.5.2'
|
32
|
+
s.add_dependency 'sassc-rails'
|
34
33
|
|
35
|
-
s.add_dependency 'autoprefixer-rails'
|
34
|
+
s.add_dependency 'autoprefixer-rails'
|
36
35
|
s.add_dependency 'handlebars_assets', '~> 0.23'
|
37
36
|
end
|
@@ -15,7 +15,7 @@ describe Spree::Admin::BaseController, type: :controller do
|
|
15
15
|
|
16
16
|
context "unauthorized request" do
|
17
17
|
before do
|
18
|
-
allow_any_instance_of(Spree::Admin::BaseController).to receive(:
|
18
|
+
allow_any_instance_of(Spree::Admin::BaseController).to receive(:try_spree_current_user).and_return(nil)
|
19
19
|
end
|
20
20
|
|
21
21
|
it "redirects to unauthorized" do
|
@@ -22,7 +22,7 @@ describe Spree::Admin::CancellationsController do
|
|
22
22
|
describe "#cancel" do
|
23
23
|
subject { post :short_ship, params: { order_id: order.number, inventory_unit_ids: inventory_units.map(&:id) } }
|
24
24
|
|
25
|
-
let(:order) { create(:
|
25
|
+
let(:order) { create(:order_with_line_items, line_items_attributes: [{ quantity: 4 }]) }
|
26
26
|
let(:referer) { "order_admin_page" }
|
27
27
|
|
28
28
|
context "no inventory unit ids are provided" do
|
@@ -67,12 +67,16 @@ describe Spree::Admin::CancellationsController do
|
|
67
67
|
end
|
68
68
|
|
69
69
|
it "creates a unit cancel" do
|
70
|
-
expect { subject }.to change { Spree::UnitCancel.count }.by(
|
70
|
+
expect { subject }.to change { Spree::UnitCancel.count }.by(4)
|
71
71
|
end
|
72
72
|
|
73
73
|
it "cancels the inventory" do
|
74
74
|
subject
|
75
|
-
expect(order.inventory_units.map(&:state).uniq).to match_array(['canceled'])
|
75
|
+
expect(order.reload.inventory_units.map(&:state).uniq).to match_array(['canceled'])
|
76
|
+
end
|
77
|
+
|
78
|
+
it "adjusts the order" do
|
79
|
+
expect { subject }.to change { order.reload.total }.by(-40.0)
|
76
80
|
end
|
77
81
|
end
|
78
82
|
end
|
@@ -7,11 +7,59 @@ describe Spree::Admin::Orders::CustomerDetailsController, type: :controller do
|
|
7
7
|
context "with authorization" do
|
8
8
|
stub_authorization!
|
9
9
|
|
10
|
-
|
10
|
+
context '#edit' do
|
11
|
+
context 'when order has no shipping nor billing address' do
|
12
|
+
let(:order) { create(:order, number: "R123456789", ship_address: nil, bill_address: nil) }
|
11
13
|
|
12
|
-
|
14
|
+
context "with a checkout_zone set as the country of Canada" do
|
15
|
+
let!(:united_states) { create(:country, iso: 'US', states_required: true) }
|
16
|
+
let!(:canada) { create(:country, iso: 'CA', states_required: true) }
|
17
|
+
let!(:checkout_zone) { create(:zone, name: "Checkout Zone", countries: [canada]) }
|
18
|
+
|
19
|
+
before do
|
20
|
+
Spree::Config.checkout_zone = checkout_zone.name
|
21
|
+
end
|
22
|
+
|
23
|
+
context "and default_country_iso of the Canada" do
|
24
|
+
before do
|
25
|
+
Spree::Config.default_country_iso = Spree::Country.find_by!(iso: "CA").iso
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'defaults the shipping address country to Canada' do
|
29
|
+
get :edit, params: { order_id: order.number }
|
30
|
+
expect(assigns(:order).shipping_address.country_id).to eq canada.id
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'defaults the billing address country to Canada' do
|
34
|
+
get :edit, params: { order_id: order.number }
|
35
|
+
expect(assigns(:order).billing_address.country_id).to eq canada.id
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
context "and default_country_iso of the United States" do
|
40
|
+
before do
|
41
|
+
Spree::Config.default_country_iso = Spree::Country.find_by!(iso: "US").iso
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'defaults the shipping address country to nil' do
|
45
|
+
get :edit, params: { order_id: order.number }
|
46
|
+
expect(assigns(:order).shipping_address.country_id).to be_nil
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'defaults the billing address country to nil' do
|
50
|
+
get :edit, params: { order_id: order.number }
|
51
|
+
expect(assigns(:order).billing_address.country_id).to be_nil
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
13
57
|
|
14
58
|
context "#update" do
|
59
|
+
let(:order) { create(:order, number: "R123456789") }
|
60
|
+
|
61
|
+
before { allow(Spree::Order).to receive_message_chain(:includes, :find_by!) { order } }
|
62
|
+
|
15
63
|
it "updates + progresses the order" do
|
16
64
|
expect(order).to receive(:update_attributes) { true }
|
17
65
|
expect(order).to receive(:next) { false }
|
@@ -69,7 +69,7 @@ describe Spree::Admin::OrdersController, type: :controller do
|
|
69
69
|
it "can page through the orders" do
|
70
70
|
get :index, params: { page: 2, per_page: 10 }
|
71
71
|
expect(assigns[:orders].offset_value).to eq(10)
|
72
|
-
expect(assigns[:orders].
|
72
|
+
expect(assigns[:orders].limit_value).to eq(10)
|
73
73
|
end
|
74
74
|
end
|
75
75
|
|
@@ -77,7 +77,7 @@ describe Spree::Admin::OrdersController, type: :controller do
|
|
77
77
|
context "#new" do
|
78
78
|
let(:user) { create(:user) }
|
79
79
|
before do
|
80
|
-
allow(controller).to receive_messages
|
80
|
+
allow(controller).to receive_messages try_spree_current_user: user
|
81
81
|
end
|
82
82
|
|
83
83
|
it "imports a new order and sets the current user as a creator" do
|
@@ -288,18 +288,30 @@ describe Spree::Admin::OrdersController, type: :controller do
|
|
288
288
|
let(:user) { create(:user) }
|
289
289
|
|
290
290
|
before do
|
291
|
-
allow(controller).to receive_messages
|
291
|
+
allow(controller).to receive_messages try_spree_current_user: user
|
292
292
|
user.spree_roles << Spree::Role.find_or_create_by(name: 'admin')
|
293
293
|
|
294
|
-
|
295
|
-
expect(Spree::Order.count).to eq
|
294
|
+
create_list(:completed_order_with_totals, 2)
|
295
|
+
expect(Spree::Order.count).to eq 2
|
296
296
|
end
|
297
297
|
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
298
|
+
context 'by line_items_variant_id_in' do
|
299
|
+
it "does not display duplicated results" do
|
300
|
+
get :index, params: { q: {
|
301
|
+
line_items_variant_id_in: Spree::Order.first.variants.map(&:id)
|
302
|
+
} }
|
303
|
+
expect(assigns[:orders].size).to eq 1
|
304
|
+
end
|
305
|
+
end
|
306
|
+
|
307
|
+
context 'by email' do
|
308
|
+
it "does not display duplicated results" do
|
309
|
+
get :index, params: { q: {
|
310
|
+
email_start: Spree::Order.first.email
|
311
|
+
} }
|
312
|
+
expect(assigns[:orders].size).to eq 1
|
313
|
+
expect(assigns[:orders][0].email).to eq(Spree::Order.first.email)
|
314
|
+
end
|
303
315
|
end
|
304
316
|
end
|
305
317
|
|
@@ -349,7 +361,7 @@ describe Spree::Admin::OrdersController, type: :controller do
|
|
349
361
|
let!(:order) { create(:completed_order_with_totals, number: 'R987654321') }
|
350
362
|
|
351
363
|
before do
|
352
|
-
allow(controller).to receive_messages
|
364
|
+
allow(controller).to receive_messages try_spree_current_user: user
|
353
365
|
end
|
354
366
|
|
355
367
|
it 'should grant access to users with an admin role' do
|
@@ -6,7 +6,7 @@ module Spree
|
|
6
6
|
module Admin
|
7
7
|
describe PaymentsController, type: :controller do
|
8
8
|
before do
|
9
|
-
allow(controller).to receive_messages
|
9
|
+
allow(controller).to receive_messages try_spree_current_user: user
|
10
10
|
end
|
11
11
|
|
12
12
|
let(:user) { create(:admin_user) }
|
@@ -50,6 +50,78 @@ describe Spree::Admin::ProductsController, type: :controller do
|
|
50
50
|
end
|
51
51
|
end
|
52
52
|
|
53
|
+
# regression test for https://github.com/solidusio/solidus/issues/2791
|
54
|
+
context "creating a product" do
|
55
|
+
before(:all) do
|
56
|
+
create(:shipping_category)
|
57
|
+
end
|
58
|
+
|
59
|
+
it "creates a product" do
|
60
|
+
post :create, params: {
|
61
|
+
product: {
|
62
|
+
name: "Product #1 - 9632",
|
63
|
+
description: "As seen on TV!",
|
64
|
+
price: 19.99,
|
65
|
+
shipping_category_id: Spree::ShippingCategory.first.id,
|
66
|
+
}
|
67
|
+
}
|
68
|
+
expect(flash[:success]).to eq("Product \"Product #1 - 9632\" has been successfully created!")
|
69
|
+
end
|
70
|
+
|
71
|
+
context "when there is a taxon" do
|
72
|
+
let(:first_taxon) { create(:taxon) }
|
73
|
+
|
74
|
+
it "creates a product with a taxon" do
|
75
|
+
post :create, params: {
|
76
|
+
product: {
|
77
|
+
name: "Product #1 - 9632",
|
78
|
+
description: "As seen on TV!",
|
79
|
+
price: 19.99,
|
80
|
+
shipping_category_id: Spree::ShippingCategory.first.id,
|
81
|
+
taxon_ids: first_taxon.id.to_s
|
82
|
+
}
|
83
|
+
}
|
84
|
+
expect(flash[:success]).to eq("Product \"Product #1 - 9632\" has been successfully created!")
|
85
|
+
end
|
86
|
+
|
87
|
+
context "when their are multiple taxons" do
|
88
|
+
let(:second_taxon) { create(:taxon) }
|
89
|
+
|
90
|
+
it "creates a product with multiple taxons" do
|
91
|
+
post :create, params: {
|
92
|
+
product: {
|
93
|
+
name: "Product #1 - 9632",
|
94
|
+
description: "As seen on TV!",
|
95
|
+
price: 19.99,
|
96
|
+
shipping_category_id: Spree::ShippingCategory.first.id,
|
97
|
+
taxon_ids: "#{first_taxon.id}, #{second_taxon.id}"
|
98
|
+
}
|
99
|
+
}
|
100
|
+
expect(flash[:success]).to eq("Product \"Product #1 - 9632\" has been successfully created!")
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
context "adding taxons to a product" do
|
107
|
+
let(:product) { create(:product) }
|
108
|
+
let(:first_taxon) { create(:taxon) }
|
109
|
+
|
110
|
+
it "adds a single taxon to a product" do
|
111
|
+
put :update, params: { id: product.to_param, product: { taxon_ids: first_taxon.id.to_s } }
|
112
|
+
expect(flash[:success]).to eq("Product #{product.name.inspect} has been successfully updated!")
|
113
|
+
end
|
114
|
+
|
115
|
+
context "when there are mulitple taxons" do
|
116
|
+
let(:second_taxon) { create(:taxon) }
|
117
|
+
|
118
|
+
it "adds multiple taxons to a product" do
|
119
|
+
put :update, params: { id: product.to_param, product: { taxon_ids: "#{first_taxon.id}, #{second_taxon.id}" } }
|
120
|
+
expect(flash[:success]).to eq("Product #{product.name.inspect} has been successfully updated!")
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
53
125
|
describe "creating variant property rules" do
|
54
126
|
let(:first_property) { create(:property) }
|
55
127
|
let(:second_property) { create(:property) }
|
@@ -11,10 +11,22 @@ describe Spree::Admin::PromotionCodesController do
|
|
11
11
|
let!(:code2) { create(:promotion_code, promotion: promotion) }
|
12
12
|
let!(:code3) { create(:promotion_code, promotion: promotion) }
|
13
13
|
|
14
|
-
it "can create a
|
14
|
+
it "can create a CSV file with all promotion codes" do
|
15
15
|
get :index, params: { promotion_id: promotion.id, format: 'csv' }
|
16
16
|
expect(response).to be_successful
|
17
17
|
parsed = CSV.parse(response.body, headers: true)
|
18
18
|
expect(parsed.entries.map(&:to_h)).to eq([{ "Code" => code1.value }, { "Code" => code2.value }, { "Code" => code3.value }])
|
19
19
|
end
|
20
|
+
|
21
|
+
it "can create a new code" do
|
22
|
+
post :create, params: { promotion_id: promotion.id, promotion_code: { value: "new_code" } }
|
23
|
+
expect(response).to redirect_to(spree.admin_promotion_promotion_codes_path(promotion))
|
24
|
+
expect(Spree::PromotionCode.where(promotion: promotion).count).to eql(4)
|
25
|
+
end
|
26
|
+
|
27
|
+
it "cannot create an existing code" do
|
28
|
+
post :create, params: { promotion_id: promotion.id, promotion_code: { value: code1.value } }
|
29
|
+
expect(flash[:error]).not_to be_nil
|
30
|
+
expect(Spree::PromotionCode.where(promotion: promotion).count).to eql(3)
|
31
|
+
end
|
20
32
|
end
|
@@ -9,6 +9,13 @@ describe Spree::Admin::ReimbursementsController, type: :controller do
|
|
9
9
|
Spree::RefundReason.find_or_create_by!(name: Spree::RefundReason::RETURN_PROCESSING_REASON, mutable: false)
|
10
10
|
end
|
11
11
|
|
12
|
+
let(:user) { stub_model(Spree::LegacyUser, has_spree_role?: true, id: 1) }
|
13
|
+
|
14
|
+
before do
|
15
|
+
allow_any_instance_of(described_class).to receive(:try_spree_current_user).
|
16
|
+
and_return(user)
|
17
|
+
end
|
18
|
+
|
12
19
|
describe '#edit' do
|
13
20
|
let(:reimbursement) { create(:reimbursement) }
|
14
21
|
let(:order) { reimbursement.order }
|
@@ -42,6 +49,10 @@ describe Spree::Admin::ReimbursementsController, type: :controller do
|
|
42
49
|
expect(assigns(:reimbursement).return_items.to_a).to eq customer_return.return_items.to_a
|
43
50
|
end
|
44
51
|
|
52
|
+
it 'order is recalculated' do
|
53
|
+
expect { subject }.to change { order.reload.payment_state }.from('paid').to('credit_owed')
|
54
|
+
end
|
55
|
+
|
45
56
|
it 'redirects to the edit page' do
|
46
57
|
subject
|
47
58
|
expect(response).to redirect_to(spree.edit_admin_order_reimbursement_path(order, assigns(:reimbursement)))
|