Sha256: 1cae09ddb495fff2181364037d631d5b40c258669c59f3231629ba2a7dd78a6e

Contents?: true

Size: 1.79 KB

Versions: 6

Compression:

Stored size: 1.79 KB

Contents

require 'spec_helper'

describe 'request to a protected resource' do
  subject { get '/protected' }

  context 'when not logged in' do
    it { should be_github_oauth_redirect }
  end

  context 'when logged in' do
    before { github_login }
    it { should be_ok }
  end

  context 'with multiple scopes' do
    subject { get '/admin/protected' }

    context 'when logged in in the wrong scope' do
      before { github_login }
      it { should be_github_oauth_redirect }
    end

    context 'when logged in in the correct scope' do
      before { github_login(:admin) }
      it { should be_ok }
    end
  end
end

describe 'request to a resource that only exists when logged in' do
  subject { get '/conditional' }

  context 'when not logged in' do
    it { should be_not_found }
  end

  context 'when logged in' do
    before { github_login }
    it { should be_ok }
  end

  context 'with mutliple scopes' do
    subject { get '/admin/conditional' }

    context 'when logged in in the wrong scope' do
      before { github_login }
      it { should be_not_found }
    end

    context 'when logged in in the correct scope' do
      before { github_login(:admin) }
      it { should be_ok }
    end
  end
end

describe 'request to a resource that only exists when logged out' do
  subject { get '/conditional_inverse' }

  context 'when not logged in' do
    it { should be_ok }
  end

  context 'when logged in' do
    before { github_login }
    it { should be_not_found }
  end

  context 'with mutliple scopes' do
    subject { get '/admin/conditional_inverse' }

    context 'when logged in in the wrong scope' do
      before { github_login }
      it { should be_ok }
    end

    context 'when logged in in the correct scope' do
      before { github_login(:admin) }
      it { should be_not_found }
    end
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
warden-github-rails-1.1.1 spec/integration/route_spec.rb
warden-github-rails-1.1.0 spec/integration/route_spec.rb
warden-github-rails-thinknear-fork-1.1.0 spec/integration/route_spec.rb
warden-github-rails-1.0.1 spec/integration/route_spec.rb
warden-github-rails-1.0.0 spec/integration/route_spec.rb
warden-github-rails-0.0.1 spec/integration/route_spec.rb