omniauth 1.2.2 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of omniauth might be problematic. Click here for more details.

@@ -1,145 +0,0 @@
1
- require 'helper'
2
-
3
- describe OmniAuth do
4
- describe '.strategies' do
5
- it 'increases when a new strategy is made' do
6
- expect do
7
- class ExampleStrategy
8
- include OmniAuth::Strategy
9
- end
10
- end.to change(OmniAuth.strategies, :size).by(1)
11
- expect(OmniAuth.strategies.last).to eq(ExampleStrategy)
12
- end
13
- end
14
-
15
- context 'configuration' do
16
- describe '.defaults' do
17
- it 'is a hash of default configuration' do
18
- expect(OmniAuth::Configuration.defaults).to be_kind_of(Hash)
19
- end
20
- end
21
-
22
- it 'is callable from .configure' do
23
- OmniAuth.configure do |c|
24
- expect(c).to be_kind_of(OmniAuth::Configuration)
25
- end
26
- end
27
-
28
- before do
29
- @old_path_prefix = OmniAuth.config.path_prefix
30
- @old_on_failure = OmniAuth.config.on_failure
31
- @old_before_callback_phase = OmniAuth.config.before_callback_phase
32
- @old_before_options_phase = OmniAuth.config.before_options_phase
33
- @old_before_request_phase = OmniAuth.config.before_request_phase
34
- end
35
-
36
- after do
37
- OmniAuth.configure do |config|
38
- config.path_prefix = @old_path_prefix
39
- config.on_failure = @old_on_failure
40
- config.before_callback_phase = @old_before_callback_phase
41
- config.before_options_phase = @old_before_options_phase
42
- config.before_request_phase = @old_before_request_phase
43
- end
44
- end
45
-
46
- it 'is able to set the path' do
47
- OmniAuth.configure do |config|
48
- config.path_prefix = '/awesome'
49
- end
50
-
51
- expect(OmniAuth.config.path_prefix).to eq('/awesome')
52
- end
53
-
54
- it 'is able to set the on_failure rack app' do
55
- OmniAuth.configure do |config|
56
- config.on_failure do
57
- 'yoyo'
58
- end
59
- end
60
-
61
- expect(OmniAuth.config.on_failure.call).to eq('yoyo')
62
- end
63
-
64
- it 'is able to set hook on option_call' do
65
- OmniAuth.configure do |config|
66
- config.before_options_phase do
67
- 'yoyo'
68
- end
69
- end
70
- expect(OmniAuth.config.before_options_phase.call).to eq('yoyo')
71
- end
72
-
73
- it 'is able to set hook on request_call' do
74
- OmniAuth.configure do |config|
75
- config.before_request_phase do
76
- 'heyhey'
77
- end
78
- end
79
- expect(OmniAuth.config.before_request_phase.call).to eq('heyhey')
80
- end
81
-
82
- it 'is able to set hook on callback_call' do
83
- OmniAuth.configure do |config|
84
- config.before_callback_phase do
85
- 'heyhey'
86
- end
87
- end
88
- expect(OmniAuth.config.before_callback_phase.call).to eq('heyhey')
89
- end
90
-
91
- describe 'mock auth' do
92
- before do
93
- OmniAuth.config.add_mock(:facebook, :uid => '12345', :info => {:name => 'Joe', :email => 'joe@example.com'})
94
- end
95
- it 'default is AuthHash' do
96
- OmniAuth.configure do |config|
97
- expect(config.mock_auth[:default]).to be_kind_of(OmniAuth::AuthHash)
98
- end
99
- end
100
- it 'facebook is AuthHash' do
101
- OmniAuth.configure do |config|
102
- expect(config.mock_auth[:facebook]).to be_kind_of(OmniAuth::AuthHash)
103
- end
104
- end
105
- it 'sets facebook attributes' do
106
- OmniAuth.configure do |config|
107
- expect(config.mock_auth[:facebook].uid).to eq('12345')
108
- expect(config.mock_auth[:facebook].info.name).to eq('Joe')
109
- expect(config.mock_auth[:facebook].info.email).to eq('joe@example.com')
110
- end
111
- end
112
- end
113
- end
114
-
115
- describe '.logger' do
116
- it 'calls through to the configured logger' do
117
- allow(OmniAuth).to receive(:config).and_return(double(:logger => 'foo'))
118
- expect(OmniAuth.logger).to eq('foo')
119
- end
120
- end
121
-
122
- describe '::Utils' do
123
- describe '.deep_merge' do
124
- it 'combines hashes' do
125
- expect(OmniAuth::Utils.deep_merge({'abc' => {'def' => 123}}, {'abc' => {'foo' => 'bar'}})).to eq('abc' => {'def' => 123, 'foo' => 'bar'})
126
- end
127
- end
128
-
129
- describe '.camelize' do
130
- it 'works on normal cases' do
131
- {
132
- 'some_word' => 'SomeWord',
133
- 'AnotherWord' => 'AnotherWord',
134
- 'one' => 'One',
135
- 'three_words_now' => 'ThreeWordsNow'
136
- }.each_pair { |k, v| expect(OmniAuth::Utils.camelize(k)).to eq(v) }
137
- end
138
-
139
- it 'works in special cases that have been added' do
140
- OmniAuth.config.add_camelization('oauth', 'OAuth')
141
- expect(OmniAuth::Utils.camelize(:oauth)).to eq('OAuth')
142
- end
143
- end
144
- end
145
- end