Commit fbdd75a4 authored by Igor's avatar Igor Committed by Dmitriy Zaporozhets

Do not make extra signatures request for Vue tree view

When Vue tree view is enabled, the signatures are fetched
via GraphQL API
parent 24c079de
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
= render partial: 'flash_messages', locals: { project: @project } = 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) - signatures_path = project_signatures_path(@project, @project.default_branch)
.js-signature-container{ data: { 'signatures-path': signatures_path } } .js-signature-container{ data: { 'signatures-path': signatures_path } }
......
...@@ -6,7 +6,8 @@ ...@@ -6,7 +6,8 @@
= content_for :meta_tags do = content_for :meta_tags do
= auto_discovery_link_tag(:atom, project_commits_url(@project, @ref, rss_url_options), title: "#{@project.name}:#{@ref} commits") = 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/last_push'
= render 'projects/files', commit: @last_commit, project: @project, ref: @ref, content_url: project_tree_path(@project, @id) = 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 ...@@ -152,4 +152,34 @@ describe 'GPG signed commits' do
end end
end 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 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 ...@@ -7,6 +7,10 @@ describe 'projects/tree/show' do
let(:project) { create(:project, :repository) } let(:project) { create(:project, :repository) }
let(:repository) { 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 before do
stub_feature_flags(vue_file_list: false) stub_feature_flags(vue_file_list: false)
...@@ -19,26 +23,45 @@ describe 'projects/tree/show' do ...@@ -19,26 +23,45 @@ describe 'projects/tree/show' do
allow(view).to receive(:can_collaborate_with_project?).and_return(true) 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_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) allow(view).to receive(:current_application_settings).and_return(Gitlab::CurrentSettings.current_application_settings)
allow(view).to receive(:current_user).and_return(project.creator)
assign(:id, File.join(ref, path))
assign(:ref, ref)
assign(:path, path)
assign(:last_commit, commit)
assign(:tree, tree)
end end
context 'for branch names ending on .json' do context 'for branch names ending on .json' do
let(:ref) { 'ends-with.json' } 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)
assign(:last_commit, commit)
assign(:tree, tree)
end
it 'displays correctly' do it 'displays correctly' do
render render
expect(rendered).to have_css('.js-project-refs-dropdown .dropdown-toggle-text', text: ref) expect(rendered).to have_css('.js-project-refs-dropdown .dropdown-toggle-text', text: ref)
expect(rendered).to have_css('.readme-holder') expect(rendered).to have_css('.readme-holder')
end end
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 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