spree_backend 3.2.9 → 3.3.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/spree/backend/admin.js +16 -15
- data/app/assets/javascripts/spree/backend/checkouts/edit.js +25 -26
- data/app/assets/javascripts/spree/backend/general_settings.js.coffee +10 -12
- data/app/assets/javascripts/spree/backend/payments/edit.js.coffee +4 -6
- data/app/assets/javascripts/spree/backend/returns/return_item_selection.js +7 -1
- data/app/assets/javascripts/spree/backend/stock_transfer.js.coffee +4 -1
- data/app/assets/javascripts/spree/backend/user_picker.js +3 -1
- data/app/assets/javascripts/spree/backend.js +3 -3
- data/app/controllers/spree/admin/countries_controller.rb +1 -0
- data/app/controllers/spree/admin/log_entries_controller.rb +2 -2
- data/app/controllers/spree/admin/orders/customer_details_controller.rb +5 -6
- data/app/controllers/spree/admin/orders_controller.rb +4 -4
- data/app/controllers/spree/admin/payments_controller.rb +21 -10
- data/app/controllers/spree/admin/products_controller.rb +5 -0
- data/app/controllers/spree/admin/promotion_rules_controller.rb +11 -7
- data/app/controllers/spree/admin/stock_transfers_controller.rb +1 -1
- data/app/controllers/spree/admin/taxons_controller.rb +31 -23
- data/app/helpers/spree/admin/base_helper.rb +1 -1
- data/app/helpers/spree/admin/navigation_helper.rb +10 -4
- data/app/views/spree/admin/adjustments/_adjustments_table.html.erb +2 -2
- data/app/views/spree/admin/general_settings/edit.html.erb +8 -8
- data/app/views/spree/admin/images/_form.html.erb +2 -2
- data/app/views/spree/admin/images/edit.html.erb +2 -2
- data/app/views/spree/admin/images/new.html.erb +1 -1
- data/app/views/spree/admin/option_types/_form.html.erb +2 -2
- data/app/views/spree/admin/option_types/index.html.erb +4 -4
- data/app/views/spree/admin/orders/_line_items.html.erb +40 -38
- data/app/views/spree/admin/orders/_shipment.html.erb +77 -76
- data/app/views/spree/admin/orders/customer_details/_form.html.erb +5 -5
- data/app/views/spree/admin/orders/index.html.erb +16 -16
- data/app/views/spree/admin/payment_methods/_form.html.erb +2 -2
- data/app/views/spree/admin/payments/_list.html.erb +1 -1
- data/app/views/spree/admin/products/_add_stock_form.html.erb +3 -3
- data/app/views/spree/admin/products/_form.html.erb +16 -16
- data/app/views/spree/admin/products/index.html.erb +4 -4
- data/app/views/spree/admin/products/new.html.erb +8 -8
- data/app/views/spree/admin/promotion_categories/index.html.erb +3 -3
- data/app/views/spree/admin/promotions/_form.html.erb +3 -3
- data/app/views/spree/admin/promotions/_promotion_rule.html.erb +1 -1
- data/app/views/spree/admin/promotions/actions/_create_adjustment.html.erb +2 -2
- data/app/views/spree/admin/promotions/actions/_create_item_adjustments.html.erb +2 -2
- data/app/views/spree/admin/promotions/actions/_create_line_items.html.erb +2 -4
- data/app/views/spree/admin/promotions/edit.html.erb +3 -3
- data/app/views/spree/admin/promotions/index.html.erb +6 -6
- data/app/views/spree/admin/promotions/rules/_item_total.html.erb +2 -2
- data/app/views/spree/admin/promotions/rules/_option_value.html.erb +4 -4
- data/app/views/spree/admin/properties/_form.html.erb +2 -2
- data/app/views/spree/admin/properties/index.html.erb +6 -6
- data/app/views/spree/admin/prototypes/index.html.erb +4 -4
- data/app/views/spree/admin/reimbursement_types/_form.html.erb +4 -4
- data/app/views/spree/admin/reimbursements/edit.html.erb +1 -1
- data/app/views/spree/admin/return_authorizations/_form.html.erb +13 -1
- data/app/views/spree/admin/return_index/customer_returns.html.erb +2 -2
- data/app/views/spree/admin/return_index/return_authorizations.html.erb +5 -5
- data/app/views/spree/admin/shared/_content_header.html.erb +2 -2
- data/app/views/spree/admin/shared/_header.html.erb +2 -2
- data/app/views/spree/admin/shared/_index_table_options.html.erb +2 -2
- data/app/views/spree/admin/shared/_order_summary.html.erb +1 -1
- data/app/views/spree/admin/shared/_table_filter.html.erb +1 -1
- data/app/views/spree/admin/shared/_translations.html.erb +0 -1
- data/app/views/spree/admin/shared/_update_order_state.js.erb +1 -1
- data/app/views/spree/admin/shipping_methods/_form.html.erb +10 -10
- data/app/views/spree/admin/state_changes/index.html.erb +3 -3
- data/app/views/spree/admin/states/_form.html.erb +2 -2
- data/app/views/spree/admin/stock_locations/_form.html.erb +2 -2
- data/app/views/spree/admin/stock_locations/_transfer_stock_form.html.erb +4 -4
- data/app/views/spree/admin/stock_transfers/index.html.erb +3 -3
- data/app/views/spree/admin/stock_transfers/new.html.erb +2 -2
- data/app/views/spree/admin/store_credits/index.html.erb +1 -1
- data/app/views/spree/admin/tax_rates/_form.html.erb +2 -2
- data/app/views/spree/admin/taxonomies/_list.html.erb +2 -2
- data/app/views/spree/admin/taxonomies/{edit.erb → edit.html.erb} +0 -0
- data/app/views/spree/admin/taxonomies/index.html.erb +2 -2
- data/app/views/spree/admin/taxons/_form.html.erb +5 -5
- data/app/views/spree/admin/taxons/edit.html.erb +3 -0
- data/app/views/spree/admin/trackers/_form.html.erb +2 -2
- data/app/views/spree/admin/users/_addresses_form.html.erb +2 -2
- data/app/views/spree/admin/users/_form.html.erb +2 -2
- data/app/views/spree/admin/users/_user_page_actions.html.erb +1 -1
- data/app/views/spree/admin/users/index.html.erb +5 -5
- data/app/views/spree/admin/users/items.html.erb +1 -1
- data/app/views/spree/admin/users/orders.html.erb +1 -1
- data/app/views/spree/admin/variants/_form.html.erb +2 -2
- data/app/views/spree/admin/zones/_form.html.erb +2 -2
- data/app/views/spree/layouts/admin.html.erb +3 -3
- data/config/initializers/assets.rb +1 -1
- data/lib/spree/backend/engine.rb +0 -1
- data/spec/controllers/spree/admin/base_controller_spec.rb +46 -0
- data/spec/controllers/spree/admin/customer_returns_controller_spec.rb +185 -0
- data/spec/controllers/spree/admin/general_settings_controller_spec.rb +41 -0
- data/spec/controllers/spree/admin/missing_products_controller_spec.rb +18 -0
- data/spec/controllers/spree/admin/orders/customer_details_controller_spec.rb +199 -0
- data/spec/controllers/spree/admin/orders_controller_spec.rb +296 -0
- data/spec/controllers/spree/admin/payment_methods_controller_spec.rb +64 -0
- data/spec/controllers/spree/admin/payments_controller_spec.rb +97 -0
- data/spec/controllers/spree/admin/products_controller_spec.rb +137 -0
- data/spec/controllers/spree/admin/promotion_actions_controller_spec.rb +21 -0
- data/spec/controllers/spree/admin/promotion_rules_controller_spec.rb +21 -0
- data/spec/controllers/spree/admin/promotions_controller_spec.rb +44 -0
- data/spec/controllers/spree/admin/refunds_controller_spec.rb +32 -0
- data/spec/controllers/spree/admin/reimbursements_controller_spec.rb +74 -0
- data/spec/controllers/spree/admin/reports_controller_spec.rb +42 -0
- data/spec/controllers/spree/admin/resource_controller_spec.rb +252 -0
- data/spec/controllers/spree/admin/return_authorizations_controller_spec.rb +225 -0
- data/spec/controllers/spree/admin/return_index_controller_spec.rb +37 -0
- data/spec/controllers/spree/admin/return_items_controller_spec.rb +27 -0
- data/spec/controllers/spree/admin/shipping_methods_controller_spec.rb +14 -0
- data/spec/controllers/spree/admin/stock_items_controller_spec.rb +19 -0
- data/spec/controllers/spree/admin/stock_locations_controller_spec.rb +41 -0
- data/spec/controllers/spree/admin/stock_transfers_controller_spec.rb +41 -0
- data/spec/controllers/spree/admin/tax_categories_controller_spec.rb +34 -0
- data/spec/controllers/spree/admin/users_controller_spec.rb +161 -0
- data/spec/controllers/spree/admin/variants_controller_spec.rb +32 -0
- data/spec/features/admin/configuration/analytics_tracker_spec.rb +47 -0
- data/spec/features/admin/configuration/countries_spec.rb +24 -0
- data/spec/features/admin/configuration/general_settings_spec.rb +44 -0
- data/spec/features/admin/configuration/payment_methods_spec.rb +63 -0
- data/spec/features/admin/configuration/roles_spec.rb +47 -0
- data/spec/features/admin/configuration/shipping_methods_spec.rb +62 -0
- data/spec/features/admin/configuration/states_spec.rb +68 -0
- data/spec/features/admin/configuration/stock_locations_spec.rb +48 -0
- data/spec/features/admin/configuration/store_credit_categories_spec.rb +50 -0
- data/spec/features/admin/configuration/tax_categories_spec.rb +56 -0
- data/spec/features/admin/configuration/tax_rates_spec.rb +18 -0
- data/spec/features/admin/configuration/zones_spec.rb +39 -0
- data/spec/features/admin/homepage_spec.rb +89 -0
- data/spec/features/admin/locale_spec.rb +31 -0
- data/spec/features/admin/orders/adjustments_promotions_spec.rb +53 -0
- data/spec/features/admin/orders/adjustments_spec.rb +124 -0
- data/spec/features/admin/orders/cancelling_and_resuming_spec.rb +47 -0
- data/spec/features/admin/orders/customer_details_spec.rb +154 -0
- data/spec/features/admin/orders/line_items_spec.rb +51 -0
- data/spec/features/admin/orders/listing_spec.rb +224 -0
- data/spec/features/admin/orders/log_entries_spec.rb +55 -0
- data/spec/features/admin/orders/new_order_spec.rb +186 -0
- data/spec/features/admin/orders/order_details_spec.rb +660 -0
- data/spec/features/admin/orders/payments_spec.rb +244 -0
- data/spec/features/admin/orders/risk_analysis_spec.rb +48 -0
- data/spec/features/admin/orders/shipments_spec.rb +64 -0
- data/spec/features/admin/orders/state_changes_spec.rb +21 -0
- data/spec/features/admin/products/edit/images_spec.rb +86 -0
- data/spec/features/admin/products/edit/products_spec.rb +56 -0
- data/spec/features/admin/products/edit/taxons_spec.rb +41 -0
- data/spec/features/admin/products/edit/variants_spec.rb +56 -0
- data/spec/features/admin/products/option_types_spec.rb +114 -0
- data/spec/features/admin/products/products_spec.rb +445 -0
- data/spec/features/admin/products/properties_spec.rb +147 -0
- data/spec/features/admin/products/prototypes_spec.rb +112 -0
- data/spec/features/admin/products/stock_management_spec.rb +124 -0
- data/spec/features/admin/products/taxonomies_spec.rb +52 -0
- data/spec/features/admin/products/variant_spec.rb +50 -0
- data/spec/features/admin/promotions/adjustments_spec.rb +258 -0
- data/spec/features/admin/promotions/option_value_rule_spec.rb +70 -0
- data/spec/features/admin/promotions/tiered_calculator_spec.rb +70 -0
- data/spec/features/admin/refund_reasons/refund_reasons_spec.rb +57 -0
- data/spec/features/admin/reimbursement_type/edit_reimbursement_type_spec.rb +36 -0
- data/spec/features/admin/reimbursement_type/new_reimbursement_type_spec.rb +62 -0
- data/spec/features/admin/reports_spec.rb +61 -0
- data/spec/features/admin/return_authorization_reasons/return_authorization_reasons_spec.rb +63 -0
- data/spec/features/admin/returns/customer_returns_spec.rb +80 -0
- data/spec/features/admin/returns/return_authorizations_spec.rb +152 -0
- data/spec/features/admin/stock_transfer_spec.rb +91 -0
- data/spec/features/admin/store_credits_spec.rb +93 -0
- data/spec/features/admin/taxons_spec.rb +53 -0
- data/spec/features/admin/users_spec.rb +286 -0
- data/spec/helpers/admin/base_helper_spec.rb +30 -0
- data/spec/helpers/admin/navigation_helper_spec.rb +111 -0
- data/spec/helpers/admin/promotion_rules_helper_spec.rb +12 -0
- data/spec/helpers/admin/stock_movements_helper_spec.rb +30 -0
- data/spec/models/spree/resource_spec.rb +48 -0
- data/spec/routing/admin_path_spec.rb +22 -0
- data/spec/spec_helper.rb +144 -0
- data/spec/support/appear_before_matcher.rb +8 -0
- data/spec/support/ror_ringer.jpeg +0 -0
- data/spec/test_views/spree/admin/submodule/posts/edit.html.erb +1 -0
- data/spec/test_views/spree/admin/submodule/posts/new.html.erb +1 -0
- data/spec/test_views/spree/admin/widgets/edit.html.erb +1 -0
- data/spec/test_views/spree/admin/widgets/new.html.erb +1 -0
- data/spree_backend.gemspec +4 -4
- data/vendor/assets/javascripts/jquery.jstree/jquery.jstree.js +130 -154
- metadata +106 -29
- data/vendor/assets/images/jquery-ui/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/vendor/assets/images/jquery-ui/ui-bg_flat_0_eeeeee_40x100.png +0 -0
- data/vendor/assets/images/jquery-ui/ui-bg_flat_55_ffffff_40x100.png +0 -0
- data/vendor/assets/images/jquery-ui/ui-bg_flat_75_ffffff_40x100.png +0 -0
- data/vendor/assets/images/jquery-ui/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/vendor/assets/images/jquery-ui/ui-bg_highlight-soft_100_f6f6f6_1x100.png +0 -0
- data/vendor/assets/images/jquery-ui/ui-bg_highlight-soft_25_0073ea_1x100.png +0 -0
- data/vendor/assets/images/jquery-ui/ui-bg_highlight-soft_50_dddddd_1x100.png +0 -0
- data/vendor/assets/images/jquery-ui/ui-icons_0073ea_256x240.png +0 -0
- data/vendor/assets/images/jquery-ui/ui-icons_454545_256x240.png +0 -0
- data/vendor/assets/images/jquery-ui/ui-icons_666666_256x240.png +0 -0
- data/vendor/assets/images/jquery-ui/ui-icons_ff0084_256x240.png +0 -0
- data/vendor/assets/images/jquery-ui/ui-icons_ffffff_256x240.png +0 -0
- data/vendor/assets/stylesheets/jquery-ui.datepicker.css.erb +0 -357
@@ -0,0 +1,114 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "Option Types", type: :feature, js: true do
|
4
|
+
stub_authorization!
|
5
|
+
|
6
|
+
before(:each) do
|
7
|
+
visit spree.admin_path
|
8
|
+
click_link "Products"
|
9
|
+
end
|
10
|
+
|
11
|
+
context "listing option types" do
|
12
|
+
it "should list existing option types" do
|
13
|
+
create(:option_type, name: "tshirt-color", presentation: "Color")
|
14
|
+
create(:option_type, name: "tshirt-size", presentation: "Size")
|
15
|
+
click_link "Option Types"
|
16
|
+
within("table#listing_option_types") do
|
17
|
+
expect(page).to have_content("Color")
|
18
|
+
expect(page).to have_content("tshirt-color")
|
19
|
+
expect(page).to have_content("Size")
|
20
|
+
expect(page).to have_content("tshirt-size")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
context "creating a new option type" do
|
26
|
+
it "should allow an admin to create a new option type" do
|
27
|
+
click_link "Option Types"
|
28
|
+
click_link "new_option_type_link"
|
29
|
+
expect(page).to have_content("New Option Type")
|
30
|
+
fill_in "option_type_name", with: "shirt colors"
|
31
|
+
fill_in "option_type_presentation", with: "colors"
|
32
|
+
click_button "Create"
|
33
|
+
expect(page).to have_content("successfully created!")
|
34
|
+
|
35
|
+
page.find('#option_type_option_values_attributes_0_name').set('color')
|
36
|
+
page.find('#option_type_option_values_attributes_0_presentation').set('black')
|
37
|
+
|
38
|
+
click_button "Update"
|
39
|
+
expect(page).to have_content("successfully updated!")
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
context "editing an existing option type" do
|
44
|
+
it "should allow an admin to update an existing option type" do
|
45
|
+
create(:option_type, name: "tshirt-color", presentation: "Color")
|
46
|
+
create(:option_type, name: "tshirt-size", presentation: "Size")
|
47
|
+
click_link "Option Types"
|
48
|
+
within('table#listing_option_types') { click_icon :edit }
|
49
|
+
fill_in "option_type_name", with: "foo-size 99"
|
50
|
+
click_button "Update"
|
51
|
+
expect(page).to have_content("successfully updated!")
|
52
|
+
expect(page).to have_content("foo-size 99")
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
# Regression test for #2277
|
57
|
+
it "can remove an option value from an option type" do
|
58
|
+
option_type = create(:option_type)
|
59
|
+
create(:option_value, option_type: option_type)
|
60
|
+
click_link "Option Types"
|
61
|
+
within('table#listing_option_types') { click_icon :edit }
|
62
|
+
expect(page).to have_content(option_type.name)
|
63
|
+
expect(all("tbody#option_values tr").count).to eq(1)
|
64
|
+
within("tbody#option_values") do
|
65
|
+
find('.spree_remove_fields').click
|
66
|
+
end
|
67
|
+
# Assert that the field is hidden automatically
|
68
|
+
expect(all("tbody#option_values tr").select(&:visible?).count).to eq(0)
|
69
|
+
|
70
|
+
# Then assert that on a page refresh that it's still not visible
|
71
|
+
visit page.current_url
|
72
|
+
# What *is* visible is a new option value field, with blank values
|
73
|
+
# Sometimes the page doesn't load before the all check is done
|
74
|
+
# lazily finding the element gives the page 10 seconds
|
75
|
+
expect(page).to have_css("tbody#option_values")
|
76
|
+
all("tbody#option_values tr input").all? { |input| input.value.blank? }
|
77
|
+
end
|
78
|
+
|
79
|
+
# Regression test for #3204
|
80
|
+
it "can remove a non-persisted option value from an option type" do
|
81
|
+
create(:option_type)
|
82
|
+
click_link "Option Types"
|
83
|
+
within('table#listing_option_types') { click_icon :edit }
|
84
|
+
|
85
|
+
wait_for_ajax
|
86
|
+
page.find("tbody#option_values", visible: true)
|
87
|
+
|
88
|
+
expect(all("tbody#option_values tr").select(&:visible?).count).to eq(1)
|
89
|
+
|
90
|
+
# Add a new option type
|
91
|
+
click_link "Add Option Value"
|
92
|
+
expect(all("tbody#option_values tr").select(&:visible?).count).to eq(2)
|
93
|
+
|
94
|
+
# Remove default option type
|
95
|
+
within("tbody#option_values") do
|
96
|
+
click_icon :delete
|
97
|
+
end
|
98
|
+
# Check that there was no HTTP request
|
99
|
+
expect(all("div#progress[style]").count).to eq(0)
|
100
|
+
# Assert that the field is hidden automatically
|
101
|
+
expect(all("tbody#option_values tr").select(&:visible?).count).to eq(1)
|
102
|
+
|
103
|
+
# Remove added option type
|
104
|
+
within("tbody#option_values") do
|
105
|
+
click_icon :delete
|
106
|
+
end
|
107
|
+
# Check that there was no HTTP request
|
108
|
+
expect(all("div#progress[style]").count).to eq(0)
|
109
|
+
# Assert that the field is hidden automatically
|
110
|
+
expect(all("tbody#option_values tr").select(&:visible?).count).to eq(0)
|
111
|
+
|
112
|
+
end
|
113
|
+
|
114
|
+
end
|
@@ -0,0 +1,445 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe "Products", type: :feature do
|
5
|
+
context "as admin user" do
|
6
|
+
stub_authorization!
|
7
|
+
|
8
|
+
def build_option_type_with_values(name, values)
|
9
|
+
ot = FactoryGirl.create(:option_type, name: name)
|
10
|
+
values.each do |val|
|
11
|
+
ot.option_values.create(name: val.downcase, presentation: val)
|
12
|
+
end
|
13
|
+
ot
|
14
|
+
end
|
15
|
+
|
16
|
+
context "listing products" do
|
17
|
+
context "sorting" do
|
18
|
+
before do
|
19
|
+
create(:product, name: 'apache baseball cap', price: 10)
|
20
|
+
create(:product, name: 'zomg shirt', price: 5)
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should list existing products with correct sorting by name" do
|
24
|
+
visit spree.admin_products_path
|
25
|
+
# Name ASC
|
26
|
+
within_row(1) { expect(page).to have_content('apache baseball cap') }
|
27
|
+
within_row(2) { expect(page).to have_content("zomg shirt") }
|
28
|
+
|
29
|
+
# Name DESC
|
30
|
+
click_link "admin_products_listing_name_title"
|
31
|
+
within_row(1) { expect(page).to have_content("zomg shirt") }
|
32
|
+
within_row(2) { expect(page).to have_content('apache baseball cap') }
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should list existing products with correct sorting by price" do
|
36
|
+
visit spree.admin_products_path
|
37
|
+
# Name ASC (default)
|
38
|
+
within_row(1) { expect(page).to have_content('apache baseball cap') }
|
39
|
+
within_row(2) { expect(page).to have_content("zomg shirt") }
|
40
|
+
|
41
|
+
# Price DESC
|
42
|
+
click_link "admin_products_listing_price_title"
|
43
|
+
within_row(1) { expect(page).to have_content("zomg shirt") }
|
44
|
+
within_row(2) { expect(page).to have_content('apache baseball cap') }
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
context "currency displaying" do
|
49
|
+
context "using Russian Rubles" do
|
50
|
+
before do
|
51
|
+
Spree::Config[:currency] = "RUB"
|
52
|
+
end
|
53
|
+
|
54
|
+
let!(:product) do
|
55
|
+
create(:product, name: "Just a product", price: 19.99)
|
56
|
+
end
|
57
|
+
|
58
|
+
# Regression test for #2737
|
59
|
+
context "uses руб as the currency symbol" do
|
60
|
+
it "on the products listing page" do
|
61
|
+
visit spree.admin_products_path
|
62
|
+
within_row(1) { expect(page).to have_content("19.99 ₽") }
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
context "searching products" do
|
70
|
+
it "should be able to search deleted products" do
|
71
|
+
create(:product, name: 'apache baseball cap', deleted_at: "2011-01-06 18:21:13")
|
72
|
+
create(:product, name: 'zomg shirt')
|
73
|
+
|
74
|
+
visit spree.admin_products_path
|
75
|
+
expect(page).to have_content("zomg shirt")
|
76
|
+
expect(page).not_to have_content("apache baseball cap")
|
77
|
+
|
78
|
+
check "Show Deleted"
|
79
|
+
click_on 'Search'
|
80
|
+
|
81
|
+
expect(page).to have_content("zomg shirt")
|
82
|
+
expect(page).to have_content("apache baseball cap")
|
83
|
+
|
84
|
+
uncheck "Show Deleted"
|
85
|
+
click_on 'Search'
|
86
|
+
|
87
|
+
expect(page).to have_content("zomg shirt")
|
88
|
+
expect(page).not_to have_content("apache baseball cap")
|
89
|
+
end
|
90
|
+
|
91
|
+
it "should be able to search products by their properties" do
|
92
|
+
create(:product, name: 'apache baseball cap', sku: "A100")
|
93
|
+
create(:product, name: 'apache baseball cap2', sku: "B100")
|
94
|
+
create(:product, name: 'zomg shirt')
|
95
|
+
|
96
|
+
visit spree.admin_products_path
|
97
|
+
fill_in "q_name_cont", with: "ap"
|
98
|
+
click_on 'Search'
|
99
|
+
|
100
|
+
expect(page).to have_content("apache baseball cap")
|
101
|
+
expect(page).to have_content("apache baseball cap2")
|
102
|
+
expect(page).not_to have_content("zomg shirt")
|
103
|
+
|
104
|
+
fill_in "q_variants_including_master_sku_cont", with: "A1"
|
105
|
+
click_on 'Search'
|
106
|
+
|
107
|
+
expect(page).to have_content("apache baseball cap")
|
108
|
+
expect(page).not_to have_content("apache baseball cap2")
|
109
|
+
expect(page).not_to have_content("zomg shirt")
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
context "creating a new product from a prototype", js: true do
|
114
|
+
def build_option_type_with_values(name, values)
|
115
|
+
ot = FactoryGirl.create(:option_type, name: name)
|
116
|
+
values.each do |val|
|
117
|
+
ot.option_values.create(name: val.downcase, presentation: val)
|
118
|
+
end
|
119
|
+
ot
|
120
|
+
end
|
121
|
+
|
122
|
+
let(:product_attributes) do
|
123
|
+
# FactoryGirl.attributes_for is un-deprecated!
|
124
|
+
# https://github.com/thoughtbot/factory_girl/issues/274#issuecomment-3592054
|
125
|
+
FactoryGirl.attributes_for(:simple_product)
|
126
|
+
end
|
127
|
+
|
128
|
+
let(:prototype) do
|
129
|
+
size = build_option_type_with_values("size", %w(Small Medium Large))
|
130
|
+
FactoryGirl.create(:prototype, name: "Size", option_types: [ size ])
|
131
|
+
end
|
132
|
+
|
133
|
+
let(:option_values_hash) do
|
134
|
+
hash = {}
|
135
|
+
prototype.option_types.each do |i|
|
136
|
+
hash[i.id.to_s] = i.option_value_ids
|
137
|
+
end
|
138
|
+
hash
|
139
|
+
end
|
140
|
+
|
141
|
+
before(:each) do
|
142
|
+
@option_type_prototype = prototype
|
143
|
+
@property_prototype = create(:prototype, name: "Random")
|
144
|
+
@shipping_category = create(:shipping_category)
|
145
|
+
visit spree.admin_products_path
|
146
|
+
click_link "admin_new_product"
|
147
|
+
within('#new_product') do
|
148
|
+
expect(page).to have_content("SKU")
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
it "should allow an admin to create a new product and variants from a prototype" do
|
153
|
+
fill_in "product_name", with: "Baseball Cap"
|
154
|
+
fill_in "product_sku", with: "B100"
|
155
|
+
fill_in "product_price", with: "100"
|
156
|
+
fill_in "product_available_on", with: "2012/01/24"
|
157
|
+
# Just so the datepicker gets out of poltergeists way.
|
158
|
+
page.execute_script("$('#ui-datepicker-div').hide();")
|
159
|
+
select "Size", from: "Prototype"
|
160
|
+
wait_for_ajax
|
161
|
+
check "Large"
|
162
|
+
select @shipping_category.name, from: "product_shipping_category_id"
|
163
|
+
click_button "Create"
|
164
|
+
expect(page).to have_content("successfully created!")
|
165
|
+
expect(Spree::Product.last.variants.length).to eq(1)
|
166
|
+
end
|
167
|
+
|
168
|
+
it "should not display variants when prototype does not contain option types" do
|
169
|
+
select "Random", from: "Prototype"
|
170
|
+
|
171
|
+
fill_in "product_name", with: "Baseball Cap"
|
172
|
+
|
173
|
+
expect(page).not_to have_content("Variants")
|
174
|
+
end
|
175
|
+
|
176
|
+
it "should keep option values selected if validation fails" do
|
177
|
+
fill_in "product_name", with: "Baseball Cap"
|
178
|
+
fill_in "product_sku", with: "B100"
|
179
|
+
fill_in "product_price", with: "100"
|
180
|
+
select "Size", from: "Prototype"
|
181
|
+
wait_for_ajax
|
182
|
+
check "Large"
|
183
|
+
click_button "Create"
|
184
|
+
expect(page).to have_content("Shipping Category can't be blank")
|
185
|
+
expect(field_labeled("Size")).to be_checked
|
186
|
+
expect(field_labeled("Large")).to be_checked
|
187
|
+
expect(field_labeled("Small")).not_to be_checked
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
191
|
+
context "creating a new product" do
|
192
|
+
before(:each) do
|
193
|
+
@shipping_category = create(:shipping_category)
|
194
|
+
visit spree.admin_products_path
|
195
|
+
click_link "admin_new_product"
|
196
|
+
within('#new_product') do
|
197
|
+
expect(page).to have_content("SKU")
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
it "should allow an admin to create a new product" do
|
202
|
+
fill_in "product_name", with: "Baseball Cap"
|
203
|
+
fill_in "product_sku", with: "B100"
|
204
|
+
fill_in "product_price", with: "100"
|
205
|
+
fill_in "product_available_on", with: "2012/01/24"
|
206
|
+
select @shipping_category.name, from: "product_shipping_category_id"
|
207
|
+
click_button "Create"
|
208
|
+
expect(page).to have_content("successfully created!")
|
209
|
+
click_button "Update"
|
210
|
+
expect(page).to have_content("successfully updated!")
|
211
|
+
end
|
212
|
+
|
213
|
+
it "should show validation errors" do
|
214
|
+
fill_in "product_name", with: "Baseball Cap"
|
215
|
+
fill_in "product_sku", with: "B100"
|
216
|
+
fill_in "product_price", with: "100"
|
217
|
+
click_button "Create"
|
218
|
+
expect(page).to have_content("Shipping Category can't be blank")
|
219
|
+
end
|
220
|
+
|
221
|
+
context "using a locale with a different decimal format " do
|
222
|
+
before do
|
223
|
+
# change English locale’s separator and delimiter to match 19,99 format
|
224
|
+
I18n.backend.store_translations(:en,
|
225
|
+
number: {
|
226
|
+
currency: {
|
227
|
+
format: {
|
228
|
+
separator: ",",
|
229
|
+
delimiter: "."
|
230
|
+
}
|
231
|
+
}
|
232
|
+
})
|
233
|
+
end
|
234
|
+
|
235
|
+
after do
|
236
|
+
# revert changes to English locale
|
237
|
+
I18n.backend.store_translations(:en,
|
238
|
+
number: {
|
239
|
+
currency: {
|
240
|
+
format: {
|
241
|
+
separator: ".",
|
242
|
+
delimiter: ","
|
243
|
+
}
|
244
|
+
}
|
245
|
+
})
|
246
|
+
end
|
247
|
+
|
248
|
+
it "should show localized price value on validation errors", js: true do
|
249
|
+
fill_in "product_price", with: "19,99"
|
250
|
+
click_button "Create"
|
251
|
+
expect(find('input#product_price').value).to eq('19,99')
|
252
|
+
end
|
253
|
+
end
|
254
|
+
|
255
|
+
# Regression test for #2097
|
256
|
+
it "can set the count on hand to a null value" do
|
257
|
+
fill_in "product_name", with: "Baseball Cap"
|
258
|
+
fill_in "product_price", with: "100"
|
259
|
+
select @shipping_category.name, from: "product_shipping_category_id"
|
260
|
+
click_button "Create"
|
261
|
+
expect(page).to have_content("successfully created!")
|
262
|
+
click_button "Update"
|
263
|
+
expect(page).to have_content("successfully updated!")
|
264
|
+
end
|
265
|
+
end
|
266
|
+
|
267
|
+
|
268
|
+
context "cloning a product", js: true do
|
269
|
+
it "should allow an admin to clone a product" do
|
270
|
+
create(:product)
|
271
|
+
|
272
|
+
visit spree.admin_products_path
|
273
|
+
within_row(1) do
|
274
|
+
click_icon :clone
|
275
|
+
end
|
276
|
+
|
277
|
+
expect(page).to have_content("Product has been cloned")
|
278
|
+
end
|
279
|
+
|
280
|
+
context "cloning a deleted product" do
|
281
|
+
it "should allow an admin to clone a deleted product" do
|
282
|
+
create(:product, name: "apache baseball cap")
|
283
|
+
|
284
|
+
visit spree.admin_products_path
|
285
|
+
click_on 'Filter'
|
286
|
+
check "Show Deleted"
|
287
|
+
click_on 'Search'
|
288
|
+
|
289
|
+
expect(page).to have_content("apache baseball cap")
|
290
|
+
|
291
|
+
within_row(1) do
|
292
|
+
click_icon :clone
|
293
|
+
end
|
294
|
+
|
295
|
+
expect(page).to have_content("Product has been cloned")
|
296
|
+
end
|
297
|
+
end
|
298
|
+
end
|
299
|
+
|
300
|
+
context 'updating a product' do
|
301
|
+
let(:product) { create(:product) }
|
302
|
+
|
303
|
+
let(:prototype) do
|
304
|
+
size = build_option_type_with_values("size", %w(Small Medium Large))
|
305
|
+
FactoryGirl.create(:prototype, name: "Size", option_types: [ size ])
|
306
|
+
end
|
307
|
+
|
308
|
+
before(:each) do
|
309
|
+
@option_type_prototype = prototype
|
310
|
+
@property_prototype = create(:prototype, name: "Random")
|
311
|
+
end
|
312
|
+
|
313
|
+
it 'should parse correctly available_on' do
|
314
|
+
visit spree.admin_product_path(product)
|
315
|
+
fill_in "product_available_on", with: "2012/12/25"
|
316
|
+
click_button "Update"
|
317
|
+
expect(page).to have_content("successfully updated!")
|
318
|
+
expect(Spree::Product.last.available_on.to_s).to eq("2012-12-25 00:00:00 UTC")
|
319
|
+
end
|
320
|
+
|
321
|
+
it 'should add option_types when selecting a prototype', js: true do
|
322
|
+
visit spree.admin_product_path(product)
|
323
|
+
within('#sidebar') do
|
324
|
+
click_link 'Properties'
|
325
|
+
end
|
326
|
+
click_link "Select From Prototype"
|
327
|
+
|
328
|
+
within("#prototypes tr#row_#{prototype.id}") do
|
329
|
+
click_link 'Select'
|
330
|
+
wait_for_ajax
|
331
|
+
end
|
332
|
+
|
333
|
+
within(:css, "tr.product_property:first-child") do
|
334
|
+
expect(first('input[type=text]').value).to eq('baseball_cap_color')
|
335
|
+
end
|
336
|
+
end
|
337
|
+
|
338
|
+
context "using a locale with a different decimal format" do
|
339
|
+
before do
|
340
|
+
# change English locale’s separator and delimiter to match 19,99 format
|
341
|
+
I18n.backend.store_translations(
|
342
|
+
:en,
|
343
|
+
number: {
|
344
|
+
currency: {
|
345
|
+
format: {
|
346
|
+
separator: ",",
|
347
|
+
delimiter: "."
|
348
|
+
}
|
349
|
+
},
|
350
|
+
format: {
|
351
|
+
separator: ",",
|
352
|
+
delimiter: "."
|
353
|
+
}
|
354
|
+
}
|
355
|
+
)
|
356
|
+
end
|
357
|
+
|
358
|
+
after do
|
359
|
+
# revert changes to English locale
|
360
|
+
I18n.backend.store_translations(
|
361
|
+
:en,
|
362
|
+
number: {
|
363
|
+
currency: {
|
364
|
+
format: {
|
365
|
+
separator: ".",
|
366
|
+
delimiter: ","
|
367
|
+
}
|
368
|
+
},
|
369
|
+
format: {
|
370
|
+
separator: ".",
|
371
|
+
delimiter: ","
|
372
|
+
}
|
373
|
+
}
|
374
|
+
)
|
375
|
+
end
|
376
|
+
|
377
|
+
it 'should parse correctly decimal values like weight' do
|
378
|
+
visit spree.admin_product_path(product)
|
379
|
+
fill_in 'product_weight', with: '1'
|
380
|
+
click_button 'Update'
|
381
|
+
weight_prev = find('#product_weight').value
|
382
|
+
click_button 'Update'
|
383
|
+
expect(find('#product_weight').value).to eq(weight_prev)
|
384
|
+
end
|
385
|
+
end
|
386
|
+
end
|
387
|
+
|
388
|
+
context 'deleting a product', js: true do
|
389
|
+
let!(:product) { create(:product) }
|
390
|
+
|
391
|
+
it "is still viewable" do
|
392
|
+
visit spree.admin_products_path
|
393
|
+
accept_alert do
|
394
|
+
click_icon :delete
|
395
|
+
wait_for_ajax
|
396
|
+
end
|
397
|
+
click_on 'Filter'
|
398
|
+
# This will show our deleted product
|
399
|
+
check "Show Deleted"
|
400
|
+
click_on 'Search'
|
401
|
+
click_link product.name
|
402
|
+
expect(find("#product_price").value.to_f).to eq(product.price.to_f)
|
403
|
+
end
|
404
|
+
end
|
405
|
+
end
|
406
|
+
|
407
|
+
context 'with only product permissions' do
|
408
|
+
|
409
|
+
before do
|
410
|
+
allow_any_instance_of(Spree::Admin::BaseController).to receive(:spree_current_user).and_return(nil)
|
411
|
+
end
|
412
|
+
|
413
|
+
custom_authorization! do |user|
|
414
|
+
can [:admin, :update, :index, :read], Spree::Product
|
415
|
+
end
|
416
|
+
let!(:product) { create(:product) }
|
417
|
+
|
418
|
+
it "should only display accessible links on index" do
|
419
|
+
visit spree.admin_products_path
|
420
|
+
|
421
|
+
expect(page).to have_link('Products')
|
422
|
+
expect(page).not_to have_link('Option Types')
|
423
|
+
expect(page).not_to have_link('Properties')
|
424
|
+
expect(page).not_to have_link('Prototypes')
|
425
|
+
expect(page).not_to have_link('New Product')
|
426
|
+
expect(page).not_to have_css('.icon-clone')
|
427
|
+
expect(page).to have_css('.icon-edit')
|
428
|
+
expect(page).not_to have_css('.delete-resource')
|
429
|
+
end
|
430
|
+
|
431
|
+
it "should only display accessible links on edit" do
|
432
|
+
visit spree.admin_product_path(product)
|
433
|
+
|
434
|
+
# product tabs should be hidden
|
435
|
+
expect(page).to have_link('Details')
|
436
|
+
expect(page).not_to have_link('Images')
|
437
|
+
expect(page).not_to have_link('Variants')
|
438
|
+
expect(page).not_to have_link('Properties')
|
439
|
+
expect(page).not_to have_link('Stock Management')
|
440
|
+
|
441
|
+
# no create permission
|
442
|
+
expect(page).not_to have_link('New Product')
|
443
|
+
end
|
444
|
+
end
|
445
|
+
end
|
@@ -0,0 +1,147 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "Properties", type: :feature, js: true do
|
4
|
+
stub_authorization!
|
5
|
+
|
6
|
+
before(:each) do
|
7
|
+
visit spree.admin_products_path
|
8
|
+
end
|
9
|
+
|
10
|
+
context "Property index" do
|
11
|
+
before do
|
12
|
+
create(:property, name: 'shirt size', presentation: 'size')
|
13
|
+
create(:property, name: 'shirt fit', presentation: 'fit')
|
14
|
+
click_link "Products"
|
15
|
+
click_link "Properties"
|
16
|
+
end
|
17
|
+
|
18
|
+
context "listing product properties" do
|
19
|
+
it "should list the existing product properties" do
|
20
|
+
within_row(1) do
|
21
|
+
expect(column_text(1)).to eq("shirt size")
|
22
|
+
expect(column_text(2)).to eq("size")
|
23
|
+
end
|
24
|
+
|
25
|
+
within_row(2) do
|
26
|
+
expect(column_text(1)).to eq("shirt fit")
|
27
|
+
expect(column_text(2)).to eq("fit")
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
context "searching properties" do
|
33
|
+
it 'should list properties matching search query' do
|
34
|
+
click_on "Filter"
|
35
|
+
fill_in "q_name_cont", with: "size"
|
36
|
+
click_on 'Search'
|
37
|
+
|
38
|
+
expect(page).to have_content("shirt size")
|
39
|
+
expect(page).not_to have_content("shirt fit")
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
context "creating a property" do
|
45
|
+
it "should allow an admin to create a new product property" do
|
46
|
+
click_link "Products"
|
47
|
+
click_link "Properties"
|
48
|
+
click_link "new_property_link"
|
49
|
+
within('.content-header') { expect(page).to have_content("New Property") }
|
50
|
+
|
51
|
+
fill_in "property_name", with: "color of band"
|
52
|
+
fill_in "property_presentation", with: "color"
|
53
|
+
click_button "Create"
|
54
|
+
expect(page).to have_content("successfully created!")
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
context "editing a property" do
|
59
|
+
before(:each) do
|
60
|
+
create(:property)
|
61
|
+
click_link "Products"
|
62
|
+
click_link "Properties"
|
63
|
+
within_row(1) { click_icon :edit }
|
64
|
+
end
|
65
|
+
|
66
|
+
it "should allow an admin to edit an existing product property" do
|
67
|
+
fill_in "property_name", with: "model 99"
|
68
|
+
click_button "Update"
|
69
|
+
expect(page).to have_content("successfully updated!")
|
70
|
+
expect(page).to have_content("model 99")
|
71
|
+
end
|
72
|
+
|
73
|
+
it "should show validation errors" do
|
74
|
+
fill_in "property_name", with: ""
|
75
|
+
click_button "Update"
|
76
|
+
expect(page).to have_content("Name can't be blank")
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
context "linking a property to a product" do
|
81
|
+
before do
|
82
|
+
create(:product)
|
83
|
+
visit spree.admin_products_path
|
84
|
+
click_icon :edit
|
85
|
+
within('#sidebar') do
|
86
|
+
click_link "Properties"
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
# Regression test for #2279
|
91
|
+
it "successfully create and then remove product property" do
|
92
|
+
fill_in_property
|
93
|
+
# Sometimes the page doesn't load before the all check is done
|
94
|
+
# lazily finding the element gives the page 10 seconds
|
95
|
+
expect(page).to have_css("tbody#product_properties tr:nth-child(2)")
|
96
|
+
expect(all("tbody#product_properties tr").count).to eq(2)
|
97
|
+
|
98
|
+
delete_product_property
|
99
|
+
|
100
|
+
check_property_row_count(1)
|
101
|
+
end
|
102
|
+
|
103
|
+
# Regression test for #4466
|
104
|
+
it "successfully remove and create a product property at the same time" do
|
105
|
+
fill_in_property
|
106
|
+
|
107
|
+
fill_in "product_product_properties_attributes_1_property_name", with: "New Property"
|
108
|
+
fill_in "product_product_properties_attributes_1_value", with: "New Value"
|
109
|
+
|
110
|
+
delete_product_property
|
111
|
+
|
112
|
+
# Give fadeOut time to complete
|
113
|
+
expect(page).not_to have_selector("#product_product_properties_attributes_0_property_name")
|
114
|
+
expect(page).not_to have_selector("#product_product_properties_attributes_0_value")
|
115
|
+
|
116
|
+
click_button "Update"
|
117
|
+
|
118
|
+
expect(page).not_to have_content("Product is not found")
|
119
|
+
|
120
|
+
check_property_row_count(2)
|
121
|
+
end
|
122
|
+
|
123
|
+
def fill_in_property
|
124
|
+
fill_in "product_product_properties_attributes_0_property_name", with: "A Property"
|
125
|
+
fill_in "product_product_properties_attributes_0_value", with: "A Value"
|
126
|
+
click_button "Update"
|
127
|
+
within('#sidebar') do
|
128
|
+
click_link "Properties"
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
def delete_product_property
|
133
|
+
accept_alert do
|
134
|
+
click_icon :delete
|
135
|
+
wait_for_ajax # delete action must finish before reloading
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
def check_property_row_count(expected_row_count)
|
140
|
+
within('#sidebar') do
|
141
|
+
click_link "Properties"
|
142
|
+
end
|
143
|
+
expect(page).to have_css("tbody#product_properties")
|
144
|
+
expect(all("tbody#product_properties tr").count).to eq(expected_row_count)
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|