debian-mirror-gitlab/spec/services/protected_tags/create_service_spec.rb

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

37 lines
1 KiB
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 ProtectedTags::CreateService do
2017-09-10 17:25:29 +05:30
let(:project) { create(:project) }
2022-03-02 08:16:31 +05:30
let(:user) { project.first_owner }
2017-08-17 22:00:37 +05:30
let(:params) do
{
2022-01-26 12:08:38 +05:30
name: name,
2018-11-18 11:00:15 +05:30
create_access_levels_attributes: [{ access_level: Gitlab::Access::MAINTAINER }]
2017-08-17 22:00:37 +05:30
}
end
describe '#execute' do
2022-01-26 12:08:38 +05:30
let(:name) { 'tag' }
2017-08-17 22:00:37 +05:30
subject(:service) { described_class.new(project, user, params) }
it 'creates a new protected tag' do
expect { service.execute }.to change(ProtectedTag, :count).by(1)
2018-11-18 11:00:15 +05:30
expect(project.protected_tags.last.create_access_levels.map(&:access_level)).to eq([Gitlab::Access::MAINTAINER])
2017-08-17 22:00:37 +05:30
end
2022-01-26 12:08:38 +05:30
2022-02-05 19:09:49 +05:30
context 'protecting a tag with a name that contains HTML tags' do
let(:name) { 'foo<b>bar<\b>' }
2022-01-26 12:08:38 +05:30
2022-02-05 19:09:49 +05:30
subject(:service) { described_class.new(project, user, params) }
2022-01-26 12:08:38 +05:30
2022-02-05 19:09:49 +05:30
it 'creates a new protected tag' do
expect { service.execute }.to change(ProtectedTag, :count).by(1)
expect(project.protected_tags.last.name).to eq(name)
2022-01-26 12:08:38 +05:30
end
end
2017-08-17 22:00:37 +05:30
end
end