Skip to content

Commit

Permalink
Fix test to avoid memoization bug
Browse files Browse the repository at this point in the history
I don't believe primary_key is ever changed within a request
  • Loading branch information
vprigent committed Jan 21, 2025
1 parent 42d2473 commit f9677ab
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions spec/bullet/ext/object_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,21 @@
end

it 'should return primary key value' do
post = Post.first
Post.primary_key = 'name'
post = Post.first
expect(post.bullet_primary_key_value).to eq(post.name)
Post.primary_key = 'id'
end

it 'should return value for multiple primary keys from the composite_primary_key gem' do
post = Post.first
allow(Post).to receive(:primary_keys).and_return(%i[category_id writer_id])
post = Post.first
expect(post.bullet_primary_key_value).to eq("#{post.category_id},#{post.writer_id}")
end

it 'should return value for multiple primary keys from ActiveRecord 7.1' do
post = Post.first
allow(Post).to receive(:primary_key).and_return(%i[category_id writer_id])
post = Post.first
expect(post.bullet_primary_key_value).to eq("#{post.category_id},#{post.writer_id}")
end

Expand Down

0 comments on commit f9677ab

Please sign in to comment.