@@ -5,19 +5,6 @@ def setup
55 super
66 @controller = Api ::V1 ::OmniauthCallbacksController . new
77 OmniAuth . config . test_mode = true
8- OmniAuth . config . mock_auth [ :twitter ] = OmniAuth ::AuthHash . new ( {
9- provider : 'twitter' ,
10- uid : '654321' ,
11- info : {
12- name : 'Test' ,
13- image : 'http://twitter.com/test/image.png' ,
14- nickname : 'test'
15- } ,
16- credentials : {
17- token : '123456' ,
18- secret : 'top_secret'
19- }
20- } )
218 OmniAuth . config . mock_auth [ :facebook ] = OmniAuth ::AuthHash . new ( {
229 provider : 'facebook' ,
2310 uid : '654321' ,
@@ -77,8 +64,11 @@ def setup
7764 secret : 'top_secret'
7865 }
7966 } )
67+ [ { email :
'[email protected] ' , name :
'Test' } , { email :
'[email protected] ' , name :
'Mohamed El-Sawy' } ] . each do |
info |
68+ invite_new_user info
69+ end
8070 request . env [ 'devise.mapping' ] = Devise . mappings [ :api_user ]
81- [ 'https://twitter.com/test' , 'https:// facebook.com/654321', 'https://www.googleapis.com/plus/v1/people/654321' ] . each do |url |
71+ [ 'https://facebook.com/654321' , 'https://www.googleapis.com/plus/v1/people/654321' ] . each do |url |
8272 WebMock . stub_request ( :get , CheckConfig . get ( 'pender_url_private' ) + '/api/medias' ) . with ( { query : { url : url } } ) . to_return ( body : '{"type":"media","data":{"type":"profile"}}' )
8373 end
8474 User . current = nil
@@ -89,25 +79,6 @@ def teardown
8979 User . current = nil
9080 end
9181
92- test "should redirect to root after Twitter authentication" do
93- request . env [ 'omniauth.auth' ] = OmniAuth . config . mock_auth [ :twitter ]
94- get :twitter , params : { }
95- assert_redirected_to '/close.html'
96- end
97-
98- test "should set information in session after Twitter authentication" do
99- request . env [ 'omniauth.auth' ] = OmniAuth . config . mock_auth [ :twitter ]
100- assert_nil session [ 'checkdesk.user' ]
101- get :twitter , params : { }
102- assert_not_nil session [ 'checkdesk.current_user_id' ]
103- end
104-
105- test "should redirect to destination after Twitter authentication" do
106- request . env [ 'omniauth.auth' ] = OmniAuth . config . mock_auth [ :twitter ]
107- get :twitter , params : { destination : '/close.html' }
108- assert_redirected_to '/close.html'
109- end
110-
11182 test "should set information in session after Facebook authentication" do
11283 request . env [ 'omniauth.auth' ] = OmniAuth . config . mock_auth [ :facebook ]
11384 assert_nil session [ 'checkdesk.user' ]
@@ -190,12 +161,11 @@ def teardown
190161 end
191162
192163 test "should connect when current user set" do
193- p1 = random_complex_password
194- u = create_user login :
'test' , password :
p1 , password_confirmation :
p1 , email :
'[email protected] ' 164+ u = User . where ( email :
'[email protected] ' ) . first 195165 u . confirm
196166 authenticate_with_user ( u )
197- request . env [ 'omniauth.auth' ] = OmniAuth . config . mock_auth [ :twitter ]
198- get :twitter , params : { }
167+ request . env [ 'omniauth.auth' ] = OmniAuth . config . mock_auth [ :facebook ]
168+ get :facebook , params : { }
199169 u = User . find ( u . id )
200170 assert_equal 1 , u . source . accounts . count
201171 end
@@ -219,12 +189,6 @@ def teardown
219189 assert_redirected_to '/close.html'
220190 end
221191
222- test "should setup Twitter authentication" do
223- request . env [ 'omniauth.strategy' ] = OmniAuth ::Strategies ::Twitter . new ( { } )
224- get :setup , params : { }
225- assert_response 404
226- end
227-
228192 test "should setup Facebook authentication" do
229193 request . env [ 'omniauth.strategy' ] = OmniAuth ::Strategies ::Facebook . new ( { } )
230194 get :setup , params : { }
0 commit comments