Sha256: e32f6ebf04f67efdb7685d2f3434d040db59e737f5c888a047516e6441e42fa0

Contents?: true

Size: 970 Bytes

Versions: 1

Compression:

Stored size: 970 Bytes

Contents

require 'spec_helper'
require 'hashie'

describe TentD::API::Authorization do
  def app
    TentD::API.new
  end

  let(:env) { Hashie::Mash.new }

  not_authorized = proc do
    it 'should not authorize scopes' do
      described_class.new(app).call(env)
      expect(env.authorized_scopes).to eq([])
    end
  end

  context 'without current_auth', &not_authorized

  context 'with current_auth' do
    context 'when Follower' do
      before do
        env.current_auth = Fabricate(:follower)
      end

      context '', &not_authorized
    end

    context 'when AppAuthorization' do
      before do
        env.current_auth = Fabricate(
          :app_authorization,
          :scopes => ['read_posts', 'write_posts'],
          :app => Fabricate(:app)
        )
      end

      it 'should lookup authorized scopes' do
        described_class.new(app).call(env)
        expect(env.authorized_scopes).to eq([:read_posts, :write_posts])
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tentd-0.0.1 spec/unit/api/authorization_spec.rb