diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-06-07 21:09:51 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-06-07 21:09:51 +0300 |
commit | 9ee2305f46a2b3d1d1e8a1f1182512599a74dbe1 (patch) | |
tree | 82c0631433839156f7d2fa88a5026c385b2b5703 /spec/models | |
parent | 9498dc957345829f29fe0bc4e55c969783b457be (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/models')
-rw-r--r-- | spec/models/packages/helm/file_metadatum_spec.rb | 8 | ||||
-rw-r--r-- | spec/models/packages/npm/metadatum_spec.rb | 2 | ||||
-rw-r--r-- | spec/models/snippet_spec.rb | 28 |
3 files changed, 33 insertions, 5 deletions
diff --git a/spec/models/packages/helm/file_metadatum_spec.rb b/spec/models/packages/helm/file_metadatum_spec.rb index 995179b391d..516b3fad940 100644 --- a/spec/models/packages/helm/file_metadatum_spec.rb +++ b/spec/models/packages/helm/file_metadatum_spec.rb @@ -49,11 +49,11 @@ RSpec.describe Packages::Helm::FileMetadatum, type: :model do describe '#metadata' do it 'validates #metadata', :aggregate_failures do is_expected.not_to validate_presence_of(:metadata) - is_expected.to allow_value({ 'name': 'foo', 'version': 'v1.0', 'apiVersion': 'v2' }).for(:metadata) + is_expected.to allow_value({ name: 'foo', version: 'v1.0', apiVersion: 'v2' }).for(:metadata) is_expected.not_to allow_value({}).for(:metadata) - is_expected.not_to allow_value({ 'version': 'v1.0', 'apiVersion': 'v2' }).for(:metadata) - is_expected.not_to allow_value({ 'name': 'foo', 'apiVersion': 'v2' }).for(:metadata) - is_expected.not_to allow_value({ 'name': 'foo', 'version': 'v1.0' }).for(:metadata) + is_expected.not_to allow_value({ version: 'v1.0', apiVersion: 'v2' }).for(:metadata) + is_expected.not_to allow_value({ name: 'foo', apiVersion: 'v2' }).for(:metadata) + is_expected.not_to allow_value({ name: 'foo', version: 'v1.0' }).for(:metadata) end end end diff --git a/spec/models/packages/npm/metadatum_spec.rb b/spec/models/packages/npm/metadatum_spec.rb index 92daddded7e..418194bffdd 100644 --- a/spec/models/packages/npm/metadatum_spec.rb +++ b/spec/models/packages/npm/metadatum_spec.rb @@ -25,7 +25,7 @@ RSpec.describe Packages::Npm::Metadatum, type: :model, feature_category: :packag let(:valid_json) { { 'name' => 'foo', 'version' => 'v1.0', 'dist' => { 'tarball' => 'x', 'shasum' => 'x' } } } it { is_expected.to allow_value(valid_json).for(:package_json) } - it { is_expected.to allow_value(valid_json.merge('extra-field': { 'foo': 'bar' })).for(:package_json) } + it { is_expected.to allow_value(valid_json.merge('extra-field': { foo: 'bar' })).for(:package_json) } it { is_expected.to allow_value(with_dist { |dist| dist.merge('extra-field': 'x') }).for(:package_json) } %w[name version dist].each do |field| diff --git a/spec/models/snippet_spec.rb b/spec/models/snippet_spec.rb index a808c12a39a..4c6f1476481 100644 --- a/spec/models/snippet_spec.rb +++ b/spec/models/snippet_spec.rb @@ -805,6 +805,34 @@ RSpec.describe Snippet do include_examples 'size checker for snippet' end + describe '#hook_attrs' do + let_it_be(:snippet) { create(:personal_snippet, secret_token: 'foo') } + + subject(:attrs) { snippet.hook_attrs } + + it 'includes the expected attributes' do + is_expected.to match( + 'id' => snippet.id, + 'title' => snippet.title, + 'content' => snippet.content, + 'description' => snippet.description, + 'file_name' => snippet.file_name, + 'author_id' => snippet.author_id, + 'project_id' => snippet.project_id, + 'visibility_level' => snippet.visibility_level, + 'encrypted_secret_token' => snippet.encrypted_secret_token, + 'encrypted_secret_token_iv' => snippet.encrypted_secret_token_iv, + 'secret' => false, + 'secret_token' => nil, + 'repository_read_only' => snippet.repository_read_only?, + 'url' => Gitlab::UrlBuilder.build(snippet), + 'type' => 'PersonalSnippet', + 'created_at' => be_like_time(snippet.created_at), + 'updated_at' => be_like_time(snippet.updated_at) + ) + end + end + describe '#can_cache_field?' do using RSpec::Parameterized::TableSyntax |