diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2013-10-16 11:43:13 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2013-10-16 11:43:13 -0700 |
commit | 2549f6d8ee104d1f83f573f5057c5f5e7c699608 (patch) | |
tree | fe7955cb4cf106458e6ce45c15b18c65bf4246bb | |
parent | 23f35b2fd87b586278b167bb3f614df00811b104 (diff) | |
parent | f2ca5aa5c2e9fed43ab11937906d98bd436ab820 (diff) | |
download | rails-2549f6d8ee104d1f83f573f5057c5f5e7c699608.tar.gz rails-2549f6d8ee104d1f83f573f5057c5f5e7c699608.tar.bz2 rails-2549f6d8ee104d1f83f573f5057c5f5e7c699608.zip |
Merge branch 'master' into joindep
* master:
Rephrase ActiveRecord transaction rollback warning
Fix code blocks identation on AR and AS CHANGELOGs
Removing unused fake models from actionpack tests
-rw-r--r-- | actionpack/test/lib/controller/fake_models.rb | 95 | ||||
-rw-r--r-- | activerecord/CHANGELOG.md | 12 | ||||
-rw-r--r-- | activesupport/CHANGELOG.md | 12 | ||||
-rw-r--r-- | guides/source/active_record_callbacks.md | 2 |
4 files changed, 13 insertions, 108 deletions
diff --git a/actionpack/test/lib/controller/fake_models.rb b/actionpack/test/lib/controller/fake_models.rb index 38abb16d08..08af187311 100644 --- a/actionpack/test/lib/controller/fake_models.rb +++ b/actionpack/test/lib/controller/fake_models.rb @@ -96,88 +96,6 @@ class Comment attr_accessor :body end -class Tag - extend ActiveModel::Naming - include ActiveModel::Conversion - - attr_reader :id - attr_reader :post_id - def initialize(id = nil, post_id = nil); @id, @post_id = id, post_id end - def to_key; id ? [id] : nil end - def save; @id = 1; @post_id = 1 end - def persisted?; @id.present? end - def to_param; @id; end - def value - @id.nil? ? "new #{self.class.name.downcase}" : "#{self.class.name.downcase} ##{@id}" - end - - attr_accessor :relevances - def relevances_attributes=(attributes); end - -end - -class CommentRelevance - extend ActiveModel::Naming - include ActiveModel::Conversion - - attr_reader :id - attr_reader :comment_id - def initialize(id = nil, comment_id = nil); @id, @comment_id = id, comment_id end - def to_key; id ? [id] : nil end - def save; @id = 1; @comment_id = 1 end - def persisted?; @id.present? end - def to_param; @id; end - def value - @id.nil? ? "new #{self.class.name.downcase}" : "#{self.class.name.downcase} ##{@id}" - end -end - -class Sheep - extend ActiveModel::Naming - include ActiveModel::Conversion - - attr_reader :id - def to_key; id ? [id] : nil end - def save; @id = 1 end - def new_record?; @id.nil? end - def name - @id.nil? ? 'new sheep' : "sheep ##{@id}" - end -end - - -class TagRelevance - extend ActiveModel::Naming - include ActiveModel::Conversion - - attr_reader :id - attr_reader :tag_id - def initialize(id = nil, tag_id = nil); @id, @tag_id = id, tag_id end - def to_key; id ? [id] : nil end - def save; @id = 1; @tag_id = 1 end - def persisted?; @id.present? end - def to_param; @id; end - def value - @id.nil? ? "new #{self.class.name.downcase}" : "#{self.class.name.downcase} ##{@id}" - end -end - -class Author < Comment - attr_accessor :post - def post_attributes=(attributes); end -end - -class HashBackedAuthor < Hash - extend ActiveModel::Naming - include ActiveModel::Conversion - - def persisted?; false; end - - def name - "hash backed author" - end -end - module Blog def self.use_relative_model_naming? true @@ -193,21 +111,8 @@ module Blog end end -class ArelLike - def to_ary - true - end - def each - a = Array.new(2) { |id| Comment.new(id + 1) } - a.each { |i| yield i } - end -end - class RenderJsonTestException < Exception def to_json(options = nil) return { :error => self.class.name, :message => self.to_s }.to_json end end - -class Car < Struct.new(:color) -end diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md index 6e93477c3b..2d19e44abc 100644 --- a/activerecord/CHANGELOG.md +++ b/activerecord/CHANGELOG.md @@ -342,13 +342,13 @@ * Reset @column_defaults when assigning `locking_column`. We had a potential problem. For example: - class Post < ActiveRecord::Base - self.column_defaults # if we call this unintentionally before setting locking_column ... - self.locking_column = 'my_locking_column' - end + class Post < ActiveRecord::Base + self.column_defaults # if we call this unintentionally before setting locking_column ... + self.locking_column = 'my_locking_column' + end - Post.column_defaults["my_locking_column"] - => nil # expected value is 0 ! + Post.column_defaults["my_locking_column"] + => nil # expected value is 0 ! *kennyj* diff --git a/activesupport/CHANGELOG.md b/activesupport/CHANGELOG.md index f1dd7c312d..246d94882b 100644 --- a/activesupport/CHANGELOG.md +++ b/activesupport/CHANGELOG.md @@ -22,14 +22,14 @@ You can do this: - class JokeSubscriber < ActiveSupport::Subscriber - # This is much easier to read! - attach_to "active_record" + class JokeSubscriber < ActiveSupport::Subscriber + # This is much easier to read! + attach_to "active_record" - def sql(event) - puts "A rabbi and a priest walk into a bar..." + def sql(event) + puts "A rabbi and a priest walk into a bar..." + end end - end This should make it easier to read and understand these subscribers. diff --git a/guides/source/active_record_callbacks.md b/guides/source/active_record_callbacks.md index aa2ce99f6d..5cc6ca5798 100644 --- a/guides/source/active_record_callbacks.md +++ b/guides/source/active_record_callbacks.md @@ -204,7 +204,7 @@ As you start registering new callbacks for your models, they will be queued for The whole callback chain is wrapped in a transaction. If any _before_ callback method returns exactly `false` or raises an exception, the execution chain gets halted and a ROLLBACK is issued; _after_ callbacks can only accomplish that by raising an exception. -WARNING. Raising an arbitrary exception may break code that expects `save` and its friends not to fail like that. The `ActiveRecord::Rollback` exception is thought precisely to tell Active Record a rollback is going on. That one is internally captured but not reraised. +WARNING. Any exception that is not `ActiveRecord::Rollback` will be re-raised by Rails after the callback chain is halted. Raising an exception other than `ActiveRecord::Rollback` may break code that does not expect methods like `save` and `update_attributes` (which normally try to return `true` or `false`) to raise an exception. Relational Callbacks -------------------- |