Commit e8841e8d authored by Oswaldo Ferreira's avatar Oswaldo Ferreira

Drop merge_check endpoint and use only MR show instead

parent e4eec191
...@@ -6,7 +6,7 @@ Vue.use(VueResource); ...@@ -6,7 +6,7 @@ Vue.use(VueResource);
export default class MRWidgetService { export default class MRWidgetService {
constructor(endpoints) { constructor(endpoints) {
this.mergeResource = Vue.resource(endpoints.mergePath); this.mergeResource = Vue.resource(endpoints.mergePath);
this.mergeCheckResource = Vue.resource(endpoints.mergeCheckPath); this.mergeCheckResource = Vue.resource(endpoints.statusPath);
this.cancelAutoMergeResource = Vue.resource(endpoints.cancelAutoMergePath); this.cancelAutoMergeResource = Vue.resource(endpoints.cancelAutoMergePath);
this.removeWIPResource = Vue.resource(endpoints.removeWIPPath); this.removeWIPResource = Vue.resource(endpoints.removeWIPPath);
this.removeSourceBranchResource = Vue.resource(endpoints.sourceBranchPath); this.removeSourceBranchResource = Vue.resource(endpoints.sourceBranchPath);
......
...@@ -9,14 +9,15 @@ class Projects::MergeRequestsController < Projects::ApplicationController ...@@ -9,14 +9,15 @@ class Projects::MergeRequestsController < Projects::ApplicationController
before_action :module_enabled before_action :module_enabled
before_action :merge_request, only: [ before_action :merge_request, only: [
:edit, :update, :show, :diffs, :commits, :conflicts, :conflict_for_path, :pipelines, :merge, :merge_check, :edit, :update, :show, :diffs, :commits, :conflicts, :conflict_for_path, :pipelines, :merge,
:pipeline_status, :ci_environments_status, :toggle_subscription, :cancel_merge_when_pipeline_succeeds, :remove_wip, :resolve_conflicts, :assign_related_issues, :commit_change_content :pipeline_status, :ci_environments_status, :toggle_subscription, :cancel_merge_when_pipeline_succeeds, :remove_wip, :resolve_conflicts, :assign_related_issues, :commit_change_content
] ]
before_action :validates_merge_request, only: [:show, :diffs, :commits, :pipelines] before_action :validates_merge_request, only: [:show, :diffs, :commits, :pipelines]
before_action :define_show_vars, only: [:show, :diffs, :commits, :conflicts, :conflict_for_path, :builds, :pipelines] before_action :define_show_vars, only: [:diffs, :commits, :conflicts, :conflict_for_path, :builds, :pipelines]
before_action :define_commit_vars, only: [:diffs] before_action :define_commit_vars, only: [:diffs]
before_action :ensure_ref_fetched, only: [:show, :diffs, :commits, :builds, :conflicts, :conflict_for_path, :pipelines] before_action :ensure_ref_fetched, only: [:show, :diffs, :commits, :builds, :conflicts, :conflict_for_path, :pipelines]
before_action :close_merge_request_without_source_project, only: [:show, :diffs, :commits, :builds, :pipelines] before_action :close_merge_request_without_source_project, only: [:show, :diffs, :commits, :builds, :pipelines]
before_action :check_if_can_be_merged, only: :show
before_action :apply_diff_view_cookie!, only: [:new_diffs] before_action :apply_diff_view_cookie!, only: [:new_diffs]
before_action :build_merge_request, only: [:new, :new_diffs] before_action :build_merge_request, only: [:new, :new_diffs]
...@@ -75,9 +76,12 @@ class Projects::MergeRequestsController < Projects::ApplicationController ...@@ -75,9 +76,12 @@ class Projects::MergeRequestsController < Projects::ApplicationController
respond_to do |format| respond_to do |format|
format.html do format.html do
define_discussion_vars define_discussion_vars
define_show_vars
end end
format.json do format.json do
Gitlab::PollingInterval.set_header(response, interval: 10_000)
render json: serializer.represent(@merge_request, basic: params[:basic]) render json: serializer.represent(@merge_request, basic: params[:basic])
end end
...@@ -309,12 +313,6 @@ class Projects::MergeRequestsController < Projects::ApplicationController ...@@ -309,12 +313,6 @@ class Projects::MergeRequestsController < Projects::ApplicationController
render json: serializer.represent(@merge_request) render json: serializer.represent(@merge_request)
end end
def merge_check
@merge_request.check_if_can_be_merged
render json: serializer.represent(@merge_request)
end
def commit_change_content def commit_change_content
render partial: 'projects/merge_requests/widget/commit_change_content', layout: false render partial: 'projects/merge_requests/widget/commit_change_content', layout: false
end end
...@@ -640,6 +638,10 @@ class Projects::MergeRequestsController < Projects::ApplicationController ...@@ -640,6 +638,10 @@ class Projects::MergeRequestsController < Projects::ApplicationController
private private
def check_if_can_be_merged
@merge_request.check_if_can_be_merged
end
def merge! def merge!
# Disable the CI check if merge_when_pipeline_succeeds is enabled since we have # Disable the CI check if merge_when_pipeline_succeeds is enabled since we have
# to wait until CI completes to know # to wait until CI completes to know
......
...@@ -119,6 +119,15 @@ describe Projects::MergeRequestsController do ...@@ -119,6 +119,15 @@ describe Projects::MergeRequestsController do
expect(response).to match_response_schema('entities/merge_request') expect(response).to match_response_schema('entities/merge_request')
end end
end end
context 'number of queries' do
it 'verifies number of queries' do
recorded = ActiveRecord::QueryRecorder.new { go(format: :json) }
expect(recorded.count).to be_within(1).of(94)
expect(recorded.cached_count).to eq(0)
end
end
end end
describe "as diff" do describe "as diff" 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