OSDN Git Service

Disable observers in specs. Enable only when observer is under test.
authorRobb Kidd <robb@thekidds.org>
Tue, 12 Jun 2012 18:27:03 +0000 (14:27 -0400)
committerRobb Kidd <robb@thekidds.org>
Wed, 20 Jun 2012 18:09:46 +0000 (14:09 -0400)
commitdfb5da9da339096ad0a8e754f4f42ca2007b5ae6
tree3d5464ebdcf31bd3bc3cf44a35e072aa1cde3849
parent5303cc285a2067b59f1e8b68f707e8dbf90fe59e
Disable observers in specs. Enable only when observer is under test.

Used the built-in observer enable/disable feature in ActiveModel[1].
ActiveRecord::Base includes ActiveModel::Observing which provides this
behavior.

Simple wraps to enable the observer under test were added to the specs
for: ActivityObserver, IssueObserver, Admin::Users and Issues.

The spec for Project.last_activity was refactored to separate the tests
for #last_activity and #last_activity_date. Each had doubles added to
isolate the spec from the hidden dependency on the ActivityObserver
action to create an Event for the project when an Issue is created. This
ActivityObserver behavior is already tested by its spec.

[1] http://api.rubyonrails.org/classes/ActiveModel/ObserverArray.html
spec/models/activity_observer_spec.rb
spec/models/issue_observer_spec.rb
spec/models/project_spec.rb
spec/requests/admin/admin_users_spec.rb
spec/requests/issues_spec.rb
spec/spec_helper.rb