warden-github 0.14.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ v1.0.0 2013/09/03
2
+ -----------------
3
+
4
+ * Explicitly require Octokit 2.1.1
5
+ * Fixups for moving to octokit 2.1.1
@@ -59,7 +59,7 @@ module Warden
59
59
  end
60
60
 
61
61
  def build_uri(path, params)
62
- URI(Octokit::Configuration::DEFAULT_WEB_ENDPOINT).tap do |uri|
62
+ URI(Octokit.web_endpoint).tap do |uri|
63
63
  uri.path = path
64
64
  uri.query = encode_params(normalize_params(params))
65
65
  end
@@ -6,8 +6,12 @@ module Warden
6
6
  ATTRIBUTES = %w[id login name gravatar_id email company site_admin].freeze
7
7
 
8
8
  def self.load(access_token)
9
- api = Octokit::Client.new(:oauth_token => access_token)
10
- data = Hash[api.user.to_hash.select { |k,_| ATTRIBUTES.include?(k) }]
9
+ api = Octokit::Client.new(:access_token => access_token)
10
+ data = { }
11
+
12
+ api.user.to_hash.each do |k,v|
13
+ data[k.to_s] = v if ATTRIBUTES.include?(k.to_s)
14
+ end
11
15
 
12
16
  new(data, access_token)
13
17
  end
@@ -55,40 +59,27 @@ module Warden
55
59
  #
56
60
  # Returns: true if the user has access, false otherwise
57
61
  def team_member?(team_id)
58
- memberships.fetch_membership(:team, team_id) do
59
- # TODO: Use next line as method body once pengwynn/octokit#206 is public.
60
- # api.team_member?(team_id, login)
61
-
62
- begin
63
- # A user is only able to query for team members if they're a member.
64
- # Thus, if querying does succeed, they will be in the list and
65
- # checking the list won't be necessary.
66
- api.team_members(team_id)
67
- true
68
- rescue Octokit::NotFound
69
- false
70
- end
71
- end
62
+ api.team_member?(team_id, login)
72
63
  end
73
64
 
74
65
  # Identify GitHub employees/staff members.
75
66
  #
76
67
  # Returns: true if the authenticated user is a GitHub employee, false otherwise
77
68
  def site_admin?
78
- site_admin || false
69
+ !!site_admin
79
70
  end
80
71
 
81
72
  # Access the GitHub API from Octokit
82
73
  #
83
74
  # Octokit is a robust client library for the GitHub API
84
- # https://github.com/pengwynn/octokit
75
+ # https://github.com/octokit/octokit.rb
85
76
  #
86
77
  # Returns a cached client object for easy use
87
78
  def api
88
79
  # Don't cache instance for now because of a ruby marshaling bug present
89
80
  # in MRI 1.9.3 (Bug #7627) that causes instance variables to be
90
81
  # marshaled even when explicitly specifying #marshal_dump.
91
- Octokit::Client.new(:login => login, :oauth_token => token)
82
+ Octokit::Client.new(:login => login, :access_token => token)
92
83
  end
93
84
 
94
85
  private
@@ -1,5 +1,5 @@
1
1
  module Warden
2
2
  module GitHub
3
- VERSION = "0.14.0"
3
+ VERSION = "1.0.0"
4
4
  end
5
5
  end
@@ -4,7 +4,7 @@ describe Warden::GitHub::Config do
4
4
  let(:warden_scope) { :test_scope }
5
5
 
6
6
  let(:env) do
7
- { 'warden' => stub(:config => warden_config) }
7
+ { 'warden' => double(:config => warden_config) }
8
8
  end
9
9
 
10
10
  let(:warden_config) do
@@ -16,7 +16,7 @@ describe Warden::GitHub::Config do
16
16
  end
17
17
 
18
18
  let(:request) do
19
- stub(:url => 'http://example.com/the/path', :path => '/the/path')
19
+ double(:url => 'http://example.com/the/path', :path => '/the/path')
20
20
  end
21
21
 
22
22
  subject(:config) do
@@ -15,7 +15,7 @@ describe Warden::GitHub::OAuth do
15
15
  describe '#authorize_uri' do
16
16
  it 'contains the base uri' do
17
17
  oauth.authorize_uri.to_s.should \
18
- include Octokit::Configuration::DEFAULT_WEB_ENDPOINT
18
+ include Octokit.web_endpoint
19
19
  end
20
20
 
21
21
  %w[ client_id state redirect_uri ].each do |name|
@@ -34,7 +34,7 @@ describe Warden::GitHub::User do
34
34
 
35
35
  api.should be_an Octokit::Client
36
36
  api.login.should eq user.login
37
- api.oauth_token.should eq user.token
37
+ api.access_token.should eq user.token
38
38
  end
39
39
  end
40
40
 
@@ -65,11 +65,10 @@ describe Warden::GitHub::User do
65
65
  describe '#team_member?' do
66
66
  context 'when user is not member' do
67
67
  it 'returns false' do
68
- api = double
68
+ api = double()
69
69
  user.stub(:api => api)
70
70
 
71
- # api.stub(:team_member?, [123, user.login]).and_raise(Octokit::NotFound.new({}))
72
- api.stub(:team_members, [123]).and_raise(Octokit::NotFound.new({}))
71
+ api.stub(:team_member?).with(123, user.login).and_return(false)
73
72
 
74
73
  user.should_not be_team_member(123)
75
74
  end
@@ -77,10 +76,9 @@ describe Warden::GitHub::User do
77
76
 
78
77
  context 'when user is member' do
79
78
  it 'returns true' do
80
- api = double
79
+ api = double()
81
80
  user.stub(:api => api)
82
- # api.stub(:team_member?, [123, user.login])
83
- api.stub(:team_members, [123])
81
+ api.stub(:team_member?).with(123, user.login).and_return(true)
84
82
 
85
83
  user.should be_team_member(123)
86
84
  end
@@ -94,7 +92,7 @@ describe Warden::GitHub::User do
94
92
 
95
93
  Octokit::Client.
96
94
  should_receive(:new).
97
- with(:oauth_token => token).
95
+ with(:access_token => token).
98
96
  and_return(client)
99
97
  client.should_receive(:user).and_return(attrs)
100
98
 
@@ -14,7 +14,7 @@ Gem::Specification.new do |s|
14
14
  s.rubyforge_project = "warden-github"
15
15
 
16
16
  s.add_dependency "warden", ">1.0"
17
- s.add_dependency "octokit", ">=1.22.0"
17
+ s.add_dependency "octokit", ">2.1.0"
18
18
 
19
19
  s.add_development_dependency "rack", "~>1.4.1"
20
20
  s.add_development_dependency "rake"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: warden-github
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.0
4
+ version: 1.0.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-04-25 00:00:00.000000000 Z
12
+ date: 2013-09-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: warden
@@ -32,17 +32,17 @@ dependencies:
32
32
  requirement: !ruby/object:Gem::Requirement
33
33
  none: false
34
34
  requirements:
35
- - - ! '>='
35
+ - - ! '>'
36
36
  - !ruby/object:Gem::Version
37
- version: 1.22.0
37
+ version: 2.1.0
38
38
  type: :runtime
39
39
  prerelease: false
40
40
  version_requirements: !ruby/object:Gem::Requirement
41
41
  none: false
42
42
  requirements:
43
- - - ! '>='
43
+ - - ! '>'
44
44
  - !ruby/object:Gem::Version
45
- version: 1.22.0
45
+ version: 2.1.0
46
46
  - !ruby/object:Gem::Dependency
47
47
  name: rack
48
48
  requirement: !ruby/object:Gem::Requirement
@@ -213,6 +213,7 @@ files:
213
213
  - .gitignore
214
214
  - .rspec
215
215
  - .travis.yml
216
+ - CHANGELOG.md
216
217
  - Gemfile
217
218
  - LICENSE.md
218
219
  - README.md