Commit 2b1afa0e authored by Riyad Preukschas's avatar 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 class MergeRequestsController < ProjectResourceController
before_filter :module_enabled before_filter :module_enabled
before_filter :merge_request, only: [:edit, :update, :destroy, :show, :commits, :diffs, :automerge, :automerge_check, :raw] before_filter :merge_request, only: [:edit, :update, :destroy, :show, :commits, :diffs, :automerge, :automerge_check]
before_filter :validates_merge_request, only: [:show, :diffs, :raw] before_filter :validates_merge_request, only: [:show, :diffs]
before_filter :define_show_vars, only: [:show, :diffs] before_filter :define_show_vars, only: [:show, :diffs]
# Allow read any merge_request # Allow read any merge_request
...@@ -16,7 +16,6 @@ class MergeRequestsController < ProjectResourceController ...@@ -16,7 +16,6 @@ class MergeRequestsController < ProjectResourceController
# Allow destroy merge_request # Allow destroy merge_request
before_filter :authorize_admin_merge_request!, only: [:destroy] before_filter :authorize_admin_merge_request!, only: [:destroy]
def index def index
@merge_requests = MergeRequestsLoadContext.new(project, current_user, params).execute @merge_requests = MergeRequestsLoadContext.new(project, current_user, params).execute
end end
...@@ -25,11 +24,10 @@ class MergeRequestsController < ProjectResourceController ...@@ -25,11 +24,10 @@ class MergeRequestsController < ProjectResourceController
respond_to do |format| respond_to do |format|
format.html format.html
format.js format.js
end
end
def raw format.diff { render text: @merge_request.to_diff }
send_file @merge_request.to_raw format.patch { render text: @merge_request.to_patch }
end
end end
def diffs def diffs
......
- if @merge_request.valid_diffs? - if @merge_request.valid_diffs?
= render "commits/diffs", diffs: @diffs = render "commits/diffs", diffs: @diffs
- elsif @merge_request.broken_diffs? - elsif @merge_request.broken_diffs?
%h4.nothing_here_message %h4.nothing_here_message
Can't load diff. 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 - else
%h4.nothing_here_message Nothing to merge %h4.nothing_here_message Nothing to merge
...@@ -13,9 +13,9 @@ ...@@ -13,9 +13,9 @@
= "MERGED" = "MERGED"
- if can?(current_user, :modify_merge_request, @merge_request) - if can?(current_user, :modify_merge_request, @merge_request)
- if @merge_request.open? - 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 %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" = 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 ...@@ -159,12 +159,11 @@ Gitlab::Application.routes.draw do
end end
end end
resources :merge_requests do resources :merge_requests, constraints: {id: /\d+/} do
member do member do
get :diffs get :diffs
get :automerge get :automerge
get :automerge_check get :automerge_check
get :raw
end end
collection do collection do
......
...@@ -208,7 +208,6 @@ end ...@@ -208,7 +208,6 @@ end
# diffs_project_merge_request GET /:project_id/merge_requests/:id/diffs(.:format) merge_requests#diffs # 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_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 # 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_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 # 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 # project_merge_requests GET /:project_id/merge_requests(.:format) merge_requests#index
...@@ -231,10 +230,6 @@ describe MergeRequestsController, "routing" do ...@@ -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') get("/gitlabhq/merge_requests/1/automerge_check").should route_to('merge_requests#automerge_check', project_id: 'gitlabhq', id: '1')
end 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 it "to #branch_from" do
get("/gitlabhq/merge_requests/branch_from").should route_to('merge_requests#branch_from', project_id: 'gitlabhq') get("/gitlabhq/merge_requests/branch_from").should route_to('merge_requests#branch_from', project_id: 'gitlabhq')
end end
...@@ -243,6 +238,11 @@ describe MergeRequestsController, "routing" do ...@@ -243,6 +238,11 @@ describe MergeRequestsController, "routing" do
get("/gitlabhq/merge_requests/branch_to").should route_to('merge_requests#branch_to', project_id: 'gitlabhq') get("/gitlabhq/merge_requests/branch_to").should route_to('merge_requests#branch_to', project_id: 'gitlabhq')
end 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 it_behaves_like "RESTful project resources" do
let(:controller) { 'merge_requests' } let(:controller) { 'merge_requests' }
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