friendis 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4bf3a3b9ceda6f6f0c1045c01c5e49604a8f00fd
4
- data.tar.gz: 8629c044909318e0d42a39a91f973d54a730fdaa
3
+ metadata.gz: 2bfbf27325dc7aeb0b8d2f49f3aeecf49db19106
4
+ data.tar.gz: 0d8f9ee977a62be3f5134f63c7705c1d71f33104
5
5
  SHA512:
6
- metadata.gz: 435aa6e473b98b049f43c05e835f4948bee86ec32a567cbdc3f5bc1093151d110baf230530c3346cd8c1217ed8b22ef5b6d614fdcbc65933ce0ccf88a98985ca
7
- data.tar.gz: 66e55c40636396e1a7cda23e429f6e966280d1ea3cf466e2e9077ab695745a4859c72341738c0f050ed06a728da89705ed566cbeba359776a56430f9e10709c1
6
+ metadata.gz: c9d6f3a03d2628becef77db1da3fc01e6c388dddec80e57a4e1135d002c6134541fd61d9af5658bd3b9a6ec047ca996e04e79ed32d5857762fccde4bbbcac35f
7
+ data.tar.gz: 16432b72c2cbeb7514f0e63633abb0d038dc09e123a37e820ba0902b4156324cfdfc60d796c41b98e2e9264f5ade3e785a25c71c9fbae56c150ab50ec20ce839
data/Changelog ADDED
@@ -0,0 +1,5 @@
1
+ 0.0.3
2
+ -----
3
+
4
+ * Allow ignoring friend requests
5
+ * Fixed - default redis connection setup
data/README.md CHANGED
@@ -82,6 +82,10 @@ The `id` attribute will automatically be cached.
82
82
 
83
83
  @user2.approve_friend_request(@user1)
84
84
 
85
+ ## Ignoring Friend Requests
86
+
87
+ @user2.ignore_friend_request(@user!) #=> @user1 will still see the sent friend request.
88
+
85
89
  ### Lisiting Friends
86
90
 
87
91
  @user1.friends
data/lib/friendis.rb CHANGED
@@ -13,6 +13,7 @@ module Friendis
13
13
  end
14
14
 
15
15
  def self.redis
16
+ @configuration ||= Friendis::Configuration.new
16
17
  @configuration.redis_connection ||= Redis.new
17
18
  end
18
19
 
@@ -66,6 +66,20 @@ module Friendis
66
66
  end
67
67
  end
68
68
 
69
+ def ignore_friend_request(friend)
70
+ if !(Friendis.redis.sismember(friendis_incoming_friend_requests_key, friend.id.to_s))
71
+ return false
72
+ else
73
+
74
+ # Ignoring a friend request, leaves the request in the requester queue, but removes
75
+ # it from the pending requests list of the recipient.
76
+ Friendis.redis.multi do
77
+ Friendis.redis.srem friendis_incoming_friend_requests_key, friend.id.to_s
78
+ end
79
+ return true
80
+ end
81
+ end
82
+
69
83
  def unfriend(friend)
70
84
  Friendis.redis.multi do
71
85
  Friendis.redis.srem friendis_my_friends_key, friend.id
@@ -1,3 +1,3 @@
1
1
  module Friendis
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -3,6 +3,12 @@ require 'models/user'
3
3
 
4
4
  describe Friendis::Friendable do
5
5
 
6
+ # Configure Friendis, so it can be used
7
+ before(:all) do
8
+ Friendis.configure do |c|
9
+ end
10
+ end
11
+
6
12
  describe "#send_friend_request" do
7
13
  before(:each) do
8
14
  @user1 = User.new(1)
@@ -44,6 +50,25 @@ describe Friendis::Friendable do
44
50
  end
45
51
  end
46
52
 
53
+ describe "#ignore_friend_request" do
54
+ before(:each) do
55
+ @user1 = User.new(1)
56
+ @user2 = User.new(2)
57
+ @user1.clear_friendis_data
58
+ @user2.clear_friendis_data
59
+
60
+ @user1.save
61
+ @user2.save
62
+ @user1.send_friend_request(@user2)
63
+ end
64
+
65
+ it "should show friend on friends list after approval" do
66
+ @user2.ignore_friend_request(@user1).should be_truthy
67
+ @user2.pending_friend_requests.should be_empty
68
+ @user1.sent_friend_requests.should_not be_empty
69
+ end
70
+ end
71
+
47
72
  describe "#unfriend" do
48
73
  before(:each) do
49
74
  @user1 = User.new(1)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: friendis
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elad Meidar
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-27 00:00:00.000000000 Z
11
+ date: 2014-08-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -75,6 +75,7 @@ extra_rdoc_files: []
75
75
  files:
76
76
  - .gitignore
77
77
  - .rspec
78
+ - Changelog
78
79
  - Gemfile
79
80
  - LICENSE.txt
80
81
  - README.md