Skip to content

Commit ab5a82d

Browse files
author
bmarkons
committed
Make all controllers in admin/ inherit AdminController
1 parent 234fe7a commit ab5a82d

9 files changed

Lines changed: 35 additions & 39 deletions

File tree

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
class Admin::DashboardController < AdminController
2+
def dashboard
3+
end
4+
end

app/controllers/admin/groups_controller.rb

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,4 @@
1-
class Admin::GroupsController < ApplicationController
2-
http_basic_authenticate_with(
3-
name: 'admin',
4-
password: Rails.application.secrets.admin_password
5-
) unless Rails.env.test?
6-
7-
layout 'admin'
8-
9-
before_action :set_repos, :set_admin
1+
class Admin::GroupsController < AdminController
102
before_action :set_group, only: [:show, :edit, :update, :destroy]
113

124
def index
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
class Admin::ReposController < AdminController
2+
before_action :set_repo
3+
4+
def show
5+
end
6+
7+
def run_commits
8+
ManualRunner.new(@repo).run_last(
9+
params[:count].to_i,
10+
pattern: params[:pattern] == 'all' ? '' : params[:pattern]
11+
)
12+
13+
redirect_to admin_repo_path(@repo.name), notice: "#{@repo.name.capitalize} suite is running for last #{params[:count].to_i} commits."
14+
end
15+
16+
private
17+
18+
def set_repo
19+
@repo = Repo.find_by(name: params[:repo_name])
20+
end
21+
end

app/controllers/admin_controller.rb

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,34 +7,14 @@ class AdminController < ApplicationController
77
layout 'admin'
88

99
before_action :set_repos, :set_admin
10-
before_action :set_repo, only: [:repo, :run]
10+
11+
private
1112

1213
def set_admin
1314
session['admin'] = true unless session['admin'] || Rails.env.test?
1415
end
1516

16-
def home
17-
end
18-
19-
def repo
20-
end
21-
22-
def run
23-
ManualRunner.new(@repo).run_last(
24-
params[:count].to_i,
25-
pattern: params[:pattern] == 'all' ? '' : params[:pattern]
26-
)
27-
28-
redirect_to admin_repo_path(@repo.name), notice: "#{@repo.name.capitalize} suite is running for last #{params[:count].to_i} commits."
29-
end
30-
31-
private
32-
3317
def set_repos
3418
@repos = Repo.all
3519
end
36-
37-
def set_repo
38-
@repo = Repo.find_by(name: params[:repo_name])
39-
end
4020
end
File renamed without changes.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
.panel.panel-warning
1414
.panel-body
15-
= form_tag(admin_repo_run_path(@repo.name), id: 'manual_run_form') do
15+
= form_tag(admin_run_commits_path(@repo.name), id: 'manual_run_form') do
1616
.form-group
1717
= label_tag(t('admin.manual_run_pattern_label'))
1818
= text_field_tag(:pattern, 'all', class: 'form-control')

app/views/layouts/admin/_navbar.html.haml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
.sidebar-nav.navbar-collapse
1717
%ul#side-menu.nav.in
1818
%li
19-
= link_to admin_path do
19+
= link_to admin_dashboard_path do
2020
%i.fa.fa-dashboard.fa-fw
2121
= t('admin.dashboard')
2222
%li

config/routes.rb

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,11 @@
2323
get ':organization_name/:repo_name/commits' => 'repos#commits', as: :commits
2424
get ':organization_name/:repo_name/releases' => 'repos#releases', as: :releases
2525

26-
get 'admin' => 'admin#home'
27-
get 'admin/repos/:repo_name' => 'admin#repo', as: :admin_repo
28-
get 'admin/toggle' => 'admin#toggle_admin'
29-
post 'admin/repos/:repo_name/run' => 'admin#run', as: :admin_repo_run
30-
3126
namespace :admin do
3227
resources :groups, except: [:show]
28+
29+
get '' => 'dashboard#dashboard', as: :dashboard
30+
get 'repos/:repo_name' => 'repos#show', as: :repo
31+
post 'repos/:repo_name/run_commits' => 'repos#run_commits', as: :run_commits
3332
end
3433
end

test/integration/manual_run_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ def test_running_commits_manually
77

88
ManualRunner.any_instance.expects(:run_last).with(100, pattern: pattern)
99

10-
post(admin_repo_run_path(@repo.name), params: { count: 100, pattern: pattern })
10+
post(admin_run_commits_path(@repo.name), params: { count: 100, pattern: pattern })
1111
end
1212
end

0 commit comments

Comments
 (0)