Load the Merge Request > Commits tab lazily
This commit is contained in:
parent
ce20400628
commit
bc027c5183
|
@ -71,7 +71,10 @@ class Projects::MergeRequestsController < Projects::ApplicationController
|
|||
end
|
||||
|
||||
def commits
|
||||
render 'show'
|
||||
respond_to do |format|
|
||||
format.html { render 'show' }
|
||||
format.json { render json: { html: view_to_html_string('projects/merge_requests/show/_commits') } }
|
||||
end
|
||||
end
|
||||
|
||||
def new
|
||||
|
|
|
@ -56,6 +56,7 @@
|
|||
#notes.notes.tab-pane.voting_notes
|
||||
= render "projects/merge_requests/discussion"
|
||||
#commits.commits.tab-pane
|
||||
- if current_page?(action: 'commits')
|
||||
= render "projects/merge_requests/show/commits"
|
||||
#diffs.diffs.tab-pane
|
||||
- if current_page?(action: 'diffs')
|
||||
|
@ -64,7 +65,6 @@
|
|||
.mr-loading-status
|
||||
= spinner
|
||||
|
||||
|
||||
:javascript
|
||||
var merge_request;
|
||||
|
||||
|
|
|
@ -79,8 +79,32 @@ describe Projects::MergeRequestsController do
|
|||
end
|
||||
end
|
||||
|
||||
context '#diffs with forked projects with submodules' do
|
||||
describe 'GET diffs' do
|
||||
def go(format: 'html')
|
||||
get :diffs, namespace_id: project.namespace.to_param,
|
||||
project_id: project.to_param, id: merge_request.iid, format: format
|
||||
end
|
||||
|
||||
context 'as html' do
|
||||
it 'renders the diff template' do
|
||||
go
|
||||
|
||||
expect(response).to render_template('diffs')
|
||||
end
|
||||
end
|
||||
|
||||
context 'as json' do
|
||||
it 'renders the diffs template to a string' do
|
||||
go format: 'json'
|
||||
|
||||
expect(response).to render_template('projects/merge_requests/show/_diffs')
|
||||
expect(JSON.parse(response.body)).to have_key('html')
|
||||
end
|
||||
end
|
||||
|
||||
context 'with forked projects with submodules' do
|
||||
render_views
|
||||
|
||||
let(:project) { create(:project) }
|
||||
let(:fork_project) { create(:forked_project_with_submodules) }
|
||||
let(:merge_request) { create(:merge_request_with_diffs, source_project: fork_project, source_branch: 'add-submodule-version-bump', target_branch: 'master', target_project: project) }
|
||||
|
@ -91,11 +115,36 @@ describe Projects::MergeRequestsController do
|
|||
merge_request.reload
|
||||
end
|
||||
|
||||
it '#diffs' do
|
||||
get(:diffs, namespace_id: project.namespace.to_param,
|
||||
project_id: project.to_param, id: merge_request.iid, format: 'json')
|
||||
it 'renders' do
|
||||
go format: 'json'
|
||||
|
||||
expect(response).to be_success
|
||||
expect(response.body).to have_content('Subproject commit')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'GET commits' do
|
||||
def go(format: 'html')
|
||||
get :commits, namespace_id: project.namespace.to_param,
|
||||
project_id: project.to_param, id: merge_request.iid, format: format
|
||||
end
|
||||
|
||||
context 'as html' do
|
||||
it 'renders the show template' do
|
||||
go
|
||||
|
||||
expect(response).to render_template('show')
|
||||
end
|
||||
end
|
||||
|
||||
context 'as json' do
|
||||
it 'renders the commits template to a string' do
|
||||
go format: 'json'
|
||||
|
||||
expect(response).to render_template('projects/merge_requests/show/_commits')
|
||||
expect(JSON.parse(response.body)).to have_key('html')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue