File tree 3 files changed +36
-3
lines changed
3 files changed +36
-3
lines changed Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ def create
27
27
current_user . apply_oauth ( oauth )
28
28
current_user . save!
29
29
flash [ :notice ] = "#{ oauth [ :provider ] . humanize } account linked"
30
- redirect_to ( destination_url )
30
+ redirect_to ( edit_user_url ( current_user ) )
31
31
else
32
32
@user = User . find_with_oauth ( oauth )
33
33
if @user && !@user . new_record?
Original file line number Diff line number Diff line change 36
36
BetterErrors ::Middleware . allow_ip! ENV [ 'TRUSTED_IP' ] if ENV [ 'TRUSTED_IP' ]
37
37
#Rails.logger = Logger.new(STDOUT)
38
38
#Rails.logger.level = Logger::DEBUG
39
+
40
+ # Mock account credentials
41
+ OmniAuth . config . test_mode = true
42
+ OmniAuth . config . mock_auth [ :linkedin ] = OmniAuth ::AuthHash . new ( {
43
+ :provider => 'linkedin' ,
44
+ :uid => 'linkedin12345' ,
45
+ :info => { :nickname => 'linkedinuser' } ,
46
+ :credentials => {
47
+ :token => 'linkedin1' ,
48
+ :secret => 'secret' } } )
49
+ OmniAuth . config . mock_auth [ :twitter ] = OmniAuth ::AuthHash . new ( {
50
+ :provider => 'twitter' ,
51
+ :uid => 'twitter123545' ,
52
+ :info => { :nickname => 'twitteruser' } ,
53
+ :credentials => {
54
+ :token => 'twitter1' ,
55
+ :secret => 'secret' } } )
56
+ OmniAuth . config . mock_auth [ :github ] = OmniAuth ::AuthHash . new ( {
57
+ :provider => 'github' ,
58
+ :uid => 'github123545' ,
59
+ :info => { :nickname => 'githubuser' } ,
60
+ :credentials => {
61
+ :token => 'github1' ,
62
+ :secret => 'secret' } } )
39
63
end
Original file line number Diff line number Diff line change 106
106
expect ( response ) . to redirect_to ( new_user_url )
107
107
end
108
108
109
- it 'redirects back to profile page if user is already signed in' do
109
+ it 'redirects back to settings page if user is already signed in' do
110
110
sign_in ( user = Fabricate ( :user , username : 'darth' ) )
111
111
request . env [ 'omniauth.auth' ] = OmniAuth . config . mock_auth [ :github ] = github_response
112
112
get :create
113
113
expect ( flash [ :notice ] ) . to include ( 'linked' )
114
- expect ( response ) . to redirect_to ( badge_url ( username : 'darth' ) )
114
+ expect ( response ) . to redirect_to ( edit_user_url ( controller . send :current_user ) )
115
115
end
116
116
end
117
117
202
202
get :create
203
203
expect ( flash [ :error ] ) . to include ( 'already associated with a different member' )
204
204
end
205
+
206
+ it 'successful linking of an account should redirect to settings page' do
207
+ user = Fabricate ( :user , twitter : 'mdeiters' , twitter_id : '6271932' )
208
+ sign_in ( user )
209
+ request . env [ 'omniauth.auth' ] = OmniAuth . config . mock_auth [ :twitter ] = twitter_response
210
+ get :create
211
+ expect ( flash [ :notice ] ) . to include ( 'linked' )
212
+ expect ( response ) . to redirect_to ( edit_user_url ( controller . send :current_user ) )
213
+ end
205
214
end
206
215
207
216
end
You can’t perform that action at this time.
0 commit comments