Description:
change depricated before_filter to before_action
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r745:75264caa616f - - 20 files changed: 38 inserted, 31 deleted
@@ -13,6 +13,7 | |||
|
13 | 13 | gem 'mysql2' |
|
14 | 14 | #for testing |
|
15 | 15 | gem 'sqlite3' |
|
16 | + gem 'rails-controller-testing' | |
|
16 | 17 | #for dumping database into yaml |
|
17 | 18 | gem 'yaml_db' |
|
18 | 19 |
@@ -159,6 +159,10 | |||
|
159 | 159 | bundler (>= 1.3.0) |
|
160 | 160 | railties (= 5.0.7.2) |
|
161 | 161 | sprockets-rails (>= 2.0.0) |
|
162 | + rails-controller-testing (1.0.4) | |
|
163 | + actionpack (>= 5.0.1.x) | |
|
164 | + actionview (>= 5.0.1.x) | |
|
165 | + activesupport (>= 5.0.1.x) | |
|
162 | 166 | rails-dom-testing (2.0.3) |
|
163 | 167 | activesupport (>= 4.2.0) |
|
164 | 168 | nokogiri (>= 1.6) |
@@ -258,6 +262,7 | |||
|
258 | 262 | momentjs-rails |
|
259 | 263 | mysql2 |
|
260 | 264 | rails (~> 5.0) |
|
265 | + rails-controller-testing | |
|
261 | 266 | rails_bootstrap_sortable |
|
262 | 267 | rdiscount |
|
263 | 268 | rouge |
@@ -1,6 +1,6 | |||
|
1 | 1 | class AnnouncementsController < ApplicationController |
|
2 | 2 | |
|
3 |
- before_ |
|
|
3 | + before_action :admin_authorization | |
|
4 | 4 | |
|
5 | 5 | in_place_edit_for :announcement, :published |
|
6 | 6 |
@@ -1,7 +1,7 | |||
|
1 | 1 | class ApplicationController < ActionController::Base |
|
2 | 2 | protect_from_forgery |
|
3 | 3 | |
|
4 |
- before_ |
|
|
4 | + before_action :current_user | |
|
5 | 5 | |
|
6 | 6 | SINGLE_USER_MODE_CONF_KEY = 'system.single_user_mode' |
|
7 | 7 | MULTIPLE_IP_LOGIN_CONF_KEY = 'right.multiple_ip_login' |
@@ -1,7 +1,7 | |||
|
1 | 1 | class ConfigurationsController < ApplicationController |
|
2 | 2 | |
|
3 |
- before_ |
|
|
4 |
- before_ |
|
|
3 | + before_action :authenticate | |
|
4 | + before_action { |controller| controller.authorization_by_roles(['admin'])} | |
|
5 | 5 | |
|
6 | 6 | |
|
7 | 7 | def index |
@@ -1,6 +1,6 | |||
|
1 | 1 | class ContestManagementController < ApplicationController |
|
2 | 2 | |
|
3 |
- before_ |
|
|
3 | + before_action :admin_authorization | |
|
4 | 4 | |
|
5 | 5 | def index |
|
6 | 6 | @num_contests = Contest.count() |
@@ -1,6 +1,6 | |||
|
1 | 1 | class ContestsController < ApplicationController |
|
2 | 2 | |
|
3 |
- before_ |
|
|
3 | + before_action :admin_authorization | |
|
4 | 4 | |
|
5 | 5 | in_place_edit_for :contest, :title |
|
6 | 6 | in_place_edit_for :contest, :enabled |
@@ -1,6 +1,6 | |||
|
1 | 1 | class GradersController < ApplicationController |
|
2 | 2 | |
|
3 |
- before_ |
|
|
3 | + before_action :admin_authorization | |
|
4 | 4 | |
|
5 | 5 | verify :method => :post, :only => ['clear_all', |
|
6 | 6 | 'start_exam', |
@@ -1,5 +1,5 | |||
|
1 | 1 | class HeartbeatController < ApplicationController |
|
2 |
- before_ |
|
|
2 | + before_action :admin_authorization, :only => ['index'] | |
|
3 | 3 | |
|
4 | 4 | def edit |
|
5 | 5 | #@user = User.find_by_login(params[:id]) |
@@ -1,19 +1,19 | |||
|
1 | 1 | class MainController < ApplicationController |
|
2 | 2 | |
|
3 |
- before_ |
|
|
4 |
- before_ |
|
|
3 | + before_action :authenticate, :except => [:index, :login] | |
|
4 | + before_action :check_viewability, :except => [:index, :login] | |
|
5 | 5 | |
|
6 |
- append_before_ |
|
|
6 | + append_before_action :confirm_and_update_start_time, | |
|
7 | 7 | :except => [:index, |
|
8 | 8 | :login, |
|
9 | 9 | :confirm_contest_start] |
|
10 | 10 | |
|
11 | 11 | # to prevent log in box to be shown when user logged out of the |
|
12 | 12 | # system only in some tab |
|
13 |
- prepend_before_ |
|
|
13 | + prepend_before_action :reject_announcement_refresh_when_logged_out, | |
|
14 | 14 | :only => [:announcements] |
|
15 | 15 | |
|
16 |
- before_ |
|
|
16 | + before_action :authenticate_by_ip_address, :only => [:list] | |
|
17 | 17 | |
|
18 | 18 | # COMMENTED OUT: filter in each action instead |
|
19 | 19 | # before_filter :verify_time_limit, :only => [:submit] |
@@ -1,6 +1,6 | |||
|
1 | 1 | class MessagesController < ApplicationController |
|
2 | 2 | |
|
3 |
- before_ |
|
|
3 | + before_action :authenticate | |
|
4 | 4 | |
|
5 | 5 | verify :method => :post, :only => ['create'], |
|
6 | 6 | :redirect_to => { :action => 'list' } |
@@ -2,11 +2,11 | |||
|
2 | 2 | |
|
3 | 3 | class ReportController < ApplicationController |
|
4 | 4 | |
|
5 |
- before_ |
|
|
5 | + before_action :authenticate | |
|
6 | 6 | |
|
7 |
- before_ |
|
|
7 | + before_action :admin_authorization, only: [:login_stat,:submission_stat, :stuck, :cheat_report, :cheat_scruntinize, :show_max_score, :current_score] | |
|
8 | 8 | |
|
9 |
- before_ |
|
|
9 | + before_action(only: [:problem_hof]) { |c| | |
|
10 | 10 | return false unless authenticate |
|
11 | 11 | |
|
12 | 12 | admin_authorization unless GraderConfiguration["right.user_view_submission"] |
@@ -1,6 +1,6 | |||
|
1 | 1 | class SiteController < ApplicationController |
|
2 | 2 | |
|
3 |
- before_ |
|
|
3 | + before_action :site_admin_authorization, :except => 'login' | |
|
4 | 4 | |
|
5 | 5 | def login |
|
6 | 6 | # Site administrator login |
@@ -1,6 +1,6 | |||
|
1 | 1 | class SitesController < ApplicationController |
|
2 | 2 | |
|
3 |
- before_ |
|
|
3 | + before_action :admin_authorization | |
|
4 | 4 | |
|
5 | 5 | # GET /sites |
|
6 | 6 | # GET /sites.xml |
@@ -1,6 +1,6 | |||
|
1 | 1 | class TasksController < ApplicationController |
|
2 | 2 | |
|
3 |
- before_ |
|
|
3 | + before_action :authenticate, :check_viewability | |
|
4 | 4 | |
|
5 | 5 | def index |
|
6 | 6 | redirect_to :action => 'list' |
@@ -1,6 +1,6 | |||
|
1 | 1 | class TestController < ApplicationController |
|
2 | 2 | |
|
3 |
- before_ |
|
|
3 | + before_action :authenticate, :check_viewability | |
|
4 | 4 | |
|
5 | 5 | # |
|
6 | 6 | # COMMENT OUT: filter in each action instead |
@@ -4,7 +4,7 | |||
|
4 | 4 | |
|
5 | 5 | include MailHelperMethods |
|
6 | 6 | |
|
7 |
- before_ |
|
|
7 | + before_action :admin_authorization | |
|
8 | 8 | |
|
9 | 9 | # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html) |
|
10 | 10 | verify :method => :post, :only => [ |
@@ -4,19 +4,19 | |||
|
4 | 4 | |
|
5 | 5 | include MailHelperMethods |
|
6 | 6 | |
|
7 |
- before_ |
|
|
7 | + before_action :authenticate, :except => [:new, | |
|
8 | 8 | :register, |
|
9 | 9 | :confirm, |
|
10 | 10 | :forget, |
|
11 | 11 | :retrieve_password] |
|
12 | 12 | |
|
13 |
- before_ |
|
|
13 | + before_action :verify_online_registration, :only => [:new, | |
|
14 | 14 | :register, |
|
15 | 15 | :forget, |
|
16 | 16 | :retrieve_password] |
|
17 |
- before_ |
|
|
17 | + before_action :authenticate, :profile_authorization, only: [:profile] | |
|
18 | 18 | |
|
19 |
- before_ |
|
|
19 | + before_action :admin_authorization, only: [:stat, :toggle_activate, :toggle_enable] | |
|
20 | 20 | |
|
21 | 21 | |
|
22 | 22 | verify :method => :post, :only => [:chg_passwd], |
@@ -5,7 +5,8 | |||
|
5 | 5 | root :to => 'main#login' |
|
6 | 6 | |
|
7 | 7 | #logins |
|
8 |
- |
|
|
8 | + match 'login/login', to: 'login#login', via: [:get,:post] | |
|
9 | + | |
|
9 | 10 | |
|
10 | 11 | resources :contests |
|
11 | 12 |
@@ -8,14 +8,14 | |||
|
8 | 8 | test "login with invalid information" do |
|
9 | 9 | get root_path |
|
10 | 10 | assert_response :success |
|
11 | - post login_login_path, login: "root", password: "hahaha" | |
|
11 | + post login_login_path, params: {login: "root", password: "hahaha"} | |
|
12 | 12 | assert_redirected_to root_path |
|
13 | 13 | end |
|
14 | 14 | |
|
15 | 15 | test "normal user login" do |
|
16 | 16 | get root_path |
|
17 | 17 | assert_response :success |
|
18 | - post login_login_path, {login: "john", password: "hello" } | |
|
18 | + post login_login_path, params: {login: "john", password: "hello" } | |
|
19 | 19 | assert_redirected_to main_list_path |
|
20 | 20 | end |
|
21 | 21 | |
@@ -24,7 +24,7 | |||
|
24 | 24 | GraderConfiguration.reload |
|
25 | 25 | get root_path |
|
26 | 26 | assert_response :success |
|
27 | - post login_login_path, {login: "john", password: "hello" } | |
|
27 | + post login_login_path, params: {login: "john", password: "hello" } | |
|
28 | 28 | follow_redirect! |
|
29 | 29 | assert_redirected_to root_path |
|
30 | 30 | end |
@@ -34,7 +34,7 | |||
|
34 | 34 | GraderConfiguration.reload |
|
35 | 35 | get root_path |
|
36 | 36 | assert_response :success |
|
37 | - post login_login_path, {login: "admin", password: "admin" } | |
|
37 | + post login_login_path, params: {login: "admin", password: "admin" } | |
|
38 | 38 | assert_redirected_to main_list_path |
|
39 | 39 | end |
|
40 | 40 | end |
You need to be logged in to leave comments.
Login now