Skip to content

Commit

Permalink
Bump version to 0.2.4
Browse files Browse the repository at this point in the history
  • Loading branch information
DmitryTsepelev committed Nov 21, 2018
1 parent 4bb451d commit 757a3ad
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 45 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Expand Up @@ -2,6 +2,10 @@

## master

## 0.2.4 (2018-11-21)

- [PR [#14](https://github.com/DmitryTsepelev/ar_lazy_preload/pull/14)] Fix deep association preloading when specified via array of hash ([@PikachuEXE][])

## 0.2.3 (2018-11-20)

- [PR [#13](https://github.com/DmitryTsepelev/ar_lazy_preload/pull/13)] Fix association loading when specified in hash inside array ([@PikachuEXE][])
Expand Down
2 changes: 1 addition & 1 deletion lib/ar_lazy_preload/version.rb
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module ArLazyPreload
VERSION = "0.2.3"
VERSION = "0.2.4"
end
15 changes: 3 additions & 12 deletions spec/ar_lazy_preload/active_record/relation_spec.rb
Expand Up @@ -39,20 +39,11 @@
# SELECT "users".* FROM "users" WHERE "users"."id" IN (...)
# SELECT "posts".* FROM "posts" WHERE "posts"."user_id" IN (...)
it "loads lazy_preloaded association only when needed" do
comments = Comment.lazy_preload(
post: [
{
user: [
{
posts: :comments
}
]
}
]
)
comments = Comment.lazy_preload(post: [{ user: [{ posts: :comments }] }])

expect do
comments.each do |comment|
comment&.post&.user&.posts&.each { |post| post.id }
comment&.post&.user&.posts&.each(&:id)
end
end.to make_database_queries(count: 4)
end
Expand Down
36 changes: 4 additions & 32 deletions spec/ar_lazy_preload/association_tree_builder_spec.rb
Expand Up @@ -26,41 +26,13 @@
end

it "supports arrays in single hash" do
subject = described_class.new(
user: [
{
posts: :comments
}
]
)
expect(subject.subtree_for(:user)).to eq(
[
{
posts: :comments
}
]
)
subject = described_class.new(user: [{ posts: :comments }])
expect(subject.subtree_for(:user)).to eq([{ posts: :comments }])
end

it "supports arrays in array of hashes" do
subject = described_class.new(
[
{
user: [
{
posts: :comments
}
]
}
]
)
expect(subject.subtree_for(:user)).to eq(
[
{
posts: :comments
}
]
)
subject = described_class.new([{ user: [{ posts: :comments }] }])
expect(subject.subtree_for(:user)).to eq([{ posts: :comments }])
end
end
end

0 comments on commit 757a3ad

Please sign in to comment.