Welcome to mirror list, hosted at ThFree Co, Russian Federation.

create_service_spec.rb « protected_tags « services « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: a0b99b595e32ba0c60fd9e17b30cdabd20c284c5 (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
30
31
32
33
34
35
36
# frozen_string_literal: true

require 'spec_helper'

RSpec.describe ProtectedTags::CreateService do
  let(:project) { create(:project) }
  let(:user) { project.first_owner }
  let(:params) do
    {
      name: name,
      create_access_levels_attributes: [{ access_level: Gitlab::Access::MAINTAINER }]
    }
  end

  describe '#execute' do
    let(:name) { 'tag' }

    subject(:service) { described_class.new(project, user, params) }

    it 'creates a new protected tag' do
      expect { service.execute }.to change(ProtectedTag, :count).by(1)
      expect(project.protected_tags.last.create_access_levels.map(&:access_level)).to eq([Gitlab::Access::MAINTAINER])
    end

    context 'protecting a tag with a name that contains HTML tags' do
      let(:name) { 'foo<b>bar<\b>' }

      subject(:service) { described_class.new(project, user, params) }

      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)
      end
    end
  end
end