solidus_marketplace 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +18 -0
- data/.rspec +1 -0
- data/.travis.yml +11 -0
- data/Gemfile +8 -0
- data/LICENSE +26 -0
- data/README.md +123 -0
- data/Rakefile +15 -0
- data/Versionfile +6 -0
- data/app/assets/javascripts/spree/backend/solidus_marketplace.js +5 -0
- data/app/assets/javascripts/spree/backend/solidus_marketplace_routes.js +1 -0
- data/app/assets/javascripts/spree/backend/suppliers_autocomplete.js +55 -0
- data/app/assets/javascripts/spree/frontend/solidus_marketplace.js +1 -0
- data/app/assets/stylesheets/spree/backend/solidus_marketplace.scss +22 -0
- data/app/assets/stylesheets/spree/frontend/solidus_marketplace.css +3 -0
- data/app/controllers/ckeditor/attachment_files_controller_decorator.rb +20 -0
- data/app/controllers/ckeditor/pictures_controller_decorator.rb +17 -0
- data/app/controllers/spree/admin/marketplace_settings_controller.rb +19 -0
- data/app/controllers/spree/admin/products_controller_decorator.rb +79 -0
- data/app/controllers/spree/admin/reports_controller_decorator.rb +68 -0
- data/app/controllers/spree/admin/shipments_controller.rb +47 -0
- data/app/controllers/spree/admin/stock_items_controller_decorator.rb +10 -0
- data/app/controllers/spree/admin/stock_locations_controller_decorator.rb +23 -0
- data/app/controllers/spree/admin/suppliers_controller.rb +54 -0
- data/app/controllers/spree/admin/users_controller_decorator.rb +34 -0
- data/app/controllers/spree/api/suppliers_controller.rb +16 -0
- data/app/controllers/spree/api/v1/stock_locations_controller_decorator.rb +18 -0
- data/app/controllers/spree/base_controller_decorator.rb +13 -0
- data/app/helpers/spree/api/api_helpers_decorator.rb +22 -0
- data/app/mailers/spree/marketplace_order_mailer.rb +13 -0
- data/app/mailers/spree/supplier_mailer.rb +12 -0
- data/app/models/ckeditor/asset_decorator.rb +5 -0
- data/app/models/spree.rb +5 -0
- data/app/models/spree/marketplace_configuration.rb +14 -0
- data/app/models/spree/order_decorator.rb +44 -0
- data/app/models/spree/payment_decorator.rb +7 -0
- data/app/models/spree/product_decorator.rb +52 -0
- data/app/models/spree/shipment_decorator.rb +40 -0
- data/app/models/spree/stock/splitter/marketplace.rb +47 -0
- data/app/models/spree/stock_location_decorator.rb +23 -0
- data/app/models/spree/supplier.rb +120 -0
- data/app/models/spree/supplier_ability.rb +35 -0
- data/app/models/spree/supplier_variant.rb +6 -0
- data/app/models/spree/user_decorator.rb +23 -0
- data/app/models/spree/variant_decorator.rb +24 -0
- data/app/overrides/spree/admin/menus.rb +15 -0
- data/app/overrides/spree/admin/products/_form/converted_admin_product_form_right.html.erb.deface +5 -0
- data/app/overrides/spree/admin/products/edit/override_rows.html.erb.deface +22 -0
- data/app/overrides/spree/admin/stock_locations/_form/add_supplier.html.erb.deface +12 -0
- data/app/views/spree/admin/marketplace_settings/edit.html.erb +21 -0
- data/app/views/spree/admin/orders/index.html.erb +187 -0
- data/app/views/spree/admin/products/_form.html.erb +198 -0
- data/app/views/spree/admin/reports/earnings.html.erb +34 -0
- data/app/views/spree/admin/shared/_marketplace_settings.html.erb +1 -0
- data/app/views/spree/admin/shared/_marketplace_tabs.html.erb +4 -0
- data/app/views/spree/admin/shipments/edit.html.erb +24 -0
- data/app/views/spree/admin/shipments/index.html.erb +93 -0
- data/app/views/spree/admin/suppliers/_form.html.erb +75 -0
- data/app/views/spree/admin/suppliers/edit.html.erb +22 -0
- data/app/views/spree/admin/suppliers/index.html.erb +68 -0
- data/app/views/spree/admin/suppliers/new.html.erb +17 -0
- data/app/views/spree/api/shared/_pagination.json.jbuilder +5 -0
- data/app/views/spree/api/suppliers/_supplier.json.jbuilder +1 -0
- data/app/views/spree/api/suppliers/index.json.jbuilder +4 -0
- data/app/views/spree/marketplace_order_mailer/supplier_order.html.erb +119 -0
- data/app/views/spree/shared/unauthorized.erb +1 -0
- data/app/views/spree/supplier_mailer/welcome.html.erb +53 -0
- data/config/locales/en.yml +107 -0
- data/config/locales/es.yml +133 -0
- data/config/routes.rb +24 -0
- data/db/default/spree/marketplace_roles.rb +14 -0
- data/db/migrate/20121006073854_create_suppliers.rb +20 -0
- data/db/migrate/20130216070944_product_belongs_to_supplier.rb +6 -0
- data/db/migrate/20130405005502_stock_locations_belongs_to_supplier.rb +6 -0
- data/db/migrate/20130405011127_user_belongs_to_supplier.rb +6 -0
- data/db/migrate/20130428063053_add_balanced_token_to_suppliers.rb +7 -0
- data/db/migrate/20130510181443_add_supplier_id_to_ckeditor_assets.rb +8 -0
- data/db/migrate/20130606220913_add_permalink_to_suppliers.rb +6 -0
- data/db/migrate/20140323170638_add_supplier_commission_to_shipments.rb +5 -0
- data/db/migrate/20140416184616_migrate_payment_and_commission.rb +7 -0
- data/db/migrate/20140529041325_create_spree_supplier_variants.rb +15 -0
- data/db/migrate/20171027180043_add_paypal_email_to_suppliers.rb +5 -0
- data/db/seeds.rb +8 -0
- data/lib/generators/solidus_marketplace/install/install_generator.rb +36 -0
- data/lib/solidus_marketplace.rb +6 -0
- data/lib/solidus_marketplace/engine.rb +53 -0
- data/lib/solidus_marketplace/factories.rb +107 -0
- data/lib/solidus_marketplace/version.rb +3 -0
- data/lib/spree/permitted_attributes_decorator.rb +18 -0
- data/lib/tasks/spree_sample.rake +72 -0
- data/log/awesome.log +1 -0
- data/script/rails +7 -0
- data/solidus_marketplace.gemspec +46 -0
- data/spec/features/admin/orders_spec.rb +11 -0
- data/spec/features/admin/products_spec.rb +25 -0
- data/spec/features/admin/return_authorizations_spec.rb +7 -0
- data/spec/features/admin/settings_spec.rb +33 -0
- data/spec/features/admin/shipments_spec.rb +80 -0
- data/spec/features/admin/stock_management_spec.rb +156 -0
- data/spec/features/admin/stock_spec.rb +98 -0
- data/spec/features/admin/suppliers_spec.rb +130 -0
- data/spec/models/spree/order_decorator_spec.rb +80 -0
- data/spec/models/spree/payment_decorator_spec.rb +7 -0
- data/spec/models/spree/product_decorator_spec.rb +56 -0
- data/spec/models/spree/shipment_decorator_spec.rb +48 -0
- data/spec/models/spree/stock/splitter/marketplace_spec.rb +62 -0
- data/spec/models/spree/stock_location_decorator_spec.rb +33 -0
- data/spec/models/spree/supplier_ability_spec.rb +182 -0
- data/spec/models/spree/supplier_spec.rb +123 -0
- data/spec/models/spree/supplier_variant_spec.rb +5 -0
- data/spec/models/spree/user_decorator_spec.rb +57 -0
- data/spec/models/spree/variant_decorator_spec.rb +7 -0
- data/spec/spec_helper.rb +91 -0
- data/spec/support/ability_helpers.rb +11 -0
- data/spec/support/integration_helpers.rb +15 -0
- metadata +473 -0
data/log/awesome.log
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Logfile created on 2016-07-17 08:42:50 +0100 by logger.rb/47272
|
data/script/rails
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
|
|
2
|
+
|
|
3
|
+
ENGINE_ROOT = File.expand_path('../..', __FILE__)
|
|
4
|
+
ENGINE_PATH = File.expand_path('../../lib/solidus_marketplace/engine', __FILE__)
|
|
5
|
+
|
|
6
|
+
require 'rails/all'
|
|
7
|
+
require 'rails/engine/commands'
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# encoding: UTF-8
|
|
2
|
+
|
|
3
|
+
lib = File.expand_path('../lib/', __FILE__)
|
|
4
|
+
$:.unshift lib unless $:.include?(lib)
|
|
5
|
+
require 'solidus_marketplace/version'
|
|
6
|
+
|
|
7
|
+
Gem::Specification.new do |s|
|
|
8
|
+
s.platform = Gem::Platform::RUBY
|
|
9
|
+
s.name = 'solidus_marketplace'
|
|
10
|
+
s.version = SolidusMarketplace::VERSION
|
|
11
|
+
s.summary = 'Solidus Marketplace Extension'
|
|
12
|
+
s.description = 'Adds marketplace functionality to Solidus stores.'
|
|
13
|
+
s.required_ruby_version = '>= 2.0.0'
|
|
14
|
+
|
|
15
|
+
s.author = 'Boomer Digital'
|
|
16
|
+
s.email = ''
|
|
17
|
+
s.homepage = 'https://github.com/boomerdigital/solidus_marketplace'
|
|
18
|
+
|
|
19
|
+
s.files = `git ls-files`.split("\n")
|
|
20
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
|
21
|
+
s.require_path = 'lib'
|
|
22
|
+
s.requirements << 'none'
|
|
23
|
+
|
|
24
|
+
s.add_dependency 'durable_decorator', '~> 0.2.0'
|
|
25
|
+
s.add_dependency 'solidus_api'
|
|
26
|
+
s.add_dependency 'solidus_backend'
|
|
27
|
+
s.add_dependency 'solidus_core'
|
|
28
|
+
s.add_dependency 'solidus_gateway'
|
|
29
|
+
|
|
30
|
+
s.add_development_dependency 'capybara', '~> 2.2'
|
|
31
|
+
s.add_development_dependency 'coffee-rails'
|
|
32
|
+
s.add_development_dependency 'coveralls'
|
|
33
|
+
s.add_development_dependency 'database_cleaner'
|
|
34
|
+
s.add_development_dependency 'factory_girl_rails', '~> 4.2'
|
|
35
|
+
s.add_development_dependency 'ffaker'
|
|
36
|
+
s.add_development_dependency 'launchy'
|
|
37
|
+
s.add_development_dependency 'rspec-rails'
|
|
38
|
+
s.add_development_dependency 'sass-rails', '~> 5.0.0.beta1'
|
|
39
|
+
s.add_development_dependency 'selenium-webdriver'
|
|
40
|
+
s.add_development_dependency 'shoulda-matchers'
|
|
41
|
+
s.add_development_dependency 'solidus_sample'
|
|
42
|
+
s.add_development_dependency 'sqlite3'
|
|
43
|
+
s.add_development_dependency 'log_buddy'
|
|
44
|
+
s.add_development_dependency 'awesome_print'
|
|
45
|
+
s.add_development_dependency 'pry'
|
|
46
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe 'Admin - Products', js: true do
|
|
4
|
+
|
|
5
|
+
context 'as Admin' do
|
|
6
|
+
|
|
7
|
+
xit 'should be able to change supplier' do
|
|
8
|
+
s1 = create(:supplier)
|
|
9
|
+
s2 = create(:supplier)
|
|
10
|
+
product = create :product
|
|
11
|
+
product.add_supplier! s1
|
|
12
|
+
|
|
13
|
+
login_user create(:admin_user)
|
|
14
|
+
visit spree.admin_product_path(product)
|
|
15
|
+
|
|
16
|
+
select2 s2.name, from: 'Supplier'
|
|
17
|
+
click_button 'Update'
|
|
18
|
+
|
|
19
|
+
expect(page).to have_content("Product \"#{product.name}\" has been successfully updated!")
|
|
20
|
+
expect(product.reload.suppliers.first.id).to eql(s2.id)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe 'Admin - Marketplace Settings' do
|
|
4
|
+
|
|
5
|
+
before do
|
|
6
|
+
login_user create(:admin_user)
|
|
7
|
+
|
|
8
|
+
visit spree.admin_path
|
|
9
|
+
within '[data-hook=admin_tabs]' do
|
|
10
|
+
click_link 'Settings'
|
|
11
|
+
end
|
|
12
|
+
within 'ul[data-hook=admin_configurations_sidebar_menu]' do
|
|
13
|
+
click_link 'Marketplace Settings'
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
xit 'should be able to be updated' do
|
|
18
|
+
# Change settings
|
|
19
|
+
uncheck 'send_supplier_email'
|
|
20
|
+
fill_in 'default_commission_flat_rate', with: 0.30
|
|
21
|
+
fill_in 'default_commission_percentage', with: 10
|
|
22
|
+
click_button 'Update'
|
|
23
|
+
expect(page).to have_content('Marketplace settings successfully updated.')
|
|
24
|
+
|
|
25
|
+
# Verify update saved properly by reversing checkboxes or checking field values.
|
|
26
|
+
check 'send_supplier_email'
|
|
27
|
+
click_button 'Update'
|
|
28
|
+
expect(find_field('default_commission_flat_rate').value.to_f).to eql(0.3)
|
|
29
|
+
expect(find_field('default_commission_percentage').value.to_f).to eql(10.0)
|
|
30
|
+
expect(page).to have_content('Marketplace settings successfully updated.')
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
end
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe 'Admin - Shipments', js: true do
|
|
4
|
+
|
|
5
|
+
context 'as Supplier' do
|
|
6
|
+
|
|
7
|
+
let!(:order) { build(:order_from_supplier_ready_to_ship, state: 'complete', completed_at: "2011-02-01 12:36:15", number: "R100") }
|
|
8
|
+
let!(:supplier) { create(:supplier) }
|
|
9
|
+
|
|
10
|
+
let!(:product) {
|
|
11
|
+
p = create(:product, name: 'spree t-shirt', price: 20.00)
|
|
12
|
+
p.add_supplier! supplier.id
|
|
13
|
+
p
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
let!(:shipment) { create(:shipment, order: order, stock_location: supplier.stock_locations.first) }
|
|
17
|
+
let!(:shipping_method) { create(:shipping_method, name: "Default") }
|
|
18
|
+
|
|
19
|
+
before do
|
|
20
|
+
# Adjust qoh so shipment will be ready
|
|
21
|
+
shipment.stock_location.stock_items.where(variant_id: product.master.id).first.adjust_count_on_hand(10)
|
|
22
|
+
# Add product and update shipment
|
|
23
|
+
order.contents.add(product.master, 2)
|
|
24
|
+
shipment.refresh_rates
|
|
25
|
+
shipment.update_state!(order)
|
|
26
|
+
shipment.update_amounts
|
|
27
|
+
|
|
28
|
+
# TODO this is a hack until capture_on_dispatch finished https://github.com/spree/spree/issues/4727
|
|
29
|
+
shipment.update_attribute :state, 'ready'
|
|
30
|
+
|
|
31
|
+
user = create(:user, supplier: supplier)
|
|
32
|
+
user.generate_spree_api_key!
|
|
33
|
+
login_user user
|
|
34
|
+
|
|
35
|
+
visit spree.edit_admin_shipment_path(shipment)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
context 'edit page' do
|
|
39
|
+
|
|
40
|
+
xit "can add tracking information" do
|
|
41
|
+
within '.table tr.show-tracking' do
|
|
42
|
+
click_icon :edit
|
|
43
|
+
end
|
|
44
|
+
within '.table tr.edit-tracking' do
|
|
45
|
+
fill_in "tracking", with: "FOOBAR"
|
|
46
|
+
click_icon :save
|
|
47
|
+
end
|
|
48
|
+
wait_for_ajax
|
|
49
|
+
within '.table tr.show-tracking' do
|
|
50
|
+
expect(page).to have_content("Tracking: FOOBAR")
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
xit "can change the shipping method" do
|
|
55
|
+
within(".table tr.show-method") do
|
|
56
|
+
click_icon :edit
|
|
57
|
+
end
|
|
58
|
+
select2 "Default", from: "Shipping Method"
|
|
59
|
+
click_icon :save
|
|
60
|
+
wait_for_ajax
|
|
61
|
+
|
|
62
|
+
expect(page).to have_content("Default $0.00")
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
xit "can ship a completed order" do
|
|
66
|
+
click_on "Ship"
|
|
67
|
+
wait_for_ajax
|
|
68
|
+
|
|
69
|
+
expect(page).to have_content("shipped package")
|
|
70
|
+
expect(order.reload.shipment_state).to eq "shipped"
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
xit 'should render unauthorized visiting another suppliers shipment' do
|
|
75
|
+
visit spree.edit_admin_shipment_path(create(:shipment))
|
|
76
|
+
expect(page).to have_content('Authorization Failure')
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
end
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe "Stock Management", js: true do
|
|
4
|
+
|
|
5
|
+
before do
|
|
6
|
+
@user = create(:supplier_user)
|
|
7
|
+
login_user @user
|
|
8
|
+
visit spree.admin_shipments_path
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
context "as supplier user" do
|
|
12
|
+
|
|
13
|
+
context "given a product with a variant and a stock location" do
|
|
14
|
+
before do
|
|
15
|
+
@secondary = create(:stock_location, name: 'Secondary', supplier: @user.supplier)
|
|
16
|
+
@product = create(:product, name: 'apache baseball cap', price: 10)
|
|
17
|
+
@v = @product.variants.create!(sku: 'FOOBAR')
|
|
18
|
+
@user.supplier.reload.stock_locations.update_all backorderable_default: false # True database default is false.
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
context 'with single variant' do
|
|
22
|
+
before do
|
|
23
|
+
@product.add_supplier! @user.supplier
|
|
24
|
+
@v.stock_items.first.update_column(:count_on_hand, 10)
|
|
25
|
+
@secondary.stock_item(@v).destroy
|
|
26
|
+
click_link "Products"
|
|
27
|
+
sleep(1)
|
|
28
|
+
within '#sidebar-product' do
|
|
29
|
+
click_link "Products"
|
|
30
|
+
end
|
|
31
|
+
click_link @product.name
|
|
32
|
+
within '[data-hook=admin_product_tabs]' do
|
|
33
|
+
click_link "Stock"
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
xit "should not show deleted stock_items" do
|
|
38
|
+
within(:css, '.stock_location_info') do
|
|
39
|
+
expect(page).to have_content(@user.supplier.name)
|
|
40
|
+
expect(page).to_not have_content('Secondary')
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
xit "can toggle backorderable for a variant's stock item", js: true do
|
|
45
|
+
backorderable = find(".stock_item_backorderable")
|
|
46
|
+
expect(backorderable).to_not be_checked
|
|
47
|
+
|
|
48
|
+
backorderable.set(true)
|
|
49
|
+
|
|
50
|
+
visit current_path
|
|
51
|
+
|
|
52
|
+
backorderable = find(".stock_item_backorderable")
|
|
53
|
+
expect(backorderable).to be_checked
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# Regression test for #2896
|
|
57
|
+
# The regression was that unchecking the last checkbox caused a redirect
|
|
58
|
+
# to happen. By ensuring that we're still on an /admin/products URL, we
|
|
59
|
+
# assert that the redirect is *not* happening.
|
|
60
|
+
xit "can toggle backorderable for the second variant stock item", js: true do
|
|
61
|
+
new_location = create(:stock_location, name: "Another Location", supplier: @user.supplier)
|
|
62
|
+
visit page.current_path
|
|
63
|
+
|
|
64
|
+
new_location_backorderable = find "#stock_item_backorderable_#{new_location.id}"
|
|
65
|
+
new_location_backorderable.set(false)
|
|
66
|
+
# Wait for API request to complete.
|
|
67
|
+
sleep(1)
|
|
68
|
+
|
|
69
|
+
expect(page.current_url).to include("/admin/products")
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
xit "can create a new stock movement", js: true do
|
|
73
|
+
fill_in "stock_movement_quantity", with: 5
|
|
74
|
+
select2 @user.supplier.name, from: "Stock Location"
|
|
75
|
+
click_button "Add Stock"
|
|
76
|
+
|
|
77
|
+
expect(page).to have_content('successfully created')
|
|
78
|
+
within(:css, '.stock_location_info table') do
|
|
79
|
+
expect(column_text(2)).to eq '15'
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
xit "can create a new negative stock movement", js: true do
|
|
84
|
+
fill_in "stock_movement_quantity", with: -5
|
|
85
|
+
select2 @user.supplier.name, from: "Stock Location"
|
|
86
|
+
click_button "Add Stock"
|
|
87
|
+
|
|
88
|
+
expect(page).to have_content('successfully created')
|
|
89
|
+
|
|
90
|
+
within(:css, '.stock_location_info table') do
|
|
91
|
+
expect(column_text(2)).to eq '5'
|
|
92
|
+
end
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
xit "can create a new negative stock movement", js: true do
|
|
96
|
+
fill_in "stock_movement_quantity", with: -5
|
|
97
|
+
select2 @user.supplier.name, from: "Stock Location"
|
|
98
|
+
click_button "Add Stock"
|
|
99
|
+
|
|
100
|
+
expect(page).to have_content('successfully created')
|
|
101
|
+
|
|
102
|
+
within(:css, '.stock_location_info table') do
|
|
103
|
+
expect(column_text(2)).to eq '5'
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
context "with multiple variants" do
|
|
109
|
+
before do
|
|
110
|
+
v = @product.variants.create!(sku: 'SPREEC')
|
|
111
|
+
@product.add_supplier! @user.supplier
|
|
112
|
+
v.stock_items.first.update_column(:count_on_hand, 30)
|
|
113
|
+
|
|
114
|
+
click_link "Products"
|
|
115
|
+
sleep(1)
|
|
116
|
+
within '#sidebar-product' do
|
|
117
|
+
click_link 'Products'
|
|
118
|
+
end
|
|
119
|
+
click_link @product.name
|
|
120
|
+
within '[data-hook=admin_product_tabs]' do
|
|
121
|
+
click_link "Stock"
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
xit "can create a new stock movement for the specified variant", js: true do
|
|
126
|
+
fill_in "stock_movement_quantity", with: 10
|
|
127
|
+
select2 "SPREEC", from: "Variant"
|
|
128
|
+
click_button "Add Stock"
|
|
129
|
+
|
|
130
|
+
expect(page).to have_content('successfully created')
|
|
131
|
+
end
|
|
132
|
+
end
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
# Regression test for #3304
|
|
136
|
+
context "with no stock location" do
|
|
137
|
+
before do
|
|
138
|
+
@product = create(:product, name: 'apache baseball cap', price: 10)
|
|
139
|
+
@product.add_supplier! @user.supplier
|
|
140
|
+
@product.variants.create!(sku: 'FOOBAR')
|
|
141
|
+
Spree::StockLocation.delete_all
|
|
142
|
+
click_link "Products"
|
|
143
|
+
sleep(1)
|
|
144
|
+
within '#sidebar-product' do
|
|
145
|
+
click_link 'Products'
|
|
146
|
+
end
|
|
147
|
+
click_link @product.name
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
xit "redirects to stock locations page" do
|
|
151
|
+
expect(page).to have_content(Spree.t(:stock_management_requires_a_stock_location))
|
|
152
|
+
expect(page.current_url).to include("admin/stock_locations")
|
|
153
|
+
end
|
|
154
|
+
end
|
|
155
|
+
end
|
|
156
|
+
end
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
feature 'Admin - Product Stock Management', js: true do
|
|
4
|
+
|
|
5
|
+
before do
|
|
6
|
+
@user = create(:supplier_admin)
|
|
7
|
+
@supplier1 = @user.supplier
|
|
8
|
+
@supplier2 = create(:supplier)
|
|
9
|
+
@product = create :product
|
|
10
|
+
@product.add_supplier! @supplier1
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
context 'as Admin' do
|
|
14
|
+
|
|
15
|
+
xscenario 'should display all existing stock item locations' do
|
|
16
|
+
login_user create(:admin_user)
|
|
17
|
+
visit spree.stock_admin_product_path(@product)
|
|
18
|
+
|
|
19
|
+
within '.stock_location_info' do
|
|
20
|
+
expect(page).to have_content(@supplier1.name)
|
|
21
|
+
# Stock item doesn't exist
|
|
22
|
+
expect(page).to_not have_content(@supplier2.name)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
context 'as Supplier' do
|
|
29
|
+
|
|
30
|
+
before(:each) do
|
|
31
|
+
login_user @user
|
|
32
|
+
visit '/admin/products'
|
|
33
|
+
click_link "Stock Locations"
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
xscenario 'should only display suppliers stock locations' do
|
|
37
|
+
visit spree.stock_admin_product_path(@product)
|
|
38
|
+
|
|
39
|
+
within '.stock_location_info' do
|
|
40
|
+
expect(page).to have_content(@supplier1.name)
|
|
41
|
+
expect(page).to_not have_content(@supplier2.name)
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
xscenario "can create a new stock location" do
|
|
46
|
+
visit spree.new_admin_stock_location_path
|
|
47
|
+
fill_in "Name", with: "London"
|
|
48
|
+
check "Active"
|
|
49
|
+
click_button "Create"
|
|
50
|
+
|
|
51
|
+
expect(page).to have_content("successfully created")
|
|
52
|
+
expect(page).to have_content("London")
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
xscenario "can delete an existing stock location", js: true do
|
|
56
|
+
create(:stock_location, supplier: @user.supplier)
|
|
57
|
+
visit current_path
|
|
58
|
+
|
|
59
|
+
expect(find('#listing_stock_locations')).to have_content("NY Warehouse")
|
|
60
|
+
within_row(2) { click_icon :delete }
|
|
61
|
+
page.driver.browser.switch_to.alert.accept
|
|
62
|
+
# Wait for API request to complete.
|
|
63
|
+
sleep(1)
|
|
64
|
+
visit current_path
|
|
65
|
+
|
|
66
|
+
expect(find('#listing_stock_locations')).to_not have_content("NY Warehouse")
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
scenario "can update an existing stock location" do
|
|
70
|
+
create(:stock_location, supplier: @user.supplier)
|
|
71
|
+
visit current_path
|
|
72
|
+
|
|
73
|
+
expect(page).to have_content("Big Store")
|
|
74
|
+
|
|
75
|
+
within_row(1) { click_icon :edit }
|
|
76
|
+
fill_in "Name", with: "London"
|
|
77
|
+
click_button "Update"
|
|
78
|
+
|
|
79
|
+
expect(page).to have_content("successfully updated")
|
|
80
|
+
expect(page).to have_content("London")
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
scenario "can deactivate an existing stock location" do
|
|
84
|
+
create(:stock_location, supplier: @user.supplier)
|
|
85
|
+
visit current_path
|
|
86
|
+
|
|
87
|
+
expect(page).to have_content("Big Store")
|
|
88
|
+
|
|
89
|
+
within_row(1) { click_icon :edit }
|
|
90
|
+
uncheck "Active"
|
|
91
|
+
click_button "Update"
|
|
92
|
+
|
|
93
|
+
expect(find('#listing_stock_locations')).to have_content("Inactive")
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
end
|