diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-11-08 12:06:07 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-11-08 12:06:07 +0300 |
commit | d23b2a0871f3ca507aafa949e0314625f1f0c6a7 (patch) | |
tree | b1e26c7460bdae25f19103e14978a3aaeef52037 /spec/models/project_snippet_spec.rb | |
parent | 1ef4b65f55f4fc6524a47050b4f6d686beb81d3a (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/models/project_snippet_spec.rb')
-rw-r--r-- | spec/models/project_snippet_spec.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/spec/models/project_snippet_spec.rb b/spec/models/project_snippet_spec.rb index e87b4f41f4d..46025507cb5 100644 --- a/spec/models/project_snippet_spec.rb +++ b/spec/models/project_snippet_spec.rb @@ -10,4 +10,25 @@ describe ProjectSnippet do describe "Validation" do it { is_expected.to validate_presence_of(:project) } end + + describe '#embeddable?' do + [ + { project: :public, snippet: :public, embeddable: true }, + { project: :internal, snippet: :public, embeddable: false }, + { project: :private, snippet: :public, embeddable: false }, + { project: :public, snippet: :internal, embeddable: false }, + { project: :internal, snippet: :internal, embeddable: false }, + { project: :private, snippet: :internal, embeddable: false }, + { project: :public, snippet: :private, embeddable: false }, + { project: :internal, snippet: :private, embeddable: false }, + { project: :private, snippet: :private, embeddable: false } + ].each do |combination| + it 'only returns true when both project and snippet are public' do + project = create(:project, combination[:project]) + snippet = build(:project_snippet, combination[:snippet], project: project) + + expect(snippet.embeddable?).to eq(combination[:embeddable]) + end + end + end end |