2018-03-17 18:26:18 +05:30
|
|
|
describe QA::Runtime::API::Client do
|
2019-07-07 11:18:12 +05:30
|
|
|
include Helpers::StubENV
|
2018-03-17 18:26:18 +05:30
|
|
|
|
|
|
|
describe 'initialization' do
|
|
|
|
it 'defaults to :gitlab address' do
|
|
|
|
expect(described_class.new.address).to eq :gitlab
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'uses specified address' do
|
|
|
|
client = described_class.new('http:///example.com')
|
|
|
|
|
|
|
|
expect(client.address).to eq 'http:///example.com'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-12-13 13:39:08 +05:30
|
|
|
describe '#personal_access_token' do
|
|
|
|
context 'when QA::Runtime::Env.personal_access_token is present' do
|
|
|
|
before do
|
|
|
|
allow(QA::Runtime::Env).to receive(:personal_access_token).and_return('a_token')
|
|
|
|
end
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2018-12-13 13:39:08 +05:30
|
|
|
it 'returns specified token from env' do
|
|
|
|
expect(described_class.new.personal_access_token).to eq 'a_token'
|
|
|
|
end
|
2018-03-17 18:26:18 +05:30
|
|
|
end
|
|
|
|
|
2018-12-13 13:39:08 +05:30
|
|
|
context 'when QA::Runtime::Env.personal_access_token is nil' do
|
|
|
|
before do
|
|
|
|
allow(QA::Runtime::Env).to receive(:personal_access_token).and_return(nil)
|
|
|
|
end
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2018-12-13 13:39:08 +05:30
|
|
|
it 'returns a created token' do
|
|
|
|
expect(subject).to receive(:create_personal_access_token).and_return('created_token')
|
|
|
|
|
|
|
|
expect(subject.personal_access_token).to eq 'created_token'
|
|
|
|
end
|
2018-03-17 18:26:18 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|