mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
gist for Active Record issues [Neeraj Singh & Xavier Noria]
This commit closes issue #9775.
This commit is contained in:
parent
0a16cf19c2
commit
3f35924b3c
3 changed files with 90 additions and 1 deletions
35
guides/bug_report_templates/active_record_gem.rb
Normal file
35
guides/bug_report_templates/active_record_gem.rb
Normal file
|
@ -0,0 +1,35 @@
|
|||
# Activate the gem you are reporting the issue against.
|
||||
gem 'activerecord', '3.2.11'
|
||||
require 'active_record'
|
||||
require "minitest/autorun"
|
||||
|
||||
# This connection will do for database-independent bug reports.
|
||||
ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:')
|
||||
|
||||
ActiveRecord::Schema.define do
|
||||
create_table :posts do |t|
|
||||
end
|
||||
|
||||
create_table :comments do |t|
|
||||
t.integer :post_id
|
||||
end
|
||||
end
|
||||
|
||||
class Post < ActiveRecord::Base
|
||||
has_many :comments
|
||||
end
|
||||
|
||||
class Comment < ActiveRecord::Base
|
||||
belongs_to :post
|
||||
end
|
||||
|
||||
class HasManyBugTest < MiniTest::Unit::TestCase
|
||||
def test_association_stuff
|
||||
post = Post.create!
|
||||
post.comments << Comment.create!
|
||||
|
||||
assert_equal 1, post.comments.count
|
||||
assert_equal 1, Comment.count
|
||||
assert_equal post.id, Comment.first.post.id
|
||||
end
|
||||
end
|
46
guides/bug_report_templates/active_record_master.rb
Normal file
46
guides/bug_report_templates/active_record_master.rb
Normal file
|
@ -0,0 +1,46 @@
|
|||
unless File.exists?('Gemfile')
|
||||
File.write('Gemfile', <<-GEMFILE)
|
||||
source 'https://rubygems.org'
|
||||
gem 'rails', github: 'rails/rails'
|
||||
gem 'sqlite3'
|
||||
GEMFILE
|
||||
|
||||
system 'bundle'
|
||||
end
|
||||
|
||||
require 'bundler'
|
||||
Bundler.setup(:default)
|
||||
|
||||
require 'active_record'
|
||||
require "minitest/autorun"
|
||||
|
||||
# This connection will do for database-independent bug reports.
|
||||
ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:')
|
||||
|
||||
ActiveRecord::Schema.define do
|
||||
create_table :posts do |t|
|
||||
end
|
||||
|
||||
create_table :comments do |t|
|
||||
t.integer :post_id
|
||||
end
|
||||
end
|
||||
|
||||
class Post < ActiveRecord::Base
|
||||
has_many :comments
|
||||
end
|
||||
|
||||
class Comment < ActiveRecord::Base
|
||||
belongs_to :post
|
||||
end
|
||||
|
||||
class HasManyBugTest < MiniTest::Unit::TestCase
|
||||
def test_association_stuff
|
||||
post = Post.create!
|
||||
post.comments << Comment.create!
|
||||
|
||||
assert_equal 1, post.comments.count
|
||||
assert_equal 1, Comment.count
|
||||
assert_equal post.id, Comment.first.post.id
|
||||
end
|
||||
end
|
|
@ -24,12 +24,20 @@ NOTE: Bugs in the most recent released version of Ruby on Rails are likely to ge
|
|||
|
||||
### Creating a Bug Report
|
||||
|
||||
If you've found a problem in Ruby on Rails which is not a security risk, do a search in GitHub under [Issues](https://github.com/rails/rails/issues) in case it was already reported. If you find no issue addressing it you can [add a new one](https://github.com/rails/rails/issues/new). (See the next section for reporting security issues).
|
||||
If you've found a problem in Ruby on Rails which is not a security risk, do a search in GitHub under [Issues](https://github.com/rails/rails/issues) in case it was already reported. If you find no issue addressing it you can [add a new one](https://github.com/rails/rails/issues/new). (See the next section for reporting security issues.)
|
||||
|
||||
At the minimum, your issue report needs a title and descriptive text. But that's only a minimum. You should include as much relevant information as possible. You need at least to post the code sample that has the issue. Even better is to include a unit test that shows how the expected behavior is not occurring. Your goal should be to make it easy for yourself — and others — to replicate the bug and figure out a fix.
|
||||
|
||||
Then, don't get your hopes up! Unless you have a "Code Red, Mission Critical, the World is Coming to an End" kind of bug, you're creating this issue report in the hope that others with the same problem will be able to collaborate with you on solving it. Do not expect that the issue report will automatically see any activity or that others will jump to fix it. Creating an issue like this is mostly to help yourself start on the path of fixing the problem and for others to confirm it with an "I'm having this problem too" comment.
|
||||
|
||||
### Create a Self-Contained gist for Active Record Issues
|
||||
|
||||
If you are filing a bug report for Active Record, please use
|
||||
[this template for gems](https://github.com/rails/rails/blob/master/guides/bug_report_templates/active_record_gem.rb)
|
||||
if the bug is found in a published gem, and
|
||||
[this template for master](https://github.com/rails/rails/blob/master/guides/bug_report_templates/active_record_master.rb)
|
||||
if the bug happens in the master branch.
|
||||
|
||||
### Special Treatment for Security Issues
|
||||
|
||||
WARNING: Please do not report security vulnerabilities with public GitHub issue reports. The [Rails security policy page](http://rubyonrails.org/security) details the procedure to follow for security issues.
|
||||
|
|
Loading…
Reference in a new issue