diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-05-20 14:34:42 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-05-20 14:34:42 +0000 |
commit | 9f46488805e86b1bc341ea1620b866016c2ce5ed (patch) | |
tree | f9748c7e287041e37d6da49e0a29c9511dc34768 /spec/models/snippet_spec.rb | |
parent | dfc92d081ea0332d69c8aca2f0e745cb48ae5e6d (diff) | |
download | gitlab-ce-9f46488805e86b1bc341ea1620b866016c2ce5ed.tar.gz |
Add latest changes from gitlab-org/gitlab@13-0-stable-ee
Diffstat (limited to 'spec/models/snippet_spec.rb')
-rw-r--r-- | spec/models/snippet_spec.rb | 54 |
1 files changed, 21 insertions, 33 deletions
diff --git a/spec/models/snippet_spec.rb b/spec/models/snippet_spec.rb index 2061084d5ea..4d6586c1df4 100644 --- a/spec/models/snippet_spec.rb +++ b/spec/models/snippet_spec.rb @@ -180,22 +180,6 @@ describe Snippet do end end - describe '.search_code' do - let(:snippet) { create(:snippet, content: 'class Foo; end') } - - it 'returns snippets with matching content' do - expect(described_class.search_code(snippet.content)).to eq([snippet]) - end - - it 'returns snippets with partially matching content' do - expect(described_class.search_code('class')).to eq([snippet]) - end - - it 'returns snippets with matching content regardless of the casing' do - expect(described_class.search_code('FOO')).to eq([snippet]) - end - end - describe 'when default snippet visibility set to internal' do using RSpec::Parameterized::TableSyntax @@ -545,11 +529,11 @@ describe Snippet do let(:snippet) { build(:snippet) } it 'excludes secret_token from generated json' do - expect(JSON.parse(to_json).keys).not_to include("secret_token") + expect(Gitlab::Json.parse(to_json).keys).not_to include("secret_token") end it 'does not override existing exclude option value' do - expect(JSON.parse(to_json(except: [:id])).keys).not_to include("secret_token", "id") + expect(Gitlab::Json.parse(to_json(except: [:id])).keys).not_to include("secret_token", "id") end def to_json(params = {}) @@ -735,31 +719,35 @@ describe Snippet do end end - describe '#versioned_enabled_for?' do - let_it_be(:user) { create(:user) } + describe '#url_to_repo' do + subject { snippet.url_to_repo } + + context 'with personal snippet' do + let(:snippet) { create(:personal_snippet) } - subject { snippet.versioned_enabled_for?(user) } + it { is_expected.to eq(Gitlab.config.gitlab_shell.ssh_path_prefix + "snippets/#{snippet.id}.git") } + end - context 'with repository and version_snippets enabled' do - let!(:snippet) { create(:personal_snippet, :repository, author: user) } + context 'with project snippet' do + let(:snippet) { create(:project_snippet) } - it { is_expected.to be_truthy } + it { is_expected.to eq(Gitlab.config.gitlab_shell.ssh_path_prefix + "#{snippet.project.full_path}/snippets/#{snippet.id}.git") } end + end - context 'without repository' do - let!(:snippet) { create(:personal_snippet, author: user) } + describe '.max_file_limit' do + subject { described_class.max_file_limit(nil) } - it { is_expected.to be_falsy } + it "returns #{Snippet::MAX_FILE_COUNT}" do + expect(subject).to eq Snippet::MAX_FILE_COUNT end - context 'without version_snippets feature disabled' do - let!(:snippet) { create(:personal_snippet, :repository, author: user) } + context 'when feature flag :snippet_multiple_files is disabled' do + it "returns #{described_class::MAX_SINGLE_FILE_COUNT}" do + stub_feature_flags(snippet_multiple_files: false) - before do - stub_feature_flags(version_snippets: false) + expect(subject).to eq described_class::MAX_SINGLE_FILE_COUNT end - - it { is_expected.to be_falsy } end end end |