BigW Consortium Gitlab

Commit 2b1afa0e by Riyad Preukschas

Remove merge_request#raw and replace it with formats to #show

Needed to add a constraint on the id. Otherwise the format was parsed as part of the id.
parent ddb7399a
class MergeRequestsController < ProjectResourceController
before_filter :module_enabled
before_filter :merge_request, only: [:edit, :update, :destroy, :show, :commits, :diffs, :automerge, :automerge_check, :raw]
before_filter :validates_merge_request, only: [:show, :diffs, :raw]
before_filter :merge_request, only: [:edit, :update, :destroy, :show, :commits, :diffs, :automerge, :automerge_check]
before_filter :validates_merge_request, only: [:show, :diffs]
before_filter :define_show_vars, only: [:show, :diffs]
# Allow read any merge_request
......@@ -16,7 +16,6 @@ class MergeRequestsController < ProjectResourceController
# Allow destroy merge_request
before_filter :authorize_admin_merge_request!, only: [:destroy]
def index
@merge_requests = MergeRequestsLoadContext.new(project, current_user, params).execute
end
......@@ -25,11 +24,10 @@ class MergeRequestsController < ProjectResourceController
respond_to do |format|
format.html
format.js
end
end
def raw
send_file @merge_request.to_raw
format.diff { render text: @merge_request.to_diff }
format.patch { render text: @merge_request.to_patch }
end
end
def diffs
......
- if @merge_request.valid_diffs?
= render "commits/diffs", diffs: @diffs
- elsif @merge_request.broken_diffs?
%h4.nothing_here_message
%h4.nothing_here_message
Can't load diff.
You can #{link_to "download MR patch", raw_project_merge_request_path(@project, @merge_request), class: "vlink"} instead.
You can
= link_to "download it", project_merge_request_path(@project, @merge_request), format: :diff, class: "vlink"
instead.
- else
%h4.nothing_here_message Nothing to merge
......@@ -13,9 +13,9 @@
= "MERGED"
- if can?(current_user, :modify_merge_request, @merge_request)
- if @merge_request.open?
= link_to raw_project_merge_request_path(@project, @merge_request), class: "btn grouped" do
= link_to project_merge_request_path(@project, @merge_request, format: :patch), class: "btn grouped" do
%i.icon-download-alt
Get Patch
Get Patch
= link_to 'Close', project_merge_request_path(@project, @merge_request, merge_request: {closed: true }, status_only: true), method: :put, class: "btn grouped danger", title: "Close merge request"
......
......@@ -159,12 +159,11 @@ Gitlab::Application.routes.draw do
end
end
resources :merge_requests do
resources :merge_requests, constraints: {id: /\d+/} do
member do
get :diffs
get :automerge
get :automerge_check
get :raw
end
collection do
......
......@@ -208,7 +208,6 @@ end
# diffs_project_merge_request GET /:project_id/merge_requests/:id/diffs(.:format) merge_requests#diffs
# automerge_project_merge_request GET /:project_id/merge_requests/:id/automerge(.:format) merge_requests#automerge
# automerge_check_project_merge_request GET /:project_id/merge_requests/:id/automerge_check(.:format) merge_requests#automerge_check
# raw_project_merge_request GET /:project_id/merge_requests/:id/raw(.:format) merge_requests#raw
# branch_from_project_merge_requests GET /:project_id/merge_requests/branch_from(.:format) merge_requests#branch_from
# branch_to_project_merge_requests GET /:project_id/merge_requests/branch_to(.:format) merge_requests#branch_to
# project_merge_requests GET /:project_id/merge_requests(.:format) merge_requests#index
......@@ -231,10 +230,6 @@ describe MergeRequestsController, "routing" do
get("/gitlabhq/merge_requests/1/automerge_check").should route_to('merge_requests#automerge_check', project_id: 'gitlabhq', id: '1')
end
it "to #raw" do
get("/gitlabhq/merge_requests/1/raw").should route_to('merge_requests#raw', project_id: 'gitlabhq', id: '1')
end
it "to #branch_from" do
get("/gitlabhq/merge_requests/branch_from").should route_to('merge_requests#branch_from', project_id: 'gitlabhq')
end
......@@ -243,6 +238,11 @@ describe MergeRequestsController, "routing" do
get("/gitlabhq/merge_requests/branch_to").should route_to('merge_requests#branch_to', project_id: 'gitlabhq')
end
it "to #show" do
get("/gitlabhq/merge_requests/1.diff").should route_to('merge_requests#show', project_id: 'gitlabhq', id: '1', format: 'diff')
get("/gitlabhq/merge_requests/1.patch").should route_to('merge_requests#show', project_id: 'gitlabhq', id: '1', format: 'patch')
end
it_behaves_like "RESTful project resources" do
let(:controller) { 'merge_requests' }
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