Sha256: 6593bd4a224f0f5bba68ed6839d025f375b06bdc69ed9bae2deb4b8db64b4b4a

Contents?: true

Size: 1.63 KB

Versions: 10

Compression:

Stored size: 1.63 KB

Contents

require 'spec_helper'

describe Warden::GitHub::Rails::Config do
  subject(:config) { described_class.new }

  describe '#default_scope' do
    it 'defaults to :user' do
      expect(config.default_scope).to eq(:user)
    end
  end

  describe '#scopes' do
    it 'defaults to an empty hash' do
      expect(config.scopes).to eq({})
    end
  end

  describe '#teams' do
    it 'defaults to an empty hash' do
      expect(config.scopes).to eq({})
    end
  end

  describe '#add_scope' do
    it 'adds a scope with its configs' do
      scope_config = double
      config.add_scope :admin, scope_config
      expect(config.scopes[:admin]).to eq(scope_config)
    end
  end

  describe '#add_team' do
    it 'adds a name mapping for a team' do
      config.add_team :marketing, 1234
      expect(config.teams[:marketing]).to eq(1234)
    end

    it 'normalizes the input' do
      config.add_team 'marketing', '1234'
      expect(config.teams[:marketing]).to eq(1234)
    end
  end

  describe '#team_id' do
    context 'when passed a numeric value' do
      it 'returns that value' do
        expect(config.team_id('1234')).to eq(1234)
        expect(config.team_id(1234)).to eq(1234)
      end
    end

    context 'when passed an alias' do
      it 'returns the id for the alias' do
        config.add_team :marketing, 1234
        expect(config.team_id(:marketing)).to eq(1234)
        expect(config.team_id('marketing')).to eq(1234)
      end
    end

    context 'when no mapping exists' do
      it 'raises a BadConfig' do
        expect { config.team_id(:foobar) }.
          to raise_error(Warden::GitHub::Rails::Config::BadConfig)
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
warden-github-rails-1.3.0 spec/unit/config_spec.rb
warden-github-rails-1.2.3 spec/unit/config_spec.rb
warden-github-rails-1.2.2 spec/unit/config_spec.rb
warden-github-rails-1.2.1 spec/unit/config_spec.rb
warden-github-rails-1.2.0 spec/unit/config_spec.rb
warden-github-rails-1.1.2 spec/unit/config_spec.rb
warden-github-rails-1.1.1 spec/unit/config_spec.rb
warden-github-rails-1.1.0 spec/unit/config_spec.rb
warden-github-rails-thinknear-fork-1.1.0 spec/unit/config_spec.rb
warden-github-rails-1.0.1 spec/unit/config_spec.rb