diff options
author | Ciro Santilli <ciro.santilli@gmail.com> | 2014-10-06 23:37:27 +0200 |
---|---|---|
committer | Ciro Santilli <ciro.santilli@gmail.com> | 2014-10-07 10:04:09 +0200 |
commit | f4efb19038d01225374c91cca9274cce3d728b3d (patch) | |
tree | 0da33ae11e8e17994794f0241b99a428cbe2e8b6 | |
parent | 70004f4ef6160e788e6a600b9da06608c8559aa2 (diff) | |
download | gitlab-ce-f4efb19038d01225374c91cca9274cce3d728b3d.tar.gz |
Add tests for tree edit routes
Critical because of possible confusion between /:id/preview
and /:id for a path that ends in preview.
-rw-r--r-- | config/routes.rb | 1 | ||||
-rw-r--r-- | spec/routing/project_routing_spec.rb | 20 |
2 files changed, 21 insertions, 0 deletions
diff --git a/config/routes.rb b/config/routes.rb index 2534153758b..c0a970517b6 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -198,6 +198,7 @@ Gitlab::Application.routes.draw do resources :raw, only: [:show], constraints: {id: /.+/} resources :tree, only: [:show], constraints: {id: /.+/, format: /(html|js)/ } resources :edit_tree, only: [:show, :update], constraints: { id: /.+/ }, path: 'edit' do + # Cannot be GET to differentiate from GET paths that end in preview. post :preview, on: :member end resources :new_tree, only: [:show, :update], constraints: {id: /.+/}, path: 'new' diff --git a/spec/routing/project_routing_spec.rb b/spec/routing/project_routing_spec.rb index 4b2eb42c709..8a7d76cc970 100644 --- a/spec/routing/project_routing_spec.rb +++ b/spec/routing/project_routing_spec.rb @@ -432,6 +432,26 @@ describe Projects::TreeController, "routing" do end end +describe Projects::EditTreeController, 'routing' do + it 'to #show' do + get('/gitlab/gitlabhq/edit/master/app/models/project.rb').should( + route_to('projects/edit_tree#show', + project_id: 'gitlab/gitlabhq', + id: 'master/app/models/project.rb')) + get('/gitlab/gitlabhq/edit/master/app/models/project.rb/preview').should( + route_to('projects/edit_tree#show', + project_id: 'gitlab/gitlabhq', + id: 'master/app/models/project.rb/preview')) + end + + it 'to #preview' do + post('/gitlab/gitlabhq/edit/master/app/models/project.rb/preview').should( + route_to('projects/edit_tree#preview', + project_id: 'gitlab/gitlabhq', + id: 'master/app/models/project.rb')) + end +end + # 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: /[^\/]+/} |