spree_multi_vendor 2.2.0 → 2.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/.github/dependabot.yml +7 -0
  3. data/.travis.yml +1 -8
  4. data/Gemfile +5 -2
  5. data/README.md +39 -24
  6. data/app/controllers/spree/admin/vendor_settings_controller.rb +1 -1
  7. data/app/controllers/spree/admin/vendors_controller.rb +10 -2
  8. data/app/controllers/spree/api/v1/vendors_controller.rb +1 -1
  9. data/app/controllers/spree/api/v2/storefront/vendors_controller.rb +6 -1
  10. data/app/controllers/spree_multi_vendor/spree/api/base_controller_decorator.rb +2 -2
  11. data/app/controllers/spree_multi_vendor/spree/api/v1/products_controller_decorator.rb +1 -1
  12. data/app/controllers/spree_multi_vendor/spree/api/v1/users_controller_decorator.rb +1 -1
  13. data/app/finders/spree_multi_vendor/products_finder_decorator.rb +1 -1
  14. data/app/helpers/spree_multi_vendor/spree/api/api_helpers_decorator.rb +1 -1
  15. data/app/models/spree/vendor.rb +1 -1
  16. data/app/models/spree/vendor_ability.rb +1 -1
  17. data/app/models/spree_multi_vendor/spree/variant_decorator.rb +0 -1
  18. data/app/overrides/spree/admin/users/_form.rb +1 -1
  19. data/app/views/spree/admin/vendor_settings/edit.html.erb +1 -1
  20. data/app/views/spree/admin/vendors/_form.html.erb +1 -1
  21. data/app/views/spree/admin/vendors/index.html.erb +1 -1
  22. data/config/initializers/spree_permitted_attributes.rb +0 -2
  23. data/config/locales/es.yml +3 -0
  24. data/config/routes.rb +1 -1
  25. data/db/migrate/20210728120649_change_vendorized_models_vendor_id_type.rb +10 -0
  26. data/db/migrate/20210728120910_change_vendor_id_and_user_id_type_for_spree_vendor_users.rb +14 -0
  27. data/db/migrate/20210728121024_change_vendor_id_and_order_id_type_for_spree_order_commissions.rb +14 -0
  28. data/{app/models → lib}/spree_multi_vendor/configuration.rb +0 -0
  29. data/lib/spree_multi_vendor/engine.rb +10 -0
  30. data/lib/spree_multi_vendor/version.rb +1 -1
  31. data/lib/spree_multi_vendor.rb +3 -1
  32. data/spec/factories/spree/vendor_factory.rb +6 -0
  33. data/spec/features/spree/admin/orders_spec.rb +5 -4
  34. data/spec/features/spree/admin/vendor_settings_spec.rb +6 -8
  35. data/spec/requests/spree/api/v2/storefront/products_spec.rb +2 -1
  36. data/spec/requests/spree/api/v2/storefront/vendors_spec.rb +66 -0
  37. data/spec/spec_helper.rb +3 -1
  38. data/spree_multi_vendor.gemspec +5 -4
  39. metadata +20 -37
  40. data/Appraisals +0 -11
  41. data/gemfiles/spree_4_2.gemfile +0 -9
  42. data/gemfiles/spree_master.gemfile +0 -9
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b4a9ea707b2e1f2dd0c5ac2b71c82c1334ca991cb0e80cd26f35cc6e95234d06
4
- data.tar.gz: 777150a6db369707f55927a5e5066e93de22070b190539a07de79b616e028182
3
+ metadata.gz: c5387ab5edeed4f158bfb7e5f264800ea5b02efc14c2048957501948c406dcca
4
+ data.tar.gz: 523fd3aea41eea77295a9f34d33ee3bcfb08dd9b615ddba74eda769b8e65f326
5
5
  SHA512:
6
- metadata.gz: 7b084940266d45faf272d01d3ef2e4c638476b51d736f2232879427218d0c04345c1d0494f3c1eaabbd37c8e50c68712f1e87ee1fc837c12a318451f2554fc56
7
- data.tar.gz: 3a52b9945c79a47af00d3e99965176cf89cce11adce7c5cd89573ec685b41cc0d08242d4f302d5c3f07ec1c4a50c7463e53cb9e3eb5a25eb7d62c8c36cb04af4
6
+ metadata.gz: 9a8768042a152773ff4059c05c4e49f5102048cc3538e0289a9f015daa4afe0bae20124bbd8a96f61bb4d2a6f48033b4c4f2cbefcc1650c1e1ff83211f6b20b6
7
+ data.tar.gz: 97901fc6622e7d5c208656630865c01da883cac4ee158309b62bce59984c69357b971a128257dca459e556ced2097ce3ecb5aec664b297ebeb0eaffb31dc2b18
@@ -0,0 +1,7 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: bundler
4
+ directory: "/"
5
+ schedule:
6
+ interval: daily
7
+ open-pull-requests-limit: 10
data/.travis.yml CHANGED
@@ -11,6 +11,7 @@ addons:
11
11
  services:
12
12
  - mysql
13
13
  - postgresql
14
+ - redis-server
14
15
 
15
16
  language: ruby
16
17
 
@@ -22,14 +23,6 @@ env:
22
23
  - DB=mysql
23
24
  - DB=postgres
24
25
 
25
- gemfile:
26
- - gemfiles/spree_4_2.gemfile
27
- - gemfiles/spree_master.gemfile
28
-
29
- jobs:
30
- allow_failures:
31
- - gemfile: gemfiles/spree_master.gemfile
32
-
33
26
  before_install:
34
27
  - mysql -u root -e "GRANT ALL ON *.* TO 'travis'@'%';"
35
28
 
data/Gemfile CHANGED
@@ -1,7 +1,10 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gem 'spree', github: 'spree/spree', branch: 'master'
4
- gem 'spree_auth_devise', github: 'spree/spree_auth_devise', branch: 'master'
3
+ gem 'spree', github: 'spree/spree', branch: 'main'
4
+ gem 'spree_backend', github: 'spree/spree_backend', branch: 'main'
5
+ gem 'spree_frontend', github: 'spree/spree_legacy_frontend', branch: 'main'
6
+ gem 'spree_emails', github: 'spree/spree', branch: 'main'
7
+ gem 'spree_auth_devise', github: 'spree/spree_auth_devise', branch: 'main'
5
8
  gem 'rails-controller-testing'
6
9
 
7
10
  gemspec
data/README.md CHANGED
@@ -1,30 +1,31 @@
1
1
  # Spree Multi Vendor
2
2
 
3
- [![Build Status](https://travis-ci.org/spree-contrib/spree_multi_vendor.svg?branch=master)](https://travis-ci.org/spree-contrib/spree_multi_vendor)
4
-
5
3
  This is a [spree multi vendor marketplace](https://spreecommerce.org/use-cases/multi-vendor-marketplace/) extension. It's a great starting point if you're building a marketplace on top of [Spree](https://spreecommerce.org). Our goal was flexibility to allow you to tweak it to your needs.
6
4
 
7
- Check out this extension [multi vendor marketplace demo](https://spreecommerce.org/launch-a-multi-vendor-marketplace-within-a-few-weeks-with-spree-commerce/) and launch your marketplace within weeks, not months.
8
-
9
- Developed and maintained by:
10
-
11
- [![Spark Solutions](http://sparksolutions.co/wp-content/uploads/2015/01/logo-ss-tr-221x100.png)][spark]
5
+ ## Developed by
12
6
 
13
- ## Features
7
+ [![Vendo](https://assets-global.website-files.com/6230c485f2c32ea1b0daa438/623372f40a8c54ca9aea34e8_vendo%202.svg)](https://getvendo.com?utm_source=spree_multi_vendor_github)
14
8
 
15
- By default you can create and manage Vendors who can manage on their own:
9
+ > All-in-one platform for all your Marketplace and B2B eCommerce needs. [Start your 30-day free trial](https://e98esoirr8c.typeform.com/contactvendo?typeform-source=spree_multi_vendor_github)
16
10
 
17
- - [X] Orders
18
- - [X] Products
19
- - [X] Stock Locations
20
- - [X] Shipping Methods
21
- - [X] Vendor profile
11
+ ## Open source vs Vendo
22
12
 
23
- Also:
24
- - [X] Super Admins can assign Users to Vendors
25
- - [X] You can modify which permissions and models/resources Vendors can manage quite easily
13
+ If you need a product that has all of the features out of the box, such us supplier onboarding, Stripe connect payment splitting and payouts, and don't require any custom development - we recommend using [Vendo](http://getvendo.com?utm_source=spree_multi_vendor_github) which is also based on Spree.
26
14
 
27
- Contributions welcome! :)
15
+ | feature | open source | [vendo] |
16
+ |---|---|---|
17
+ | basic vendorization | ✔️ | ✔️ |
18
+ | supplier onboarding | | ✔️ |
19
+ | supplier dashboard | | ✔️ |
20
+ | supplier management | | ✔️ |
21
+ | supplier product curation | | ✔️ |
22
+ | automatic payment splitting | | ✔️ |
23
+ | automatic payouts | | ✔️ |
24
+ | Afterpay / klarna / apple pay | | ✔️ |
25
+ | shopify / bigcommerce / woocommerce integration | | ✔️ |
26
+ | USPS, UPS, FedEx, DHL, and more | | ✔️ |
27
+ | bulk upload / import of products from CSV and XSLX | | ✔️ |
28
+ | bulk export of orders, shipments and more | | ✔️ |
28
29
 
29
30
  ## Installation
30
31
 
@@ -97,6 +98,17 @@ Spree Multi Vendor adds new [API v2](https://api.spreecommerce.org/docs/api-v2/a
97
98
 
98
99
  `/api/v2/storefront/vendors/test-vendor?include=image,products`
99
100
 
101
+ 2. `GET` Returns a list of Vendors
102
+
103
+ ```
104
+ /api/v2/storefront/vendors
105
+ ```
106
+
107
+ you can also include Vendor image and/or Products in that call:
108
+
109
+ `/api/v2/storefront/vendors?include=image,products`
110
+
111
+
100
112
  And modfies existing:
101
113
 
102
114
  1. `GET` Filtering Products by Vendor ID(s):
@@ -154,13 +166,16 @@ and may be redistributed under the terms specified in the
154
166
 
155
167
  [LICENSE]: https://github.com/spark-solutions/spree_braintree_vzero/blob/master/LICENSE
156
168
 
157
- ## About Spark Solutions
169
+ ## About Vendo
170
+
171
+ <a href="https://getvendo.com?utm_source=spree_multi_vendor_github">
172
+ <img src="https://uploads-ssl.webflow.com/6230c485f2c32ea1b0daa438/62386b96518cdcbe111f134a_OG%20Image%20(2).png" style="max-height:400px" />
173
+ </a>
158
174
 
159
- [![Spark Solutions](http://sparksolutions.co/wp-content/uploads/2015/01/logo-ss-tr-221x100.png)][spark]
175
+ > [Vendo][vendo] is a great fit for marketplaces of all sizes - either with own fulfillment and multiple warehouses or in a dropshipping model. Vendo **automates everything** from **vendor onboarding**, accepting buyer **payments in over 135 currencies**, to supplier **payouts in 50 countries**.
160
176
 
161
- Spree Vendors is maintained by [Spark Solutions Sp. z o.o.](http://sparksolutions.co?utm_source=github)
177
+ > Vendo ensures excellent buyer experience with smooth product discovery and search, a multitude of payment methods and optimal shipping cost calculation. Vendo keeps suppliers happy with easy onboarding, automated products sync using their preferred method and easy payouts.
162
178
 
163
- We are passionate about open source software.
164
- We are [available for hire][spark].
179
+ > [Start your 30-day free trial](https://e98esoirr8c.typeform.com/contactvendo?typeform-source=spree_multi_vendor_github)
165
180
 
166
- [spark]:http://sparksolutions.co?utm_source=github
181
+ [vendo]:http://getvendo.com?utm_source=spree_multi_vendor_github
@@ -5,7 +5,7 @@ module Spree
5
5
  before_action :load_vendor
6
6
 
7
7
  def update
8
- if vendor_params[:image] && Spree.version.to_f >= 3.6
8
+ if vendor_params[:image]
9
9
  @vendor.create_image(attachment: vendor_params[:image])
10
10
  end
11
11
  if @vendor.update(vendor_params.except(:image))
@@ -3,14 +3,14 @@ module Spree
3
3
  class VendorsController < ResourceController
4
4
 
5
5
  def create
6
- if permitted_resource_params[:image] && Spree.version.to_f >= 3.6
6
+ if permitted_resource_params[:image]
7
7
  @vendor.build_image(attachment: permitted_resource_params.delete(:image))
8
8
  end
9
9
  super
10
10
  end
11
11
 
12
12
  def update
13
- if permitted_resource_params[:image] && Spree.version.to_f >= 3.6
13
+ if permitted_resource_params[:image]
14
14
  @vendor.create_image(attachment: permitted_resource_params.delete(:image))
15
15
  end
16
16
  format_translations if defined? SpreeGlobalize
@@ -40,10 +40,18 @@ module Spree
40
40
  @search = vendors.ransack(params[:q])
41
41
 
42
42
  @collection = @search.result.
43
+ includes(vendor_includes).
43
44
  page(params[:page]).
44
45
  per(params[:per_page])
45
46
  end
46
47
 
48
+ def vendor_includes
49
+ {
50
+ image: [],
51
+ products: []
52
+ }
53
+ end
54
+
47
55
  def format_translations
48
56
  return if params[:vendor][:translations_attributes].blank?
49
57
  params[:vendor][:translations_attributes].each do |_, data|
@@ -1,7 +1,7 @@
1
1
  module Spree
2
2
  module Api
3
3
  module V1
4
- class VendorsController < Spree::Api::BaseController
4
+ class VendorsController < Spree::Api::V1::BaseController
5
5
  def index
6
6
  @vendors = if params[:ids].present?
7
7
  scope.where(id: params[:ids].split(','))
@@ -3,7 +3,7 @@ module Spree
3
3
  module V2
4
4
  module Storefront
5
5
  class VendorsController < ::Spree::Api::V2::ResourceController
6
-
6
+
7
7
  private
8
8
 
9
9
  def model_class
@@ -21,6 +21,11 @@ module Spree
21
21
  def resource_serializer
22
22
  Spree::V2::Storefront::VendorSerializer
23
23
  end
24
+
25
+ def collection_serializer
26
+ Spree::V2::Storefront::VendorSerializer
27
+ end
28
+
24
29
  end
25
30
  end
26
31
  end
@@ -1,5 +1,5 @@
1
1
  module SpreeMultiVendor::Spree::Api::BaseControllerDecorator
2
- Spree::Api::BaseController.include(Spree::Api::VendorHelper)
2
+ Spree::Api::V1::BaseController.include(Spree::Api::VendorHelper) if SpreeMultiVendor::Engine.api_v1_available?
3
3
 
4
4
  def self.prepended(base)
5
5
  base.helper_method :current_spree_vendor
@@ -14,4 +14,4 @@ module SpreeMultiVendor::Spree::Api::BaseControllerDecorator
14
14
  end
15
15
  end
16
16
 
17
- ::Spree::Api::BaseController.prepend SpreeMultiVendor::Spree::Api::BaseControllerDecorator
17
+ ::Spree::Api::V1::BaseController.prepend SpreeMultiVendor::Spree::Api::BaseControllerDecorator if SpreeMultiVendor::Engine.api_v1_available?
@@ -6,4 +6,4 @@ module SpreeMultiVendor::Spree::Api::V1::ProductsControllerDecorator
6
6
  end
7
7
  end
8
8
 
9
- Spree::Api::V1::ProductsController.prepend SpreeMultiVendor::Spree::Api::V1::ProductsControllerDecorator
9
+ Spree::Api::V1::ProductsController.prepend SpreeMultiVendor::Spree::Api::V1::ProductsControllerDecorator if SpreeMultiVendor::Engine.api_v1_available?
@@ -10,4 +10,4 @@ module SpreeMultiVendor::Spree::Api::V1::UsersControllerDecorator
10
10
  end
11
11
  end
12
12
 
13
- Spree::Api::V1::UsersController.prepend SpreeMultiVendor::Spree::Api::V1::UsersControllerDecorator
13
+ Spree::Api::V1::UsersController.prepend SpreeMultiVendor::Spree::Api::V1::UsersControllerDecorator if SpreeMultiVendor::Engine.api_v1_available?
@@ -1,6 +1,6 @@
1
1
  module SpreeMultiVendor
2
2
  module ProductsFinderDecorator
3
- def initialize(scope:, params:, current_currency:)
3
+ def initialize(scope:, params:, current_currency: nil)
4
4
  super
5
5
 
6
6
  @vendors = params.dig(:filter, :vendor_ids)&.split(',')
@@ -16,4 +16,4 @@ module SpreeMultiVendor
16
16
  end
17
17
  end
18
18
 
19
- ::Spree::Api::ApiHelpers.prepend(SpreeMultiVendor::Spree::Api::ApiHelpersDecorator)
19
+ ::Spree::Api::ApiHelpers.prepend(SpreeMultiVendor::Spree::Api::ApiHelpersDecorator) if SpreeMultiVendor::Engine.api_v1_available?
@@ -61,7 +61,7 @@ module Spree
61
61
  private
62
62
 
63
63
  def create_stock_location
64
- stock_locations.where(name: name, country: Spree::Country.default).first_or_create!
64
+ stock_locations.where(name: name, country: Spree::Store.default.default_country).first_or_create!
65
65
  end
66
66
 
67
67
  def should_generate_new_friendly_id?
@@ -48,7 +48,7 @@ class Spree::VendorAbility
48
48
  end
49
49
 
50
50
  if order_scope.present?
51
- can %i[admin index edit update cart], Spree::Order, order_scope.merge(state: 'complete')
51
+ can %i[admin show index edit update cart], Spree::Order, order_scope.merge(state: 'complete')
52
52
  else
53
53
  cannot_display_model(Spree::Order)
54
54
  end
@@ -7,7 +7,6 @@ module SpreeMultiVendor::Spree::VariantDecorator
7
7
 
8
8
  def vendor
9
9
  @vendor ||= if self.class.reflect_on_association(:vendor) && self[:vendor_id].present?
10
- product.vendor
11
10
  ::Spree::Vendor.unscoped.find(self[:vendor_id])
12
11
  elsif Spree::Product.reflect_on_association(:vendor) && product.vendor_id.present?
13
12
  product.vendor
@@ -5,7 +5,7 @@ Deface::Override.new(
5
5
  text: <<-HTML
6
6
  <% if current_spree_user.respond_to?(:has_spree_role?) && current_spree_user.has_spree_role?(:admin) %>
7
7
  <%= f.field_container :vendor_ids, class: ['form-group'] do %>
8
- <%= f.label :vendor_ids, Spree.t(plural_resource_name(Spree::Vendor)) %>
8
+ <%= f.label :vendor_ids, plural_resource_name(Spree::Vendor) %>
9
9
  <%= f.collection_select(:vendor_ids, Spree::Vendor.all, :id, :name, { }, { class: 'select2', multiple: true }) %>
10
10
  <% end %>
11
11
  <% end %>
@@ -4,7 +4,7 @@
4
4
 
5
5
  <%= form_for [:admin, @vendor], url: admin_vendor_settings_url do |f| %>
6
6
  <fieldset>
7
- <%= render partial: 'spree/shared/error_messages', locals: { target: @vendor } %>
7
+ <%= render partial: 'spree/admin/shared/error_messages', locals: { target: @vendor } %>
8
8
  <div class="form-group">
9
9
  <%= f.field_container :name do %>
10
10
  <%= f.label :name %>
@@ -1,4 +1,4 @@
1
- <%= render partial: 'spree/shared/error_messages', locals: { target: @vendor } %>
1
+ <%= render partial: 'spree/admin/shared/error_messages', locals: { target: @vendor } %>
2
2
  <div class="form-group">
3
3
  <%= f.field_container :name do %>
4
4
  <%= f.label :name %>
@@ -1,5 +1,5 @@
1
1
  <% content_for :page_title do %>
2
- <%= Spree.t(plural_resource_name(Spree::Vendor)) %>
2
+ <%= plural_resource_name(Spree::Vendor) %>
3
3
  <% end %>
4
4
 
5
5
  <% content_for :page_actions do %>
@@ -6,7 +6,5 @@ module Spree
6
6
 
7
7
  @@vendor_attributes = [:name, :about_us, :contact_us, :notification_email]
8
8
  @@vendor_attributes << :image if Spree.version.to_f >= 3.6
9
-
10
- @@product_attributes << :vendor_id if SpreeMultiVendor::Config[:vendorized_models].include?('product')
11
9
  end
12
10
  end
@@ -7,9 +7,11 @@ es:
7
7
  attributes:
8
8
  spree/vendor:
9
9
  about_us: Acerca de
10
+ commission_rate: Porcentaje Comisión
10
11
  contact_us: Contáctanos
11
12
  image: Imagen
12
13
  name: Nombre
14
+ notification_email: Email notificación pedido
13
15
  state: estado
14
16
  created_at: creado en
15
17
  priority: prioridad
@@ -21,6 +23,7 @@ es:
21
23
  order_mailer:
22
24
  vendor_notification_email:
23
25
  dear_vendor: Estimado vendedor,
26
+ order_summary: Resumen del pedido
24
27
  subject: Notificación de vendedor
25
28
  thanks: Gracias
26
29
  vendor: Vendedor
data/config/routes.rb CHANGED
@@ -12,7 +12,7 @@ Spree::Core::Engine.routes.draw do
12
12
  namespace :api, defaults: { format: 'json' } do
13
13
  namespace :v2 do
14
14
  namespace :storefront do
15
- resources :vendors, only: [:show]
15
+ resources :vendors, only: [:show,:index]
16
16
  end
17
17
  end
18
18
  namespace :v1 do
@@ -0,0 +1,10 @@
1
+ class ChangeVendorizedModelsVendorIdType < ActiveRecord::Migration[4.2]
2
+ def change
3
+ SpreeMultiVendor.vendorized_models.each do |klass|
4
+ change_column klass.table_name, :vendor_id, :bigint
5
+ rescue
6
+ message = "Could not change vendor_id column for spree_#{klass}"
7
+ Rails.logger.error message
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,14 @@
1
+ class ChangeVendorIdAndUserIdTypeForSpreeVendorUsers < ActiveRecord::Migration[4.2]
2
+ def up
3
+ change_table(:spree_vendor_users) do |t|
4
+ t.change :vendor_id, :bigint
5
+ t.change :user_id, :bigint
6
+ end
7
+ end
8
+ def down
9
+ change_table(:spree_vendor_users) do |t|
10
+ t.change :vendor_id, :integer
11
+ t.change :user_id, :integer
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,14 @@
1
+ class ChangeVendorIdAndOrderIdTypeForSpreeOrderCommissions < ActiveRecord::Migration[4.2]
2
+ def up
3
+ change_table(:spree_order_commissions) do |t|
4
+ t.change :vendor_id, :bigint
5
+ t.change :order_id, :bigint
6
+ end
7
+ end
8
+ def down
9
+ change_table(:spree_order_commissions) do |t|
10
+ t.change :vendor_id, :integer
11
+ t.change :order_id, :integer
12
+ end
13
+ end
14
+ end
@@ -1,3 +1,5 @@
1
+ require_relative 'configuration'
2
+
1
3
  module SpreeMultiVendor
2
4
  class Engine < Rails::Engine
3
5
  require 'spree/core'
@@ -13,12 +15,20 @@ module SpreeMultiVendor
13
15
  SpreeMultiVendor::Config = SpreeMultiVendor::Configuration.new
14
16
  end
15
17
 
18
+ config.after_initialize do
19
+ ::Spree::PermittedAttributes.product_attributes << :vendor_id if SpreeMultiVendor::Config[:vendorized_models].include?('product')
20
+ end
21
+
16
22
  def self.activate
17
23
  Dir.glob(File.join(File.dirname(__FILE__), '../../app/**/*_decorator*.rb')) do |c|
18
24
  Rails.configuration.cache_classes ? require(c) : load(c)
19
25
  end
20
26
  end
21
27
 
28
+ def self.api_v1_available?
29
+ @@api_v1_available ||= Gem::Specification.find_all_by_name('spree_api_v1').any?
30
+ end
31
+
22
32
  config.to_prepare &method(:activate).to_proc
23
33
  end
24
34
  end
@@ -1,5 +1,5 @@
1
1
  module SpreeMultiVendor
2
- VERSION = '2.2.0'
2
+ VERSION = '2.4.0'
3
3
 
4
4
  module_function
5
5
 
@@ -1,4 +1,6 @@
1
1
  require 'spree_core'
2
+ require 'spree_backend'
3
+ require 'spree_emails'
2
4
  require 'spree_multi_vendor/engine'
3
5
  require 'spree_multi_vendor/version'
4
6
  require 'spree_extension'
@@ -8,7 +10,7 @@ module SpreeMultiVendor
8
10
  # TODO: this should be moved into preferences
9
11
  def self.vendorized_models
10
12
  SpreeMultiVendor::Config[:vendorized_models].map(&:classify).map do |class_name|
11
- "Spree::#{class_name}".safe_constantize
13
+ "::Spree::#{class_name}".safe_constantize
12
14
  end.compact.uniq
13
15
  end
14
16
  end
@@ -9,6 +9,12 @@ FactoryBot.define do
9
9
  state { :active }
10
10
  end
11
11
 
12
+ factory :active_vendor_list do
13
+ name { "#{FFaker::Company.name} #{FFaker::Company.suffix }" }
14
+ state { :active }
15
+ end
16
+
17
+
12
18
  factory :pending_vendor do
13
19
  name { 'Pending vendor' }
14
20
  state { :pending }
@@ -1,13 +1,14 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  RSpec.feature 'Admin Orders', :js do
4
+ let(:store) { Spree::Store.default }
4
5
  let(:vendor) { create(:active_vendor, name: 'Vendor') }
5
6
  let(:vendor_2) { create(:active_vendor, name: 'Other vendor') }
6
- let(:order) { create(:order, ship_address: create(:address), bill_address: create(:address)) }
7
- let(:order_2) { create(:order) }
7
+ let(:order) { create(:order, ship_address: create(:address), bill_address: create(:address), store: store) }
8
+ let(:order_2) { create(:order, store: store) }
8
9
  let!(:user) { create(:user, vendors: [vendor]) }
9
- let(:product) { create(:product_in_stock, vendor: vendor) }
10
- let(:product_2) { create(:product_in_stock, vendor: vendor_2) }
10
+ let(:product) { create(:product_in_stock, vendor: vendor, stores:[store]) }
11
+ let(:product_2) { create(:product_in_stock, vendor: vendor_2,stores:[store]) }
11
12
 
12
13
  before do
13
14
  create(:line_item, order: order, product: product)
@@ -42,13 +42,11 @@ RSpec.feature 'Admin Vendor Settings', :js do
42
42
  expect(page).not_to have_text 'contact_us can\'t be blank'
43
43
  end
44
44
 
45
- if Spree.version.to_f >= 3.6
46
- scenario 'can update an existing vendor image' do
47
- create(:vendor, name: 'New vendor')
48
- page.attach_file("vendor_image", Spree::Core::Engine.root + 'spec/fixtures' + 'thinking-cat.jpg')
49
- click_button 'Update'
50
- expect(page).to have_css("img[src*='thinking-cat.jpg']")
51
- end
45
+ scenario 'can update an existing vendor image' do
46
+ create(:vendor, name: 'New vendor')
47
+ page.attach_file("vendor_image", Spree::Core::Engine.root + 'spec/fixtures' + 'thinking-cat.jpg')
48
+ click_button 'Update'
49
+ expect(page).to have_css("img[src*='thinking-cat.jpg']")
52
50
  end
53
51
  end
54
52
 
@@ -70,7 +68,7 @@ RSpec.feature 'Admin Vendor Settings', :js do
70
68
 
71
69
  it 'renders forbidden page' do
72
70
  visit spree.admin_vendor_settings_path
73
- expect(current_path).to eq spree.forbidden_path
71
+ expect(current_path).to eq spree.admin_forbidden_path
74
72
  end
75
73
  end
76
74
  end
@@ -1,7 +1,8 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe 'API V2 Storefront Products Spec', type: :request do
4
- let!(:products) { create_list(:product, 5) }
4
+ let(:store) { Spree::Store.default }
5
+ let!(:products) { create_list(:product, 5, stores: [store]) }
5
6
  let!(:vendor) { create(:vendor) }
6
7
  let!(:vendor_2) { create(:vendor) }
7
8
 
@@ -5,6 +5,8 @@ describe 'API V2 Storefront Vendor Spec', type: :request do
5
5
  let!(:vendor_image) { create(:vendor_image) }
6
6
  let!(:vendor) { create(:active_vendor, name: 'vendor', image: vendor_image) }
7
7
  let!(:product) { create(:product, vendor: vendor) }
8
+ let!(:vendors) {
9
+ create_list(:active_vendor_list, 30)}
8
10
 
9
11
  describe 'vendors#show' do
10
12
  context 'with invalid slug param' do
@@ -49,4 +51,68 @@ describe 'API V2 Storefront Vendor Spec', type: :request do
49
51
  end
50
52
  end
51
53
  end
54
+
55
+
56
+ describe 'vendors#index' do
57
+ context 'returns vendors list' do
58
+
59
+ it 'must return a list of vendor paged' do
60
+ get "/api/v2/storefront/vendors"
61
+ expect(response).to have_http_status(:ok)
62
+ json_response = JSON.parse(response.body)
63
+ expect(json_response)
64
+ expect(json_response['data'].count).to eq (25)
65
+ end
66
+
67
+ it 'can request different pages' do
68
+ get "/api/v2/storefront/vendors?page=2"
69
+ expect(response).to have_http_status(:ok)
70
+ json_response = JSON.parse(response.body)
71
+ expect(json_response)
72
+ expect(json_response['data'].count).to eq (6)
73
+
74
+ end
75
+
76
+ it 'can control paging size' do
77
+ get "/api/v2/storefront/vendors?page=2&per_page=10"
78
+ expect(response).to have_http_status(:ok)
79
+ json_response = JSON.parse(response.body)
80
+ expect(json_response)
81
+ expect(json_response['data'].count).to eq (10)
82
+ end
83
+
84
+
85
+ it 'returns data type vendor' do
86
+ get "/api/v2/storefront/vendors"
87
+ json_response = JSON.parse(response.body)
88
+ expect(json_response)
89
+ expect(json_response['data'][0]['type']).to eq('vendor')
90
+ end
91
+
92
+ it 'does not return included' do
93
+ get "/api/v2/storefront/vendors"
94
+ json_response = JSON.parse(response.body)
95
+ expect(json_response.keys).to contain_exactly('data', "links", "meta")
96
+ end
97
+ end
98
+
99
+ context 'with products and images included' do
100
+ before { get "/api/v2/storefront/vendors?include=products,image" }
101
+
102
+ it_behaves_like 'returns 200 HTTP status'
103
+
104
+ it 'returns product information' do
105
+ json_response = JSON.parse(response.body)
106
+ expect(json_response.keys).to contain_exactly('data', 'included', "links", "meta")
107
+ expect(json_response['included'].first['id']).to eq(product.id.to_s)
108
+ end
109
+
110
+ it 'returns image information' do
111
+ json_response = JSON.parse(response.body)
112
+ expect(json_response.keys).to contain_exactly('data', 'included',"links", "meta")
113
+
114
+ expect(json_response['included'].second['id']).to eq(vendor_image.id.to_s)
115
+ end
116
+ end
117
+ end
52
118
  end
data/spec/spec_helper.rb CHANGED
@@ -8,4 +8,6 @@ require 'spree_dev_tools/rspec/spec_helper'
8
8
 
9
9
  # Requires supporting ruby files with custom matchers and macros, etc,
10
10
  # in spec/support/ and its subdirectories.
11
- Dir[File.join(File.dirname(__FILE__), 'support/**/*.rb')].sort.each { |f| require f }
11
+ Dir[File.join(File.dirname(__FILE__), 'support/**/*.rb')].sort.each { |f| require f }
12
+
13
+ ActiveJob::Base.queue_adapter = :inline
@@ -14,7 +14,7 @@ Gem::Specification.new do |s|
14
14
 
15
15
  s.author = 'Spark Solutions'
16
16
  s.email = 'we@sparksolutions.co'
17
- s.homepage = 'https://sparksolutions.co'
17
+ s.homepage = 'https://spreecommerce.org/use-cases/multi-vendor-marketplace-demo/'
18
18
  s.license = 'BSD-3-Clause'
19
19
 
20
20
  s.metadata = {
@@ -29,11 +29,12 @@ Gem::Specification.new do |s|
29
29
  s.require_path = 'lib'
30
30
  s.requirements << 'none'
31
31
 
32
- spree_version = '>= 4.2.0.rc5', '< 5.0'
33
- s.add_dependency 'spree_core', spree_version
34
- s.add_dependency 'spree_api', spree_version
32
+ spree_version = '>= 4.3.0.rc1'
33
+ s.add_dependency 'spree', spree_version
35
34
  s.add_dependency 'spree_backend', spree_version
35
+ s.add_dependency 'spree_emails', spree_version
36
36
  s.add_dependency 'spree_extension'
37
+
37
38
  s.add_dependency 'deface', '~> 1.0'
38
39
 
39
40
  s.add_development_dependency 'shoulda-matchers'
metadata CHANGED
@@ -1,75 +1,57 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spree_multi_vendor
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 2.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Spark Solutions
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-05-24 00:00:00.000000000 Z
11
+ date: 2022-12-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: spree_core
14
+ name: spree
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 4.2.0.rc5
20
- - - "<"
21
- - !ruby/object:Gem::Version
22
- version: '5.0'
19
+ version: 4.3.0.rc1
23
20
  type: :runtime
24
21
  prerelease: false
25
22
  version_requirements: !ruby/object:Gem::Requirement
26
23
  requirements:
27
24
  - - ">="
28
25
  - !ruby/object:Gem::Version
29
- version: 4.2.0.rc5
30
- - - "<"
31
- - !ruby/object:Gem::Version
32
- version: '5.0'
26
+ version: 4.3.0.rc1
33
27
  - !ruby/object:Gem::Dependency
34
- name: spree_api
28
+ name: spree_backend
35
29
  requirement: !ruby/object:Gem::Requirement
36
30
  requirements:
37
31
  - - ">="
38
32
  - !ruby/object:Gem::Version
39
- version: 4.2.0.rc5
40
- - - "<"
41
- - !ruby/object:Gem::Version
42
- version: '5.0'
33
+ version: 4.3.0.rc1
43
34
  type: :runtime
44
35
  prerelease: false
45
36
  version_requirements: !ruby/object:Gem::Requirement
46
37
  requirements:
47
38
  - - ">="
48
39
  - !ruby/object:Gem::Version
49
- version: 4.2.0.rc5
50
- - - "<"
51
- - !ruby/object:Gem::Version
52
- version: '5.0'
40
+ version: 4.3.0.rc1
53
41
  - !ruby/object:Gem::Dependency
54
- name: spree_backend
42
+ name: spree_emails
55
43
  requirement: !ruby/object:Gem::Requirement
56
44
  requirements:
57
45
  - - ">="
58
46
  - !ruby/object:Gem::Version
59
- version: 4.2.0.rc5
60
- - - "<"
61
- - !ruby/object:Gem::Version
62
- version: '5.0'
47
+ version: 4.3.0.rc1
63
48
  type: :runtime
64
49
  prerelease: false
65
50
  version_requirements: !ruby/object:Gem::Requirement
66
51
  requirements:
67
52
  - - ">="
68
53
  - !ruby/object:Gem::Version
69
- version: 4.2.0.rc5
70
- - - "<"
71
- - !ruby/object:Gem::Version
72
- version: '5.0'
54
+ version: 4.3.0.rc1
73
55
  - !ruby/object:Gem::Dependency
74
56
  name: spree_extension
75
57
  requirement: !ruby/object:Gem::Requirement
@@ -132,10 +114,10 @@ executables: []
132
114
  extensions: []
133
115
  extra_rdoc_files: []
134
116
  files:
117
+ - ".github/dependabot.yml"
135
118
  - ".gitignore"
136
119
  - ".rspec"
137
120
  - ".travis.yml"
138
- - Appraisals
139
121
  - Gemfile
140
122
  - LICENSE
141
123
  - README.md
@@ -166,7 +148,6 @@ files:
166
148
  - app/models/spree/vendor_image.rb
167
149
  - app/models/spree/vendor_order_totals.rb
168
150
  - app/models/spree/vendor_user.rb
169
- - app/models/spree_multi_vendor/configuration.rb
170
151
  - app/models/spree_multi_vendor/spree/ability_decorator.rb
171
152
  - app/models/spree_multi_vendor/spree/base_decorator.rb
172
153
  - app/models/spree_multi_vendor/spree/line_item_decorator.rb
@@ -220,12 +201,14 @@ files:
220
201
  - db/migrate/20190312130754_create_spree_order_commissions.rb
221
202
  - db/migrate/20190322133128_add_notification_email_to_vendors.rb
222
203
  - db/migrate/20200416030721_add_translations_to_vendor.rb
223
- - gemfiles/spree_4_2.gemfile
224
- - gemfiles/spree_master.gemfile
204
+ - db/migrate/20210728120649_change_vendorized_models_vendor_id_type.rb
205
+ - db/migrate/20210728120910_change_vendor_id_and_user_id_type_for_spree_vendor_users.rb
206
+ - db/migrate/20210728121024_change_vendor_id_and_order_id_type_for_spree_order_commissions.rb
225
207
  - lib/generators/spree_multi_vendor/install/install_generator.rb
226
208
  - lib/generators/spree_multi_vendor/mailers_preview/mailers_preview_generator.rb
227
209
  - lib/generators/spree_multi_vendor/mailers_preview/templates/mailers/previews/vendor_notification_preview.rb
228
210
  - lib/spree_multi_vendor.rb
211
+ - lib/spree_multi_vendor/configuration.rb
229
212
  - lib/spree_multi_vendor/engine.rb
230
213
  - lib/spree_multi_vendor/factories.rb
231
214
  - lib/spree_multi_vendor/version.rb
@@ -262,14 +245,14 @@ files:
262
245
  - spec/spec_helper.rb
263
246
  - spec/support/shoulda_matchers.rb
264
247
  - spree_multi_vendor.gemspec
265
- homepage: https://sparksolutions.co
248
+ homepage: https://spreecommerce.org/use-cases/multi-vendor-marketplace-demo/
266
249
  licenses:
267
250
  - BSD-3-Clause
268
251
  metadata:
269
252
  bug_tracker_uri: https://github.com/spree-contrib/spree_multi_vendor/issues
270
- changelog_uri: https://github.com/spree-contrib/spree_multi_vendor/releases/tag/v2.2.0
253
+ changelog_uri: https://github.com/spree-contrib/spree_multi_vendor/releases/tag/v2.4.0
271
254
  documentation_uri: https://guides.spreecommerce.org/
272
- source_code_uri: https://github.com/spree-contrib/spree_multi_vendor/tree/v2.2.0
255
+ source_code_uri: https://github.com/spree-contrib/spree_multi_vendor/tree/v2.4.0
273
256
  post_install_message:
274
257
  rdoc_options: []
275
258
  require_paths:
@@ -286,7 +269,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
286
269
  version: '0'
287
270
  requirements:
288
271
  - none
289
- rubygems_version: 3.2.3
272
+ rubygems_version: 3.0.9
290
273
  signing_key:
291
274
  specification_version: 4
292
275
  summary: Spree Commerce multi vendor marketplace extension
data/Appraisals DELETED
@@ -1,11 +0,0 @@
1
- appraise 'spree-4-2' do
2
- gem 'spree', '~> 4.2.0.rc4'
3
- gem 'spree_auth_devise', '~> 4.3'
4
- gem 'rails-controller-testing'
5
- end
6
-
7
- appraise 'spree-master' do
8
- gem 'spree', github: 'spree/spree', branch: 'master'
9
- gem 'spree_auth_devise', github: 'spree/spree_auth_devise', branch: 'master'
10
- gem 'rails-controller-testing'
11
- end
@@ -1,9 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "spree", "~> 4.2.0.rc4"
6
- gem "spree_auth_devise", "~> 4.3"
7
- gem "rails-controller-testing"
8
-
9
- gemspec path: "../"
@@ -1,9 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "spree", github: "spree/spree", branch: "master"
6
- gem "spree_auth_devise", github: "spree/spree_auth_devise", branch: "master"
7
- gem "rails-controller-testing"
8
-
9
- gemspec path: "../"