2019-11-08 04:06:07 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-24 14:09:03 -04:00
|
|
|
RSpec.describe PersonalSnippet do
|
2019-11-08 04:06:07 -05:00
|
|
|
describe '#embeddable?' do
|
|
|
|
[
|
|
|
|
{ snippet: :public, embeddable: true },
|
|
|
|
{ snippet: :internal, embeddable: false },
|
|
|
|
{ snippet: :private, embeddable: false }
|
|
|
|
].each do |combination|
|
|
|
|
it 'returns true when snippet is public' do
|
|
|
|
snippet = build(:personal_snippet, combination[:snippet])
|
|
|
|
|
|
|
|
expect(snippet.embeddable?).to eq(combination[:embeddable])
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2020-02-13 10:08:52 -05:00
|
|
|
|
|
|
|
it_behaves_like 'model with repository' do
|
|
|
|
let_it_be(:container) { create(:personal_snippet, :repository) }
|
|
|
|
let(:stubbed_container) { build_stubbed(:personal_snippet) }
|
2020-10-27 14:08:59 -04:00
|
|
|
let(:expected_full_path) { "snippets/#{container.id}" }
|
2020-07-23 11:09:28 -04:00
|
|
|
let(:expected_web_url_path) { "-/snippets/#{container.id}" }
|
2020-02-13 10:08:52 -05:00
|
|
|
end
|
2020-08-14 11:10:05 -04:00
|
|
|
|
|
|
|
describe '#parent_user' do
|
|
|
|
it 'returns the snippet author' do
|
|
|
|
snippet = build(:personal_snippet)
|
|
|
|
|
|
|
|
expect(snippet.parent_user).to eq(snippet.author)
|
|
|
|
end
|
|
|
|
end
|
2019-11-08 04:06:07 -05:00
|
|
|
end
|