diff options
author | Walmyr Filho <wlsf82@gmail.com> | 2019-01-02 12:33:46 +0100 |
---|---|---|
committer | Walmyr Filho <wlsf82@gmail.com> | 2019-01-02 12:33:46 +0100 |
commit | 00e07e418804e7b69e1b32b74834e6aa0aa21c24 (patch) | |
tree | 9ce72e76ece7bfe5c7c5153fda834a9bc1b0b292 /spec/models/snippet_spec.rb | |
parent | de008c132f6228793e8a9a8431dce65009075134 (diff) | |
parent | 191f461b88ba80069c2b23229cc0e26253d4fcc7 (diff) | |
download | gitlab-ce-wlsf82-branches-crud-test.tar.gz |
Merge remote-tracking branch 'upstream/master'wlsf82-branches-crud-test
Diffstat (limited to 'spec/models/snippet_spec.rb')
-rw-r--r-- | spec/models/snippet_spec.rb | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/spec/models/snippet_spec.rb b/spec/models/snippet_spec.rb index 7a7272ccb60..664dc3fa145 100644 --- a/spec/models/snippet_spec.rb +++ b/spec/models/snippet_spec.rb @@ -423,4 +423,41 @@ describe Snippet do expect(blob.data).to eq(snippet.content) end end + + describe '#embeddable?' do + context 'project snippet' 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 = create(:project_snippet, combination[:snippet], project: project) + + expect(snippet.embeddable?).to eq(combination[:embeddable]) + end + end + end + + context 'personal snippet' do + [ + { snippet: :public, embeddable: true }, + { snippet: :internal, embeddable: false }, + { snippet: :private, embeddable: false } + ].each do |combination| + it 'only returns true when snippet is public' do + snippet = create(:personal_snippet, combination[:snippet]) + + expect(snippet.embeddable?).to eq(combination[:embeddable]) + end + end + end + end end |