panda_pal 5.12.0 → 5.12.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/panda_pal/engine.rb +9 -1
- data/lib/panda_pal/spec_helper.rb +8 -5
- data/lib/panda_pal/version.rb +1 -1
- data/spec/core/apartment_multidb_spec.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5aaa770332536d17f0a40ca1501b4b1e7887d1ce06a77ceb36f379d6177fa841
|
4
|
+
data.tar.gz: 33645394c6afdc6e56a3cba902c615dc8bea904d327768193f533eff40e1ec4f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dd6acc35f33b92bb9bcb05390867c34680cd81fe02c985399ee97fa82988efe79694392024d40e8cecd4e873f606d810ed1ad9e30dad3654395355f8ec1f2a9e
|
7
|
+
data.tar.gz: 79fb4db2b78e89025737ff607a062351cec69f747c61169a93c1e5759aad19672f4c14148d49229b80eef07b1d11615c75127082946576b17f49d29a6479ef56
|
data/lib/panda_pal/engine.rb
CHANGED
@@ -66,9 +66,17 @@ module PandaPal
|
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
69
|
+
unless defined?(switch_org)
|
70
|
+
def switch_org(org, &block)
|
71
|
+
org = PandaPal::Organization.find_by(name: org) if org.is_a?(String)
|
72
|
+
org.switch_tenant(&block)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
69
76
|
unless defined?(current_organization)
|
70
77
|
def current_organization
|
71
|
-
|
78
|
+
org_name = Apartment::Tenant.split_tenant(Apartment::Tenant.current)[1]
|
79
|
+
PandaPal::Organization.find_by_name(org_name)
|
72
80
|
end
|
73
81
|
end
|
74
82
|
end
|
@@ -2,7 +2,7 @@ module PandaPal::SpecHelper
|
|
2
2
|
extend ActiveSupport::Concern
|
3
3
|
|
4
4
|
class_methods do
|
5
|
-
def with_multiple_shards(shards:,
|
5
|
+
def with_multiple_shards(shards:, tenant_names: [], determine_shard: nil, transactional: true)
|
6
6
|
self.use_transactional_tests = transactional
|
7
7
|
|
8
8
|
original_settings = {}
|
@@ -26,7 +26,7 @@ module PandaPal::SpecHelper
|
|
26
26
|
|
27
27
|
Apartment::Tenant.reload!
|
28
28
|
|
29
|
-
clean_schemas(
|
29
|
+
clean_schemas(tenant_names)
|
30
30
|
end
|
31
31
|
|
32
32
|
after :all do
|
@@ -48,7 +48,7 @@ module PandaPal::SpecHelper
|
|
48
48
|
end
|
49
49
|
|
50
50
|
before :each do
|
51
|
-
clean_schemas(
|
51
|
+
clean_schemas(tenant_names)
|
52
52
|
|
53
53
|
@each_existing_org_ids = PandaPal::Organization.pluck(:id)
|
54
54
|
|
@@ -68,9 +68,12 @@ module PandaPal::SpecHelper
|
|
68
68
|
end
|
69
69
|
|
70
70
|
define_method :clean_schemas do |schemas|
|
71
|
-
|
71
|
+
# Clean known schemas if an Organization record does not exist for them
|
72
|
+
schema_to_fqt = schemas.index_by { |s| Apartment::Tenant.split_tenant(s)[1] }
|
73
|
+
schemas_to_clean = schema_to_fqt.keys - PandaPal::Organization.pluck(:name)
|
72
74
|
|
73
|
-
|
75
|
+
schemas_to_clean.each do |schema|
|
76
|
+
# fqt = schema_to_fqt[schema]
|
74
77
|
Apartment::Tenant.drop(schema) rescue nil
|
75
78
|
shards.each do |k, v|
|
76
79
|
Apartment::Tenant.drop("#{k}:#{schema}") rescue nil
|
data/lib/panda_pal/version.rb
CHANGED
@@ -6,7 +6,7 @@ RSpec.describe PandaPal::Organization, type: :model do
|
|
6
6
|
context "across multiple DBs" do
|
7
7
|
with_multiple_shards(
|
8
8
|
shards: { alt: "panda_pal_test2" },
|
9
|
-
|
9
|
+
tenant_names: %w[on_primary alt:on_alt],
|
10
10
|
transactional: false,
|
11
11
|
determine_shard: ->(org) { org.name.include?("alt") ? "alt" : nil }
|
12
12
|
)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: panda_pal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.12.
|
4
|
+
version: 5.12.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Instructure CustomDev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-11-
|
11
|
+
date: 2024-11-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|