forked from insoshi/insoshi
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding activity when person attends event. Improved Specs
- Loading branch information
Jorge Dias
committed
Sep 10, 2008
1 parent
683c071
commit 9773da8
Showing
4 changed files
with
63 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,14 @@ | ||
class EventAttendee < ActiveRecord::Base | ||
include ActivityLogger | ||
|
||
belongs_to :person | ||
belongs_to :event, :counter_cache => true | ||
validates_uniqueness_of :person_id, :scope => :event_id | ||
|
||
after_create :log_activity | ||
|
||
def log_activity | ||
add_activities(:item => self, :person => self.person) | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') | ||
|
||
describe EventAttendee do | ||
before(:each) do | ||
@person = people(:aaron) | ||
@event = events(:public) | ||
@event_attendee = EventAttendee.new(:event => @event, | ||
:person => @person) | ||
end | ||
|
||
it 'should be valid' do | ||
@event.should be_valid | ||
end | ||
|
||
describe "event_attendee activity associations" do | ||
before(:each) do | ||
@event_attendee.save! | ||
@activity = Activity.find_by_item_id(@event_attendee) | ||
end | ||
|
||
it "should have an activity" do | ||
@activity.should_not be_nil | ||
end | ||
|
||
it "should add an activity to the attendee" do | ||
@event_attendee.person.recent_activity.should contain(@activity) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters