Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/features/snippets/show_spec.rb')
-rw-r--r--spec/features/snippets/show_spec.rb66
1 files changed, 40 insertions, 26 deletions
diff --git a/spec/features/snippets/show_spec.rb b/spec/features/snippets/show_spec.rb
index bbb120edb80..03f46ea0122 100644
--- a/spec/features/snippets/show_spec.rb
+++ b/spec/features/snippets/show_spec.rb
@@ -3,49 +3,63 @@
require 'spec_helper'
RSpec.describe 'Snippet', :js, feature_category: :source_code_management do
- let_it_be(:user) { create(:user, :no_super_sidebar) }
- let_it_be(:snippet) { create(:personal_snippet, :public, :repository, author: user) }
+ let_it_be(:owner) { create(:user) }
+ let_it_be(:snippet) { create(:personal_snippet, :public, :repository, author: owner) }
+ let(:anchor) { nil }
+ let(:file_path) { 'files/ruby/popen.rb' }
before do
- stub_feature_flags(super_sidebar_logged_out: false)
+ # rubocop: disable RSpec/AnyInstanceOf -- TODO: The usage of let_it_be forces us
+ allow_any_instance_of(Snippet).to receive(:blobs)
+ .and_return([snippet.repository.blob_at('master', file_path)])
+ # rubocop: enable RSpec/AnyInstanceOf
end
- it_behaves_like 'show and render proper snippet blob' do
- let(:anchor) { nil }
-
- subject do
- visit snippet_path(snippet, anchor: anchor)
+ def visit_page
+ visit snippet_path(snippet, anchor: anchor)
+ end
- wait_for_requests
+ context 'when signed in' do
+ before do
+ sign_in(user)
+ visit_page
end
- end
- # it_behaves_like 'showing user status' do
- # This will be handled in https://gitlab.com/gitlab-org/gitlab/-/issues/262394
+ context 'as the snippet owner' do
+ let(:user) { owner }
- it_behaves_like 'does not show New Snippet button' do
- let(:file_path) { 'files/ruby/popen.rb' }
+ it_behaves_like 'show and render proper snippet blob'
+ it_behaves_like 'does show New Snippet button'
+ it_behaves_like 'a "Your work" page with sidebar and breadcrumbs', :dashboard_snippets_path, :snippets
+ end
- subject { visit snippet_path(snippet) }
- end
+ context 'as external user' do
+ let_it_be(:user) { create(:user, :external) }
- it_behaves_like 'a "Your work" page with sidebar and breadcrumbs', :dashboard_snippets_path, :snippets
+ it_behaves_like 'show and render proper snippet blob'
+ it_behaves_like 'does not show New Snippet button'
+ it_behaves_like 'a "Your work" page with sidebar and breadcrumbs', :dashboard_snippets_path, :snippets
+ end
- context 'when unauthenticated' do
- it 'shows the "Explore" sidebar' do
- visit snippet_path(snippet)
+ context 'as another user' do
+ let_it_be(:user) { create(:user) }
- expect(page).to have_css('aside.nav-sidebar[aria-label="Explore"]')
+ it_behaves_like 'show and render proper snippet blob'
+ it_behaves_like 'does show New Snippet button'
+ it_behaves_like 'a "Your work" page with sidebar and breadcrumbs', :dashboard_snippets_path, :snippets
end
end
- context 'when authenticated as a different user' do
- let_it_be(:different_user) { create(:user, :no_super_sidebar) }
-
+ context 'when unauthenticated' do
before do
- sign_in(different_user)
+ visit_page
end
- it_behaves_like 'a "Your work" page with sidebar and breadcrumbs', :dashboard_snippets_path, :snippets
+ it_behaves_like 'show and render proper snippet blob'
+ it_behaves_like 'does not show New Snippet button'
+
+ it 'shows the "Explore" sidebar' do
+ expect(page).to have_css('#super-sidebar-context-header', text: 'Explore')
+ end
end
end