spree_multi_vendor 2.0.1 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) 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 +12 -1
  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 +61 -0
  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 +17 -0
  11. data/app/controllers/spree_multi_vendor/spree/api/v1/products_controller_decorator.rb +9 -0
  12. data/app/controllers/spree_multi_vendor/spree/api/v1/users_controller_decorator.rb +13 -0
  13. data/app/finders/spree_multi_vendor/products_finder_decorator.rb +1 -1
  14. data/app/helpers/spree/api/vendor_helper.rb +11 -0
  15. data/app/helpers/spree_multi_vendor/spree/api/api_helpers_decorator.rb +19 -0
  16. data/app/models/spree/vendor_ability.rb +24 -9
  17. data/app/models/spree/vendor_user.rb +1 -1
  18. data/app/models/spree_multi_vendor/configuration.rb +1 -1
  19. data/app/models/spree_multi_vendor/spree/order_decorator.rb +5 -3
  20. data/app/overrides/spree/admin/shared/_main_menu.rb +1 -1
  21. data/app/serializers/spree/v2/storefront/vendor_order_totals_serializer.rb +2 -0
  22. data/app/views/spree/admin/vendor_settings/edit.html.erb +1 -1
  23. data/app/views/spree/admin/vendors/_form.html.erb +1 -1
  24. data/app/views/spree/api/v1/vendors/index.rabl +3 -0
  25. data/app/views/spree/api/v1/vendors/show.rabl +2 -0
  26. data/config/initializers/spree_permitted_attributes.rb +2 -0
  27. data/config/locales/es.yml +3 -0
  28. data/config/routes.rb +4 -1
  29. data/db/migrate/20210728120649_change_vendorized_models_vendor_id_type.rb +10 -0
  30. data/db/migrate/20210728120910_change_vendor_id_and_user_id_type_for_spree_vendor_users.rb +8 -0
  31. data/db/migrate/20210728121024_change_vendor_id_and_order_id_type_for_spree_order_commissions.rb +8 -0
  32. data/lib/spree_multi_vendor/factories.rb +1 -1
  33. data/lib/spree_multi_vendor/version.rb +1 -1
  34. data/lib/spree_multi_vendor.rb +2 -1
  35. data/spec/factories/spree/vendor_factory.rb +6 -0
  36. data/spec/features/spree/admin/orders_spec.rb +62 -12
  37. data/spec/features/spree/admin/vendor_settings_spec.rb +6 -8
  38. data/spec/models/spree/order_spec.rb +16 -2
  39. data/spec/requests/spree/api/v1/products_spec.rb +221 -0
  40. data/spec/requests/spree/api/v1/users_spec.rb +31 -0
  41. data/spec/requests/spree/api/v1/vendors_spec.rb +210 -0
  42. data/spec/requests/spree/api/v2/storefront/cart_spec.rb +19 -1
  43. data/spec/requests/spree/api/v2/storefront/products_spec.rb +4 -1
  44. data/spec/requests/spree/api/v2/storefront/vendors_spec.rb +66 -0
  45. data/spec/serializers/spree/v2/storefront/vendor_order_totals_serializer_spec.rb +2 -2
  46. data/spec/spec_helper.rb +3 -1
  47. data/spree_multi_vendor.gemspec +5 -4
  48. metadata +32 -38
  49. data/Appraisals +0 -11
  50. data/app/controllers/spree_multi_vendor/spree/admin/option_types_controller_decorator.rb +0 -7
  51. data/app/controllers/spree_multi_vendor/spree/admin/properties_controller_decorator.rb +0 -7
  52. data/app/controllers/spree_multi_vendor/spree/api/v1/variants_controller_decorator.rb +0 -22
  53. data/gemfiles/spree_4_2.gemfile +0 -9
  54. data/gemfiles/spree_master.gemfile +0 -9
@@ -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
@@ -31,8 +31,8 @@ describe Spree::V2::Storefront::VendorOrderTotalsSerializer do
31
31
  display_included_tax_total: Spree::Money.new(30),
32
32
  ship_total: BigDecimal(25),
33
33
  display_ship_total: Spree::Money.new(25),
34
- subtotal: BigDecimal(600),
35
- display_subtotal: Spree::Money.new(600),
34
+ subtotal: BigDecimal(680),
35
+ display_subtotal: Spree::Money.new(680),
36
36
  promo_total: BigDecimal(60),
37
37
  display_promo_total: Spree::Money.new(60),
38
38
  total: BigDecimal(625),
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.0.1
4
+ version: 2.3.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-02-10 00:00:00.000000000 Z
11
+ date: 2021-10-07 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,29 +114,32 @@ 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
142
124
  - Rakefile
143
125
  - app/controllers/spree/admin/vendor_settings_controller.rb
144
126
  - app/controllers/spree/admin/vendors_controller.rb
127
+ - app/controllers/spree/api/v1/vendors_controller.rb
145
128
  - app/controllers/spree/api/v2/storefront/vendors_controller.rb
146
129
  - app/controllers/spree_multi_vendor/spree/admin/base_controller_decorator.rb
147
- - app/controllers/spree_multi_vendor/spree/admin/option_types_controller_decorator.rb
148
130
  - app/controllers/spree_multi_vendor/spree/admin/products_controller_decorator.rb
149
- - app/controllers/spree_multi_vendor/spree/admin/properties_controller_decorator.rb
150
131
  - app/controllers/spree_multi_vendor/spree/admin/resource_controller_decorator.rb
151
132
  - app/controllers/spree_multi_vendor/spree/admin/shipping_methods_controller_decorator.rb
152
133
  - app/controllers/spree_multi_vendor/spree/admin/stock_locations_controller_decorator.rb
153
134
  - app/controllers/spree_multi_vendor/spree/admin/users_controller_decorator.rb
154
135
  - app/controllers/spree_multi_vendor/spree/admin/variants_controller_decorator.rb
155
- - app/controllers/spree_multi_vendor/spree/api/v1/variants_controller_decorator.rb
136
+ - app/controllers/spree_multi_vendor/spree/api/base_controller_decorator.rb
137
+ - app/controllers/spree_multi_vendor/spree/api/v1/products_controller_decorator.rb
138
+ - app/controllers/spree_multi_vendor/spree/api/v1/users_controller_decorator.rb
156
139
  - app/finders/spree_multi_vendor/products_finder_decorator.rb
157
140
  - app/helpers/spree/admin/vendor_helper.rb
141
+ - app/helpers/spree/api/vendor_helper.rb
142
+ - app/helpers/spree_multi_vendor/spree/api/api_helpers_decorator.rb
158
143
  - app/mailers/spree/vendor_mailer.rb
159
144
  - app/models/concerns/spree/vendor_concern.rb
160
145
  - app/models/spree/order_commission.rb
@@ -193,6 +178,8 @@ files:
193
178
  - app/views/spree/admin/vendors/edit.html.erb
194
179
  - app/views/spree/admin/vendors/index.html.erb
195
180
  - app/views/spree/admin/vendors/new.html.erb
181
+ - app/views/spree/api/v1/vendors/index.rabl
182
+ - app/views/spree/api/v1/vendors/show.rabl
196
183
  - app/views/spree/vendor_mailer/vendor_notification_email.html.erb
197
184
  - app/views/spree/vendor_mailer/vendor_notification_email.text.erb
198
185
  - bin/rails
@@ -215,8 +202,9 @@ files:
215
202
  - db/migrate/20190312130754_create_spree_order_commissions.rb
216
203
  - db/migrate/20190322133128_add_notification_email_to_vendors.rb
217
204
  - db/migrate/20200416030721_add_translations_to_vendor.rb
218
- - gemfiles/spree_4_2.gemfile
219
- - gemfiles/spree_master.gemfile
205
+ - db/migrate/20210728120649_change_vendorized_models_vendor_id_type.rb
206
+ - db/migrate/20210728120910_change_vendor_id_and_user_id_type_for_spree_vendor_users.rb
207
+ - db/migrate/20210728121024_change_vendor_id_and_order_id_type_for_spree_order_commissions.rb
220
208
  - lib/generators/spree_multi_vendor/install/install_generator.rb
221
209
  - lib/generators/spree_multi_vendor/mailers_preview/mailers_preview_generator.rb
222
210
  - lib/generators/spree_multi_vendor/mailers_preview/templates/mailers/previews/vendor_notification_preview.rb
@@ -244,6 +232,9 @@ files:
244
232
  - spec/models/spree/vendor_order_totals_spec.rb
245
233
  - spec/models/spree/vendor_spec.rb
246
234
  - spec/models/spree/vendor_user_spec.rb
235
+ - spec/requests/spree/api/v1/products_spec.rb
236
+ - spec/requests/spree/api/v1/users_spec.rb
237
+ - spec/requests/spree/api/v1/vendors_spec.rb
247
238
  - spec/requests/spree/api/v2/storefront/cart_spec.rb
248
239
  - spec/requests/spree/api/v2/storefront/products_spec.rb
249
240
  - spec/requests/spree/api/v2/storefront/vendors_spec.rb
@@ -254,14 +245,14 @@ files:
254
245
  - spec/spec_helper.rb
255
246
  - spec/support/shoulda_matchers.rb
256
247
  - spree_multi_vendor.gemspec
257
- homepage: https://sparksolutions.co
248
+ homepage: https://spreecommerce.org/use-cases/multi-vendor-marketplace-demo/
258
249
  licenses:
259
250
  - BSD-3-Clause
260
251
  metadata:
261
252
  bug_tracker_uri: https://github.com/spree-contrib/spree_multi_vendor/issues
262
- changelog_uri: https://github.com/spree-contrib/spree_multi_vendor/releases/tag/v2.0.1
253
+ changelog_uri: https://github.com/spree-contrib/spree_multi_vendor/releases/tag/v2.3.0
263
254
  documentation_uri: https://guides.spreecommerce.org/
264
- source_code_uri: https://github.com/spree-contrib/spree_multi_vendor/tree/v2.0.1
255
+ source_code_uri: https://github.com/spree-contrib/spree_multi_vendor/tree/v2.3.0
265
256
  post_install_message:
266
257
  rdoc_options: []
267
258
  require_paths:
@@ -302,6 +293,9 @@ test_files:
302
293
  - spec/models/spree/vendor_order_totals_spec.rb
303
294
  - spec/models/spree/vendor_spec.rb
304
295
  - spec/models/spree/vendor_user_spec.rb
296
+ - spec/requests/spree/api/v1/products_spec.rb
297
+ - spec/requests/spree/api/v1/users_spec.rb
298
+ - spec/requests/spree/api/v1/vendors_spec.rb
305
299
  - spec/requests/spree/api/v2/storefront/cart_spec.rb
306
300
  - spec/requests/spree/api/v2/storefront/products_spec.rb
307
301
  - spec/requests/spree/api/v2/storefront/vendors_spec.rb
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,7 +0,0 @@
1
- module SpreeMultiVendor::Spree::Admin::OptionTypesControllerDecorator
2
- def self.prepended(base)
3
- base.before_action :set_vendor_id, only: [:create, :update]
4
- end
5
- end
6
-
7
- Spree::Admin::OptionTypesController.prepend SpreeMultiVendor::Spree::Admin::OptionTypesControllerDecorator
@@ -1,7 +0,0 @@
1
- module SpreeMultiVendor::Spree::Admin::PropertiesControllerDecorator
2
- def self.prepended(base)
3
- base.before_action :set_vendor_id, only: [:create, :update]
4
- end
5
- end
6
-
7
- Spree::Admin::PropertiesController.prepend SpreeMultiVendor::Spree::Admin::PropertiesControllerDecorator
@@ -1,22 +0,0 @@
1
- module SpreeMultiVendor::Spree::Api::V1::VariantsControllerDecorator
2
- private
3
-
4
- def scope
5
- variants = if @product
6
- @product.variants_including_master
7
- else
8
- Spree::Variant
9
- end
10
-
11
- if current_ability.can?(:manage, Spree::Variant) && params[:show_deleted]
12
- variants = variants.with_deleted
13
- end
14
-
15
- variants = variants.for_vendor_user(current_spree_user) unless @current_user_roles.include?('admin')
16
- variants = variants.eligible if Spree.version.to_f >= 3.7
17
-
18
- variants.accessible_by(current_ability, :read)
19
- end
20
- end
21
-
22
- Spree::Api::V1::VariantsController.prepend SpreeMultiVendor::Spree::Api::V1::VariantsControllerDecorator
@@ -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: "../"