Sha256: f1d0edcf8ebe835874ad54f25dd3be417437d689e07302596e131d2f614df707

Contents?: true

Size: 1.24 KB

Versions: 2

Compression:

Stored size: 1.24 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

describe OmniAuth::Strategies::SageOne do
  let(:access_token) { instance_double(OAuth2::AccessToken, options: {}) }

  let(:sageone) { OmniAuth::Strategies::SageOne.new({}) }

  before { allow(sageone).to receive(:access_token).and_return(access_token) }

  describe 'client options' do
    subject(:client_options) { sageone.options.client_options }

    it 'has correct authorize url' do
      expect(client_options.authorize_url).to eq('https://www.sageone.com/oauth2/auth/central')
    end

    it 'has correct token url' do
      expect(client_options.token_url).to eq('https://oauth.accounting.sage.com/token')
    end
  end

  describe 'authorize params' do
    it 'contains the filter' do
      expect(sageone.options.authorize_params['filter']).to eq('apiv3.1')
    end
  end

  describe '#callback_url' do
    before do
      allow(sageone).to receive(:full_host).and_return('https://example.com')
      allow(sageone).to receive(:script_name).and_return('/sub_uri')
      allow(sageone).to receive(:query_string).and_return('?country=usa')
    end

    it 'does not contain the query string' do
      expect(sageone.callback_url).to eq('https://example.com/sub_uri/auth/sageone/callback')
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
omniauth-sageone-0.6.0 spec/omniauth/strategies/sage_one_spec.rb
omniauth-sageone-0.5.0 spec/omniauth/strategies/sage_one_spec.rb