Skip to content

Instantly share code, notes, and snippets.

@madmax
Created June 21, 2016 08:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save madmax/e796a740386d1b25516449b5d19b4fd8 to your computer and use it in GitHub Desktop.
Save madmax/e796a740386d1b25516449b5d19b4fd8 to your computer and use it in GitHub Desktop.
cache_key timestamp not calculated when using offset
begin
require 'bundler/inline'
rescue LoadError => e
$stderr.puts 'Bundler version 1.10 or later is required. Please update your Bundler'
raise e
end
gemfile(true) do
source 'https://rubygems.org'
gem 'rails', github: 'rails/rails'
gem 'sqlite3'
end
require 'active_record'
require 'minitest/autorun'
require 'logger'
# This connection will do for database-independent bug reports.
ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:')
ActiveRecord::Base.logger = Logger.new(STDOUT)
ActiveRecord::Schema.define do
create_table :posts, force: true do |t|
t.timestamps
end
end
class Post < ActiveRecord::Base
end
class BugTest < Minitest::Test
def test_cache_key
10.times { Post.create! }
cache_key1 = Post.limit(5).cache_key
cache_key2 = Post.limit(5).offset(5).cache_key
puts cache_key1
puts cache_key2
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment