Add Compare#index and Compare#create actions
Create just redirects to our specially-formatted #show action
This commit is contained in:
parent
8fe63dab52
commit
6cb626ef51
|
@ -8,6 +8,9 @@ class CompareController < ApplicationController
|
||||||
before_filter :authorize_code_access!
|
before_filter :authorize_code_access!
|
||||||
before_filter :require_non_empty_project
|
before_filter :require_non_empty_project
|
||||||
|
|
||||||
|
def index
|
||||||
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
result = Commit.compare(project, params[:from], params[:to])
|
result = Commit.compare(project, params[:from], params[:to])
|
||||||
|
|
||||||
|
@ -19,4 +22,8 @@ class CompareController < ApplicationController
|
||||||
|
|
||||||
@commits = CommitDecorator.decorate(@commits)
|
@commits = CommitDecorator.decorate(@commits)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def create
|
||||||
|
redirect_to project_compare_path(@project, params[:from], params[:to])
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -162,7 +162,7 @@ Gitlab::Application.routes.draw do
|
||||||
# XXX: WIP
|
# XXX: WIP
|
||||||
resources :commit, only: [:show], constraints: {id: /[[:alnum:]]{6,40}/}
|
resources :commit, only: [:show], constraints: {id: /[[:alnum:]]{6,40}/}
|
||||||
resources :commits, only: [:show], constraints: {id: /.+/}
|
resources :commits, only: [:show], constraints: {id: /.+/}
|
||||||
resources :compare, only: [:index]
|
resources :compare, only: [:index, :create]
|
||||||
resources :blame, only: [:show], constraints: {id: /.+/}
|
resources :blame, only: [:show], constraints: {id: /.+/}
|
||||||
resources :blob, only: [:show], constraints: {id: /.+/}
|
resources :blob, only: [:show], constraints: {id: /.+/}
|
||||||
resources :tree, only: [:show], constraints: {id: /.+/}
|
resources :tree, only: [:show], constraints: {id: /.+/}
|
||||||
|
|
|
@ -399,12 +399,17 @@ describe TreeController, "routing" do
|
||||||
end
|
end
|
||||||
|
|
||||||
# project_compare_index GET /:project_id/compare(.:format) compare#index {:id=>/[^\/]+/, :project_id=>/[^\/]+/}
|
# project_compare_index GET /:project_id/compare(.:format) compare#index {:id=>/[^\/]+/, :project_id=>/[^\/]+/}
|
||||||
|
# POST /:project_id/compare(.:format) compare#create {:id=>/[^\/]+/, :project_id=>/[^\/]+/}
|
||||||
# project_compare /:project_id/compare/:from...:to(.:format) compare#show {:from=>/.+/, :to=>/.+/, :id=>/[^\/]+/, :project_id=>/[^\/]+/}
|
# project_compare /:project_id/compare/:from...:to(.:format) compare#show {:from=>/.+/, :to=>/.+/, :id=>/[^\/]+/, :project_id=>/[^\/]+/}
|
||||||
describe CompareController, "routing" do
|
describe CompareController, "routing" do
|
||||||
it "to #index" do
|
it "to #index" do
|
||||||
get("/gitlabhq/compare").should route_to('compare#index', project_id: 'gitlabhq')
|
get("/gitlabhq/compare").should route_to('compare#index', project_id: 'gitlabhq')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "to #compare" do
|
||||||
|
post("/gitlabhq/compare").should route_to('compare#create', project_id: 'gitlabhq')
|
||||||
|
end
|
||||||
|
|
||||||
it "to #show" do
|
it "to #show" do
|
||||||
get("/gitlabhq/compare/master...stable").should route_to('compare#show', project_id: 'gitlabhq', from: 'master', to: 'stable')
|
get("/gitlabhq/compare/master...stable").should route_to('compare#show', project_id: 'gitlabhq', from: 'master', to: 'stable')
|
||||||
get("/gitlabhq/compare/issue/1234...stable").should route_to('compare#show', project_id: 'gitlabhq', from: 'issue/1234', to: 'stable')
|
get("/gitlabhq/compare/issue/1234...stable").should route_to('compare#show', project_id: 'gitlabhq', from: 'issue/1234', to: 'stable')
|
||||||
|
|
Loading…
Reference in a new issue