Skip to content

Instantly share code, notes, and snippets.

@prakashmurthy
Last active August 17, 2016 13:53
Show Gist options
  • Save prakashmurthy/6cce5eb773d1adc988c8c2fc7fc70026 to your computer and use it in GitHub Desktop.
Save prakashmurthy/6cce5eb773d1adc988c8c2fc7fc70026 to your computer and use it in GitHub Desktop.
Files for adding a new test in rails codebase for issue #26122
# activerecord/test/cases/my_assignment_test.rb
require "cases/helper"
require "models/stat"
class MyAssignmentTest < ActiveRecord::TestCase
ActiveRecord::Schema.define do
create_table :stats, force: true do |t|
t.integer :count, default: 0
end
end
def test_thousands_of_assignments
stat = Stat.new
20_000.times { stat.count += 1 }
assert stat.save
end
end
# activerecord/test/models/stat.rb
class Stat < ActiveRecord::Base
end
# Script to run the above test
bundle exec ruby -I activerecord/lib:activerecord/test activerecord/test/cases/my_assignment_test.rb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment