-
-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1530 from codidact/art/maintenance-tasks
Update maintenance_tasks
- Loading branch information
Showing
8 changed files
with
67 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
class TasksController < ApplicationController | ||
before_action :check_permissions | ||
|
||
private | ||
|
||
def check_permissions | ||
# We can't use ApplicationController#verify_developer because it tries to render not_found with | ||
# layout: 'without_sidebar', which breaks because routing doesn't work under mounted applications. Bleugh. | ||
if !helpers.user_signed_in? || !helpers.current_user.developer? | ||
render plain: '403 Forbidden', status: :forbidden | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
MaintenanceTasks.parent_controller = 'TasksController' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -66,6 +66,14 @@ admin: | |
is_global_admin: false | ||
is_global_moderator: false | ||
confirmed_at: 2020-01-01T00:00:00.000000Z | ||
|
||
developer: | ||
email: [email protected] | ||
encrypted_password: '$2a$11$roUHXKxecjyQ72Qn7DWs3.9eRCCoRn176kX/UNb/xiue3aGqf7xEW' | ||
sign_in_count: 1337 | ||
username: developer | ||
developer: true | ||
confirmed_at: 2020-01-01T00:00:00.000000Z | ||
|
||
global_moderator: | ||
email: [email protected] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
require 'test_helper' | ||
|
||
class TasksIntegrationTest < ActionDispatch::IntegrationTest | ||
include Devise::Test::IntegrationHelpers | ||
|
||
test 'should deny access to anonymous users' do | ||
get '/maintenance' | ||
assert_response 403 | ||
end | ||
|
||
test 'should deny access to non-developers' do | ||
sign_in users(:admin) | ||
get '/maintenance' | ||
assert_response 403 | ||
end | ||
|
||
test 'should grant access to developers' do | ||
sign_in users(:developer) | ||
get '/maintenance' | ||
assert_response 200 | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters