diff options
author | Robert Speicher <rspeicher@gmail.com> | 2015-06-17 16:12:28 -0400 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2015-06-17 16:59:51 -0400 |
commit | bc027c51836dd601025c0a48974ef921229821b8 (patch) | |
tree | 75a60ae4852e0b44ef5a5d36281ede9e7f587fc0 /spec | |
parent | ce20400628ca6583f132d3f370ed25dacaed0b17 (diff) | |
download | gitlab-ce-bc027c51836dd601025c0a48974ef921229821b8.tar.gz |
Load the Merge Request > Commits tab lazily
Diffstat (limited to 'spec')
-rw-r--r-- | spec/controllers/projects/merge_requests_controller_spec.rb | 79 |
1 files changed, 64 insertions, 15 deletions
diff --git a/spec/controllers/projects/merge_requests_controller_spec.rb b/spec/controllers/projects/merge_requests_controller_spec.rb index c94ef1629ae..5cc5bd78cd7 100644 --- a/spec/controllers/projects/merge_requests_controller_spec.rb +++ b/spec/controllers/projects/merge_requests_controller_spec.rb @@ -79,23 +79,72 @@ describe Projects::MergeRequestsController do end end - context '#diffs 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) } - - before do - fork_project.build_forked_project_link(forked_to_project_id: fork_project.id, forked_from_project_id: project.id) - fork_project.save - merge_request.reload + 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 - it '#diffs' do - get(:diffs, namespace_id: project.namespace.to_param, - project_id: project.to_param, id: merge_request.iid, format: 'json') - expect(response).to be_success - expect(response.body).to have_content('Subproject commit') + 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) } + + before do + fork_project.build_forked_project_link(forked_to_project_id: fork_project.id, forked_from_project_id: project.id) + fork_project.save + merge_request.reload + end + + 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 |