BigW Consortium Gitlab

Commit 32b1ceb0 by Fatih Acet

Merge branch '26155-merge-request-tabs-don-t-render-when-no-commits-available' into 'master'

Resolve "Merge request tabs don't render when no commits available" Closes #26155 and #24556 See merge request !8347
parents 4a1a06f4 6e7e5052
...@@ -221,7 +221,7 @@ class MergeRequest < ActiveRecord::Base ...@@ -221,7 +221,7 @@ class MergeRequest < ActiveRecord::Base
# true base commit, so we can't simply have `#diff_base_commit` fall back on # true base commit, so we can't simply have `#diff_base_commit` fall back on
# this method. # this method.
def likely_diff_base_commit def likely_diff_base_commit
first_commit.parent || first_commit first_commit.try(:parent) || first_commit
end end
def diff_start_commit def diff_start_commit
......
...@@ -50,7 +50,6 @@ ...@@ -50,7 +50,6 @@
.content-block.content-block-small .content-block.content-block-small
= render 'award_emoji/awards_block', awardable: @merge_request, inline: true = render 'award_emoji/awards_block', awardable: @merge_request, inline: true
- if @commits_count.nonzero?
.merge-request-tabs-holder{ class: ("js-tabs-affix" unless ENV['RAILS_ENV'] == 'test') } .merge-request-tabs-holder{ class: ("js-tabs-affix" unless ENV['RAILS_ENV'] == 'test') }
%div{ class: container_class } %div{ class: container_class }
%ul.merge-request-tabs.nav-links.no-top.no-bottom %ul.merge-request-tabs.nav-links.no-top.no-bottom
......
%ol#commits-list.list-unstyled - if @commits.empty?
.commits-empty
%h4
There are no commits yet.
= custom_icon ('illustration_no_commits')
- else
%ol#commits-list.list-unstyled
= render "projects/commits/commits", project: @merge_request.source_project, ref: @merge_request.source_branch = render "projects/commits/commits", project: @merge_request.source_project, ref: @merge_request.source_branch
...@@ -23,4 +23,4 @@ ...@@ -23,4 +23,4 @@
to post a comment to post a comment
:javascript :javascript
var notes = new Notes("#{namespace_project_notes_path(namespace_id: @project.namespace, target_id: @noteable.id, target_type: @noteable.class.name.underscore)}", #{@notes.map(&:id).to_json}, #{Time.now.to_i}, "#{diff_view}") var notes = new Notes("#{namespace_project_notes_path(namespace_id: @project.namespace, project_id: @project, target_id: @noteable.id, target_type: @noteable.class.name.underscore)}", #{@notes.map(&:id).to_json}, #{Time.now.to_i}, "#{diff_view}")
---
title: display merge request discussion tab for empty branches
merge_request: 8347
author:
...@@ -4,6 +4,8 @@ require 'spec_helper' ...@@ -4,6 +4,8 @@ require 'spec_helper'
# message to be shown by JavaScript when the source branch was deleted. # message to be shown by JavaScript when the source branch was deleted.
# Please do not remove "js: true". # Please do not remove "js: true".
describe 'Deleted source branch', feature: true, js: true do describe 'Deleted source branch', feature: true, js: true do
include WaitForAjax
let(:user) { create(:user) } let(:user) { create(:user) }
let(:merge_request) { create(:merge_request) } let(:merge_request) { create(:merge_request) }
...@@ -13,7 +15,8 @@ describe 'Deleted source branch', feature: true, js: true do ...@@ -13,7 +15,8 @@ describe 'Deleted source branch', feature: true, js: true do
merge_request.update!(source_branch: 'this-branch-does-not-exist') merge_request.update!(source_branch: 'this-branch-does-not-exist')
visit namespace_project_merge_request_path( visit namespace_project_merge_request_path(
merge_request.project.namespace, merge_request.project.namespace,
merge_request.project, merge_request merge_request.project,
merge_request
) )
end end
...@@ -23,11 +26,17 @@ describe 'Deleted source branch', feature: true, js: true do ...@@ -23,11 +26,17 @@ describe 'Deleted source branch', feature: true, js: true do
) )
end end
it 'hides Discussion, Commits and Changes tabs' do it 'still contains Discussion, Commits and Changes tabs' do
within '.merge-request-details' do within '.merge-request-details' do
expect(page).to have_no_content('Discussion') expect(page).to have_content('Discussion')
expect(page).to have_no_content('Commits') expect(page).to have_content('Commits')
expect(page).to have_no_content('Changes') expect(page).to have_content('Changes')
end end
click_on 'Changes'
wait_for_ajax
expect(page).to have_selector('.diffs.tab-pane .nothing-here-block')
expect(page).to have_content('Nothing to merge from this-branch-does-not-exist into feature')
end end
end end
...@@ -7,6 +7,7 @@ describe 'projects/merge_requests/show.html.haml' do ...@@ -7,6 +7,7 @@ describe 'projects/merge_requests/show.html.haml' do
let(:project) { create(:project) } let(:project) { create(:project) }
let(:fork_project) { create(:project, forked_from_project: project) } let(:fork_project) { create(:project, forked_from_project: project) }
let(:unlink_project) { Projects::UnlinkForkService.new(fork_project, user) } let(:unlink_project) { Projects::UnlinkForkService.new(fork_project, user) }
let(:note) { create(:note_on_merge_request, project: project, noteable: closed_merge_request) }
let(:closed_merge_request) do let(:closed_merge_request) do
create(:closed_merge_request, create(:closed_merge_request,
...@@ -19,8 +20,12 @@ describe 'projects/merge_requests/show.html.haml' do ...@@ -19,8 +20,12 @@ describe 'projects/merge_requests/show.html.haml' do
assign(:project, project) assign(:project, project)
assign(:merge_request, closed_merge_request) assign(:merge_request, closed_merge_request)
assign(:commits_count, 0) assign(:commits_count, 0)
assign(:note, note)
assign(:noteable, closed_merge_request)
assign(:notes, [])
assign(:pipelines, Ci::Pipeline.none)
allow(view).to receive(:can?).and_return(true) allow(view).to receive_messages(current_user: user, can?: true)
end end
context 'when the merge request is closed' do context 'when the merge request is closed' 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