Skip to content

Commit

Permalink
Changed friends method so it accepts boolean param that forces databa…
Browse files Browse the repository at this point in the history
…se read. Remove migration, since the generator test adds it. Add step to check for frienships migration in integration test
  • Loading branch information
johnmcaliley committed May 23, 2011
1 parent 66a8df6 commit 9f7793c
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 29 deletions.
5 changes: 3 additions & 2 deletions app/models/social_engine/friendable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,13 @@ def is_friendable
include InstanceMethods
end

module InstanceMethods
module InstanceMethods
def friendable?
true
end

def friends
def friends(expire_association_cache=false)
return self.friendors(true) + self.friendees(true) if expire_association_cache
self.friendors + self.friendees
end

Expand Down
20 changes: 0 additions & 20 deletions test_app/db/migrate/20110521190117_create_friendings_table.rb

This file was deleted.

3 changes: 2 additions & 1 deletion test_app/features/generator.feature
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ Feature: generating social_engine migrations
And a timestamped file named 'create_votes_table.rb' is created in the '/db/migrate/' directory
And a timestamped file named 'create_favorites_table.rb' is created in the '/db/migrate/' directory
And a timestamped file named 'create_reputations_table.rb' is created in the '/db/migrate/' directory
And a timestamped file named 'create_reputation_actions_table.rb' is created in the '/db/migrate/' directory
And a timestamped file named 'create_reputation_actions_table.rb' is created in the '/db/migrate/' directory
And a timestamped file named 'create_friendings_table.rb' is created in the '/db/migrate/' directory
And a file named 'social_engine.yml' is created in the '/config/yettings/' directory
And a file named 'social_engine.css' is created in the '/public/stylesheets/' directory
And a file named 'formtastic.css' is created in the '/public/stylesheets/' directory
Expand Down
3 changes: 2 additions & 1 deletion test_app/features/step_definitions/social_engine_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"create_favorites_table",
"create_reputations_table",
"create_reputation_actions_table",
"create_friendings_table",
"add_reputation_to_users"]

Given 'a working directory' do
Expand All @@ -29,7 +30,7 @@
end

When /^I run the install generator$/ do
@generator_output = systemu("rails g social_engine:install")[1]
@generator_output = systemu("rails g social_engine:install")
end

When /^I run the user rep generator$/ do
Expand Down
7 changes: 2 additions & 5 deletions test_app/spec/models/friendings_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,9 @@
john.should have(1).requesting_friends
john.requesting_friends.should include(jay)
john.friends.should_not include(jay)
puts john.friend_requests.inspect
john.friend_requests.last.confirm
puts john.friend_requests.inspect
puts john.friends.inspect
#john.should have(3).friends
john.requesting_friends.should_not include(jay)
john.should have(3).friends(true)
john.requesting_friends(true).should_not include(jay)
john.friends.should include(jay)
end
end

0 comments on commit 9f7793c

Please sign in to comment.