amistad 0.9.2 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ed824f9e11cab8950dd941dd080bc73304d86411
4
+ data.tar.gz: 6e2ca13bb345b5e8a3ecfb220e565cbd39a8fd99
5
+ SHA512:
6
+ metadata.gz: 15245fd8370230189b7837512b19c2c1468140d385993057f5325151c1768f3ec6a91804a7fd4baf06af510b900e3b8e7db0124d6b6c8db80337aa11bc96917f
7
+ data.tar.gz: c29d4ed8fa6228e31ca7d7dbebef793aa3d40635456c5123ac1883ab0c3516fb790ce5465c68cfd257cb276ef5d2b9561c2cd8b63d1c4e3f8e71c42a11fa14eb
@@ -1,79 +1,92 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- amistad (0.9.2)
4
+ amistad (0.10.0)
5
5
  squeel
6
6
 
7
7
  GEM
8
8
  remote: http://rubygems.org/
9
9
  specs:
10
- activemodel (3.2.8)
11
- activesupport (= 3.2.8)
12
- builder (~> 3.0.0)
13
- activerecord (3.2.8)
14
- activemodel (= 3.2.8)
15
- activesupport (= 3.2.8)
16
- arel (~> 3.0.2)
17
- tzinfo (~> 0.3.29)
18
- activesupport (3.2.8)
19
- i18n (~> 0.6)
20
- multi_json (~> 1.0)
21
- arel (3.0.2)
22
- awesome_print (1.1.0)
23
- bson (1.7.0)
24
- bson_ext (1.7.0)
25
- bson (~> 1.7.0)
26
- builder (3.0.4)
27
- database_cleaner (0.9.1)
28
- diff-lcs (1.1.3)
29
- fuubar (1.1.0)
30
- rspec (~> 2.0)
31
- rspec-instafail (~> 0.2.0)
32
- ruby-progressbar (~> 1.0.0)
33
- i18n (0.6.1)
34
- mongo (1.7.0)
35
- bson (~> 1.7.0)
36
- mongo_mapper (0.12.0)
37
- activemodel (~> 3.0)
38
- activesupport (~> 3.0)
39
- plucky (~> 0.5.2)
40
- mongoid (3.0.9)
41
- activemodel (~> 3.1)
42
- moped (~> 1.1)
43
- origin (~> 1.0)
44
- tzinfo (~> 0.3.22)
45
- moped (1.2.7)
46
- multi_json (1.3.6)
47
- mysql2 (0.3.11)
48
- origin (1.0.9)
49
- pg (0.14.1)
50
- plucky (0.5.2)
51
- mongo (~> 1.5)
52
- polyamorous (0.5.0)
53
- activerecord (~> 3.0)
54
- rake (0.9.2.2)
55
- rspec (2.11.0)
56
- rspec-core (~> 2.11.0)
57
- rspec-expectations (~> 2.11.0)
58
- rspec-mocks (~> 2.11.0)
59
- rspec-core (2.11.1)
60
- rspec-expectations (2.11.3)
61
- diff-lcs (~> 1.1.3)
62
- rspec-instafail (0.2.4)
63
- rspec-mocks (2.11.3)
64
- ruby-progressbar (1.0.2)
65
- sqlite3 (1.3.6)
66
- squeel (1.0.13)
67
- activerecord (~> 3.0)
68
- activesupport (~> 3.0)
69
- polyamorous (~> 0.5.0)
70
- tzinfo (0.3.33)
10
+ activemodel (4.1.6)
11
+ activesupport (= 4.1.6)
12
+ builder (~> 3.1)
13
+ activerecord (4.1.6)
14
+ activemodel (= 4.1.6)
15
+ activesupport (= 4.1.6)
16
+ arel (~> 5.0.0)
17
+ activesupport (4.1.6)
18
+ i18n (~> 0.6, >= 0.6.9)
19
+ json (~> 1.7, >= 1.7.7)
20
+ minitest (~> 5.1)
21
+ thread_safe (~> 0.1)
22
+ tzinfo (~> 1.1)
23
+ arel (5.0.1.20140414130214)
24
+ awesome_print (1.2.0)
25
+ bson (2.2.0)
26
+ bson_ext (1.5.1)
27
+ builder (3.2.2)
28
+ connection_pool (2.0.0)
29
+ database_cleaner (1.3.0)
30
+ diff-lcs (1.2.5)
31
+ fuubar (2.0.0)
32
+ rspec (~> 3.0)
33
+ ruby-progressbar (~> 1.4)
34
+ i18n (0.6.11)
35
+ jnunemaker-validatable (1.8.4)
36
+ activesupport (>= 2.3.4)
37
+ json (1.8.1)
38
+ minitest (5.4.1)
39
+ mongo (1.3.1)
40
+ bson (>= 1.3.1)
41
+ mongo_mapper (0.8.6)
42
+ activesupport (>= 2.3.4)
43
+ jnunemaker-validatable (~> 1.8.4)
44
+ plucky (~> 0.3.6)
45
+ mongoid (4.0.0)
46
+ activemodel (~> 4.0)
47
+ moped (~> 2.0.0)
48
+ origin (~> 2.1)
49
+ tzinfo (>= 0.3.37)
50
+ moped (2.0.0)
51
+ bson (~> 2.2)
52
+ connection_pool (~> 2.0)
53
+ optionable (~> 0.2.0)
54
+ mysql2 (0.3.16)
55
+ optionable (0.2.0)
56
+ origin (2.1.1)
57
+ pg (0.17.1)
58
+ plucky (0.3.8)
59
+ mongo (~> 1.3)
60
+ polyamorous (1.1.0)
61
+ activerecord (>= 3.0)
62
+ rake (10.3.2)
63
+ rspec (3.1.0)
64
+ rspec-core (~> 3.1.0)
65
+ rspec-expectations (~> 3.1.0)
66
+ rspec-mocks (~> 3.1.0)
67
+ rspec-core (3.1.4)
68
+ rspec-support (~> 3.1.0)
69
+ rspec-expectations (3.1.1)
70
+ diff-lcs (>= 1.2.0, < 2.0)
71
+ rspec-support (~> 3.1.0)
72
+ rspec-mocks (3.1.1)
73
+ rspec-support (~> 3.1.0)
74
+ rspec-support (3.1.0)
75
+ ruby-progressbar (1.6.0)
76
+ sqlite3 (1.3.9)
77
+ squeel (1.2.1)
78
+ activerecord (>= 3.0)
79
+ activesupport (>= 3.0)
80
+ polyamorous (~> 1.1.0)
81
+ thread_safe (0.3.4)
82
+ tzinfo (1.2.2)
83
+ thread_safe (~> 0.1)
71
84
 
72
85
  PLATFORMS
73
86
  ruby
74
87
 
75
88
  DEPENDENCIES
76
- activerecord
89
+ activerecord (>= 4.0.0)
77
90
  amistad!
78
91
  awesome_print
79
92
  bson_ext
@@ -81,9 +94,9 @@ DEPENDENCIES
81
94
  database_cleaner
82
95
  fuubar
83
96
  mongo_mapper
84
- mongoid
85
- mysql2
86
- pg
97
+ mongoid (>= 4.0.0)
98
+ mysql2 (>= 0.3.16)
99
+ pg (>= 0.17.1)
87
100
  rake
88
- rspec
89
- sqlite3
101
+ rspec (~> 3.1.0)
102
+ sqlite3 (>= 1.3.9)
@@ -1,6 +1,6 @@
1
1
  # amistad #
2
2
 
3
- Amistad adds friendships management into a rails 3.0 application. it supports ActiveRecord 3.0.x, Mongoid 3.0.x and MongoMapper 0.12.0.
3
+ Amistad adds friendships management into a rails application. it supports ActiveRecord, Mongoid and MongoMapper.
4
4
 
5
5
  ## Installation ##
6
6
 
@@ -18,13 +18,13 @@ Gem::Specification.new do |s|
18
18
 
19
19
  s.add_development_dependency "bundler"
20
20
  s.add_development_dependency "rake"
21
- s.add_development_dependency "rspec"
22
- s.add_development_dependency "activerecord"
23
- s.add_development_dependency "mysql2"
24
- s.add_development_dependency "pg"
21
+ s.add_development_dependency "rspec", "~> 3.1.0"
22
+ s.add_development_dependency "activerecord", ">= 4.0.0"
23
+ s.add_development_dependency "mysql2", ">= 0.3.16"
24
+ s.add_development_dependency "pg", ">= 0.17.1"
25
25
  s.add_development_dependency "database_cleaner"
26
- s.add_development_dependency "sqlite3"
27
- s.add_development_dependency "mongoid"
26
+ s.add_development_dependency "sqlite3", ">= 1.3.9"
27
+ s.add_development_dependency "mongoid", ">= 4.0.0"
28
28
  s.add_development_dependency "bson_ext"
29
29
  s.add_development_dependency "fuubar"
30
30
  s.add_development_dependency "awesome_print"
@@ -12,15 +12,9 @@ module Amistad
12
12
  :class_name => "Amistad::Friendships::#{Amistad.friendship_model}",
13
13
  :foreign_key => "friendable_id"
14
14
 
15
- has_many :pending_invited,
16
- :through => :friendships,
17
- :source => :friend,
18
- :conditions => { :'friendships.pending' => true, :'friendships.blocker_id' => nil }
19
15
 
20
- has_many :invited,
21
- :through => :friendships,
22
- :source => :friend,
23
- :conditions => { :'friendships.pending' => false, :'friendships.blocker_id' => nil }
16
+ has_many :pending_invited, -> { where(:'friendships.pending' => true, :'friendships.blocker_id' => nil) }, :through => :friendships, :source => :friend
17
+ has_many :invited, -> { where(:'friendships.pending' => false, :'friendships.blocker_id' => nil) }, :through => :friendships, :source => :friend
24
18
 
25
19
  #####################################################################################
26
20
  # inverse friendships
@@ -29,15 +23,8 @@ module Amistad
29
23
  :class_name => "Amistad::Friendships::#{Amistad.friendship_model}",
30
24
  :foreign_key => "friend_id"
31
25
 
32
- has_many :pending_invited_by,
33
- :through => :inverse_friendships,
34
- :source => :friendable,
35
- :conditions => { :'friendships.pending' => true, :'friendships.blocker_id' => nil }
36
-
37
- has_many :invited_by,
38
- :through => :inverse_friendships,
39
- :source => :friendable,
40
- :conditions => { :'friendships.pending' => false, :'friendships.blocker_id' => nil }
26
+ has_many :pending_invited_by, -> { where(:'friendships.pending' => true, :'friendships.blocker_id' => nil) }, :through => :inverse_friendships, :source => :friendable
27
+ has_many :invited_by, -> { where(:'friendships.pending' => false, :'friendships.blocker_id' => nil) }, :through => :inverse_friendships, :source => :friendable
41
28
 
42
29
  #####################################################################################
43
30
  # blocked friendships
@@ -46,15 +33,9 @@ module Amistad
46
33
  :class_name => "Amistad::Friendships::#{Amistad.friendship_model}",
47
34
  :foreign_key => "blocker_id"
48
35
 
49
- has_many :blockades,
50
- :through => :blocked_friendships,
51
- :source => :friend,
52
- :conditions => "friend_id <> blocker_id"
36
+ has_many :blockades, -> {where("friend_id <> blocker_id")}, :through => :blocked_friendships, :source => :friend
37
+ has_many :blockades_by, -> {where("friendable_id <> blocker_id")} , :through => :blocked_friendships, :source => :friendable
53
38
 
54
- has_many :blockades_by,
55
- :through => :blocked_friendships,
56
- :source => :friendable,
57
- :conditions => "friendable_id <> blocker_id"
58
39
  end
59
40
 
60
41
  # suggest a user to become a friend. If the operation succeeds, the method returns true, else false
@@ -76,6 +57,7 @@ module Amistad
76
57
  return false if friendship.nil?
77
58
  friendship.destroy
78
59
  self.reload && user.reload if friendship.destroyed?
60
+ true
79
61
  end
80
62
 
81
63
  # returns the list of approved friends
@@ -35,17 +35,6 @@ module Amistad
35
35
  Array,
36
36
  :default => []
37
37
 
38
- attr_accessible(
39
- :friend_ids,
40
- :inverse_friend_ids,
41
- :pending_friend_ids,
42
- :pending_inverse_friend_ids,
43
- :blocked_friend_ids,
44
- :blocked_inverse_friend_ids,
45
- :blocked_pending_friend_ids,
46
- :blocked_pending_inverse_friend_ids,
47
- )
48
-
49
38
  %w(friend_ids inverse_friend_ids pending_friend_ids pending_inverse_friend_ids blocked_friend_ids blocked_inverse_friend_ids blocked_pending_friend_ids blocked_pending_inverse_friend_ids).each do |attribute|
50
39
  define_method(attribute.to_sym) do
51
40
  value = read_attribute(attribute)
@@ -35,16 +35,6 @@ module Amistad
35
35
  :type => Array,
36
36
  :default => []
37
37
 
38
- attr_accessible(
39
- :friend_ids,
40
- :inverse_friend_ids,
41
- :pending_friend_ids,
42
- :pending_inverse_friend_ids,
43
- :blocked_friend_ids,
44
- :blocked_inverse_friend_ids,
45
- :blocked_pending_friend_ids,
46
- :blocked_pending_inverse_friend_ids,
47
- )
48
38
  end
49
39
  end
50
40
  end
@@ -1,3 +1,3 @@
1
1
  module Amistad
2
- VERSION = "0.9.2"
2
+ VERSION = "0.10.0"
3
3
  end
@@ -19,6 +19,3 @@ RSpec.configure do |config|
19
19
  end
20
20
  end
21
21
 
22
- # needed in order to be able to compare arrays with ActiveRecord relations
23
- RSpec::Matchers::OperatorMatcher.register(ActiveRecord::Relation, '=~', RSpec::Matchers::BuiltIn::MatchArray)
24
-
@@ -5,9 +5,6 @@ describe "The friend model" do
5
5
  reload_environment
6
6
  User = Class.new(ActiveRecord::Base)
7
7
 
8
- ActiveSupport.on_load(:active_record) do
9
- attr_accessible(nil)
10
- end
11
8
  end
12
9
 
13
10
  it_should_behave_like "friend with parameterized models" do
@@ -1,10 +1,10 @@
1
1
  shared_examples_for "the friendship model" do
2
2
  it "should validate presence of the user's id and the friend's id" do
3
3
  friendship = Amistad.friendship_class.new
4
- friendship.valid?.should be_false
5
- friendship.errors.should include(:friendable_id)
6
- friendship.errors.should include(:friend_id)
7
- friendship.errors.size.should == 2
4
+ expect(friendship.valid?).to eq(false)
5
+ expect(friendship.errors).to include(:friendable_id)
6
+ expect(friendship.errors).to include(:friend_id)
7
+ expect(friendship.errors.size).to eq(2)
8
8
  end
9
9
 
10
10
  context "when creating friendship" do
@@ -14,29 +14,29 @@ shared_examples_for "the friendship model" do
14
14
  end
15
15
 
16
16
  it "should be pending" do
17
- @friendship.pending?.should be_true
17
+ expect(@friendship.pending?).to eq(true)
18
18
  end
19
19
 
20
20
  it "should not be approved" do
21
- @friendship.approved?.should be_false
21
+ expect(@friendship.approved?).to eq(false)
22
22
  end
23
23
 
24
24
  it "should be active" do
25
- @friendship.active?.should be_true
25
+ expect(@friendship.active?).to eq(true)
26
26
  end
27
27
 
28
28
  it "should not be blocked" do
29
- @friendship.blocked?.should be_false
29
+ expect(@friendship.blocked?).to eq(false)
30
30
  end
31
31
 
32
32
  it "should be available to block only by invited user" do
33
- @friendship.can_block?(@david).should be_true
34
- @friendship.can_block?(@jane).should be_false
33
+ expect(@friendship.can_block?(@david)).to eq(true)
34
+ expect(@friendship.can_block?(@jane)).to eq(false)
35
35
  end
36
36
 
37
37
  it "should not be available to unblock" do
38
- @friendship.can_unblock?(@jane).should be_false
39
- @friendship.can_unblock?(@david).should be_false
38
+ expect(@friendship.can_unblock?(@jane)).to eq(false)
39
+ expect(@friendship.can_unblock?(@david)).to eq(false)
40
40
  end
41
41
  end
42
42
 
@@ -48,29 +48,29 @@ shared_examples_for "the friendship model" do
48
48
  end
49
49
 
50
50
  it "should be approved" do
51
- @friendship.approved?.should be_true
51
+ expect(@friendship.approved?).to eq(true)
52
52
  end
53
53
 
54
54
  it "should not be pending" do
55
- @friendship.pending?.should be_false
55
+ expect(@friendship.pending?).to eq(false)
56
56
  end
57
57
 
58
58
  it "should be active" do
59
- @friendship.active?.should be_true
59
+ expect(@friendship.active?).to eq(true)
60
60
  end
61
61
 
62
62
  it "should not be blocked" do
63
- @friendship.blocked?.should be_false
63
+ expect(@friendship.blocked?).to eq(false)
64
64
  end
65
65
 
66
66
  it "should be available to block by both users" do
67
- @friendship.can_block?(@jane).should be_true
68
- @friendship.can_block?(@david).should be_true
67
+ expect(@friendship.can_block?(@jane)).to eq(true)
68
+ expect(@friendship.can_block?(@david)).to eq(true)
69
69
  end
70
70
 
71
71
  it "should not be availabel to unblock" do
72
- @friendship.can_unblock?(@jane).should be_false
73
- @friendship.can_unblock?(@david).should be_false
72
+ expect(@friendship.can_unblock?(@jane)).to eq(false)
73
+ expect(@friendship.can_unblock?(@david)).to eq(false)
74
74
  end
75
75
  end
76
76
 
@@ -82,29 +82,29 @@ shared_examples_for "the friendship model" do
82
82
  end
83
83
 
84
84
  it "should not be approved" do
85
- @friendship.approved?.should be_false
85
+ expect(@friendship.approved?).to eq(false)
86
86
  end
87
87
 
88
88
  it "should be pending" do
89
- @friendship.pending?.should be_true
89
+ expect(@friendship.pending?).to eq(true)
90
90
  end
91
91
 
92
92
  it "should not be active" do
93
- @friendship.active?.should be_false
93
+ expect(@friendship.active?).to eq(false)
94
94
  end
95
95
 
96
96
  it "should be blocked" do
97
- @friendship.blocked?.should be_true
97
+ expect(@friendship.blocked?).to eq(true)
98
98
  end
99
99
 
100
100
  it "should not be available to block" do
101
- @friendship.can_block?(@jane).should be_false
102
- @friendship.can_block?(@david).should be_false
101
+ expect(@friendship.can_block?(@jane)).to eq(false)
102
+ expect(@friendship.can_block?(@david)).to eq(false)
103
103
  end
104
104
 
105
105
  it "should be available to unblock only by user who blocked it" do
106
- @friendship.can_unblock?(@david).should be_true
107
- @friendship.can_unblock?(@jane).should be_false
106
+ expect(@friendship.can_unblock?(@david)).to eq(true)
107
+ expect(@friendship.can_unblock?(@jane)).to eq(false)
108
108
  end
109
109
  end
110
- end
110
+ end