debian-mirror-gitlab/spec/features/snippets/explore_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

65 lines
1.8 KiB
Ruby
Raw Normal View History

2019-10-12 21:52:04 +05:30
# frozen_string_literal: true
2019-12-04 20:38:33 +05:30
require 'spec_helper'
2017-08-17 22:00:37 +05:30
2023-03-04 22:38:38 +05:30
RSpec.describe 'Explore Snippets', feature_category: :source_code_management do
2017-08-17 22:00:37 +05:30
let!(:public_snippet) { create(:personal_snippet, :public) }
let!(:internal_snippet) { create(:personal_snippet, :internal) }
let!(:private_snippet) { create(:personal_snippet, :private) }
2020-01-01 13:55:28 +05:30
let(:user) { nil }
2017-08-17 22:00:37 +05:30
2020-01-01 13:55:28 +05:30
before do
sign_in(user) if user
2017-08-17 22:00:37 +05:30
visit explore_snippets_path
end
2020-01-01 13:55:28 +05:30
context 'User' do
let(:user) { create(:user) }
it 'see snippets that are not private' do
expect(page).to have_content(public_snippet.title)
expect(page).to have_content(internal_snippet.title)
expect(page).not_to have_content(private_snippet.title)
end
2017-08-17 22:00:37 +05:30
2020-01-01 13:55:28 +05:30
it 'shows new snippet button in header' do
parent_element = page.find('.page-title-controls')
expect(parent_element).to have_link('New snippet')
end
2017-08-17 22:00:37 +05:30
end
2020-01-01 13:55:28 +05:30
context 'External user' do
let(:user) { create(:user, :external) }
it 'see only public snippets' do
expect(page).to have_content(public_snippet.title)
expect(page).not_to have_content(internal_snippet.title)
expect(page).not_to have_content(private_snippet.title)
end
context 'without snippets' do
before do
Snippet.delete_all
end
it 'hides new snippet button' do
expect(page).not_to have_link('New snippet')
end
end
context 'with snippets' do
it 'hides new snippet button' do
expect(page).not_to have_link('New snippet')
end
end
end
2017-08-17 22:00:37 +05:30
2020-01-01 13:55:28 +05:30
context 'Not authenticated user' do
it 'see only public snippets' do
expect(page).to have_content(public_snippet.title)
expect(page).not_to have_content(internal_snippet.title)
expect(page).not_to have_content(private_snippet.title)
end
2017-08-17 22:00:37 +05:30
end
end