partisan 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
data/.travis.yml CHANGED
@@ -4,4 +4,8 @@ rvm:
4
4
  - 2.0.0
5
5
  - 1.9.3
6
6
 
7
+ gemfile:
8
+ - gemfiles/Gemfile.rails-4.0
9
+ - gemfiles/Gemfile.rails-3.2.x
10
+
7
11
  script: "echo 'DO IT' && bundle exec rake spec"
data/README.md CHANGED
@@ -60,11 +60,11 @@ fan.follow(band)
60
60
  fan.following_bands
61
61
  # => [<Band id=2>]
62
62
 
63
- fan.following?(band)
63
+ fan.follows?(band)
64
64
  # => true
65
65
 
66
66
  fan.unfollow(band)
67
- fan.following?(band)
67
+ fan.follows?(band)
68
68
  # => false
69
69
  ```
70
70
 
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec path: '../'
4
+
5
+ gem 'rails', '~> 3.2.0'
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec path: '../'
4
+
5
+ gem 'rails', '~> 4.0.0'
@@ -48,11 +48,12 @@ module Partisan
48
48
  # @user.following?(@team)
49
49
  #
50
50
  # @return (Boolean)
51
- def following?(resource)
51
+ def follows?(resource)
52
52
  return false if self == resource
53
53
 
54
54
  !!fetch_follows(resource).exists?
55
55
  end
56
+ alias_method :following?, :follows?
56
57
 
57
58
  # Get all follows record related to a resource
58
59
  #
@@ -1,3 +1,3 @@
1
1
  module Partisan
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.3"
3
3
  end
@@ -37,7 +37,7 @@ describe Partisan::Followable do
37
37
 
38
38
  describe :followers_by_type do
39
39
  it { expect(band.followers_by_type('User').count).to eq 1 }
40
- it { expect(band.followers_by_type('User')).to be_an_instance_of(ActiveRecord::Relation::ActiveRecord_Relation_User) }
40
+ it { expect(band.followers_by_type('User')).to be_an_instance_of(relation_class(User)) }
41
41
  it { expect(band.followers_by_type('User').first).to be_an_instance_of(User) }
42
42
  it { expect(band.followers_by_type('Fan').count).to eq 0 }
43
43
  end
@@ -50,7 +50,7 @@ describe Partisan::Followable do
50
50
 
51
51
  describe :followers_by_type_in_method_missing do
52
52
  it { expect(band.user_followers.count).to eq 1 }
53
- it { expect(band.user_followers).to be_an_instance_of(ActiveRecord::Relation::ActiveRecord_Relation_User) }
53
+ it { expect(band.user_followers).to be_an_instance_of(relation_class(User)) }
54
54
  it { expect(band.user_followers.first).to be_an_instance_of(User) }
55
55
  it { expect(band.fan_followers.count).to eq 0 }
56
56
  end
@@ -49,16 +49,16 @@ describe Partisan::Follower do
49
49
  it { expect{user.unfollow band}.to change{Partisan::Follow.last}.to(nil) }
50
50
  end
51
51
 
52
- describe :following? do
52
+ describe :follows? do
53
53
  let(:band2) { Band.create }
54
54
 
55
- it { expect(user.following? band).to be_true }
56
- it { expect(user.following? band2).to be_false }
55
+ it { expect(user.follows? band).to be_true }
56
+ it { expect(user.follows? band2).to be_false }
57
57
  end
58
58
 
59
59
  describe :following_by_type do
60
60
  it { expect(user.following_by_type('Band').count).to eq 1 }
61
- it { expect(user.following_by_type('Band')).to be_an_instance_of(ActiveRecord::Relation::ActiveRecord_Relation_Band) }
61
+ it { expect(user.following_by_type('Band')).to be_an_instance_of(relation_class(Band)) }
62
62
  it { expect(user.following_by_type('Band').first).to be_an_instance_of(Band) }
63
63
  it { expect(user.following_by_type('Concert').count).to eq 0 }
64
64
  end
@@ -71,11 +71,11 @@ describe Partisan::Follower do
71
71
 
72
72
  describe :following_by_type_in_method_missing do
73
73
  it { expect(user.following_bands.count).to eq 1 }
74
- it { expect(user.following_bands).to be_an_instance_of(ActiveRecord::Relation::Relation::ActiveRecord_Relation_Band) }
74
+ it { expect(user.following_bands).to be_an_instance_of(relation_class(Band)) }
75
75
  it { expect(user.following_bands.first).to be_an_instance_of(Band) }
76
76
 
77
77
  it { expect(user.following_concerts.count).to eq 0 }
78
- it { expect(user.following_concerts).to be_an_instance_of(ActiveRecord::Relation::Relation::ActiveRecord_Relation_Concert) }
78
+ it { expect(user.following_concerts).to be_an_instance_of(relation_class(Concert)) }
79
79
  end
80
80
 
81
81
  describe :following_fields_by_type_in_method_missing do
@@ -153,9 +153,10 @@ describe Partisan::Follower do
153
153
  end
154
154
 
155
155
  describe :AliasMethods do
156
- subject { User.create }
156
+ subject { User.new }
157
157
 
158
158
  it { should respond_to :start_following }
159
159
  it { should respond_to :stop_following }
160
+ it { should respond_to :following? }
160
161
  end
161
162
  end
data/spec/spec_helper.rb CHANGED
@@ -15,6 +15,7 @@ RSpec.configure do |config|
15
15
  # Include our macros
16
16
  config.include DatabaseMacros
17
17
  config.include ModelMacros
18
+ config.include RailsMacros
18
19
 
19
20
  config.before(:each) do
20
21
  # Create the SQLite database
@@ -0,0 +1,9 @@
1
+ module RailsMacros
2
+ def relation_class(klass)
3
+ if ActiveRecord::VERSION::MAJOR == 3
4
+ ActiveRecord::Relation
5
+ else
6
+ "ActiveRecord::Relation::ActiveRecord_Relation_#{klass.name}".constantize
7
+ end
8
+ end
9
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: partisan
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-07-31 00:00:00.000000000 Z
13
+ date: 2013-08-09 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails
@@ -109,6 +109,8 @@ files:
109
109
  - LICENSE.md
110
110
  - README.md
111
111
  - Rakefile
112
+ - gemfiles/Gemfile.rails-3.2.x
113
+ - gemfiles/Gemfile.rails-4.0
112
114
  - lib/generators/partisan/USAGE
113
115
  - lib/generators/partisan/install_generator.rb
114
116
  - lib/generators/partisan/templates/migration.rb
@@ -120,11 +122,12 @@ files:
120
122
  - lib/partisan/railtie.rb
121
123
  - lib/partisan/version.rb
122
124
  - partisan.gemspec
125
+ - spec/partisan/followable_spec.rb
126
+ - spec/partisan/follower_spec.rb
123
127
  - spec/spec_helper.rb
124
- - spec/support/followable_spec.rb
125
- - spec/support/follower_spec.rb
126
128
  - spec/support/macros/database_macros.rb
127
129
  - spec/support/macros/model_macros.rb
130
+ - spec/support/macros/rails_macros.rb
128
131
  homepage: https://github.com/mirego/partisan
129
132
  licenses:
130
133
  - BSD 3-Clause
@@ -140,7 +143,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
140
143
  version: '0'
141
144
  segments:
142
145
  - 0
143
- hash: 390646380941659305
146
+ hash: 598192539115200308
144
147
  required_rubygems_version: !ruby/object:Gem::Requirement
145
148
  none: false
146
149
  requirements:
@@ -149,7 +152,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
149
152
  version: '0'
150
153
  segments:
151
154
  - 0
152
- hash: 390646380941659305
155
+ hash: 598192539115200308
153
156
  requirements: []
154
157
  rubyforge_project:
155
158
  rubygems_version: 1.8.23
@@ -158,8 +161,9 @@ specification_version: 3
158
161
  summary: Partisan is a Ruby library that allows ActiveRecord records to be follower
159
162
  and followable
160
163
  test_files:
164
+ - spec/partisan/followable_spec.rb
165
+ - spec/partisan/follower_spec.rb
161
166
  - spec/spec_helper.rb
162
- - spec/support/followable_spec.rb
163
- - spec/support/follower_spec.rb
164
167
  - spec/support/macros/database_macros.rb
165
168
  - spec/support/macros/model_macros.rb
169
+ - spec/support/macros/rails_macros.rb