facemock-oauth 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -39,7 +39,7 @@ for Rails
39
39
 
40
40
  $ vi config/environments/development.rb
41
41
 
42
- Facemock::OAuth::LoginHook.path = '/facebook/sign_in'
42
+ Facemock::OAuth::LoginHook.paths = [ '/facebook/sign_in', '/user/facebook/sign_in' ]
43
43
  Facemock::OAuth::CallbackHook.path = '/users/facemock/auth/callback'
44
44
 
45
45
  config.middleware.use Facemock::OAuth::LoginHook
@@ -54,7 +54,7 @@ for Sinatra
54
54
  require 'sinatra'
55
55
  require 'facemock-oauth'
56
56
 
57
- Facemock::OAuth::LoginHook.path = '/facebook/sign_in'
57
+ Facemock::OAuth::LoginHook.paths = [ '/facebook/sign_in', '/user/facebook/sign_in' ]
58
58
  Facemock::OAuth::CallbackHook.path = '/users/facemock/auth/callback'
59
59
 
60
60
  use Facemock::OAuth::LoginHook
@@ -3,6 +3,10 @@ require 'facemock'
3
3
  module Facemock
4
4
  module OAuth
5
5
  class Authentication < RackMiddleware
6
+ class << self
7
+ attr_accessor :path
8
+ end
9
+
6
10
  DEFAULT_PATH = "/facemock/oauth"
7
11
  @path = DEFAULT_PATH
8
12
 
@@ -3,6 +3,10 @@ require 'facemock'
3
3
  module Facemock
4
4
  module OAuth
5
5
  class CallbackHook < RackMiddleware
6
+ class << self
7
+ attr_accessor :path
8
+ end
9
+
6
10
  DEFAULT_PATH = "/users/auth/callback"
7
11
  @path = DEFAULT_PATH
8
12
 
@@ -3,6 +3,10 @@
3
3
  module Facemock
4
4
  module OAuth
5
5
  class Login < RackMiddleware
6
+ class << self
7
+ attr_accessor :path
8
+ end
9
+
6
10
  VIEW_DIRECTORY = File.expand_path("../../../../view", __FILE__)
7
11
  VIEW_FILE_NAME = "login.html"
8
12
  DEFAULT_PATH = "/facemock/sign_in"
@@ -1,12 +1,16 @@
1
1
  module Facemock
2
2
  module OAuth
3
3
  class LoginHook < RackMiddleware
4
+ class << self
5
+ attr_accessor :paths
6
+ end
7
+
4
8
  DEFAULT_PATH = "/sign_in"
5
- @path = DEFAULT_PATH
9
+ @paths = [ DEFAULT_PATH ]
6
10
 
7
11
  def call(env)
8
12
  res = super
9
- if env["PATH_INFO"] == LoginHook.path
13
+ if LoginHook.paths.include?(env["PATH_INFO"])
10
14
  code = 302
11
15
  body = []
12
16
  header = { "Content-Type" => "text/html;charset=utf-8",
@@ -3,10 +3,6 @@ require 'rack'
3
3
  module Facemock
4
4
  module OAuth
5
5
  class RackMiddleware
6
- class << self
7
- attr_accessor :path
8
- end
9
-
10
6
  def initialize(app)
11
7
  @app = app
12
8
  end
@@ -1,5 +1,5 @@
1
1
  module Facemock
2
2
  module OAuth
3
- VERSION = '0.0.4'
3
+ VERSION = '0.0.5'
4
4
  end
5
5
  end
@@ -15,18 +15,19 @@ describe Facemock::OAuth::LoginHook do
15
15
  end
16
16
 
17
17
  describe '.path' do
18
- subject { Facemock::OAuth::LoginHook.path }
19
- it { is_expected.to eq path }
18
+ subject { Facemock::OAuth::LoginHook.paths }
19
+ it { is_expected.to eq [ path ] }
20
20
  end
21
21
 
22
22
  describe '.path=' do
23
23
  context 'with "/test"' do
24
24
  before { @path = "/test" }
25
- after { Facemock::OAuth::LoginHook.path = path }
25
+ after { Facemock::OAuth::LoginHook.paths = [ path ] }
26
26
 
27
27
  it 'should set class instance variable path' do
28
- Facemock::OAuth::LoginHook.path = @path
29
- expect(Facemock::OAuth::LoginHook.path).to eq @path
28
+ Facemock::OAuth::LoginHook.paths << @path
29
+ expect(Facemock::OAuth::LoginHook.paths).to include path
30
+ expect(Facemock::OAuth::LoginHook.paths).to include @path
30
31
  end
31
32
  end
32
33
  end
@@ -48,7 +49,7 @@ describe Facemock::OAuth::LoginHook do
48
49
  before { @path = '/' }
49
50
  end
50
51
 
51
- describe "GET '/facebook/sign_in'" do
52
+ describe "GET '/sign_in'" do
52
53
  context 'when path is default value', assert: :RedirectToFacemockSignin do
53
54
  before { @path = path }
54
55
  end
@@ -56,9 +57,9 @@ describe Facemock::OAuth::LoginHook do
56
57
  context 'when path variable set ather path', assert: :RequestSuccess do
57
58
  before do
58
59
  @path = path
59
- Facemock::OAuth::LoginHook.path = "/test"
60
+ Facemock::OAuth::LoginHook.paths = [ "/test" ]
60
61
  end
61
- after { Facemock::OAuth::LoginHook.path = path }
62
+ after { Facemock::OAuth::LoginHook.paths = [ path ] }
62
63
  end
63
64
  end
64
65
 
@@ -66,9 +67,9 @@ describe Facemock::OAuth::LoginHook do
66
67
  context "when path variable set '/test'", assert: :RedirectToFacemockSignin do
67
68
  before do
68
69
  @path = "/test"
69
- Facemock::OAuth::LoginHook.path = @path
70
+ Facemock::OAuth::LoginHook.paths = [ @path ]
70
71
  end
71
- after { Facemock::OAuth::LoginHook.path = path }
72
+ after { Facemock::OAuth::LoginHook.paths = [ path ] }
72
73
  end
73
74
  end
74
75
  end
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Facemock::OAuth do
4
- let(:version) { '0.0.4' }
4
+ let(:version) { '0.0.5' }
5
5
 
6
6
  it 'should have a version number' do
7
7
  expect(Facemock::OAuth::VERSION).to eq version
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: facemock-oauth
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
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: 2014-09-08 00:00:00.000000000 Z
12
+ date: 2014-09-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: facemock
@@ -203,7 +203,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
203
203
  version: '0'
204
204
  segments:
205
205
  - 0
206
- hash: -2283618699220724282
206
+ hash: 422700096564625871
207
207
  required_rubygems_version: !ruby/object:Gem::Requirement
208
208
  none: false
209
209
  requirements:
@@ -212,7 +212,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
212
212
  version: '0'
213
213
  segments:
214
214
  - 0
215
- hash: -2283618699220724282
215
+ hash: 422700096564625871
216
216
  requirements: []
217
217
  rubyforge_project:
218
218
  rubygems_version: 1.8.25