Commit 115fb465 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'id-avoid-loading-signatures-for-vue-file-list' into 'master'

Do not make extra signatures request for Vue tree view

See merge request gitlab-org/gitlab!18577
parents 24c079de fbdd75a4
......@@ -6,7 +6,7 @@
= render partial: 'flash_messages', locals: { project: @project }
- if !@project.empty_repo? && can?(current_user, :download_code, @project)
- if !@project.empty_repo? && can?(current_user, :download_code, @project) && !vue_file_list_enabled?
- signatures_path = project_signatures_path(@project, @project.default_branch)
.js-signature-container{ data: { 'signatures-path': signatures_path } }
......
......@@ -6,7 +6,8 @@
= content_for :meta_tags do
= auto_discovery_link_tag(:atom, project_commits_url(@project, @ref, rss_url_options), title: "#{@project.name}:#{@ref} commits")
.js-signature-container{ data: { 'signatures-path': signatures_path } }
- unless vue_file_list_enabled?
.js-signature-container{ data: { 'signatures-path': signatures_path } }
= render 'projects/last_push'
= render 'projects/files', commit: @last_commit, project: @project, ref: @ref, content_url: project_tree_path(@project, @id)
......@@ -152,4 +152,34 @@ describe 'GPG signed commits' do
end
end
end
context 'view signed commit on the tree view', :js do
shared_examples 'a commit with a signature' do
before do
visit project_tree_path(project, 'signed-commits')
end
it 'displays commit signature' do
expect(page).to have_button 'Unverified'
click_on 'Unverified'
within '.popover' do
expect(page).to have_content 'This commit was signed with an unverified signature'
end
end
end
context 'with vue tree view enabled' do
it_behaves_like 'a commit with a signature'
end
context 'with vue tree view disabled' do
before do
stub_feature_flags(vue_file_list: false)
end
it_behaves_like 'a commit with a signature'
end
end
end
# frozen_string_literal: true
require 'spec_helper'
describe 'projects/show' do
include Devise::Test::ControllerHelpers
let(:user) { create(:admin) }
let(:project) { create(:project, :repository) }
before do
presented_project = project.present(current_user: user)
allow(presented_project).to receive(:default_view).and_return('customize_workflow')
allow(controller).to receive(:current_user).and_return(user)
assign(:project, presented_project)
end
context 'commit signatures' do
context 'with vue tree view disabled' do
before do
stub_feature_flags(vue_file_list: false)
end
it 'rendered via js-signature-container' do
render
expect(rendered).to have_css('.js-signature-container')
end
end
context 'with vue tree view enabled' do
it 'are not rendered via js-signature-container' do
render
expect(rendered).not_to have_css('.js-signature-container')
end
end
end
end
......@@ -7,6 +7,10 @@ describe 'projects/tree/show' do
let(:project) { create(:project, :repository) }
let(:repository) { project.repository }
let(:ref) { 'master' }
let(:commit) { repository.commit(ref) }
let(:path) { '' }
let(:tree) { repository.tree(commit.id, path) }
before do
stub_feature_flags(vue_file_list: false)
......@@ -19,15 +23,8 @@ describe 'projects/tree/show' do
allow(view).to receive(:can_collaborate_with_project?).and_return(true)
allow(view).to receive_message_chain('user_access.can_push_to_branch?').and_return(true)
allow(view).to receive(:current_application_settings).and_return(Gitlab::CurrentSettings.current_application_settings)
end
allow(view).to receive(:current_user).and_return(project.creator)
context 'for branch names ending on .json' do
let(:ref) { 'ends-with.json' }
let(:commit) { repository.commit(ref) }
let(:path) { '' }
let(:tree) { repository.tree(commit.id, path) }
before do
assign(:id, File.join(ref, path))
assign(:ref, ref)
assign(:path, path)
......@@ -35,10 +32,36 @@ describe 'projects/tree/show' do
assign(:tree, tree)
end
context 'for branch names ending on .json' do
let(:ref) { 'ends-with.json' }
it 'displays correctly' do
render
expect(rendered).to have_css('.js-project-refs-dropdown .dropdown-toggle-text', text: ref)
expect(rendered).to have_css('.readme-holder')
end
end
context 'commit signatures' do
context 'with vue tree view disabled' do
it 'rendered via js-signature-container' do
render
expect(rendered).to have_css('.js-signature-container')
end
end
context 'with vue tree view enabled' do
before do
stub_feature_flags(vue_file_list: true)
end
it 'are not rendered via js-signature-container' do
render
expect(rendered).not_to have_css('.js-signature-container')
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment