Skip to content

Commit

Permalink
Do not use default_scope in ActiveRecord::Persistence#touch.
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitriy-kiriyenko authored and jonleighton committed Jun 7, 2011
1 parent 050d6ef commit 7c1f73c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion activerecord/lib/active_record/persistence.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ def touch(name = nil)


@changed_attributes.except!(*changes.keys) @changed_attributes.except!(*changes.keys)
primary_key = self.class.primary_key primary_key = self.class.primary_key
self.class.update_all(changes, { primary_key => self[primary_key] }) == 1 self.class.unscoped.update_all(changes, { primary_key => self[primary_key] }) == 1
end end
end end


Expand Down
9 changes: 9 additions & 0 deletions activerecord/test/cases/timestamp_test.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -40,6 +40,15 @@ def test_touching_a_record_updates_its_timestamp
assert_equal previous_salary, @developer.salary assert_equal previous_salary, @developer.salary
end end


def test_touching_a_record_with_default_scope_that_exludes_it_updates_its_timestamp
developer = @developer.becomes(DeveloperCalledJamis)

developer.touch
assert_not_equal @previously_updated_at, developer.updated_at
developer.reload
assert_not_equal @previously_updated_at, developer.updated_at
end

def test_saving_when_record_timestamps_is_false_doesnt_update_its_timestamp def test_saving_when_record_timestamps_is_false_doesnt_update_its_timestamp
Developer.record_timestamps = false Developer.record_timestamps = false
@developer.name = "John Smith" @developer.name = "John Smith"
Expand Down

0 comments on commit 7c1f73c

Please sign in to comment.