warden-github-rails 1.1.1 → 1.1.2

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: e4b21d7a28bf42f74da5eafddadfad17630e05a0
4
- data.tar.gz: aa412e1be503469bc2771ee0cb51a820445f0268
3
+ metadata.gz: 7a96bbb9fc625a4f55a485c3b6be6d1643370446
4
+ data.tar.gz: 31f25b811a1ca9e55ab0f2a090a5ba475dfd3a20
5
5
  SHA512:
6
- metadata.gz: 5e5c27ca1244250f732b1ea0ce6065006d0c46134d7bb451aa96e76e7d3014b23e1d707886d8602539774865b402165631671c5adccefe78d9a006d7f2048621
7
- data.tar.gz: 2d8abd4c0e093228ca14cd82fb29b7914ceb8670d6950cdf3f9d8ccf6f9e391dc069d18c23e7658e5aafdc4dc4ddcb2980db17d4ae48d23b2da85a29499f2462
6
+ metadata.gz: d2e5abd46558cf29888cf3eab6ee6ae3589fb3800d8f65095557bc4610c8138112db42f9f9f4ef999636075c2c906a3322de4952e6ca0adf718022ab8d4916e2
7
+ data.tar.gz: 1e0b6b703e7d12fb1c3fcd7e37299fb68fe0f453499fd20bf75ff984e749561de59b85c3b4c02afdcf036a121771c33588acb436f6cb2763f5aee21c064dbbab
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## v1.1.2
4
+
5
+ - Prevent loss of memberships in mocked user when marshaling
6
+
3
7
  ## v1.1.1
4
8
 
5
9
  - Transform string to integer when stubbing team membership
data/README.md CHANGED
@@ -214,7 +214,7 @@ This gems comes with a couple test helpers to make your life easier:
214
214
 
215
215
  ```ruby
216
216
  subject { get '/some-url-that-triggers-oauth' }
217
- it { should be_github_oauth_redirect }
217
+ it { is_expected.to be_github_oauth_redirect }
218
218
  ```
219
219
 
220
220
  - A mock user that allows you to stub team and organization memberships:
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.1
1
+ 1.1.2
@@ -25,6 +25,15 @@ module Warden
25
25
  def organization_member?(id)
26
26
  memberships[:org].include?(id)
27
27
  end
28
+
29
+ def marshal_dump
30
+ [memberships, super]
31
+ end
32
+
33
+ def marshal_load(data)
34
+ @memberships, super_data = data
35
+ super(super_data)
36
+ end
28
37
  end
29
38
  end
30
39
  end
@@ -78,7 +78,7 @@ describe 'controller helpers' do
78
78
  subject(:request) { get "/#{type}/session" }
79
79
 
80
80
  context 'when not logged in' do
81
- it 'should be nil' do
81
+ it 'returns nil' do
82
82
  expect(request.body).to be_blank
83
83
  end
84
84
  end
@@ -6,7 +6,7 @@ describe 'request to a protected resource' do
6
6
  subject { get '/team/protected' }
7
7
 
8
8
  context 'when not logged in' do
9
- it { should be_github_oauth_redirect }
9
+ it { is_expected.to be_github_oauth_redirect }
10
10
  end
11
11
 
12
12
  context 'when logged in' do
@@ -16,12 +16,12 @@ describe 'request to a protected resource' do
16
16
  user.stub_membership(team: 123)
17
17
  end
18
18
 
19
- it { should be_ok }
19
+ it { is_expected.to be_ok }
20
20
  end
21
21
 
22
22
  context 'and not team member' do
23
23
  before { github_login }
24
- it { should be_not_found}
24
+ it { is_expected.to be_not_found}
25
25
  end
26
26
  end
27
27
  end
@@ -30,7 +30,7 @@ describe 'request to a protected resource' do
30
30
  subject { get '/team_alias/protected' }
31
31
 
32
32
  context 'when not logged in' do
33
- it { should be_github_oauth_redirect }
33
+ it { is_expected.to be_github_oauth_redirect }
34
34
  end
35
35
 
36
36
  context 'when logged in' do
@@ -40,12 +40,12 @@ describe 'request to a protected resource' do
40
40
  user.stub_membership(team: 456)
41
41
  end
42
42
 
43
- it { should be_ok }
43
+ it { is_expected.to be_ok }
44
44
  end
45
45
 
46
46
  context 'and not team member' do
47
47
  before { github_login }
48
- it { should be_not_found}
48
+ it { is_expected.to be_not_found}
49
49
  end
50
50
  end
51
51
  end
@@ -60,12 +60,12 @@ describe 'request to a protected resource' do
60
60
  user.stub_membership(team: 123)
61
61
  end
62
62
 
63
- it { should be_ok }
63
+ it { is_expected.to be_ok }
64
64
  end
65
65
 
66
66
  context 'and not team member' do
67
67
  before { github_login }
68
- it { should be_not_found}
68
+ it { is_expected.to be_not_found}
69
69
  end
70
70
  end
71
71
  end
@@ -77,7 +77,7 @@ describe 'request to a protected resource' do
77
77
  subject { get "/#{key}/protected" }
78
78
 
79
79
  context 'when not logged in' do
80
- it { should be_github_oauth_redirect }
80
+ it { is_expected.to be_github_oauth_redirect }
81
81
  end
82
82
 
83
83
  context 'when logged in' do
@@ -87,12 +87,12 @@ describe 'request to a protected resource' do
87
87
  user.stub_membership(org: value)
88
88
  end
89
89
 
90
- it { should be_ok }
90
+ it { is_expected.to be_ok }
91
91
  end
92
92
 
93
93
  context 'and not organization member' do
94
94
  before { github_login }
95
- it { should be_not_found }
95
+ it { is_expected.to be_not_found }
96
96
  end
97
97
  end
98
98
  end
@@ -108,12 +108,12 @@ describe 'request to a protected resource' do
108
108
  user.stub_membership(org: 'some_org')
109
109
  end
110
110
 
111
- it { should be_ok }
111
+ it { is_expected.to be_ok }
112
112
  end
113
113
 
114
114
  context 'and not organization member' do
115
115
  before { github_login }
116
- it { should be_not_found}
116
+ it { is_expected.to be_not_found}
117
117
  end
118
118
  end
119
119
  end
@@ -131,12 +131,12 @@ describe 'request to a resource that only exists when logged in' do
131
131
  user.stub_membership(team: 123)
132
132
  end
133
133
 
134
- it { should be_ok }
134
+ it { is_expected.to be_ok }
135
135
  end
136
136
 
137
137
  context 'when not team member' do
138
138
  before { github_login }
139
- it { should be_not_found}
139
+ it { is_expected.to be_not_found}
140
140
  end
141
141
  end
142
142
 
@@ -149,12 +149,12 @@ describe 'request to a resource that only exists when logged in' do
149
149
  user.stub_membership(team: 456)
150
150
  end
151
151
 
152
- it { should be_ok }
152
+ it { is_expected.to be_ok }
153
153
  end
154
154
 
155
155
  context 'when not team member' do
156
156
  before { github_login }
157
- it { should be_not_found}
157
+ it { is_expected.to be_not_found}
158
158
  end
159
159
  end
160
160
  end
@@ -170,12 +170,12 @@ describe 'request to a resource that only exists when logged in' do
170
170
  user.stub_membership(org: value)
171
171
  end
172
172
 
173
- it { should be_ok }
173
+ it { is_expected.to be_ok }
174
174
  end
175
175
 
176
176
  context 'when not organization member' do
177
177
  before { github_login }
178
- it { should be_not_found }
178
+ it { is_expected.to be_not_found }
179
179
  end
180
180
  end
181
181
  end
@@ -4,12 +4,12 @@ describe 'request to a protected resource' do
4
4
  subject { get '/protected' }
5
5
 
6
6
  context 'when not logged in' do
7
- it { should be_github_oauth_redirect }
7
+ it { is_expected.to be_github_oauth_redirect }
8
8
  end
9
9
 
10
10
  context 'when logged in' do
11
11
  before { github_login }
12
- it { should be_ok }
12
+ it { is_expected.to be_ok }
13
13
  end
14
14
 
15
15
  context 'with multiple scopes' do
@@ -17,12 +17,12 @@ describe 'request to a protected resource' do
17
17
 
18
18
  context 'when logged in in the wrong scope' do
19
19
  before { github_login }
20
- it { should be_github_oauth_redirect }
20
+ it { is_expected.to be_github_oauth_redirect }
21
21
  end
22
22
 
23
23
  context 'when logged in in the correct scope' do
24
24
  before { github_login(:admin) }
25
- it { should be_ok }
25
+ it { is_expected.to be_ok }
26
26
  end
27
27
  end
28
28
  end
@@ -31,12 +31,12 @@ describe 'request to a resource that only exists when logged in' do
31
31
  subject { get '/conditional' }
32
32
 
33
33
  context 'when not logged in' do
34
- it { should be_not_found }
34
+ it { is_expected.to be_not_found }
35
35
  end
36
36
 
37
37
  context 'when logged in' do
38
38
  before { github_login }
39
- it { should be_ok }
39
+ it { is_expected.to be_ok }
40
40
  end
41
41
 
42
42
  context 'with mutliple scopes' do
@@ -44,12 +44,12 @@ describe 'request to a resource that only exists when logged in' do
44
44
 
45
45
  context 'when logged in in the wrong scope' do
46
46
  before { github_login }
47
- it { should be_not_found }
47
+ it { is_expected.to be_not_found }
48
48
  end
49
49
 
50
50
  context 'when logged in in the correct scope' do
51
51
  before { github_login(:admin) }
52
- it { should be_ok }
52
+ it { is_expected.to be_ok }
53
53
  end
54
54
  end
55
55
  end
@@ -58,12 +58,12 @@ describe 'request to a resource that only exists when logged out' do
58
58
  subject { get '/conditional_inverse' }
59
59
 
60
60
  context 'when not logged in' do
61
- it { should be_ok }
61
+ it { is_expected.to be_ok }
62
62
  end
63
63
 
64
64
  context 'when logged in' do
65
65
  before { github_login }
66
- it { should be_not_found }
66
+ it { is_expected.to be_not_found }
67
67
  end
68
68
 
69
69
  context 'with mutliple scopes' do
@@ -71,12 +71,12 @@ describe 'request to a resource that only exists when logged out' do
71
71
 
72
72
  context 'when logged in in the wrong scope' do
73
73
  before { github_login }
74
- it { should be_ok }
74
+ it { is_expected.to be_ok }
75
75
  end
76
76
 
77
77
  context 'when logged in in the correct scope' do
78
78
  before { github_login(:admin) }
79
- it { should be_not_found }
79
+ it { is_expected.to be_not_found }
80
80
  end
81
81
  end
82
82
  end
@@ -1,4 +1,5 @@
1
1
  RailsApp::Application.configure do
2
+ config.eager_load = false
2
3
  config.cache_classes = false
3
4
  config.whiny_nils = true
4
5
  config.consider_all_requests_local = true
@@ -1,4 +1,5 @@
1
1
  RailsApp::Application.configure do
2
+ config.eager_load = true
2
3
  config.cache_classes = true
3
4
  config.consider_all_requests_local = false
4
5
  config.action_controller.perform_caching = true
@@ -1,4 +1,5 @@
1
1
  RailsApp::Application.configure do
2
+ config.eager_load = true
2
3
  config.cache_classes = true
3
4
  config.serve_static_assets = true
4
5
  config.static_cache_control = "public, max-age=3600"
data/spec/spec_helper.rb CHANGED
@@ -25,9 +25,7 @@ ENV['GITHUB_CLIENT_ID'] = 'test_client_id'
25
25
  ENV['GITHUB_CLIENT_SECRET'] = 'test_client_secret'
26
26
 
27
27
  RSpec.configure do |config|
28
- config.treat_symbols_as_metadata_keys_with_true_values = true
29
28
  config.run_all_when_everything_filtered = true
30
- config.filter_run :focus
31
29
  config.order = 'random'
32
30
  config.expect_with :rspec do |c|
33
31
  c.syntax = :expect
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Warden::GitHub::Rails::TestHelpers::MockUser do
4
- it { should be_a Warden::GitHub::User }
4
+ it { is_expected.to be_a Warden::GitHub::User }
5
5
 
6
6
  describe '#stub_membership' do
7
7
  subject(:user) { described_class.new }
@@ -18,4 +18,12 @@ describe Warden::GitHub::Rails::TestHelpers::MockUser do
18
18
  expect(user).to be_organization_member('foobar')
19
19
  end
20
20
  end
21
+
22
+ it 'can be marshaled' do
23
+ user = described_class.new
24
+ user.stub_membership(org: ['apple', 'facebook'], team: [12, 34])
25
+ marshaled_user = Marshal.load(Marshal.dump(user))
26
+
27
+ expect(marshaled_user.memberships).to eq(user.memberships)
28
+ end
21
29
  end
@@ -2,38 +2,30 @@ require 'spec_helper'
2
2
 
3
3
  describe Warden::GitHub::Rails::TestHelpers do
4
4
  describe '#github_login' do
5
+ before { allow(self).to receive(:login_as) }
6
+
5
7
  context 'when no scope is specified' do
6
8
  it 'uses the default scope from config to login' do
7
- Warden::GitHub::Rails.stub(default_scope: :foobar)
8
- should_receive(:login_as).with do |_, opts|
9
- expect(opts.fetch(:scope)).to eq(:foobar)
10
- end
9
+ allow(Warden::GitHub::Rails).to receive(:default_scope) { :foobar }
11
10
 
12
11
  github_login
12
+
13
+ expect(self).to have_received(:login_as).with(
14
+ an_instance_of(Warden::GitHub::Rails::TestHelpers::MockUser),
15
+ match(scope: :foobar)
16
+ )
13
17
  end
14
18
  end
15
19
 
16
20
  context 'when a scope is specified' do
17
21
  it 'uses that scope to login' do
18
- should_receive(:login_as).with do |_, opts|
19
- expect(opts.fetch(:scope)).to eq(:admin)
20
- end
21
-
22
22
  github_login(:admin)
23
- end
24
- end
25
-
26
- it 'logs in a mock user' do
27
- expected_user = nil
28
23
 
29
- should_receive(:login_as).with do |user, _|
30
- expected_user = user
31
- expect(user).to be_a(Warden::GitHub::Rails::TestHelpers::MockUser)
24
+ expect(self).to have_received(:login_as).with(
25
+ an_instance_of(Warden::GitHub::Rails::TestHelpers::MockUser),
26
+ match(scope: :admin)
27
+ )
32
28
  end
33
-
34
- user = github_login
35
-
36
- expect(user).to eq(expected_user)
37
29
  end
38
30
  end
39
31
  end
@@ -14,7 +14,7 @@ Gem::Specification.new do |gem|
14
14
  gem.files = `git ls-files`.split($/) - Dir.glob('example/**/*')
15
15
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
16
16
 
17
- gem.add_development_dependency 'rspec', '~> 2.14'
17
+ gem.add_development_dependency 'rspec', '~> 3.1'
18
18
  gem.add_development_dependency 'rails', '>= 3.2'
19
19
  gem.add_development_dependency 'rack-test', '~> 0.6'
20
20
  gem.add_development_dependency 'addressable', '~> 2.3'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: warden-github-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Philipe Fatio
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-17 00:00:00.000000000 Z
11
+ date: 2014-10-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '2.14'
19
+ version: '3.1'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '2.14'
26
+ version: '3.1'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rails
29
29
  requirement: !ruby/object:Gem::Requirement