summaryrefslogtreecommitdiff
path: root/spec/lib/omni_auth/strategies/bitbucket_spec.rb
blob: d85ce71d60a5a3d933a4de11054a1f4f1f1f233f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe OmniAuth::Strategies::Bitbucket do
  subject { described_class.new({}) }

  describe '#callback_url' do
    let(:base_url) { 'https://example.com' }

    context 'when script name is not present' do
      it 'has the correct default callback path' do
        allow(subject).to receive(:full_host) { base_url }
        allow(subject).to receive(:script_name).and_return('')
        allow(subject).to receive(:query_string).and_return('')
        expect(subject.callback_url).to eq("#{base_url}/users/auth/bitbucket/callback")
      end
    end

    context 'when script name is present' do
      it 'sets the callback path with script_name' do
        allow(subject).to receive(:full_host) { base_url }
        allow(subject).to receive(:script_name).and_return('/v1')
        allow(subject).to receive(:query_string).and_return('')
        expect(subject.callback_url).to eq("#{base_url}/v1/users/auth/bitbucket/callback")
      end
    end
  end
end