oa-recruitmilitary 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,5 @@
1
1
  module OmniAuth
2
2
  module Recruitmilitary
3
- VERSION = "0.0.5"
3
+ VERSION = "0.0.6"
4
4
  end
5
5
  end
@@ -15,27 +15,46 @@ module OmniAuth
15
15
 
16
16
  class Configuration
17
17
 
18
- DEFAULT_SITE = 'http://connect.recruitmilitary.com'
19
- DEFAULT_AUTHORIZE_URL = '/auth/authorize'
20
- DEFAULT_ACCESS_TOKEN_URL = '/auth/access_token'
21
- DEFAULT_USER_DATA_URL = '/auth/user.json'
18
+ DEFAULT_SITE = 'http://connect.recruitmilitary.com'
19
+ DEFAULT_AUTHORIZE_PATH = '/auth/authorize'
20
+ DEFAULT_ACCESS_TOKEN_PATH = '/auth/access_token'
21
+ DEFAULT_USER_DATA_PATH = '/auth/user.json'
22
22
 
23
23
  attr_accessor :site, :authorize_url, :access_token_url, :user_data_url
24
+ attr_accessor :authorize_path, :access_token_path, :user_data_path
24
25
 
25
26
  def initialize(options = {})
26
- @site = DEFAULT_SITE
27
+ @site = options.fetch(:site, DEFAULT_SITE)
28
+ @authorize_path = options.fetch(:authorize_path, DEFAULT_AUTHORIZE_PATH)
29
+ @access_token_path = options.fetch(:access_token_path, DEFAULT_ACCESS_TOKEN_PATH)
30
+ @user_data_path = options.fetch(:user_data_path, DEFAULT_USER_DATA_PATH)
31
+ end
32
+
33
+ def authorize_path=(authorize_path)
34
+ @authorize_path = authorize_path
35
+ @authorize_url = nil
36
+ end
37
+
38
+ def access_token_path=(access_token_path)
39
+ @access_token_path = access_token_path
40
+ @access_token_url = nil
41
+ end
42
+
43
+ def user_data_path(user_data_path)
44
+ @user_data_path = user_data_path
45
+ @user_data_url = nil
27
46
  end
28
47
 
29
48
  def authorize_url
30
- @site + DEFAULT_AUTHORIZE_URL
49
+ @authorize_url || @site + @authorize_path
31
50
  end
32
51
 
33
52
  def access_token_url
34
- @site + DEFAULT_ACCESS_TOKEN_URL
53
+ @access_token_url || @site + @access_token_path
35
54
  end
36
55
 
37
56
  def user_data_url
38
- @site + DEFAULT_USER_DATA_URL
57
+ @user_data_url || @site + @user_data_path
39
58
  end
40
59
  end
41
60
 
@@ -4,17 +4,25 @@ require 'oa-recruitmilitary'
4
4
  describe OmniAuth::RecruitMilitary do
5
5
 
6
6
  describe OmniAuth::RecruitMilitary::Configuration do
7
+ let(:config) { OmniAuth::RecruitMilitary::Configuration.new }
8
+
9
+ it 'sets properties from the initializer' do
10
+ config = OmniAuth::RecruitMilitary::Configuration.new(
11
+ :site => 'http://localhost:3000',
12
+ :authorize_path => '/oauth/authorize')
13
+
14
+ config.site.should == 'http://localhost:3000'
15
+ config.authorize_url.should == 'http://localhost:3000/oauth/authorize'
16
+ end
17
+
7
18
  context 'without modification' do
8
19
  it 'has sane values' do
9
- config = OmniAuth::RecruitMilitary::Configuration.new
10
-
11
20
  config.authorize_url.should == 'http://connect.recruitmilitary.com/auth/authorize'
12
21
  end
13
22
  end
14
23
 
15
24
  context 'when modifying the site url' do
16
25
  it 'updates all related urls' do
17
- config = OmniAuth::RecruitMilitary::Configuration.new
18
26
  config.site = 'http://localhost:3000'
19
27
 
20
28
  config.authorize_url.should == 'http://localhost:3000/auth/authorize'
@@ -22,6 +30,30 @@ describe OmniAuth::RecruitMilitary do
22
30
  config.user_data_url.should == 'http://localhost:3000/auth/user.json'
23
31
  end
24
32
  end
33
+
34
+ context 'when modifying a path' do
35
+ it 'preserves the original site' do
36
+ config.authorize_path = '/oauth/authorize'
37
+
38
+ config.authorize_url = config.site + '/oauth/authorize'
39
+ end
40
+ end
41
+
42
+ it 'allows the url to be modified directly' do
43
+ config.authorize_url = 'http://google.com'
44
+
45
+ config.authorize_url.should == 'http://google.com'
46
+ end
47
+
48
+ context 'when the url has been modified' do
49
+ it 'is modifiable by changing path' do
50
+ config.authorize_url = 'http://google.com'
51
+
52
+ config.authorize_path = '/blah/blah'
53
+
54
+ config.authorize_url.should == config.site + '/blah/blah'
55
+ end
56
+ end
25
57
  end
26
58
 
27
59
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oa-recruitmilitary
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 5
10
- version: 0.0.5
9
+ - 6
10
+ version: 0.0.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - Michael Guterl