diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-01-18 22:00:14 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-01-18 22:00:14 +0300 |
commit | 05f0ebba3a2c8ddf39e436f412dc2ab5bf1353b2 (patch) | |
tree | 11d0f2a6ec31c7793c184106cedc2ded3d9a2cc5 /spec/models/projects/branch_rule_spec.rb | |
parent | ec73467c23693d0db63a797d10194da9e72a74af (diff) |
Add latest changes from gitlab-org/gitlab@15-8-stable-eev15.8.0-rc42
Diffstat (limited to 'spec/models/projects/branch_rule_spec.rb')
-rw-r--r-- | spec/models/projects/branch_rule_spec.rb | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/spec/models/projects/branch_rule_spec.rb b/spec/models/projects/branch_rule_spec.rb new file mode 100644 index 00000000000..6910fbbb6db --- /dev/null +++ b/spec/models/projects/branch_rule_spec.rb @@ -0,0 +1,32 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Projects::BranchRule, feature_category: :source_code_management do + let_it_be(:project) { create(:project, :repository) } + let_it_be(:protected_branch) { create(:protected_branch, project: project, name: 'feature*') } + + subject { described_class.new(protected_branch.project, protected_branch) } + + it 'delegates methods to protected branch' do + expect(subject).to delegate_method(:name).to(:protected_branch) + expect(subject).to delegate_method(:group).to(:protected_branch) + expect(subject).to delegate_method(:default_branch?).to(:protected_branch) + expect(subject).to delegate_method(:created_at).to(:protected_branch) + expect(subject).to delegate_method(:updated_at).to(:protected_branch) + end + + it 'is protected' do + expect(subject.protected?).to eq(true) + end + + it 'branch protection returns protected branch' do + expect(subject.branch_protection).to eq(protected_branch) + end + + describe '#matching_branches_count' do + it 'returns the number of branches that are matching the protected branch name' do + expect(subject.matching_branches_count).to eq(2) + end + end +end |