debian-mirror-gitlab/spec/lib/gitlab/slash_commands/presenters/access_spec.rb

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

80 lines
2.1 KiB
Ruby
Raw Permalink Normal View History

2019-12-04 20:38:33 +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 Gitlab::SlashCommands::Presenters::Access do
2019-12-21 20:55:43 +05:30
shared_examples_for 'displays an error message' do
it do
expect(subject[:text]).to match(error_message)
expect(subject[:response_type]).to be(:ephemeral)
end
end
2017-08-17 22:00:37 +05:30
describe '#access_denied' do
2019-12-04 20:38:33 +05:30
let(:project) { build(:project) }
subject { described_class.new.access_denied(project) }
2017-08-17 22:00:37 +05:30
it { is_expected.to be_a(Hash) }
2019-12-21 20:55:43 +05:30
it_behaves_like 'displays an error message' do
let(:error_message) { 'you do not have access to the GitLab project' }
end
end
2019-12-26 22:10:19 +05:30
describe '#generic_access_denied' do
subject { described_class.new.generic_access_denied }
it { is_expected.to be_a(Hash) }
it_behaves_like 'displays an error message' do
let(:error_message) { 'You are not allowed to perform the given chatops command.' }
end
end
2019-12-21 20:55:43 +05:30
describe '#deactivated' do
subject { described_class.new.deactivated }
it { is_expected.to be_a(Hash) }
it_behaves_like 'displays an error message' do
let(:error_message) { 'your account has been deactivated by your administrator' }
2017-08-17 22:00:37 +05:30
end
end
describe '#not_found' do
subject { described_class.new.not_found }
it { is_expected.to be_a(Hash) }
it 'tells the user the resource was not found' do
expect(subject[:text]).to match("not found!")
expect(subject[:response_type]).to be(:ephemeral)
end
end
describe '#authorize' do
context 'with an authorization URL' do
subject { described_class.new('http://authorize.me').authorize }
it { is_expected.to be_a(Hash) }
it 'tells the user to authorize' do
expect(subject[:text]).to match("connect your GitLab account")
expect(subject[:response_type]).to be(:ephemeral)
end
end
context 'without authorization url' do
subject { described_class.new.authorize }
it { is_expected.to be_a(Hash) }
it 'tells the user to authorize' do
expect(subject[:text]).to match("Couldn't identify you")
expect(subject[:response_type]).to be(:ephemeral)
end
end
end
end