solidus_backend 1.0.7 → 1.1.0.beta1
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/app/assets/javascripts/spree/backend.js +3 -0
- data/app/assets/javascripts/spree/backend/admin.js.erb +17 -24
- data/app/assets/javascripts/spree/backend/checkouts/edit.js +3 -5
- data/app/assets/javascripts/spree/backend/flash.coffee +17 -0
- data/app/assets/javascripts/spree/backend/handlebars_extensions.coffee +9 -0
- data/app/assets/javascripts/spree/backend/option_type_autocomplete.js.erb +6 -6
- data/app/assets/javascripts/spree/backend/option_value_picker.js +43 -0
- data/app/assets/javascripts/spree/backend/product_picker.js +10 -8
- data/app/assets/javascripts/spree/backend/promotions.js.coffee +101 -0
- data/app/assets/javascripts/spree/backend/routes.js +2 -1
- data/app/assets/javascripts/spree/backend/shipments.js.erb +1 -1
- data/app/assets/javascripts/spree/backend/stock_management/index_add_forms.coffee +1 -1
- data/app/assets/javascripts/spree/backend/stock_movement.js.coffee +2 -2
- data/app/assets/javascripts/spree/backend/stock_transfers/variant_form.coffee +1 -1
- data/app/assets/javascripts/spree/backend/taxon_autocomplete.js.erb +6 -6
- data/app/assets/javascripts/spree/backend/taxons.js.coffee +6 -7
- data/app/assets/javascripts/spree/backend/templates/orders/customer_details/autocomplete.hbs +17 -0
- data/app/assets/javascripts/spree/backend/templates/products/sortable.hbs +5 -0
- data/app/assets/javascripts/spree/backend/templates/promotions/calculators/fields/tiered_flat_rate.hbs +17 -0
- data/app/assets/javascripts/spree/backend/templates/promotions/calculators/fields/tiered_percent.hbs +17 -0
- data/app/assets/javascripts/spree/backend/templates/promotions/rules/option_values.hbs +10 -0
- data/app/assets/javascripts/spree/backend/templates/promotions/rules/option_values_select.hbs +1 -0
- data/app/assets/javascripts/spree/backend/templates/stock_items/stock_location_stock_item.hbs +19 -0
- data/app/assets/javascripts/spree/backend/templates/stock_transfers/transfer_item.hbs.erb +52 -0
- data/app/assets/javascripts/spree/backend/templates/variants/autocomplete.hbs.erb +23 -0
- data/app/assets/javascripts/spree/backend/templates/variants/autocomplete_stock.hbs +51 -0
- data/app/assets/javascripts/spree/backend/templates/variants/line_items_autocomplete_stock.hbs +67 -0
- data/app/assets/javascripts/spree/backend/templates/variants/split.hbs +27 -0
- data/app/assets/javascripts/spree/backend/user_picker.js +8 -8
- data/app/assets/javascripts/spree/backend/variant_autocomplete.js.coffee.erb +6 -8
- data/app/assets/stylesheets/spree/backend/components/_messages.scss +6 -3
- data/app/assets/stylesheets/spree/backend/sections/_promotions.scss +16 -0
- data/app/controllers/spree/admin/base_controller.rb +1 -1
- data/app/controllers/spree/admin/option_types_controller.rb +1 -3
- data/app/controllers/spree/admin/orders/customer_details_controller.rb +1 -1
- data/app/controllers/spree/admin/orders_controller.rb +6 -11
- data/app/controllers/spree/admin/product_properties_controller.rb +9 -0
- data/app/controllers/spree/admin/products_controller.rb +20 -5
- data/app/controllers/spree/admin/promotions_controller.rb +2 -1
- data/app/controllers/spree/admin/reimbursements_controller.rb +20 -0
- data/app/controllers/spree/admin/resource_controller.rb +1 -1
- data/app/controllers/spree/admin/return_authorizations_controller.rb +5 -0
- data/app/controllers/spree/admin/root_controller.rb +1 -1
- data/app/controllers/spree/admin/search_controller.rb +2 -4
- data/app/controllers/spree/admin/states_controller.rb +1 -1
- data/app/controllers/spree/admin/stock_items_controller.rb +1 -1
- data/app/controllers/spree/admin/stock_transfers_controller.rb +3 -14
- data/app/controllers/spree/admin/users_controller.rb +2 -3
- data/app/controllers/spree/admin/variant_property_rule_values_controller.rb +7 -0
- data/app/controllers/spree/admin/variants_controller.rb +1 -1
- data/app/controllers/spree/admin/zones_controller.rb +1 -1
- data/app/helpers/spree/admin/adjustments_helper.rb +4 -9
- data/app/helpers/spree/admin/base_helper.rb +7 -6
- data/app/helpers/spree/admin/navigation_helper.rb +8 -2
- data/app/helpers/spree/admin/orders_helper.rb +1 -1
- data/app/helpers/spree/admin/products_helper.rb +2 -4
- data/app/helpers/spree/admin/stock_movements_helper.rb +3 -3
- data/app/views/spree/admin/adjustments/_adjustment.html.erb +1 -1
- data/app/views/spree/admin/orders/_add_line_item.html.erb +0 -5
- data/app/views/spree/admin/orders/_add_product.html.erb +0 -3
- data/app/views/spree/admin/orders/_carton.html.erb +0 -1
- data/app/views/spree/admin/orders/_shipment.html.erb +0 -1
- data/app/views/spree/admin/orders/confirm/_shipment.html.erb +0 -1
- data/app/views/spree/admin/orders/customer_details/_form.html.erb +1 -1
- data/app/views/spree/admin/orders/customer_details/edit.html.erb +0 -1
- data/app/views/spree/admin/orders/index.html.erb +1 -2
- data/app/views/spree/admin/payment_methods/_form.html.erb +0 -4
- data/app/views/spree/admin/payment_methods/index.html.erb +0 -2
- data/app/views/spree/admin/payments/source_views/_gateway.html.erb +3 -0
- data/app/views/spree/admin/product_properties/index.html.erb +52 -2
- data/app/views/spree/admin/promotions/_actions.html.erb +14 -10
- data/app/views/spree/admin/promotions/_promotion_action.html.erb +5 -3
- data/app/views/spree/admin/promotions/_promotion_rule.html.erb +5 -3
- data/app/views/spree/admin/promotions/_rules.html.erb +18 -14
- data/app/views/spree/admin/promotions/calculators/tiered_flat_rate/_fields.html.erb +5 -28
- data/app/views/spree/admin/promotions/calculators/tiered_percent/_fields.html.erb +5 -27
- data/app/views/spree/admin/promotions/edit.html.erb +6 -4
- data/app/views/spree/admin/promotions/index.html.erb +1 -1
- data/app/views/spree/admin/promotions/rules/_option_value.html.erb +13 -0
- data/app/views/spree/admin/refund_reasons/index.html.erb +2 -2
- data/app/views/spree/admin/reimbursements/edit.html.erb +1 -1
- data/app/views/spree/admin/return_authorizations/_form.html.erb +2 -2
- data/app/views/spree/admin/search/users.rabl +1 -1
- data/app/views/spree/admin/shared/_order_summary.html.erb +6 -0
- data/app/views/spree/admin/shared/_tabs.html.erb +2 -2
- data/app/views/spree/admin/shared/_translations.html.erb +16 -46
- data/app/views/spree/admin/shared/named_types/_index.html.erb +2 -2
- data/app/views/spree/admin/stock_items/_stock_management.html.erb +0 -2
- data/app/views/spree/admin/stock_movements/_form.html.erb +0 -2
- data/app/views/spree/admin/stock_transfers/edit.html.erb +0 -3
- data/app/views/spree/admin/stock_transfers/receive.html.erb +0 -2
- data/app/views/spree/admin/stock_transfers/show.html.erb +1 -1
- data/app/views/spree/admin/taxons/index.html.erb +0 -1
- data/app/views/spree/admin/users/_addresses_form.html.erb +4 -4
- data/app/views/spree/layouts/admin.html.erb +11 -9
- data/config/routes.rb +5 -0
- data/lib/spree/backend.rb +1 -2
- metadata +41 -139
- data/CHANGELOG.md +0 -1
- data/Gemfile +0 -6
- data/Rakefile +0 -15
- data/app/assets/javascripts/spree/backend/handlebar_extensions.js +0 -9
- data/app/assets/javascripts/spree/backend/promotions.js +0 -73
- data/app/assets/javascripts/spree/backend/stock_transfer.js.coffee +0 -196
- data/app/views/spree/admin/products/_autocomplete.js.erb +0 -14
- data/app/views/spree/admin/products/_sortable.html +0 -7
- data/app/views/spree/admin/stock_items/_stock_location_stock_item_template.html.erb +0 -21
- data/app/views/spree/admin/stock_transfers/_transfer_item_template.html.erb +0 -54
- data/app/views/spree/admin/variants/_autocomplete.js.erb +0 -25
- data/app/views/spree/admin/variants/_autocomplete_line_items_stock.js.erb +0 -69
- data/app/views/spree/admin/variants/_autocomplete_stock.js.erb +0 -53
- data/app/views/spree/admin/variants/_split.js.erb +0 -29
- data/script/rails +0 -9
- data/solidus_backend.gemspec +0 -30
- data/spec/controllers/spree/admin/base_controller_spec.rb +0 -24
- data/spec/controllers/spree/admin/cancellations_controller_spec.rb +0 -77
- data/spec/controllers/spree/admin/customer_returns_controller_spec.rb +0 -234
- data/spec/controllers/spree/admin/general_settings_controller_spec.rb +0 -41
- data/spec/controllers/spree/admin/missing_products_controller_spec.rb +0 -18
- data/spec/controllers/spree/admin/orders/customer_details_controller_spec.rb +0 -80
- data/spec/controllers/spree/admin/orders_controller_spec.rb +0 -472
- data/spec/controllers/spree/admin/payment_methods_controller_spec.rb +0 -49
- data/spec/controllers/spree/admin/payments_controller_spec.rb +0 -175
- data/spec/controllers/spree/admin/products_controller_spec.rb +0 -45
- data/spec/controllers/spree/admin/promotion_actions_controller_spec.rb +0 -21
- data/spec/controllers/spree/admin/promotion_codes_controller_spec.rb +0 -18
- data/spec/controllers/spree/admin/promotion_rules_controller_spec.rb +0 -21
- data/spec/controllers/spree/admin/promotions_controller_spec.rb +0 -122
- data/spec/controllers/spree/admin/refunds_controller_spec.rb +0 -32
- data/spec/controllers/spree/admin/reimbursements_controller_spec.rb +0 -75
- data/spec/controllers/spree/admin/reports_controller_spec.rb +0 -134
- data/spec/controllers/spree/admin/resource_controller_spec.rb +0 -166
- data/spec/controllers/spree/admin/return_authorizations_controller_spec.rb +0 -226
- data/spec/controllers/spree/admin/return_items_controller_spec.rb +0 -27
- data/spec/controllers/spree/admin/root_controller_spec.rb +0 -41
- data/spec/controllers/spree/admin/search_controller_spec.rb +0 -104
- data/spec/controllers/spree/admin/shipping_methods_controller_spec.rb +0 -14
- data/spec/controllers/spree/admin/stock_items_controller_spec.rb +0 -50
- data/spec/controllers/spree/admin/stock_locations_controller_spec.rb +0 -41
- data/spec/controllers/spree/admin/stock_transfers_controller_spec.rb +0 -331
- data/spec/controllers/spree/admin/store_credits_controller_spec.rb +0 -309
- data/spec/controllers/spree/admin/users_controller_spec.rb +0 -236
- data/spec/controllers/spree/admin/variants_controller_spec.rb +0 -32
- data/spec/features/admin/configuration/analytics_tracker_spec.rb +0 -54
- data/spec/features/admin/configuration/countries_spec.rb +0 -22
- data/spec/features/admin/configuration/general_settings_spec.rb +0 -45
- data/spec/features/admin/configuration/payment_methods_spec.rb +0 -125
- data/spec/features/admin/configuration/shipping_methods_spec.rb +0 -64
- data/spec/features/admin/configuration/states_spec.rb +0 -64
- data/spec/features/admin/configuration/stock_locations_spec.rb +0 -50
- data/spec/features/admin/configuration/tax_categories_spec.rb +0 -56
- data/spec/features/admin/configuration/tax_rates_spec.rb +0 -30
- data/spec/features/admin/configuration/taxonomies_spec.rb +0 -52
- data/spec/features/admin/configuration/zones_spec.rb +0 -39
- data/spec/features/admin/homepage_spec.rb +0 -78
- data/spec/features/admin/locale_spec.rb +0 -30
- data/spec/features/admin/orders/adjustments_promotions_spec.rb +0 -53
- data/spec/features/admin/orders/adjustments_spec.rb +0 -126
- data/spec/features/admin/orders/cancelling_and_resuming_spec.rb +0 -48
- data/spec/features/admin/orders/cancelling_inventory_spec.rb +0 -48
- data/spec/features/admin/orders/customer_details_spec.rb +0 -163
- data/spec/features/admin/orders/line_items_spec.rb +0 -50
- data/spec/features/admin/orders/listing_spec.rb +0 -130
- data/spec/features/admin/orders/log_entries_spec.rb +0 -55
- data/spec/features/admin/orders/new_order_spec.rb +0 -197
- data/spec/features/admin/orders/order_details_spec.rb +0 -533
- data/spec/features/admin/orders/payments_spec.rb +0 -228
- data/spec/features/admin/orders/risk_analysis_spec.rb +0 -47
- data/spec/features/admin/orders/shipments_spec.rb +0 -65
- data/spec/features/admin/payments/store_credits_spec.rb +0 -21
- data/spec/features/admin/products/edit/images_spec.rb +0 -87
- data/spec/features/admin/products/edit/products_spec.rb +0 -66
- data/spec/features/admin/products/edit/taxons_spec.rb +0 -56
- data/spec/features/admin/products/edit/variants_spec.rb +0 -61
- data/spec/features/admin/products/option_types_spec.rb +0 -114
- data/spec/features/admin/products/products_spec.rb +0 -392
- data/spec/features/admin/products/properties_spec.rb +0 -139
- data/spec/features/admin/products/prototypes_spec.rb +0 -110
- data/spec/features/admin/products/stock_management_spec.rb +0 -82
- data/spec/features/admin/products/variant_spec.rb +0 -51
- data/spec/features/admin/promotion_adjustments_spec.rb +0 -220
- data/spec/features/admin/promotions/tiered_calculator_spec.rb +0 -69
- data/spec/features/admin/promotions/user_rule_spec.rb +0 -25
- data/spec/features/admin/reports_spec.rb +0 -61
- data/spec/features/admin/stock_transfer_spec.rb +0 -86
- data/spec/features/admin/store_credits_spec.rb +0 -82
- data/spec/features/admin/taxons_spec.rb +0 -31
- data/spec/features/admin/users_spec.rb +0 -270
- data/spec/helpers/admin/base_helper_spec.rb +0 -24
- data/spec/helpers/admin/navigation_helper_spec.rb +0 -73
- data/spec/helpers/admin/reimbursements_helper_spec.rb +0 -34
- data/spec/helpers/admin/stock_movements_helper_spec.rb +0 -29
- data/spec/helpers/admin/store_credit_events_helper_spec.rb +0 -95
- data/spec/helpers/promotion_rules_helper_spec.rb +0 -12
- data/spec/spec_helper.rb +0 -108
- data/spec/support/appear_before_matcher.rb +0 -8
- data/spec/support/ror_ringer.jpeg +0 -0
- data/spec/test_views/spree/admin/widgets/edit.html.erb +0 -1
- data/spec/test_views/spree/admin/widgets/new.html.erb +0 -1
- data/vendor/assets/javascripts/handlebars.js +0 -2746
@@ -1,53 +0,0 @@
|
|
1
|
-
<script type='text/template' id='variant_autocomplete_stock_template'>
|
2
|
-
<fieldset>
|
3
|
-
<legend align="center"><%= Spree.t(:select_stock) %></legend>
|
4
|
-
<table class="stock-levels" data-hook="stock-levels">
|
5
|
-
<colgroup>
|
6
|
-
<col style="width: 30%;" />
|
7
|
-
<col style="width: 40%;" />
|
8
|
-
<col style="width: 20%;" />
|
9
|
-
<col style="width: 10%;" />
|
10
|
-
</colgroup>
|
11
|
-
<thead>
|
12
|
-
<th><%= Spree.t(:location) %></th>
|
13
|
-
<th><%= Spree.t(:count_on_hand) %></th>
|
14
|
-
<th><%= Spree.t(:quantity) %></th>
|
15
|
-
<th class="actions"></th>
|
16
|
-
</thead>
|
17
|
-
<tbody>
|
18
|
-
{{#each variant.stock_items}}
|
19
|
-
<tr>
|
20
|
-
<td>{{this.stock_location_name}}</td>
|
21
|
-
{{#unless ../variant.track_inventory}}
|
22
|
-
<td>
|
23
|
-
It doesn't track inventory
|
24
|
-
</td>
|
25
|
-
<td>
|
26
|
-
<input class="quantity" id="stock_item_quantity" data-stock-location-id="{{this.stock_location_id}}" type="number" min="1" value="1">
|
27
|
-
</td>
|
28
|
-
<td class="actions">
|
29
|
-
<button class="add_variant no-text fa fa-plus icon_link with-tip" data-stock-location-id="{{this.stock_location_id}}" title="<%= Spree.t(:add) %>" data-action="add"></button>
|
30
|
-
</td>
|
31
|
-
{{else}}
|
32
|
-
{{#if this.available}}
|
33
|
-
<td>
|
34
|
-
{{this.count_on_hand}}
|
35
|
-
{{#if this.backorderable}} (<%= Spree.t(:backorders_allowed) %>) {{/if}}
|
36
|
-
</td>
|
37
|
-
<td>
|
38
|
-
<input class="quantity" id="stock_item_quantity" data-stock-location-id="{{this.stock_location_id}}" type="number" min="1" value="1">
|
39
|
-
</td>
|
40
|
-
<td class="actions">
|
41
|
-
<button class="add_variant no-text fa fa-plus icon_link with-tip" data-stock-location-id="{{this.stock_location_id}}" title="<%= Spree.t(:add) %>" data-action="add"></button>
|
42
|
-
</td>
|
43
|
-
{{else}}
|
44
|
-
<td><%= Spree.t(:out_of_stock) %></td>
|
45
|
-
<td>0</td>
|
46
|
-
{{/if}}
|
47
|
-
{{/unless}}
|
48
|
-
</tr>
|
49
|
-
{{/each}}
|
50
|
-
</tbody>
|
51
|
-
</table>
|
52
|
-
</fieldset>
|
53
|
-
</script>
|
@@ -1,29 +0,0 @@
|
|
1
|
-
<script type='text/template' id='variant_split_template'>
|
2
|
-
<tr class='stock-item-split' data-variant-id='{{variant.id}}'>
|
3
|
-
<td colspan='2'>
|
4
|
-
<%=Spree.t("move_variant_to", default: "Move {{variant.name}} to")%>
|
5
|
-
</td>
|
6
|
-
<td colspan='2'>
|
7
|
-
<select name="item_stock_location" id='item_stock_location' style='width:100%;'>
|
8
|
-
<option></option>
|
9
|
-
<optgroup label="<%=Spree.t('existing_shipments')%>">
|
10
|
-
{{#each shipments}}
|
11
|
-
<option data-shipment-number='{{this.number}}' value='{{this.stock_location_id}}'>{{this.stock_location.name}}({{this.number}})</option>
|
12
|
-
{{/each}}
|
13
|
-
</optgroup>
|
14
|
-
<optgroup label="<%=Spree.t('new_shipment_at_location')%>">
|
15
|
-
{{#each variant.stock_items}}
|
16
|
-
<option data-new-shipment='true' value='{{this.stock_location_id}}'>{{this.stock_location_name}} ({{this.count_on_hand}} on hand)</option>
|
17
|
-
{{/each}}
|
18
|
-
</optgroup>
|
19
|
-
</select>
|
20
|
-
</td>
|
21
|
-
<td>
|
22
|
-
<input class="quantity" id="item_quantity" type="number" min="1" value="1" max="{{max_quantity}}">
|
23
|
-
</td>
|
24
|
-
<td class='actions'>
|
25
|
-
<a href='#' class='save-split icon_link fa fa-ok no-text with-tip' title='Save'></a>
|
26
|
-
<a href='#' class='cancel-split icon_link fa fa-cancel no-text with-tip' title='Cancel'></a>
|
27
|
-
</td>
|
28
|
-
</tr>
|
29
|
-
</script>
|
data/script/rails
DELETED
@@ -1,9 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
|
3
|
-
|
4
|
-
ENGINE_ROOT = File.expand_path('../..', __FILE__)
|
5
|
-
ENGINE_PATH = File.expand_path('../../lib/spree/backend/engine', __FILE__)
|
6
|
-
|
7
|
-
require 'rails/all'
|
8
|
-
require 'rails/engine/commands'
|
9
|
-
|
data/solidus_backend.gemspec
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
version = File.read(File.expand_path("../../SOLIDUS_VERSION", __FILE__)).strip
|
3
|
-
|
4
|
-
Gem::Specification.new do |s|
|
5
|
-
s.platform = Gem::Platform::RUBY
|
6
|
-
s.name = 'solidus_backend'
|
7
|
-
s.version = version
|
8
|
-
s.summary = 'Admin interface for the Solidus e-commerce framework.'
|
9
|
-
s.description = s.summary
|
10
|
-
|
11
|
-
s.required_ruby_version = '>= 2.1.0'
|
12
|
-
s.author = 'Solidus Team'
|
13
|
-
s.email = 'contact@solidus.io'
|
14
|
-
s.homepage = 'http://solidus.io'
|
15
|
-
s.rubyforge_project = 'solidus_backend'
|
16
|
-
|
17
|
-
s.files = `git ls-files`.split("\n")
|
18
|
-
s.require_path = 'lib'
|
19
|
-
s.requirements << 'none'
|
20
|
-
|
21
|
-
s.add_dependency 'solidus_api', version
|
22
|
-
s.add_dependency 'solidus_core', version
|
23
|
-
|
24
|
-
s.add_dependency 'bourbon'
|
25
|
-
s.add_dependency 'sass-rails'
|
26
|
-
s.add_dependency 'coffee-rails'
|
27
|
-
s.add_dependency 'jquery-rails'
|
28
|
-
s.add_dependency 'jquery-ui-rails', '~> 5.0.0'
|
29
|
-
s.add_dependency 'select2-rails', '3.5.9.1' # 3.5.9.2 breaks forms
|
30
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
# Spree's rpsec controller tests get the Spree::ControllerHacks
|
2
|
-
# we don't need those for the anonymous controller here, so
|
3
|
-
# we call process directly instead of get
|
4
|
-
require 'spec_helper'
|
5
|
-
|
6
|
-
describe Spree::Admin::BaseController, :type => :controller do
|
7
|
-
controller(Spree::Admin::BaseController) do
|
8
|
-
def index
|
9
|
-
authorize! :update, Spree::Order
|
10
|
-
render :text => 'test'
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
context "unauthorized request" do
|
15
|
-
before do
|
16
|
-
allow_any_instance_of(Spree::Admin::BaseController).to receive(:spree_current_user).and_return(nil)
|
17
|
-
end
|
18
|
-
|
19
|
-
it "redirects to unauthorized" do
|
20
|
-
get :index
|
21
|
-
expect(response).to redirect_to '/unauthorized'
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
@@ -1,77 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Spree::Admin::CancellationsController do
|
4
|
-
stub_authorization!
|
5
|
-
|
6
|
-
describe "#index" do
|
7
|
-
subject { spree_get :index, order_id: order.number }
|
8
|
-
|
9
|
-
let(:order) { create(:order_ready_to_ship, line_items_count: 1)}
|
10
|
-
|
11
|
-
context "for an order with inventory" do
|
12
|
-
render_views
|
13
|
-
|
14
|
-
it "succeeds" do
|
15
|
-
expect(response).to be_ok
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
describe "#cancel" do
|
21
|
-
subject { spree_post :short_ship, order_id: order.number, inventory_unit_ids: inventory_units.map(&:id) }
|
22
|
-
|
23
|
-
let(:order) { order = create(:order_ready_to_ship, :number => "R100", :state => "complete", line_items_count: 1) }
|
24
|
-
let(:referer) { "order_admin_page" }
|
25
|
-
|
26
|
-
context "no inventory unit ids are provided" do
|
27
|
-
subject { spree_post :short_ship, order_id: order.number }
|
28
|
-
|
29
|
-
it "redirects back" do
|
30
|
-
subject
|
31
|
-
expect(response).to redirect_to(spree.admin_order_cancellations_path(order))
|
32
|
-
end
|
33
|
-
|
34
|
-
it "sets an error message" do
|
35
|
-
subject
|
36
|
-
expect(flash[:error]).to eq Spree.t(:no_inventory_selected)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
context "unable to find all the inventory" do
|
41
|
-
let(:inventory_units) { [Spree::InventoryUnit.new(id: -1)] }
|
42
|
-
|
43
|
-
it "redirects back" do
|
44
|
-
subject
|
45
|
-
expect(response).to redirect_to(spree.admin_order_cancellations_path(order))
|
46
|
-
end
|
47
|
-
|
48
|
-
it "sets an error message" do
|
49
|
-
subject
|
50
|
-
expect(flash[:error]).to eq Spree.t(:unable_to_find_all_inventory_units)
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
context "successfully cancels inventory" do
|
55
|
-
let(:inventory_units) { order.inventory_units.not_canceled }
|
56
|
-
|
57
|
-
it "redirects to admin order edit" do
|
58
|
-
subject
|
59
|
-
expect(response).to redirect_to(spree.edit_admin_order_path(order))
|
60
|
-
end
|
61
|
-
|
62
|
-
it "sets an success message" do
|
63
|
-
subject
|
64
|
-
expect(flash[:success]).to eq Spree.t(:inventory_canceled)
|
65
|
-
end
|
66
|
-
|
67
|
-
it "creates a unit cancel" do
|
68
|
-
expect { subject }.to change { Spree::UnitCancel.count }.by(1)
|
69
|
-
end
|
70
|
-
|
71
|
-
it "cancels the inventory" do
|
72
|
-
subject
|
73
|
-
expect(order.inventory_units.map(&:state).uniq).to match_array(['canceled'])
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
@@ -1,234 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module Spree
|
4
|
-
module Admin
|
5
|
-
describe CustomerReturnsController, :type => :controller do
|
6
|
-
stub_authorization!
|
7
|
-
|
8
|
-
describe "#index" do
|
9
|
-
let(:order) { customer_return.order }
|
10
|
-
let(:customer_return) { create(:customer_return) }
|
11
|
-
|
12
|
-
subject do
|
13
|
-
spree_get :index, { order_id: customer_return.order.to_param }
|
14
|
-
end
|
15
|
-
|
16
|
-
before { subject }
|
17
|
-
|
18
|
-
it "loads the order" do
|
19
|
-
expect(assigns(:order)).to eq order
|
20
|
-
end
|
21
|
-
|
22
|
-
it "loads the customer return" do
|
23
|
-
expect(assigns(:customer_returns)).to include(customer_return)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
describe "#new" do
|
28
|
-
let(:order) { create(:shipped_order, line_items_count: 1) }
|
29
|
-
let!(:inactive_reimbursement_type) { create(:reimbursement_type, active: false) }
|
30
|
-
let!(:first_active_reimbursement_type) { create(:reimbursement_type) }
|
31
|
-
let!(:second_active_reimbursement_type) { create(:reimbursement_type) }
|
32
|
-
|
33
|
-
subject do
|
34
|
-
spree_get :new, { order_id: order.to_param }
|
35
|
-
end
|
36
|
-
|
37
|
-
it "loads the order" do
|
38
|
-
subject
|
39
|
-
expect(assigns(:order)).to eq order
|
40
|
-
end
|
41
|
-
|
42
|
-
it "builds a new customer return" do
|
43
|
-
subject
|
44
|
-
expect(assigns(:customer_return)).to_not be_persisted
|
45
|
-
end
|
46
|
-
|
47
|
-
context "with previous customer return" do
|
48
|
-
let(:return_reason_1) { create(:return_reason) }
|
49
|
-
let(:return_reason_2) { create(:return_reason) }
|
50
|
-
let(:return_reason_3) { create(:return_reason) }
|
51
|
-
let!(:inactive_rma_reason) { create(:return_reason, active: false) }
|
52
|
-
|
53
|
-
|
54
|
-
let(:order) { create(:shipped_order, line_items_count: 4) }
|
55
|
-
let(:rma) { create(:return_authorization, order: order, reason: return_reason_1) }
|
56
|
-
|
57
|
-
let!(:rma_return_item) { create(:return_item, return_authorization: rma, inventory_unit: order.inventory_units.first, return_reason: return_reason_2) }
|
58
|
-
let!(:customer_return_return_item) { create(:return_item, return_authorization: nil, inventory_unit: order.inventory_units.last, return_reason: return_reason_3) }
|
59
|
-
|
60
|
-
context "all return items are associated with a customer return" do
|
61
|
-
let!(:previous_customer_return) { create(:customer_return_without_return_items, return_items: [rma_return_item, customer_return_return_item]) }
|
62
|
-
|
63
|
-
before { subject }
|
64
|
-
|
65
|
-
it "loads the possible return items" do
|
66
|
-
total_inventory_count = 4
|
67
|
-
rma_return_items_count = 1
|
68
|
-
customer_return_return_items_count = 1
|
69
|
-
expect(assigns(:new_return_items).length).to eq (total_inventory_count - rma_return_items_count - customer_return_return_items_count)
|
70
|
-
end
|
71
|
-
|
72
|
-
it "builds new return items" do
|
73
|
-
expect(assigns(:new_return_items).all? { |return_item| !return_item.persisted? }).to eq true
|
74
|
-
end
|
75
|
-
|
76
|
-
it "does not have any rma return items" do
|
77
|
-
expect(assigns(:rma_return_items)).to eq []
|
78
|
-
end
|
79
|
-
|
80
|
-
it "loads the correct return authorization reasons" do
|
81
|
-
expect(assigns(:reasons)).to match_array([return_reason_1, return_reason_2, return_reason_3])
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
context "there is a return item associated with an rma but not a customer return" do
|
86
|
-
let!(:previous_customer_return) { create(:customer_return_without_return_items, return_items: [customer_return_return_item]) }
|
87
|
-
|
88
|
-
before do
|
89
|
-
subject
|
90
|
-
end
|
91
|
-
|
92
|
-
it "loads the possible return items" do
|
93
|
-
rma_return_item_count = rma.return_items.count
|
94
|
-
total_unit_count = order.inventory_units.count
|
95
|
-
customer_returned_count = previous_customer_return.return_items.count
|
96
|
-
expected_total = total_unit_count - customer_returned_count - rma_return_item_count
|
97
|
-
expect(assigns(:new_return_items).length).to eq expected_total
|
98
|
-
end
|
99
|
-
|
100
|
-
it "builds new return items" do
|
101
|
-
expect(assigns(:new_return_items).all? { |return_item| !return_item.persisted? }).to eq true
|
102
|
-
end
|
103
|
-
|
104
|
-
it "loads the persisted rma return items" do
|
105
|
-
expect(assigns(:rma_return_items).all? { |return_item| return_item.persisted? }).to eq true
|
106
|
-
end
|
107
|
-
|
108
|
-
it "has one rma return item" do
|
109
|
-
expect(assigns(:rma_return_items)).to include(rma_return_item)
|
110
|
-
end
|
111
|
-
|
112
|
-
it "loads the correct return authorization reasons" do
|
113
|
-
expect(assigns(:reasons)).to match_array([return_reason_1, return_reason_2, return_reason_3])
|
114
|
-
end
|
115
|
-
end
|
116
|
-
end
|
117
|
-
end
|
118
|
-
|
119
|
-
describe "#edit" do
|
120
|
-
let(:order) { customer_return.order }
|
121
|
-
let(:customer_return) { create(:customer_return, line_items_count: 3) }
|
122
|
-
|
123
|
-
let!(:inactive_rma_reason) { create(:return_reason, active: false) }
|
124
|
-
|
125
|
-
let!(:accepted_return_item) { customer_return.return_items.order('id').first.tap(&:accept!) }
|
126
|
-
let!(:rejected_return_item) { customer_return.return_items.order('id').second.tap(&:reject!)}
|
127
|
-
let!(:manual_intervention_return_item) { customer_return.return_items.order('id').third.tap(&:require_manual_intervention!) }
|
128
|
-
|
129
|
-
subject do
|
130
|
-
spree_get :edit, { order_id: order.to_param, id: customer_return.to_param }
|
131
|
-
end
|
132
|
-
|
133
|
-
it "loads the order" do
|
134
|
-
subject
|
135
|
-
expect(assigns(:order)).to eq order
|
136
|
-
end
|
137
|
-
|
138
|
-
it "loads the customer return" do
|
139
|
-
subject
|
140
|
-
expect(assigns(:customer_return)).to eq customer_return
|
141
|
-
end
|
142
|
-
|
143
|
-
it "loads the accepted return items" do
|
144
|
-
subject
|
145
|
-
expect(assigns(:accepted_return_items)).to eq [accepted_return_item]
|
146
|
-
end
|
147
|
-
|
148
|
-
it "loads the rejected return items" do
|
149
|
-
subject
|
150
|
-
expect(assigns(:rejected_return_items)).to eq [rejected_return_item]
|
151
|
-
end
|
152
|
-
|
153
|
-
it "loads the return items that require manual intervention" do
|
154
|
-
subject
|
155
|
-
expect(assigns(:manual_intervention_return_items)).to eq [manual_intervention_return_item]
|
156
|
-
end
|
157
|
-
|
158
|
-
it "loads the return items that are still pending" do
|
159
|
-
subject
|
160
|
-
expect(assigns(:pending_return_items)).to eq []
|
161
|
-
end
|
162
|
-
|
163
|
-
it "loads the reimbursements that are still pending" do
|
164
|
-
subject
|
165
|
-
expect(assigns(:pending_reimbursements)).to eq []
|
166
|
-
end
|
167
|
-
|
168
|
-
it "loads the correct return authorization reasons" do
|
169
|
-
subject
|
170
|
-
expect(assigns(:reasons)).to match(Spree::ReturnReason.active)
|
171
|
-
end
|
172
|
-
|
173
|
-
context "a return item has an inactive return authorization reason" do
|
174
|
-
before(:each) do
|
175
|
-
accepted_return_item.update_attributes(return_reason_id: inactive_rma_reason.id)
|
176
|
-
end
|
177
|
-
|
178
|
-
it "includes the inactive return authorization reason" do
|
179
|
-
subject
|
180
|
-
expect(assigns(:reasons)).to match(Spree::ReturnReason.active + [inactive_rma_reason])
|
181
|
-
end
|
182
|
-
end
|
183
|
-
end
|
184
|
-
|
185
|
-
describe "#create" do
|
186
|
-
let(:order) { create(:shipped_order, line_items_count: 1) }
|
187
|
-
let(:reception_status_event) { 'receive' }
|
188
|
-
let(:stock_location_id) { order.shipments.last.stock_location.id }
|
189
|
-
let(:customer_return_params) do
|
190
|
-
{
|
191
|
-
order_id: order.to_param,
|
192
|
-
customer_return: {
|
193
|
-
stock_location_id: stock_location_id,
|
194
|
-
return_items_attributes: {
|
195
|
-
"0" => {
|
196
|
-
returned: "1",
|
197
|
-
"pre_tax_amount"=>"15.99",
|
198
|
-
inventory_unit_id: order.inventory_units.shipped.last.id,
|
199
|
-
reception_status_event: reception_status_event
|
200
|
-
}
|
201
|
-
}
|
202
|
-
}
|
203
|
-
}
|
204
|
-
end
|
205
|
-
|
206
|
-
subject { spree_post :create, customer_return_params }
|
207
|
-
|
208
|
-
it { expect { subject }.to change { Spree::CustomerReturn.count }.by(1) }
|
209
|
-
it do
|
210
|
-
subject
|
211
|
-
expect(response).to redirect_to spree.edit_admin_order_customer_return_path(order, id: Spree::CustomerReturn.last.id)
|
212
|
-
end
|
213
|
-
|
214
|
-
it 'executes the reception status event on the return items' do
|
215
|
-
subject
|
216
|
-
customer_return = Spree::CustomerReturn.last
|
217
|
-
expect(customer_return.return_items.map(&:reception_status).uniq).to eq ['received']
|
218
|
-
end
|
219
|
-
|
220
|
-
context "missing stock location" do
|
221
|
-
let(:stock_location_id) { '' }
|
222
|
-
it { expect{ subject }.to_not change { Spree::CustomerReturn.count } }
|
223
|
-
it { subject; expect(response).to render_template(:new) }
|
224
|
-
end
|
225
|
-
|
226
|
-
context "missing reception status event" do
|
227
|
-
let(:reception_status_event) { '' }
|
228
|
-
it { expect{ subject }.to_not change { Spree::CustomerReturn.count } }
|
229
|
-
it { subject; expect(response).to redirect_to spree.new_admin_order_customer_return_path(order) }
|
230
|
-
end
|
231
|
-
end
|
232
|
-
end
|
233
|
-
end
|
234
|
-
end
|