Commit f1f9b5e2 authored by Paco Guzman's avatar Paco Guzman

Be explicit on merge request discussion variables

parent 3ca92534
......@@ -56,6 +56,7 @@ v 8.10.0 (unreleased)
- Add API endpoint for a group issues !4520 (mahcsig)
- Add Bugzilla integration !4930 (iamtjg)
- Instrument Rinku usage
- Be explicit to define merge request discussion variables
- Metrics for Rouge::Plugins::Redcarpet and Rouge::Formatters::HTMLGitlab
- RailsCache metris now includes fetch_hit/fetch_miss and read_hit/read_miss info.
- Allow [ci skip] to be in any case and allow [skip ci]. !4785 (simon_w)
......
......@@ -56,7 +56,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController
def show
respond_to do |format|
format.html
format.html { define_discussion_vars }
format.json do
render json: @merge_request
......@@ -82,7 +82,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController
@merge_request_diff = @merge_request.merge_request_diff
respond_to do |format|
format.html
format.html { define_discussion_vars }
format.json { render json: { html: view_to_html_string("projects/merge_requests/show/_diffs") } }
end
end
......@@ -108,7 +108,11 @@ class Projects::MergeRequestsController < Projects::ApplicationController
def commits
respond_to do |format|
format.html { render 'show' }
format.html do
define_discussion_vars
render 'show'
end
format.json do
# Get commits from repository
# or from cache if already merged
......@@ -123,7 +127,11 @@ class Projects::MergeRequestsController < Projects::ApplicationController
def builds
respond_to do |format|
format.html { render 'show' }
format.html do
define_discussion_vars
render 'show'
end
format.json { render json: { html: view_to_html_string('projects/merge_requests/show/_builds') } }
end
end
......@@ -353,14 +361,11 @@ class Projects::MergeRequestsController < Projects::ApplicationController
@merge_request.unlock_mr
@merge_request.close
end
if request.format == :html || action_name == 'show'
define_show_html_vars
end
end
# Discussion tab data is only required on html requests
def define_show_html_vars
# Discussion tab data is rendered on html responses of actions
# :show, :diff, :commits, :builds. but not when request the data through AJAX
def define_discussion_vars
# Build a note object for comment form
@note = @project.notes.new(noteable: @noteable)
......
require 'spec_helper'
feature 'Diffs URL', js: true, feature: true do
before do
login_as :admin
@merge_request = create(:merge_request)
@project = @merge_request.source_project
end
context 'when visit with */* as accept header' do
before(:each) do
page.driver.add_header('Accept', '*/*')
end
it 'renders the notes' do
create :note_on_merge_request, project: @project, noteable: @merge_request, note: 'Rebasing with master'
visit diffs_namespace_project_merge_request_path(@project.namespace, @project, @merge_request)
# Load notes and diff through AJAX
expect(page).to have_css('.note-text', visible: false, text: 'Rebasing with master')
expect(page).to have_css('.diffs.tab-pane.active')
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