Description:
fix test to match button name in create new list of user
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r781:e1003a3daa2b - - 2 files changed: 1 inserted, 2 deleted

@@ -54,152 +54,151
54 post 'add_problem', to: 'groups#add_problem', as: 'add_problem'
54 post 'add_problem', to: 'groups#add_problem', as: 'add_problem'
55 delete 'remove_problem/:problem_id', to: 'groups#remove_problem', as: 'remove_problem'
55 delete 'remove_problem/:problem_id', to: 'groups#remove_problem', as: 'remove_problem'
56 delete 'remove_all_problem', to: 'groups#remove_all_problem', as: 'remove_all_problem'
56 delete 'remove_all_problem', to: 'groups#remove_all_problem', as: 'remove_all_problem'
57 end
57 end
58 collection do
58 collection do
59
59
60 end
60 end
61 end
61 end
62
62
63 resources :testcases, only: [] do
63 resources :testcases, only: [] do
64 member do
64 member do
65 get 'download_input'
65 get 'download_input'
66 get 'download_sol'
66 get 'download_sol'
67 end
67 end
68 collection do
68 collection do
69 get 'show_problem/:problem_id(/:test_num)' => 'testcases#show_problem', as: 'show_problem'
69 get 'show_problem/:problem_id(/:test_num)' => 'testcases#show_problem', as: 'show_problem'
70 end
70 end
71 end
71 end
72
72
73 resources :grader_configuration, controller: 'configurations' do
73 resources :grader_configuration, controller: 'configurations' do
74 collection do
74 collection do
75 get 'set_exam_right(/:value)', action: 'set_exam_right', as: 'set_exam_right'
75 get 'set_exam_right(/:value)', action: 'set_exam_right', as: 'set_exam_right'
76 end
76 end
77 end
77 end
78
78
79 resources :users do
79 resources :users do
80 member do
80 member do
81 get 'toggle_activate', 'toggle_enable'
81 get 'toggle_activate', 'toggle_enable'
82 get 'stat'
82 get 'stat'
83 end
83 end
84 collection do
84 collection do
85 get 'profile'
85 get 'profile'
86 post 'chg_passwd'
86 post 'chg_passwd'
87 end
87 end
88 end
88 end
89
89
90 resources :submissions do
90 resources :submissions do
91 member do
91 member do
92 get 'download'
92 get 'download'
93 get 'compiler_msg'
93 get 'compiler_msg'
94 get 'rejudge'
94 get 'rejudge'
95 get 'source'
95 get 'source'
96 end
96 end
97 collection do
97 collection do
98 get 'prob/:problem_id', to: 'submissions#index', as: 'problem'
98 get 'prob/:problem_id', to: 'submissions#index', as: 'problem'
99 get 'direct_edit_problem/:problem_id(/:user_id)', to: 'submissions#direct_edit_problem', as: 'direct_edit_problem'
99 get 'direct_edit_problem/:problem_id(/:user_id)', to: 'submissions#direct_edit_problem', as: 'direct_edit_problem'
100 get 'get_latest_submission_status/:uid/:pid', to: 'submissions#get_latest_submission_status', as: 'get_latest_submission_status'
100 get 'get_latest_submission_status/:uid/:pid', to: 'submissions#get_latest_submission_status', as: 'get_latest_submission_status'
101 end
101 end
102 end
102 end
103
103
104
104
105 #user admin
105 #user admin
106 resources :user_admin do
106 resources :user_admin do
107 collection do
107 collection do
108 match 'bulk_manage', via: [:get, :post]
108 match 'bulk_manage', via: [:get, :post]
109 get 'bulk_mail'
109 get 'bulk_mail'
110 get 'user_stat'
110 get 'user_stat'
111 get 'import'
111 get 'import'
112 get 'new_list'
112 get 'new_list'
113 get 'admin'
113 get 'admin'
114 get 'active'
114 get 'active'
115 get 'mass_mailing'
115 get 'mass_mailing'
116 get 'revoke_admin'
116 get 'revoke_admin'
117 post 'grant_admin'
117 post 'grant_admin'
118 match 'create_from_list', via: [:get, :post]
118 match 'create_from_list', via: [:get, :post]
119 match 'random_all_passwords', via: [:get, :post]
119 match 'random_all_passwords', via: [:get, :post]
120 end
120 end
121 member do
121 member do
122 get 'clear_last_ip'
122 get 'clear_last_ip'
123 end
123 end
124 end
124 end
125
125
126 resources :contest_management, only: [:index] do
126 resources :contest_management, only: [:index] do
127 collection do
127 collection do
128 get 'user_stat'
128 get 'user_stat'
129 get 'clear_stat'
129 get 'clear_stat'
130 get 'clear_all_stat'
130 get 'clear_all_stat'
131 get 'change_contest_mode'
131 get 'change_contest_mode'
132 end
132 end
133 end
133 end
134
134
135 #get 'user_admin', to: 'user_admin#index'
135 #get 'user_admin', to: 'user_admin#index'
136 #get 'user_admin/bulk_manage', to: 'user_admin#bulk_manage', as: 'bulk_manage_user_admin'
136 #get 'user_admin/bulk_manage', to: 'user_admin#bulk_manage', as: 'bulk_manage_user_admin'
137 #post 'user_admin', to: 'user_admin#create'
137 #post 'user_admin', to: 'user_admin#create'
138 #delete 'user_admin/:id', to: 'user_admin#destroy', as: 'user_admin_destroy'
138 #delete 'user_admin/:id', to: 'user_admin#destroy', as: 'user_admin_destroy'
139
139
140 #singular resource
140 #singular resource
141 #---- BEWARE ---- singular resource maps to plural controller by default, we can override by provide controller name directly
141 #---- BEWARE ---- singular resource maps to plural controller by default, we can override by provide controller name directly
142 #report
142 #report
143 resource :report, only: [], controller: 'report' do
143 resource :report, only: [], controller: 'report' do
144 get 'login'
144 get 'login'
145 get 'multiple_login'
145 get 'multiple_login'
146 get 'problem_hof(/:id)', action: 'problem_hof', as: 'problem_hof'
146 get 'problem_hof(/:id)', action: 'problem_hof', as: 'problem_hof'
147 get 'current_score(/:group_id)', action: 'current_score', as: 'current_score'
147 get 'current_score(/:group_id)', action: 'current_score', as: 'current_score'
148 get 'max_score'
148 get 'max_score'
149 post 'show_max_score'
149 post 'show_max_score'
150 - get 'problem_hof(/:id)', action: 'problem_hof', as: 'problem_hof'
151 get 'stuck'
150 get 'stuck'
152 get 'cheat_report'
151 get 'cheat_report'
153 post 'cheat_report'
152 post 'cheat_report'
154 get 'cheat_scruntinize'
153 get 'cheat_scruntinize'
155 post 'cheat_scruntinize'
154 post 'cheat_scruntinize'
156 end
155 end
157 #get 'report/current_score', to: 'report#current_score', as: 'report_current_score'
156 #get 'report/current_score', to: 'report#current_score', as: 'report_current_score'
158 #get 'report/problem_hof(/:id)', to: 'report#problem_hof', as: 'report_problem_hof'
157 #get 'report/problem_hof(/:id)', to: 'report#problem_hof', as: 'report_problem_hof'
159 #get "report/login"
158 #get "report/login"
160 #get 'report/max_score', to: 'report#max_score', as: 'report_max_score'
159 #get 'report/max_score', to: 'report#max_score', as: 'report_max_score'
161 #post 'report/show_max_score', to: 'report#show_max_score', as: 'report_show_max_score'
160 #post 'report/show_max_score', to: 'report#show_max_score', as: 'report_show_max_score'
162
161
163 resource :main, only: [], controller: 'main' do
162 resource :main, only: [], controller: 'main' do
164 get 'login'
163 get 'login'
165 get 'logout'
164 get 'logout'
166 get 'list'
165 get 'list'
167 get 'submission(/:id)', action: 'submission', as: 'main_submission'
166 get 'submission(/:id)', action: 'submission', as: 'main_submission'
168 get 'announcements'
167 get 'announcements'
169 get 'help'
168 get 'help'
170 post 'submit'
169 post 'submit'
171 end
170 end
172 #main
171 #main
173 #get "main/list"
172 #get "main/list"
174 #get 'main/submission(/:id)', to: 'main#submission', as: 'main_submission'
173 #get 'main/submission(/:id)', to: 'main#submission', as: 'main_submission'
175 #post 'main/submit', to: 'main#submit'
174 #post 'main/submit', to: 'main#submit'
176 #get 'main/announcements', to: 'main#announcements'
175 #get 'main/announcements', to: 'main#announcements'
177
176
178
177
179 #
178 #
180 get 'tasks/view/:file.:ext' => 'tasks#view'
179 get 'tasks/view/:file.:ext' => 'tasks#view'
181 get 'tasks/download/:id/:file.:ext' => 'tasks#download'
180 get 'tasks/download/:id/:file.:ext' => 'tasks#download'
182 get 'heartbeat/:id/edit' => 'heartbeat#edit'
181 get 'heartbeat/:id/edit' => 'heartbeat#edit'
183
182
184 #grader
183 #grader
185 get 'graders/list', to: 'graders#list', as: 'grader_list'
184 get 'graders/list', to: 'graders#list', as: 'grader_list'
186 namespace :graders do
185 namespace :graders do
187 get 'task/:id/:type', action: 'task', as: 'task'
186 get 'task/:id/:type', action: 'task', as: 'task'
188 get 'view/:id/:type', action: 'view', as: 'view'
187 get 'view/:id/:type', action: 'view', as: 'view'
189 get 'clear/:id', action: 'clear', as: 'clear'
188 get 'clear/:id', action: 'clear', as: 'clear'
190 get 'stop'
189 get 'stop'
191 get 'stop_all'
190 get 'stop_all'
192 get 'clear_all'
191 get 'clear_all'
193 get 'clear_terminated'
192 get 'clear_terminated'
194 get 'start_grading'
193 get 'start_grading'
195 get 'start_exam'
194 get 'start_exam'
196
195
197 end
196 end
198
197
199
198
200 # See how all your routes lay out with "rake routes"
199 # See how all your routes lay out with "rake routes"
201
200
202 # This is a legacy wild controller route that's not recommended for RESTful applications.
201 # This is a legacy wild controller route that's not recommended for RESTful applications.
203 # Note: This route will make all actions in every controller accessible via GET requests.
202 # Note: This route will make all actions in every controller accessible via GET requests.
204 # match ':controller(/:action(/:id))(.:format)', via: [:get, :post]
203 # match ':controller(/:action(/:id))(.:format)', via: [:get, :post]
205 end
204 end
@@ -1,121 +1,121
1 require "application_system_test_case"
1 require "application_system_test_case"
2
2
3 class UsersTest < ApplicationSystemTestCase
3 class UsersTest < ApplicationSystemTestCase
4 # test "visiting the index" do
4 # test "visiting the index" do
5 # visit users_url
5 # visit users_url
6 #
6 #
7 # assert_selector "h1", text: "User"
7 # assert_selector "h1", text: "User"
8 # end
8 # end
9
9
10 test "add new user and edit" do
10 test "add new user and edit" do
11 login('admin','admin')
11 login('admin','admin')
12 within 'header' do
12 within 'header' do
13 click_on 'Manage'
13 click_on 'Manage'
14 click_on 'Users', match: :first
14 click_on 'Users', match: :first
15 end
15 end
16
16
17 assert_text "Users"
17 assert_text "Users"
18 assert_text "New user"
18 assert_text "New user"
19
19
20 click_on "New user", match: :first
20 click_on "New user", match: :first
21 fill_in 'Login', with: 'test1'
21 fill_in 'Login', with: 'test1'
22 fill_in 'Full name', with: 'test1 McTestface'
22 fill_in 'Full name', with: 'test1 McTestface'
23 fill_in 'e-mail', with: 'a@a.com'
23 fill_in 'e-mail', with: 'a@a.com'
24 fill_in 'Password', with: 'abcdef'
24 fill_in 'Password', with: 'abcdef'
25 fill_in 'Password confirmation', with: 'abcdef'
25 fill_in 'Password confirmation', with: 'abcdef'
26
26
27 click_on 'Create'
27 click_on 'Create'
28
28
29 assert_text 'User was successfully created'
29 assert_text 'User was successfully created'
30 assert_text 'a@a.com'
30 assert_text 'a@a.com'
31 assert_text 'test1 McTestface'
31 assert_text 'test1 McTestface'
32
32
33 within('tr', text: 'McTestface') do
33 within('tr', text: 'McTestface') do
34 click_on 'Edit'
34 click_on 'Edit'
35 end
35 end
36
36
37 fill_in 'Alias', with: 'hahaha'
37 fill_in 'Alias', with: 'hahaha'
38 fill_in 'Remark', with: 'section 2'
38 fill_in 'Remark', with: 'section 2'
39 click_on 'Update User'
39 click_on 'Update User'
40
40
41 assert_text 'section 2'
41 assert_text 'section 2'
42 end
42 end
43
43
44 test "add multiple users" do
44 test "add multiple users" do
45 login 'admin', 'admin'
45 login 'admin', 'admin'
46 within 'header' do
46 within 'header' do
47 click_on 'Manage'
47 click_on 'Manage'
48 click_on 'Users', match: :first
48 click_on 'Users', match: :first
49 end
49 end
50
50
51 click_on 'New list of users', match: :first
51 click_on 'New list of users', match: :first
52 find(:css, 'textarea').fill_in with:"abc1,Boaty McBoatface,abcdef,alias1,remark1,\nabc2,Boaty2 McSecond,acbdef123,aias2,remark2"
52 find(:css, 'textarea').fill_in with:"abc1,Boaty McBoatface,abcdef,alias1,remark1,\nabc2,Boaty2 McSecond,acbdef123,aias2,remark2"
53 - click_on 'create users'
53 + click_on 'Create following users'
54
54
55 assert_text('remark1')
55 assert_text('remark1')
56 assert_text('remark2')
56 assert_text('remark2')
57 end
57 end
58
58
59 test "grant admin right" do
59 test "grant admin right" do
60 login 'admin', 'admin'
60 login 'admin', 'admin'
61 within 'header' do
61 within 'header' do
62 click_on 'Manage'
62 click_on 'Manage'
63 click_on 'Users', match: :first
63 click_on 'Users', match: :first
64 end
64 end
65
65
66 click_on "View administrator"
66 click_on "View administrator"
67 fill_in 'login', with: 'john'
67 fill_in 'login', with: 'john'
68 click_on "Grant"
68 click_on "Grant"
69
69
70 visit logout_main_path
70 visit logout_main_path
71 login 'john','hello'
71 login 'john','hello'
72 within 'header' do
72 within 'header' do
73 click_on 'Manage'
73 click_on 'Manage'
74 click_on 'Problem', match: :first
74 click_on 'Problem', match: :first
75 end
75 end
76 assert_text "Turn off all problems"
76 assert_text "Turn off all problems"
77 end
77 end
78
78
79 test "try using admin from normal user" do
79 test "try using admin from normal user" do
80 login 'admin','admin'
80 login 'admin','admin'
81 visit bulk_manage_user_admin_index_path
81 visit bulk_manage_user_admin_index_path
82 assert_current_path bulk_manage_user_admin_index_path
82 assert_current_path bulk_manage_user_admin_index_path
83 visit logout_main_path
83 visit logout_main_path
84
84
85 login 'jack','morning'
85 login 'jack','morning'
86 visit bulk_manage_user_admin_index_path
86 visit bulk_manage_user_admin_index_path
87 assert_text 'You are not authorized'
87 assert_text 'You are not authorized'
88 assert_current_path login_main_path
88 assert_current_path login_main_path
89
89
90 login 'james','morning'
90 login 'james','morning'
91 visit new_list_user_admin_index_path
91 visit new_list_user_admin_index_path
92 assert_text 'You are not authorized'
92 assert_text 'You are not authorized'
93 assert_current_path login_main_path
93 assert_current_path login_main_path
94 end
94 end
95
95
96 test "login then change password" do
96 test "login then change password" do
97 newpassword = '1234asdf'
97 newpassword = '1234asdf'
98 login 'john', 'hello'
98 login 'john', 'hello'
99 visit profile_users_path
99 visit profile_users_path
100
100
101 fill_in 'password', with: newpassword
101 fill_in 'password', with: newpassword
102 fill_in 'password_confirmation', with: newpassword
102 fill_in 'password_confirmation', with: newpassword
103
103
104 click_on 'Edit'
104 click_on 'Edit'
105
105
106 visit logout_main_path
106 visit logout_main_path
107 login 'john', 'hello'
107 login 'john', 'hello'
108 assert_text 'Wrong password'
108 assert_text 'Wrong password'
109
109
110 login 'john', newpassword
110 login 'john', newpassword
111 assert_text "MAIN"
111 assert_text "MAIN"
112 assert_text "Submission"
112 assert_text "Submission"
113 end
113 end
114
114
115 def login(username,password)
115 def login(username,password)
116 visit root_path
116 visit root_path
117 fill_in "Login", with: username
117 fill_in "Login", with: username
118 fill_in "Password", with: password
118 fill_in "Password", with: password
119 click_on "Login"
119 click_on "Login"
120 end
120 end
121 end
121 end
You need to be logged in to leave comments. Login now