diff options
Diffstat (limited to 'spec/models/project_snippet_spec.rb')
-rw-r--r-- | spec/models/project_snippet_spec.rb | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/spec/models/project_snippet_spec.rb b/spec/models/project_snippet_spec.rb index 3d1c87771f3..5ce9499c420 100644 --- a/spec/models/project_snippet_spec.rb +++ b/spec/models/project_snippet_spec.rb @@ -2,11 +2,24 @@ require 'spec_helper' -RSpec.describe ProjectSnippet do +RSpec.describe ProjectSnippet, feature_category: :source_code_management do describe "Associations" do it { is_expected.to belong_to(:project) } end + describe 'scopes' do + describe '.by_project' do + subject { described_class.by_project(project) } + + let_it_be(:project) { create(:project) } + let_it_be(:snippet1) { create(:project_snippet, project: project) } + let_it_be(:snippet2) { create(:project_snippet, project: build(:project)) } + let_it_be(:snippet3) { create(:personal_snippet) } + + it { is_expected.to contain_exactly(snippet1) } + end + end + describe "Validation" do it { is_expected.to validate_presence_of(:project) } it { is_expected.to validate_inclusion_of(:secret).in_array([false]) } |