diff --git a/lib/omniauth/strategies/github.rb b/lib/omniauth/strategies/github.rb index 26d31e7..c60b2d1 100644 --- a/lib/omniauth/strategies/github.rb +++ b/lib/omniauth/strategies/github.rb @@ -69,6 +69,10 @@ def email_access_allowed? scopes = options['scope'].split(',') (scopes & email_scopes).any? end + + def callback_url + full_host + script_name + callback_path + end end end end diff --git a/spec/omniauth/strategies/github_spec.rb b/spec/omniauth/strategies/github_spec.rb index 0d4c313..302ee61 100644 --- a/spec/omniauth/strategies/github_spec.rb +++ b/spec/omniauth/strategies/github_spec.rb @@ -149,4 +149,13 @@ expect(subject.info['urls']['GitHub']).to eq('http://enterprise/me') end end + + describe '#callback_url' do + it 'is a combination of host, script name, and callback path' do + allow(subject).to receive(:full_host).and_return('https://example.com') + allow(subject).to receive(:script_name).and_return('/sub_uri') + + expect(subject.callback_url).to eq('https://example.com/sub_uri/auth/github/callback') + end + end end