solidus_acts_as_tenant 0.0.5

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.
Files changed (52) hide show
  1. checksums.yaml +7 -0
  2. data/.gem_release.yml +5 -0
  3. data/.github/stale.yml +1 -0
  4. data/.github/workflows/lint.yml +25 -0
  5. data/.github/workflows/test.yml +71 -0
  6. data/.github_changelog_generator +2 -0
  7. data/.gitignore +21 -0
  8. data/.rspec +2 -0
  9. data/.rubocop.yml +24 -0
  10. data/CHANGELOG.md +3 -0
  11. data/Gemfile +51 -0
  12. data/LICENSE +26 -0
  13. data/README.md +99 -0
  14. data/Rakefile +7 -0
  15. data/app/decorators/solidus_acts_as_tenant/store_credit_decorator.rb +12 -0
  16. data/app/decorators/solidus_acts_as_tenant/variant_decorator.rb +31 -0
  17. data/app/models/spree/products_taxon.rb +9 -0
  18. data/app/models/spree/reimbursement_credit.rb +9 -0
  19. data/app/models/spree/tenant.rb +11 -0
  20. data/bin/console +17 -0
  21. data/bin/rails +7 -0
  22. data/bin/rails-engine +13 -0
  23. data/bin/rails-sandbox +16 -0
  24. data/bin/rake +7 -0
  25. data/bin/sandbox +77 -0
  26. data/bin/setup +8 -0
  27. data/config/locales/en.yml +4 -0
  28. data/config/routes.rb +5 -0
  29. data/db/migrate/20241204043609_add_tenant_id_to_solidus_tables.rb +103 -0
  30. data/db/migrate/20241204055845_update_spree_unique_indexes_with_tenant_scope.rb +21 -0
  31. data/db/migrate/20241204105318_create_spree_tenants.rb +16 -0
  32. data/lib/generators/solidus_acts_as_tenant/install/install_generator.rb +36 -0
  33. data/lib/generators/solidus_acts_as_tenant/install/templates/initializer.rb +15 -0
  34. data/lib/generators/solidus_acts_as_tenant/install/templates/tenant_aware_models.yml +98 -0
  35. data/lib/solidus_acts_as_tenant/configuration.rb +32 -0
  36. data/lib/solidus_acts_as_tenant/engine.rb +23 -0
  37. data/lib/solidus_acts_as_tenant/factories/preference_factory.rb +7 -0
  38. data/lib/solidus_acts_as_tenant/factories/tenant_factory.rb +9 -0
  39. data/lib/solidus_acts_as_tenant/tenant_aware.rb +51 -0
  40. data/lib/solidus_acts_as_tenant/testing_support/factories.rb +5 -0
  41. data/lib/solidus_acts_as_tenant/utils/tenant_selector.rb +74 -0
  42. data/lib/solidus_acts_as_tenant/version.rb +5 -0
  43. data/lib/solidus_acts_as_tenant.rb +8 -0
  44. data/solidus_acts_as_tenant.gemspec +38 -0
  45. data/spec/lib/solidus_acts_as_tenant/configuration_spec.rb +43 -0
  46. data/spec/lib/solidus_acts_as_tenant/solidus_acts_as_tenant_spec.rb +27 -0
  47. data/spec/lib/solidus_acts_as_tenant/tenant_aware_spec.rb +48 -0
  48. data/spec/models/spree/store_credit_spec.rb +15 -0
  49. data/spec/models/spree/variant_spec.rb +37 -0
  50. data/spec/spec_helper.rb +34 -0
  51. data/spec/support/config.rb +23 -0
  52. metadata +179 -0
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ describe Spree::StoreCredit, set_tenant: true do
4
+ describe '#shipping_category' do
5
+ let(:store_credit) { described_class.new }
6
+
7
+ it 'does not raise an error when #payment_method_id is called' do
8
+ expect { store_credit.payment_method_id }.not_to raise_error
9
+ end
10
+
11
+ it 'returns nil for #payment_method_id' do
12
+ expect(store_credit.payment_method_id).to be_nil
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ describe Spree::Variant, set_tenant: true do
4
+ describe '#shipping_category' do
5
+ let(:variant) { described_class.new }
6
+ let(:shipping_category) { create(:shipping_category) }
7
+ let(:product) { create(:product, shipping_category: shipping_category) }
8
+
9
+ it 'returns nil for shipping_category when not set' do
10
+ expect(variant.shipping_category).to be_nil
11
+ end
12
+
13
+ it 'returns nil for shipping_category_id when not set' do
14
+ expect(variant.shipping_category_id).to be_nil
15
+ end
16
+
17
+ it 'returns the product shipping category when the variant shipping category is nil' do
18
+ variant.product = product
19
+ expect(variant.shipping_category).to eq(product.shipping_category)
20
+ end
21
+
22
+ it 'returns the product shipping category id when the variant shipping category is nil' do
23
+ variant.product = product
24
+ expect(variant.shipping_category_id).to eq(product.shipping_category_id)
25
+ end
26
+
27
+ it 'returns the correct shipping category id when the variant shipping category is set' do
28
+ variant.shipping_category = shipping_category
29
+ expect(variant.shipping_category_id).to eq(shipping_category.id)
30
+ end
31
+
32
+ it 'returns the correct shipping category when the variant shipping category is set' do
33
+ variant.shipping_category = shipping_category
34
+ expect(variant.shipping_category).to eq(shipping_category)
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'pry'
4
+
5
+ # Configure Rails Environment
6
+ ENV['RAILS_ENV'] = 'test'
7
+
8
+ # Run Coverage report
9
+ require 'solidus_dev_support/rspec/coverage'
10
+
11
+ # Create the dummy app if it's still missing.
12
+ dummy_env = "#{__dir__}/dummy/config/environment.rb"
13
+ system 'bin/rake extension:test_app' unless File.exist? dummy_env
14
+ require dummy_env
15
+
16
+ # Requires factories and other useful helpers defined in spree_core.
17
+ require 'solidus_dev_support/rspec/feature_helper'
18
+
19
+ # Requires supporting ruby files with custom matchers and macros, etc,
20
+ # in spec/support/ and its subdirectories.
21
+ Dir["#{__dir__}/support/**/*.rb"].sort.each { |f| require f }
22
+
23
+ # Requires factories defined in Solidus core and this extension.
24
+ # See: lib/solidus_acts_as_tenant/testing_support/factories.rb
25
+ SolidusDevSupport::TestingSupport::Factories.load_for(SolidusActsAsTenant::Engine)
26
+
27
+ RSpec.configure do |config|
28
+ config.infer_spec_type_from_file_location!
29
+ config.use_transactional_fixtures = false
30
+
31
+ if Spree.solidus_gem_version < Gem::Version.new('2.11')
32
+ config.extend Spree::TestingSupport::AuthorizationHelpers::Request, type: :system
33
+ end
34
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'pry'
4
+
5
+ RSpec.configure do |config|
6
+ config.before(:each, set_tenant: true) do
7
+ unless ::ActsAsTenant.current_tenant
8
+ ::ActsAsTenant.current_tenant =
9
+ ::SolidusActsAsTenant.config.class_name.constantize.find_or_create_by!(name: 'Test')
10
+ end
11
+ end
12
+
13
+ config.before(:suite, set_tenant: true) do
14
+ unless ::ActsAsTenant.current_tenant
15
+ ::ActsAsTenant.current_tenant =
16
+ ::SolidusActsAsTenant.config.class_name.constantize.find_or_create_by!(name: 'Test')
17
+ end
18
+ end
19
+
20
+ config.after do
21
+ ::ActsAsTenant.current_tenant = nil
22
+ end
23
+ end
metadata ADDED
@@ -0,0 +1,179 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: solidus_acts_as_tenant
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.5
5
+ platform: ruby
6
+ authors:
7
+ - Ikraam Ghoor
8
+ bindir: exe
9
+ cert_chain: []
10
+ date: 2025-03-10 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: acts_as_tenant
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - "~>"
17
+ - !ruby/object:Gem::Version
18
+ version: 1.0.1
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - "~>"
24
+ - !ruby/object:Gem::Version
25
+ version: 1.0.1
26
+ - !ruby/object:Gem::Dependency
27
+ name: solidus_core
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 2.0.0
33
+ - - "<"
34
+ - !ruby/object:Gem::Version
35
+ version: '5'
36
+ type: :runtime
37
+ prerelease: false
38
+ version_requirements: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: 2.0.0
43
+ - - "<"
44
+ - !ruby/object:Gem::Version
45
+ version: '5'
46
+ - !ruby/object:Gem::Dependency
47
+ name: solidus_support
48
+ requirement: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: 0.14.1
53
+ type: :runtime
54
+ prerelease: false
55
+ version_requirements: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: 0.14.1
60
+ - !ruby/object:Gem::Dependency
61
+ name: pry
62
+ requirement: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: '0'
67
+ type: :development
68
+ prerelease: false
69
+ version_requirements: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
74
+ - !ruby/object:Gem::Dependency
75
+ name: solidus_dev_support
76
+ requirement: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - "~>"
79
+ - !ruby/object:Gem::Version
80
+ version: '2.11'
81
+ type: :development
82
+ prerelease: false
83
+ version_requirements: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - "~>"
86
+ - !ruby/object:Gem::Version
87
+ version: '2.11'
88
+ description: Adds tenant functionality to solidus using the row level acts_as_tenant
89
+ gem
90
+ email: consult.ikraam@gmail.com
91
+ executables: []
92
+ extensions: []
93
+ extra_rdoc_files: []
94
+ files:
95
+ - ".gem_release.yml"
96
+ - ".github/stale.yml"
97
+ - ".github/workflows/lint.yml"
98
+ - ".github/workflows/test.yml"
99
+ - ".github_changelog_generator"
100
+ - ".gitignore"
101
+ - ".rspec"
102
+ - ".rubocop.yml"
103
+ - CHANGELOG.md
104
+ - Gemfile
105
+ - LICENSE
106
+ - README.md
107
+ - Rakefile
108
+ - app/decorators/solidus_acts_as_tenant/store_credit_decorator.rb
109
+ - app/decorators/solidus_acts_as_tenant/variant_decorator.rb
110
+ - app/models/spree/products_taxon.rb
111
+ - app/models/spree/reimbursement_credit.rb
112
+ - app/models/spree/tenant.rb
113
+ - bin/console
114
+ - bin/rails
115
+ - bin/rails-engine
116
+ - bin/rails-sandbox
117
+ - bin/rake
118
+ - bin/sandbox
119
+ - bin/setup
120
+ - config/locales/en.yml
121
+ - config/routes.rb
122
+ - db/migrate/20241204043609_add_tenant_id_to_solidus_tables.rb
123
+ - db/migrate/20241204055845_update_spree_unique_indexes_with_tenant_scope.rb
124
+ - db/migrate/20241204105318_create_spree_tenants.rb
125
+ - lib/generators/solidus_acts_as_tenant/install/install_generator.rb
126
+ - lib/generators/solidus_acts_as_tenant/install/templates/initializer.rb
127
+ - lib/generators/solidus_acts_as_tenant/install/templates/tenant_aware_models.yml
128
+ - lib/solidus_acts_as_tenant.rb
129
+ - lib/solidus_acts_as_tenant/configuration.rb
130
+ - lib/solidus_acts_as_tenant/engine.rb
131
+ - lib/solidus_acts_as_tenant/factories/preference_factory.rb
132
+ - lib/solidus_acts_as_tenant/factories/tenant_factory.rb
133
+ - lib/solidus_acts_as_tenant/tenant_aware.rb
134
+ - lib/solidus_acts_as_tenant/testing_support/factories.rb
135
+ - lib/solidus_acts_as_tenant/utils/tenant_selector.rb
136
+ - lib/solidus_acts_as_tenant/version.rb
137
+ - solidus_acts_as_tenant.gemspec
138
+ - spec/lib/solidus_acts_as_tenant/configuration_spec.rb
139
+ - spec/lib/solidus_acts_as_tenant/solidus_acts_as_tenant_spec.rb
140
+ - spec/lib/solidus_acts_as_tenant/tenant_aware_spec.rb
141
+ - spec/models/spree/store_credit_spec.rb
142
+ - spec/models/spree/variant_spec.rb
143
+ - spec/spec_helper.rb
144
+ - spec/support/config.rb
145
+ homepage: https://github.com/nebulab/solidus_acts_as_tenant#readme
146
+ licenses:
147
+ - BSD-3-Clause
148
+ metadata:
149
+ homepage_uri: https://github.com/nebulab/solidus_acts_as_tenant#readme
150
+ source_code_uri: https://github.com/nebulab/solidus_acts_as_tenant
151
+ changelog_uri: https://github.com/nebulab/solidus_acts_as_tenant/blob/main/CHANGELOG.md
152
+ rdoc_options: []
153
+ require_paths:
154
+ - lib
155
+ required_ruby_version: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '2.5'
160
+ - - "<"
161
+ - !ruby/object:Gem::Version
162
+ version: '4'
163
+ required_rubygems_version: !ruby/object:Gem::Requirement
164
+ requirements:
165
+ - - ">="
166
+ - !ruby/object:Gem::Version
167
+ version: '0'
168
+ requirements: []
169
+ rubygems_version: 3.6.2
170
+ specification_version: 4
171
+ summary: Adds tenant functionality to solidus using the row level acts_as_tenant gem
172
+ test_files:
173
+ - spec/lib/solidus_acts_as_tenant/configuration_spec.rb
174
+ - spec/lib/solidus_acts_as_tenant/solidus_acts_as_tenant_spec.rb
175
+ - spec/lib/solidus_acts_as_tenant/tenant_aware_spec.rb
176
+ - spec/models/spree/store_credit_spec.rb
177
+ - spec/models/spree/variant_spec.rb
178
+ - spec/spec_helper.rb
179
+ - spec/support/config.rb