Skip to content

Commit

Permalink
Remove / to about routing malarky
Browse files Browse the repository at this point in the history
No need to route / and /public/ to controllers that redirect to AboutController#index.
Just route to AboutController#index directly.
  • Loading branch information
hennevogel committed Oct 23, 2020
1 parent d6a957d commit f7bae74
Show file tree
Hide file tree
Showing 7 changed files with 5 additions and 52 deletions.
12 changes: 0 additions & 12 deletions src/api/app/controllers/main_controller.rb

This file was deleted.

4 changes: 0 additions & 4 deletions src/api/app/controllers/public_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ class PublicController < ApplicationController
skip_before_action :extract_user
skip_before_action :require_login

def index
redirect_to controller: 'about', action: 'index'
end

# GET /public/build/:project/:repository/:arch/:package
def build
required_parameters :project
Expand Down
10 changes: 4 additions & 6 deletions src/api/config/routes/api_routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
cons = RoutesHelper::RoutesConstraints::CONS

constraints(RoutesHelper::APIMatcher) do
get '/' => 'main#index'
get '/', to: redirect('/about')

resources :about, only: :index

resource :configuration, only: [:show, :update, :schedulers]

Expand Down Expand Up @@ -42,8 +44,6 @@
### /source
get 'source/:project/_keyinfo' => 'source/key_info#show', constraints: cons

resources :about, only: :index

controller :attribute_namespace do
get 'attribute' => :index
get 'attribute/:namespace' => :index
Expand Down Expand Up @@ -196,7 +196,7 @@

### /public
controller :public do
get 'public' => :index
get 'public', to: redirect('/public/about')
get 'public/about' => 'about#index'
get 'public/configuration' => :configuration_show
get 'public/configuration.xml' => :configuration_show
Expand All @@ -213,8 +213,6 @@
get 'public/build/:project(/:repository(/:arch(/:package(/:filename))))' => 'public#build', constraints: cons, as: :public_build
end

get '/404' => 'main#notfound'

scope 'public' do
resources :image_templates, constraints: cons, only: [:index], controller: 'webui/image_templates'
end
Expand Down
8 changes: 0 additions & 8 deletions src/api/spec/controllers/public_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,6 @@
it { expect(response.body).to eq(package.source_file('somefile.txt')) }
end

describe 'GET #index' do
before do
get :index
end

it { is_expected.to redirect_to(about_index_path) }
end

describe 'GET #build' do
before do
get :build, params: { project: project.name }
Expand Down
2 changes: 0 additions & 2 deletions src/api/spec/routing/api_matcher_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
end

RSpec.shared_examples '/public routes to PublicController independent of format' do |format|
it { expect(get("/public?format=#{format}")).to route_to(controller: 'public', action: 'index', format: format) }
it { expect(get("/about?format=#{format}")).to route_to(controller: 'about', action: 'index', format: format) }
it { expect(get("/public/distributions?format=#{format}")).to route_to(controller: 'public', action: 'distributions', format: format) }
it { expect(get("/public/request/1?format=#{format}")).to route_to(controller: 'public', action: 'show_request', number: '1', format: format) }
it { expect(get("/public/configuration?format=#{format}")).to route_to(controller: 'public', action: 'configuration_show', format: format) }
Expand Down
19 changes: 0 additions & 19 deletions src/api/test/functional/main_controller_test.rb

This file was deleted.

2 changes: 1 addition & 1 deletion src/api/test/functional/public_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def setup

def test_index
get '/public'
assert_response 302
assert_response 301
end

def test_about
Expand Down

0 comments on commit f7bae74

Please sign in to comment.