Commit 82aadc77 authored by Grzegorz Bizon's avatar Grzegorz Bizon

Merge branch 'id-call-lfs-once-when-vue-file-list-enabled' into 'master'

Execute Gitaly LFS call once when Vue file enabled

Closes #36864

See merge request gitlab-org/gitlab!22168
parents d5ace2b9 b1505c50
...@@ -28,7 +28,8 @@ class Projects::TreeController < Projects::ApplicationController ...@@ -28,7 +28,8 @@ class Projects::TreeController < Projects::ApplicationController
respond_to do |format| respond_to do |format|
format.html do format.html do
lfs_blob_ids lfs_blob_ids if Feature.disabled?(:vue_file_list, @project)
@last_commit = @repository.last_commit_for_path(@commit.id, @tree.path) || @commit @last_commit = @repository.last_commit_for_path(@commit.id, @tree.path) || @commit
end end
end end
......
...@@ -21,8 +21,7 @@ class ProjectsController < Projects::ApplicationController ...@@ -21,8 +21,7 @@ class ProjectsController < Projects::ApplicationController
before_action :assign_ref_vars, if: -> { action_name == 'show' && repo_exists? } before_action :assign_ref_vars, if: -> { action_name == 'show' && repo_exists? }
before_action :tree, before_action :tree,
if: -> { action_name == 'show' && repo_exists? && project_view_files? } if: -> { action_name == 'show' && repo_exists? && project_view_files? }
before_action :lfs_blob_ids, before_action :lfs_blob_ids, if: :show_blob_ids?, only: :show
if: -> { action_name == 'show' && repo_exists? && project_view_files? }
before_action :project_export_enabled, only: [:export, :download_export, :remove_export, :generate_new_export] before_action :project_export_enabled, only: [:export, :download_export, :remove_export, :generate_new_export]
before_action :present_project, only: [:edit] before_action :present_project, only: [:edit]
before_action :authorize_download_code!, only: [:refs] before_action :authorize_download_code!, only: [:refs]
...@@ -296,6 +295,10 @@ class ProjectsController < Projects::ApplicationController ...@@ -296,6 +295,10 @@ class ProjectsController < Projects::ApplicationController
private private
def show_blob_ids?
repo_exists? && project_view_files? && Feature.disabled?(:vue_file_list, @project)
end
# Render project landing depending of which features are available # Render project landing depending of which features are available
# So if page is not available in the list it renders the next page # So if page is not available in the list it renders the next page
# #
......
---
title: Execute Gitaly LFS call once when Vue file enabled
merge_request: 22168
author:
type: performance
...@@ -89,6 +89,34 @@ describe Projects::TreeController do ...@@ -89,6 +89,34 @@ describe Projects::TreeController do
end end
end end
describe "GET show" do
context 'lfs_blob_ids instance variable' do
let(:id) { 'master' }
context 'with vue tree view enabled' do
before do
get(:show, params: { namespace_id: project.namespace.to_param, project_id: project, id: id })
end
it 'is not set' do
expect(assigns[:lfs_blob_ids]).to be_nil
end
end
context 'with vue tree view disabled' do
before do
stub_feature_flags(vue_file_list: false)
get(:show, params: { namespace_id: project.namespace.to_param, project_id: project, id: id })
end
it 'is set' do
expect(assigns[:lfs_blob_ids]).not_to be_nil
end
end
end
end
describe 'GET show with whitespace in ref' do describe 'GET show with whitespace in ref' do
render_views render_views
......
...@@ -289,6 +289,36 @@ describe ProjectsController do ...@@ -289,6 +289,36 @@ describe ProjectsController do
.not_to exceed_query_limit(2).for_query(expected_query) .not_to exceed_query_limit(2).for_query(expected_query)
end end
end end
context 'lfs_blob_ids instance variable' do
let(:project) { create(:project, :public, :repository) }
before do
sign_in(user)
end
context 'with vue tree view enabled' do
before do
get :show, params: { namespace_id: project.namespace, id: project }
end
it 'is not set' do
expect(assigns[:lfs_blob_ids]).to be_nil
end
end
context 'with vue tree view disabled' do
before do
stub_feature_flags(vue_file_list: false)
get :show, params: { namespace_id: project.namespace, id: project }
end
it 'is set' do
expect(assigns[:lfs_blob_ids]).not_to be_nil
end
end
end
end end
describe 'GET edit' do describe 'GET edit' do
......
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