spree_backend 3.0.5 → 3.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +1 -0
- data/Gemfile +6 -0
- data/Rakefile +29 -0
- data/app/assets/javascripts/spree/backend/admin.js +26 -0
- data/app/controllers/spree/admin/resource_controller.rb +4 -2
- data/app/helpers/spree/admin/navigation_helper.rb +10 -1
- data/app/views/spree/admin/images/new.html.erb +1 -1
- data/app/views/spree/admin/payments/_list.html.erb +1 -1
- data/app/views/spree/admin/products/_form.html.erb +1 -1
- data/app/views/spree/admin/shared/_index_table_options.html.erb +1 -11
- data/app/views/spree/admin/shared/sub_menu/_product.html.erb +1 -1
- data/script/rails +9 -0
- 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 +42 -0
- data/spec/controllers/spree/admin/orders_controller_spec.rb +247 -0
- data/spec/controllers/spree/admin/payment_methods_controller_spec.rb +49 -0
- data/spec/controllers/spree/admin/payments_controller_spec.rb +97 -0
- data/spec/controllers/spree/admin/products_controller_spec.rb +53 -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 +276 -0
- data/spec/controllers/spree/admin/return_authorizations_controller_spec.rb +225 -0
- data/spec/controllers/spree/admin/return_items_controller_spec.rb +27 -0
- data/spec/controllers/spree/admin/root_controller_spec.rb +35 -0
- data/spec/controllers/spree/admin/search_controller_spec.rb +56 -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 +46 -0
- data/spec/features/admin/configuration/countries_spec.rb +24 -0
- data/spec/features/admin/configuration/general_settings_spec.rb +43 -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/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 +81 -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 +129 -0
- data/spec/features/admin/orders/cancelling_and_resuming_spec.rb +47 -0
- data/spec/features/admin/orders/customer_details_spec.rb +182 -0
- data/spec/features/admin/orders/line_items_spec.rb +51 -0
- data/spec/features/admin/orders/listing_spec.rb +225 -0
- data/spec/features/admin/orders/log_entries_spec.rb +55 -0
- data/spec/features/admin/orders/new_order_spec.rb +161 -0
- data/spec/features/admin/orders/order_details_spec.rb +620 -0
- data/spec/features/admin/orders/payments_spec.rb +229 -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 +64 -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 +113 -0
- data/spec/features/admin/products/products_spec.rb +394 -0
- data/spec/features/admin/products/properties_spec.rb +140 -0
- data/spec/features/admin/products/prototypes_spec.rb +112 -0
- data/spec/features/admin/products/stock_management_spec.rb +123 -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 +255 -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/reports_spec.rb +61 -0
- data/spec/features/admin/stock_transfer_spec.rb +75 -0
- data/spec/features/admin/taxons_spec.rb +47 -0
- data/spec/features/admin/users_spec.rb +284 -0
- data/spec/helpers/admin/base_helper_spec.rb +24 -0
- data/spec/helpers/admin/navigation_helper_spec.rb +106 -0
- data/spec/helpers/admin/stock_movements_helper_spec.rb +30 -0
- data/spec/helpers/promotion_rules_helper_spec.rb +12 -0
- data/spec/models/spree/resource_spec.rb +48 -0
- data/spec/spec_helper.rb +133 -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 +29 -0
- metadata +101 -14
@@ -0,0 +1,140 @@
|
|
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", js: true 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
|
+
click_link "Properties"
|
86
|
+
end
|
87
|
+
|
88
|
+
# Regression test for #2279
|
89
|
+
it "successfully create and then remove product property" do
|
90
|
+
fill_in_property
|
91
|
+
# Sometimes the page doesn't load before the all check is done
|
92
|
+
# lazily finding the element gives the page 10 seconds
|
93
|
+
expect(page).to have_css("tbody#product_properties tr:nth-child(2)")
|
94
|
+
expect(all("tbody#product_properties tr").count).to eq(2)
|
95
|
+
|
96
|
+
delete_product_property
|
97
|
+
|
98
|
+
check_property_row_count(1)
|
99
|
+
end
|
100
|
+
|
101
|
+
# Regression test for #4466
|
102
|
+
it "successfully remove and create a product property at the same time" do
|
103
|
+
fill_in_property
|
104
|
+
|
105
|
+
fill_in "product_product_properties_attributes_1_property_name", with: "New Property"
|
106
|
+
fill_in "product_product_properties_attributes_1_value", with: "New Value"
|
107
|
+
|
108
|
+
delete_product_property
|
109
|
+
|
110
|
+
# Give fadeOut time to complete
|
111
|
+
expect(page).not_to have_selector("#product_product_properties_attributes_0_property_name")
|
112
|
+
expect(page).not_to have_selector("#product_product_properties_attributes_0_value")
|
113
|
+
|
114
|
+
click_button "Update"
|
115
|
+
|
116
|
+
expect(page).not_to have_content("Product is not found")
|
117
|
+
|
118
|
+
check_property_row_count(2)
|
119
|
+
end
|
120
|
+
|
121
|
+
def fill_in_property
|
122
|
+
fill_in "product_product_properties_attributes_0_property_name", with: "A Property"
|
123
|
+
fill_in "product_product_properties_attributes_0_value", with: "A Value"
|
124
|
+
click_button "Update"
|
125
|
+
click_link "Properties"
|
126
|
+
end
|
127
|
+
|
128
|
+
def delete_product_property
|
129
|
+
page.evaluate_script('window.confirm = function() { return true; }')
|
130
|
+
click_icon :delete
|
131
|
+
wait_for_ajax # delete action must finish before reloading
|
132
|
+
end
|
133
|
+
|
134
|
+
def check_property_row_count(expected_row_count)
|
135
|
+
click_link "Properties"
|
136
|
+
expect(page).to have_css("tbody#product_properties")
|
137
|
+
expect(all("tbody#product_properties tr").count).to eq(expected_row_count)
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
@@ -0,0 +1,112 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "Prototypes", type: :feature, js: true do
|
4
|
+
stub_authorization!
|
5
|
+
|
6
|
+
context "listing prototypes" do
|
7
|
+
it "should be able to list existing prototypes" do
|
8
|
+
create(:property, name: "model", presentation: "Model")
|
9
|
+
create(:property, name: "brand", presentation: "Brand")
|
10
|
+
create(:property, name: "shirt_fabric", presentation: "Fabric")
|
11
|
+
create(:property, name: "shirt_sleeve_length", presentation: "Sleeve")
|
12
|
+
create(:property, name: "mug_type", presentation: "Type")
|
13
|
+
create(:property, name: "bag_type", presentation: "Type")
|
14
|
+
create(:property, name: "manufacturer", presentation: "Manufacturer")
|
15
|
+
create(:property, name: "bag_size", presentation: "Size")
|
16
|
+
create(:property, name: "mug_size", presentation: "Size")
|
17
|
+
create(:property, name: "gender", presentation: "Gender")
|
18
|
+
create(:property, name: "shirt_fit", presentation: "Fit")
|
19
|
+
create(:property, name: "bag_material", presentation: "Material")
|
20
|
+
create(:property, name: "shirt_type", presentation: "Type")
|
21
|
+
p = create(:prototype, name: "Shirt")
|
22
|
+
%w( brand gender manufacturer model shirt_fabric shirt_fit shirt_sleeve_length shirt_type ).each do |prop|
|
23
|
+
p.properties << Spree::Property.find_by_name(prop)
|
24
|
+
end
|
25
|
+
p = create(:prototype, name: "Mug")
|
26
|
+
%w( mug_size mug_type ).each do |prop|
|
27
|
+
p.properties << Spree::Property.find_by_name(prop)
|
28
|
+
end
|
29
|
+
p = create(:prototype, name: "Bag")
|
30
|
+
%w( bag_type bag_material ).each do |prop|
|
31
|
+
p.properties << Spree::Property.find_by_name(prop)
|
32
|
+
end
|
33
|
+
|
34
|
+
visit spree.admin_path
|
35
|
+
click_link "Products"
|
36
|
+
click_link "Prototypes"
|
37
|
+
|
38
|
+
within_row(1) { expect(column_text(1)).to eq "Shirt" }
|
39
|
+
within_row(2) { expect(column_text(1)).to eq "Mug" }
|
40
|
+
within_row(3) { expect(column_text(1)).to eq "Bag" }
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
context "creating a prototype" do
|
45
|
+
it "should allow an admin to create a new product prototype" do
|
46
|
+
visit spree.admin_path
|
47
|
+
click_link "Products"
|
48
|
+
click_link "Prototypes"
|
49
|
+
|
50
|
+
click_link "new_prototype_link"
|
51
|
+
within('.content-header') do
|
52
|
+
expect(page).to have_content("New Prototype")
|
53
|
+
end
|
54
|
+
fill_in "prototype_name", with: "male shirts"
|
55
|
+
click_button "Create"
|
56
|
+
expect(page).to have_content("successfully created!")
|
57
|
+
click_link "Products"
|
58
|
+
click_link "Prototypes"
|
59
|
+
within_row(1) { click_icon :edit }
|
60
|
+
fill_in "prototype_name", with: "Shirt 99"
|
61
|
+
click_button "Update"
|
62
|
+
expect(page).to have_content("successfully updated!")
|
63
|
+
expect(page).to have_content("Shirt 99")
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
context "editing a prototype" do
|
68
|
+
it "should allow to empty its properties" do
|
69
|
+
model_property = create(:property, name: "model", presentation: "Model")
|
70
|
+
brand_property = create(:property, name: "brand", presentation: "Brand")
|
71
|
+
|
72
|
+
shirt_prototype = create(:prototype, name: "Shirt", properties: [])
|
73
|
+
%w( brand model ).each do |prop|
|
74
|
+
shirt_prototype.properties << Spree::Property.find_by_name(prop)
|
75
|
+
end
|
76
|
+
|
77
|
+
visit spree.admin_path
|
78
|
+
click_link "Products"
|
79
|
+
click_link "Prototypes"
|
80
|
+
|
81
|
+
click_icon :edit
|
82
|
+
property_ids = find_field("prototype_property_ids").value.map(&:to_i)
|
83
|
+
expect(property_ids).to match_array [model_property.id, brand_property.id]
|
84
|
+
|
85
|
+
unselect "Brand", from: "prototype_property_ids"
|
86
|
+
unselect "Model", from: "prototype_property_ids"
|
87
|
+
|
88
|
+
click_button 'Update'
|
89
|
+
|
90
|
+
click_icon :edit
|
91
|
+
|
92
|
+
expect(find_field("prototype_property_ids").value).to be_empty
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
it 'should be deletable', js: true do
|
97
|
+
shirt_prototype = create(:prototype, name: "Shirt", properties: [])
|
98
|
+
shirt_prototype.taxons << create(:taxon)
|
99
|
+
|
100
|
+
visit spree.admin_path
|
101
|
+
click_link "Products"
|
102
|
+
click_link "Prototypes"
|
103
|
+
|
104
|
+
within("#spree_prototype_#{shirt_prototype.id}") do
|
105
|
+
page.find('.delete-resource').click
|
106
|
+
end
|
107
|
+
|
108
|
+
page.evaluate_script('window.confirm = function() { return true; }')
|
109
|
+
|
110
|
+
expect(page).to have_content("Prototype \"#{shirt_prototype.name}\" has been successfully removed!")
|
111
|
+
end
|
112
|
+
end
|
@@ -0,0 +1,123 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "Stock Management", type: :feature, js: true do
|
4
|
+
stub_authorization!
|
5
|
+
|
6
|
+
context "given a product with a variant and a stock location" do
|
7
|
+
let!(:stock_location) { create(:stock_location, name: 'Default') }
|
8
|
+
let!(:product) { create(:product, name: 'apache baseball cap', price: 10) }
|
9
|
+
let!(:variant) { product.master }
|
10
|
+
|
11
|
+
before do
|
12
|
+
stock_location.stock_item(variant).update_column(:count_on_hand, 10)
|
13
|
+
visit spree.stock_admin_product_path(product)
|
14
|
+
end
|
15
|
+
|
16
|
+
context "toggle backorderable for a variant's stock item" do
|
17
|
+
let(:backorderable) { find ".stock_item_backorderable" }
|
18
|
+
|
19
|
+
before do
|
20
|
+
expect(backorderable).to be_checked
|
21
|
+
backorderable.set(false)
|
22
|
+
wait_for_ajax
|
23
|
+
end
|
24
|
+
|
25
|
+
it "persists the value when page reload", js: true do
|
26
|
+
visit current_path
|
27
|
+
expect(backorderable).not_to be_checked
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
context "toggle track inventory for a variant's stock item" do
|
32
|
+
let(:track_inventory) { find ".track_inventory_checkbox" }
|
33
|
+
|
34
|
+
before do
|
35
|
+
expect(track_inventory).to be_checked
|
36
|
+
track_inventory.set(false)
|
37
|
+
wait_for_ajax
|
38
|
+
end
|
39
|
+
|
40
|
+
it "persists the value when page reloaded", js: true do
|
41
|
+
visit current_path
|
42
|
+
expect(track_inventory).not_to be_checked
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
# Regression test for #2896
|
47
|
+
# The regression was that unchecking the last checkbox caused a redirect
|
48
|
+
# to happen. By ensuring that we're still on an /admin/products URL, we
|
49
|
+
# assert that the redirect is *not* happening.
|
50
|
+
it "can toggle backorderable for the second variant stock item", js: true do
|
51
|
+
new_location = create(:stock_location, name: "Another Location")
|
52
|
+
visit current_url
|
53
|
+
|
54
|
+
new_location_backorderable = find "#stock_item_backorderable_#{new_location.id}"
|
55
|
+
new_location_backorderable.set(false)
|
56
|
+
wait_for_ajax
|
57
|
+
|
58
|
+
expect(page.current_url).to include("/admin/products")
|
59
|
+
end
|
60
|
+
|
61
|
+
it "can create a new stock movement", js: true do
|
62
|
+
fill_in "stock_movement_quantity", with: 5
|
63
|
+
select2 "default", from: "Stock Location"
|
64
|
+
click_button "Add Stock"
|
65
|
+
|
66
|
+
expect(page).to have_content('successfully created')
|
67
|
+
|
68
|
+
within(:css, '.stock_location_info table') do
|
69
|
+
expect(column_text(2)).to eq '15'
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
it "can create a new negative stock movement", js: true do
|
74
|
+
fill_in "stock_movement_quantity", with: -5
|
75
|
+
select2 "default", from: "Stock Location"
|
76
|
+
click_button "Add Stock"
|
77
|
+
|
78
|
+
expect(page).to have_content('successfully created')
|
79
|
+
|
80
|
+
within(:css, '.stock_location_info table') do
|
81
|
+
expect(column_text(2)).to eq '5'
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
context "with multiple variants" do
|
86
|
+
before do
|
87
|
+
variant = product.variants.create!(sku: 'SPREEC')
|
88
|
+
variant.stock_items.first.update_column(:count_on_hand, 30)
|
89
|
+
visit current_url
|
90
|
+
end
|
91
|
+
|
92
|
+
it "can create a new stock movement for the specified variant", js: true do
|
93
|
+
fill_in "stock_movement_quantity", with: 10
|
94
|
+
select2 "SPREEC", from: "Variant"
|
95
|
+
click_button "Add Stock"
|
96
|
+
|
97
|
+
expect(page).to have_content('successfully created')
|
98
|
+
|
99
|
+
within("#listing_product_stock tr", :text => "SPREEC") do
|
100
|
+
within("table") do
|
101
|
+
expect(column_text(2)).to eq '40'
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
# Regression test for #3304
|
108
|
+
context "with no stock location" do
|
109
|
+
before do
|
110
|
+
@product = create(:product, name: 'apache baseball cap', price: 10)
|
111
|
+
v = @product.variants.create!(sku: 'FOOBAR')
|
112
|
+
Spree::StockLocation.delete_all
|
113
|
+
|
114
|
+
visit spree.stock_admin_product_path(@product)
|
115
|
+
end
|
116
|
+
|
117
|
+
it "redirects to stock locations page" do
|
118
|
+
expect(page).to have_content(Spree.t(:stock_management_requires_a_stock_location))
|
119
|
+
expect(page.current_url).to include("admin/stock_locations")
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "Taxonomies", 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 "show" do
|
12
|
+
it "should display existing taxonomies" do
|
13
|
+
create(:taxonomy, name: 'Brand')
|
14
|
+
create(:taxonomy, name: 'Categories')
|
15
|
+
click_link "Taxonomies"
|
16
|
+
within_row(1) { expect(page).to have_content("Brand") }
|
17
|
+
within_row(2) { expect(page).to have_content("Categories") }
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
context "create" do
|
22
|
+
before(:each) do
|
23
|
+
click_link "Taxonomies"
|
24
|
+
click_link "admin_new_taxonomy_link"
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should allow an admin to create a new taxonomy" do
|
28
|
+
expect(page).to have_content("New Taxonomy")
|
29
|
+
fill_in "taxonomy_name", with: "sports"
|
30
|
+
click_button "Create"
|
31
|
+
expect(page).to have_content("successfully created!")
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should display validation errors" do
|
35
|
+
fill_in "taxonomy_name", with: ""
|
36
|
+
click_button "Create"
|
37
|
+
expect(page).to have_content("can't be blank")
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
context "edit" do
|
42
|
+
it "should allow an admin to update an existing taxonomy" do
|
43
|
+
create(:taxonomy)
|
44
|
+
click_link "Taxonomies"
|
45
|
+
within_row(1) { click_icon :edit }
|
46
|
+
fill_in "taxonomy_name", with: "sports 99"
|
47
|
+
click_button "Update"
|
48
|
+
expect(page).to have_content("successfully updated!")
|
49
|
+
expect(page).to have_content("sports 99")
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe "Variants", type: :feature, js: true do
|
5
|
+
stub_authorization!
|
6
|
+
|
7
|
+
let(:product) { create(:product_with_option_types, price: "1.99", cost_price: "1.00", weight: "2.5", height: "3.0", width: "1.0", depth: "1.5") }
|
8
|
+
|
9
|
+
context "creating a new variant" do
|
10
|
+
it "should allow an admin to create a new variant" do
|
11
|
+
product.options.each do |option|
|
12
|
+
create(:option_value, option_type: option.option_type)
|
13
|
+
end
|
14
|
+
|
15
|
+
visit spree.admin_products_path
|
16
|
+
within_row(1) { click_icon :edit }
|
17
|
+
click_link "Variants"
|
18
|
+
click_on "Add One"
|
19
|
+
expect(find('input#variant_price').value).to eq("1.99")
|
20
|
+
expect(find('input#variant_cost_price').value).to eq("1.00")
|
21
|
+
expect(find('input#variant_weight').value).to eq("2.50")
|
22
|
+
expect(find('input#variant_height').value).to eq("3.00")
|
23
|
+
expect(find('input#variant_width').value).to eq("1.00")
|
24
|
+
expect(find('input#variant_depth').value).to eq("1.50")
|
25
|
+
expect(page).to have_select('variant[tax_category_id]')
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
context "listing variants" do
|
30
|
+
context "currency displaying" do
|
31
|
+
context "using Russian Rubles" do
|
32
|
+
before do
|
33
|
+
Spree::Config[:currency] = "RUB"
|
34
|
+
end
|
35
|
+
|
36
|
+
let!(:variant) do
|
37
|
+
create(:variant, product: product, price: 19.99)
|
38
|
+
end
|
39
|
+
|
40
|
+
# Regression test for #2737
|
41
|
+
context "uses руб as the currency symbol" do
|
42
|
+
it "on the products listing page" do
|
43
|
+
visit spree.admin_product_variants_path(product)
|
44
|
+
within_row(1) { expect(page).to have_content("19.99 ₽") }
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|