Sha256: 8a08a39547fa44318d9e595222a2c6d60eca0f9fd3e89439e7756f7d281a63a8

Contents?: true

Size: 1.07 KB

Versions: 2

Compression:

Stored size: 1.07 KB

Contents

require 'spec_helper'

# Test if the configs in rails_app/config/initializers/warden_github_rails.rb
# are actually being set and used by warden.
describe 'request to custom configured scope' do
  def test_redirect(url, args)
    request = get url
    params = Addressable::URI.parse(request.location).query_values

    request.should be_github_oauth_redirect
    params.fetch('client_id').should eq args.fetch(:client_id)
    params.fetch('redirect_uri').should =~ args.fetch(:redirect_uri)
    params.fetch('scope').should eq args.fetch(:scope)
  end

  context 'user' do
    it 'passes the correct configs to the oauth flow' do
      test_redirect('/protected',
                    :client_id => 'foo',
                    :redirect_uri => /\/protected$/,
                    :scope => 'user')
    end
  end

  context 'admin' do
    it 'passes the correct configs to the oauth flow' do
      test_redirect('/admin/protected',
                    :client_id => 'abc',
                    :redirect_uri => /\/admin\/login\/callback$/,
                    :scope => 'repo')
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
warden-github-rails-1.0.0 spec/integration/scope_spec.rb
warden-github-rails-0.0.1 spec/integration/scope_spec.rb