diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-18 10:34:06 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-18 10:34:06 +0000 |
commit | 859a6fb938bb9ee2a317c46dfa4fcc1af49608f0 (patch) | |
tree | d7f2700abe6b4ffcb2dcfc80631b2d87d0609239 /spec/models/operations/feature_flag_spec.rb | |
parent | 446d496a6d000c73a304be52587cd9bbc7493136 (diff) | |
download | gitlab-ce-13.9.0-rc42.tar.gz |
Add latest changes from gitlab-org/gitlab@13-9-stable-eev13.9.0-rc42
Diffstat (limited to 'spec/models/operations/feature_flag_spec.rb')
-rw-r--r-- | spec/models/operations/feature_flag_spec.rb | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/spec/models/operations/feature_flag_spec.rb b/spec/models/operations/feature_flag_spec.rb index 93dd7d4f0bb..d5b3c7a8582 100644 --- a/spec/models/operations/feature_flag_spec.rb +++ b/spec/models/operations/feature_flag_spec.rb @@ -16,6 +16,35 @@ RSpec.describe Operations::FeatureFlag do it { is_expected.to have_many(:scopes) } end + describe '.reference_pattern' do + subject { described_class.reference_pattern } + + it { is_expected.to match('[feature_flag:123]') } + it { is_expected.to match('[feature_flag:gitlab-org/gitlab/123]') } + end + + describe '.link_reference_pattern' do + subject { described_class.link_reference_pattern } + + it { is_expected.to match("#{Gitlab.config.gitlab.url}/gitlab-org/gitlab/-/feature_flags/123/edit") } + it { is_expected.not_to match("#{Gitlab.config.gitlab.url}/gitlab-org/gitlab/issues/123/edit") } + it { is_expected.not_to match("gitlab-org/gitlab/-/feature_flags/123/edit") } + end + + describe '#to_reference' do + let(:namespace) { build(:namespace, path: 'sample-namespace') } + let(:project) { build(:project, name: 'sample-project', namespace: namespace) } + let(:feature_flag) { build(:operations_feature_flag, iid: 1, project: project) } + + it 'returns feature flag id' do + expect(feature_flag.to_reference).to eq '[feature_flag:1]' + end + + it 'returns complete path to the feature flag with full: true' do + expect(feature_flag.to_reference(full: true)).to eq '[feature_flag:sample-namespace/sample-project/1]' + end + end + describe 'validations' do it { is_expected.to validate_presence_of(:project) } it { is_expected.to validate_presence_of(:name) } |