diff options
author | Xavier Noria <fxn@hashref.com> | 2013-04-01 09:42:23 +0200 |
---|---|---|
committer | Xavier Noria <fxn@hashref.com> | 2013-04-01 09:43:57 +0200 |
commit | 3f35924b3c8202e1e8546270cc12a9670b138953 (patch) | |
tree | 49ec34468c810b8ceaadbd1c22827542e02b6aaa /guides | |
parent | 0a16cf19c2e2a2ba5cdb6ca849b60751f6cb52ed (diff) | |
download | rails-3f35924b3c8202e1e8546270cc12a9670b138953.tar.gz rails-3f35924b3c8202e1e8546270cc12a9670b138953.tar.bz2 rails-3f35924b3c8202e1e8546270cc12a9670b138953.zip |
gist for Active Record issues [Neeraj Singh & Xavier Noria]
This commit closes issue #9775.
Diffstat (limited to 'guides')
-rw-r--r-- | guides/bug_report_templates/active_record_gem.rb | 35 | ||||
-rw-r--r-- | guides/bug_report_templates/active_record_master.rb | 46 | ||||
-rw-r--r-- | guides/source/contributing_to_ruby_on_rails.md | 10 |
3 files changed, 90 insertions, 1 deletions
diff --git a/guides/bug_report_templates/active_record_gem.rb b/guides/bug_report_templates/active_record_gem.rb new file mode 100644 index 0000000000..5ef1397ecd --- /dev/null +++ b/guides/bug_report_templates/active_record_gem.rb @@ -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 diff --git a/guides/bug_report_templates/active_record_master.rb b/guides/bug_report_templates/active_record_master.rb new file mode 100644 index 0000000000..9a3ccd8554 --- /dev/null +++ b/guides/bug_report_templates/active_record_master.rb @@ -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 diff --git a/guides/source/contributing_to_ruby_on_rails.md b/guides/source/contributing_to_ruby_on_rails.md index b6363bdfb1..0be9bb1ced 100644 --- a/guides/source/contributing_to_ruby_on_rails.md +++ b/guides/source/contributing_to_ruby_on_rails.md @@ -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. |