docbrown/spec/models/application_record_spec.rb
rhymes 9b2886979a ActiveRecord count optimizations (#5478) [deploy]
* Do not load messages in memory, just to count them
* Add Model.estimated_count
* Use Model.estimated_count in task record_db_table_counts
* Use size and estimated_count
* Use table_name so that .estimated_count works with all models
* Add comment to explain the .load.size + .each pattern
2020-01-14 12:03:38 -05:00

10 lines
317 B
Ruby

require "rails_helper"
# ApplicationRecord is an abstract class, tests will use one of the core models
RSpec.describe ApplicationRecord, type: :model do
describe ".estimated_count" do
it "does not raise errors if there are no rows" do
expect { User.estimated_count }.not_to raise_error
end
end
end