amistad 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.markdown CHANGED
@@ -8,7 +8,7 @@ Just run the following command :
8
8
 
9
9
  gem install amistad
10
10
 
11
- Then in your gem file add the following line :
11
+ Then in your Gemfile add the following line :
12
12
 
13
13
  gem 'amistad'
14
14
 
@@ -81,6 +81,11 @@ It is also possible to check if two users are friends :
81
81
  @john.is_friend_with? @jane #=> true
82
82
  @victoria.is_friend_with? @john #=> false
83
83
 
84
+ You can also check if a user invited anoter :
85
+
86
+ @john.was_invited_by? @john #=> true
87
+ @victoria.was_invited_by? @john #=> false
88
+
84
89
  You can also find the friends that two users have in common :
85
90
 
86
91
  @john.common_friend_with(@peter) #=> [@jane]
@@ -92,13 +97,21 @@ The __remove()__ method allow a user to remove its friendships :
92
97
  @john.remove @jane
93
98
  @john.remove @peter
94
99
  @john.remove @victoria
100
+
101
+ ## Testing the gem ##
102
+
103
+ It is possible to test amistad by running the following command from the gem directory:
104
+
105
+ rake spec
106
+
107
+ Remember that amistad is only compatible with ActiveRecord 3.x.
108
+
95
109
 
96
110
  ## Note on Patches/Pull Requests ##
97
111
 
98
112
  * Fork the project.
99
113
  * Make your feature addition or bug fix.
100
114
  * Add tests for it. This is important so I don't break it in a future version unintentionally.
101
- *
102
115
  * Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
103
116
  * Send me a pull request. Bonus points for topic branches.
104
117
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.2.0
@@ -69,6 +69,13 @@ module Amistad
69
69
  friends.include?(user)
70
70
  end
71
71
 
72
+ def was_invited_by?(user)
73
+ inverse_friendships.each do |friendship|
74
+ return true if friendship.user == user
75
+ end
76
+ false
77
+ end
78
+
72
79
  def common_friends_with(user)
73
80
  self.friends & user.friends
74
81
  end
@@ -88,6 +88,14 @@ describe Amistad::FriendModel do
88
88
  @john.is_friend_with?(@peter).should == false
89
89
  end
90
90
 
91
+ it "checks if a user was invited by another" do
92
+ @jane.was_invited_by?(@john).should == true
93
+ @james.was_invited_by?(@john).should == true
94
+
95
+ @john.was_invited_by?(@jane).should == false
96
+ @victoria.was_invited_by?(@john).should == false
97
+ end
98
+
91
99
  it "lists the friends he has in common with another user" do
92
100
  @james.common_friends_with(@mary).count.should == 1
93
101
  @james.common_friends_with(@mary).should include(@john)
data/spec/spec_helper.rb CHANGED
@@ -9,6 +9,8 @@ ActiveRecord::Base.establish_connection(
9
9
  :database => "tmp/amistad.sqlite3.db"
10
10
  )
11
11
 
12
+ ActiveRecord::Migration.verbose = false
13
+
12
14
  ActiveRecord::Schema.define do
13
15
  create_table :users, :force => true do |t|
14
16
  t.string :name, :null => false
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 1
7
+ - 2
8
8
  - 0
9
- version: 0.1.0
9
+ version: 0.2.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Rawane ZOSSOU
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-04-13 00:00:00 +02:00
17
+ date: 2010-05-16 00:00:00 +02:00
18
18
  default_executable:
19
19
  dependencies: []
20
20