debian-mirror-gitlab/spec/services/chat_names/authorize_user_service_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

41 lines
976 B
Ruby
Raw Normal View History

2019-07-31 22:56:46 +05:30
# frozen_string_literal: true
2017-08-17 22:00:37 +05:30
require 'spec_helper'
2020-07-28 23:09:34 +05:30
RSpec.describe ChatNames::AuthorizeUserService do
2017-08-17 22:00:37 +05:30
describe '#execute' do
2022-03-02 08:16:31 +05:30
let(:integration) { create(:integration) }
2019-12-04 20:38:33 +05:30
let(:result) { subject.execute }
2022-03-02 08:16:31 +05:30
subject { described_class.new(integration, params) }
2017-08-17 22:00:37 +05:30
context 'when all parameters are valid' do
let(:params) { { team_id: 'T0001', team_domain: 'myteam', user_id: 'U0001', user_name: 'user' } }
2019-12-04 20:38:33 +05:30
it 'produces a valid HTTP URL' do
expect(result).to be_http_url
end
2017-08-17 22:00:37 +05:30
it 'requests a new token' do
2019-12-04 20:38:33 +05:30
expect(subject).to receive(:request_token).once.and_call_original
subject.execute
2017-08-17 22:00:37 +05:30
end
end
context 'when there are missing parameters' do
let(:params) { {} }
2019-12-04 20:38:33 +05:30
it 'does not produce a URL' do
expect(result).to be_nil
end
2017-08-17 22:00:37 +05:30
it 'does not request a new token' do
2019-12-04 20:38:33 +05:30
expect(subject).not_to receive(:request_token)
subject.execute
2017-08-17 22:00:37 +05:30
end
end
end
end