jit_preloader 3.0.0 → 3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 11ad98c8ab59226bb807d9686a0440140b7ca802d2faf33a0c26c428f2371e7a
4
- data.tar.gz: 0e4832fbea9fc6fafce7445390ef34eed82c3984df471486a7e871db4c6b2717
3
+ metadata.gz: dac1fcb3b291d3064e2f06455c08d0b25d7c4875bb4f7c5938c194c6ca9dc232
4
+ data.tar.gz: 5704f5b84dfd9b99898bf145622cd3175afbbf5a4cee3ecb2a4599d7a7e5fbc5
5
5
  SHA512:
6
- metadata.gz: c8932fc1d40b83fd0678ceed57856ab13021e047e9c4ea82b6b42434b98b760f9d51d5b77b232db249573bce512e930e7374b006e09977d9105086a24ff79b1b
7
- data.tar.gz: 9595ae9cddddde356275480f54efe19c3792e93b100abad3ddced491644c06d8dfc197af4651a7be7af9aa1fe4d319fcf8f383e6493f2e7efec245094926e56e
6
+ metadata.gz: e1b603e9e2fc4748b8765b8329ac435a17cdf5753b9a69479c44fdd78f3398293e1ffccd666667bf93a83db15dc326fa9d389a06bc930d00998032111c2dcea4
7
+ data.tar.gz: 88c93ec8fb2ad3e24b2209ed4c456389b0f93c0b8b729f60ccccd5f00e7960cb12251f4cfaf364d0f718cfe788803cc2dbd55799ae61832d2ee3f07d6291fe50
@@ -9,6 +9,7 @@ on:
9
9
  jobs:
10
10
  test:
11
11
  runs-on: ubuntu-latest
12
+ timeout-minutes: 5
12
13
  strategy:
13
14
  fail-fast: false
14
15
  matrix:
data/.gitignore CHANGED
@@ -50,3 +50,4 @@ Gemfile.lock
50
50
 
51
51
  # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
52
52
  .rvmrc
53
+ .ruby-version
@@ -10,7 +10,10 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ["kyle.doliveira@clio.com"]
11
11
  spec.summary = %q{Tool to understand N+1 queries and to remove them}
12
12
  spec.description = %q{The JitPreloader has the ability to send notifications when N+1 queries occur to help guage how problematic they are for your code base and a way to remove all of the commons explicitly or automatically}
13
- spec.homepage = ""
13
+ spec.homepage = "https://github.com/clio/jit_preloader"
14
+ spec.metadata["homepage_uri"] = spec.homepage
15
+ spec.metadata["source_code_uri"] = spec.homepage
16
+
14
17
  spec.license = "MIT"
15
18
 
16
19
  spec.files = `git ls-files -z`.split("\x0")
@@ -22,6 +22,7 @@ module JitPreloadExtension
22
22
  def preload_scoped_relation(name:, base_association:, preload_scope: nil)
23
23
  return jit_preload_scoped_relations[name] if jit_preload_scoped_relations&.key?(name)
24
24
 
25
+ base_association = base_association.to_sym
25
26
  records = jit_preloader&.records || [self]
26
27
  previous_association_values = {}
27
28
 
@@ -55,6 +56,7 @@ module JitPreloadExtension
55
56
  def preload_scoped_relation(name:, base_association:, preload_scope: nil)
56
57
  return jit_preload_scoped_relations[name] if jit_preload_scoped_relations&.key?(name)
57
58
 
59
+ base_association = base_association.to_sym
58
60
  records = jit_preloader&.records || [self]
59
61
  previous_association_values = {}
60
62
 
@@ -1,3 +1,3 @@
1
1
  module JitPreloader
2
- VERSION = "3.0.0"
2
+ VERSION = "3.1.0"
3
3
  end
@@ -106,5 +106,27 @@ RSpec.describe "ActiveRecord::Base Extensions" do
106
106
  expect(value).to eq([])
107
107
  end
108
108
  end
109
+
110
+ context "when preload_scoped_relation with string base_association name" do
111
+ it "preload properly" do
112
+ contacts = Contact.jit_preload.limit(2).to_a
113
+
114
+ call_with_string = lambda { |contact| contact.preload_scoped_relation(
115
+ name: "American Addresses",
116
+ base_association: "addresses",
117
+ preload_scope: Address.where(country: usa)
118
+ ) }
119
+
120
+ usa_addresses = contacts.first.addresses.where(country: usa).to_a
121
+ expect do
122
+ expect(call_with_string.call(contacts.first)).to match_array usa_addresses
123
+ end.to make_database_queries(count: 1)
124
+
125
+ usa_addresses = contacts.last.addresses.where(country: usa).to_a
126
+ expect do
127
+ expect(call_with_string.call(contacts.last)).to match_array usa_addresses
128
+ end.to_not make_database_queries
129
+ end
130
+ end
109
131
  end
110
132
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jit_preloader
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kyle d'Oliveira
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-06-13 00:00:00.000000000 Z
11
+ date: 2024-11-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -176,10 +176,12 @@ files:
176
176
  - spec/spec_helper.rb
177
177
  - spec/support/database.rb
178
178
  - spec/support/models.rb
179
- homepage: ''
179
+ homepage: https://github.com/clio/jit_preloader
180
180
  licenses:
181
181
  - MIT
182
- metadata: {}
182
+ metadata:
183
+ homepage_uri: https://github.com/clio/jit_preloader
184
+ source_code_uri: https://github.com/clio/jit_preloader
183
185
  post_install_message:
184
186
  rdoc_options: []
185
187
  require_paths: