Description:
more test on user_admin
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r752:3a8a3897c926 - - 6 files changed: 71 inserted, 59 deleted
@@ -0,0 +1,50 | |||
|
1 | + require "application_system_test_case" | |
|
2 | + | |
|
3 | + class UsersTest < ApplicationSystemTestCase | |
|
4 | + # test "visiting the index" do | |
|
5 | + # visit users_url | |
|
6 | + # | |
|
7 | + # assert_selector "h1", text: "User" | |
|
8 | + # end | |
|
9 | + | |
|
10 | + test "add new user and edit" do | |
|
11 | + login('admin','admin') | |
|
12 | + within 'header' do | |
|
13 | + click_on 'Manage' | |
|
14 | + click_on 'Users', match: :first | |
|
15 | + end | |
|
16 | + | |
|
17 | + assert_text "Users" | |
|
18 | + assert_text "New user" | |
|
19 | + | |
|
20 | + click_on "New user", match: :first | |
|
21 | + fill_in 'Login', with: 'test1' | |
|
22 | + fill_in 'Full name', with: 'test1 McTestface' | |
|
23 | + fill_in 'e-mail', with: 'a@a.com' | |
|
24 | + fill_in 'Password', with: 'abcdef' | |
|
25 | + fill_in 'Password confirmation', with: 'abcdef' | |
|
26 | + | |
|
27 | + click_on 'Create' | |
|
28 | + | |
|
29 | + assert_text 'User was successfully created' | |
|
30 | + assert_text 'a@a.com' | |
|
31 | + assert_text 'test1 McTestface' | |
|
32 | + | |
|
33 | + within('tr', text: 'McTestface') do | |
|
34 | + click_on 'Edit' | |
|
35 | + end | |
|
36 | + | |
|
37 | + fill_in 'Alias', with: 'hahaha' | |
|
38 | + fill_in 'Remark', with: 'section 2' | |
|
39 | + click_on 'Update User' | |
|
40 | + | |
|
41 | + assert_text 'section 2' | |
|
42 | + end | |
|
43 | + | |
|
44 | + def login(username,password) | |
|
45 | + visit root_path | |
|
46 | + fill_in "Login", with: username | |
|
47 | + fill_in "Password", with: password | |
|
48 | + click_on "Login" | |
|
49 | + end | |
|
50 | + end |
@@ -206,24 +206,23 | |||
|
206 | 206 | |
|
207 | 207 | def random_all_passwords |
|
208 | 208 | users = User.all |
|
209 | 209 | @prefix = params[:prefix] || '' |
|
210 | 210 | @non_admin_users = User.find_non_admin_with_prefix(@prefix) |
|
211 | 211 | @changed = false |
|
212 | - if request.request_method == 'POST' | |
|
212 | + if params[:commit] == 'Go ahead' | |
|
213 | 213 | @non_admin_users.each do |user| |
|
214 | 214 | password = random_password |
|
215 | 215 | user.password = password |
|
216 | 216 | user.password_confirmation = password |
|
217 | 217 | user.save |
|
218 | 218 | end |
|
219 | 219 | @changed = true |
|
220 | 220 | end |
|
221 | 221 | end |
|
222 | 222 | |
|
223 | - | |
|
224 | 223 | # contest management |
|
225 | 224 | |
|
226 | 225 | def contests |
|
227 | 226 | @contest, @users = find_contest_and_user_from_contest_id(params[:id]) |
|
228 | 227 | @contests = Contest.enabled |
|
229 | 228 | end |
@@ -1,38 +1,14 | |||
|
1 | - = error_messages_for 'user' | |
|
2 | - / [form:user] | |
|
3 | - .form-group | |
|
4 | - %label.col-md-2.control-label{for: :login} Login | |
|
5 | - .col-md-4 | |
|
6 | - = text_field 'user', 'login', class: 'form-control' | |
|
7 | - .col-md-6 | |
|
8 | - .form-group | |
|
9 | - %label.col-md-2.control-label{for: :full_name} Full name | |
|
10 | - .col-md-4 | |
|
11 | - = text_field 'user', 'full_name', class: 'form-control' | |
|
12 | - .col-md-6 | |
|
13 | - .form-group | |
|
14 | - %label.col-md-2.control-label{for: :password} Password | |
|
15 | - .col-md-4 | |
|
16 | - = password_field 'user', 'password', class: 'form-control' | |
|
17 | - .col-md-6 | |
|
18 | - .form-group | |
|
19 | - %label.col-md-2.control-label{for: :password_confirmation} Password (confirm) | |
|
20 | - .col-md-4 | |
|
21 | - = password_field 'user', 'password_confirmation', class: 'form-control' | |
|
22 | - .col-md-6 | |
|
23 | - .form-group | |
|
24 | - %label.col-md-2.control-label{for: :email} E-mail | |
|
25 | - .col-md-4 | |
|
26 | - = email_field 'user', 'email', class: 'form-control' | |
|
27 | - .col-md-6 | |
|
28 | - .form-group | |
|
29 | - %label.col-md-2.control-label{for: :alias} Alias | |
|
30 | - .col-md-4 | |
|
31 | - = text_field 'user', 'alias', class: 'form-control' | |
|
32 | - .col-md-6 | |
|
33 | - .form-group | |
|
34 | - %label.col-md-2.control-label{for: :remark} Remark | |
|
35 | - .col-md-4 | |
|
36 | - = text_field 'user', 'remark', class: 'form-control' | |
|
37 | - .col-md-6 | |
|
38 | - / [eoform:user] | |
|
1 | + = simple_form_for(@user) do |f| | |
|
2 | + = f.error_notification | |
|
3 | + .row | |
|
4 | + .col-md-6.col-md-offset-2 | |
|
5 | + = f.input :login, label: 'Login' | |
|
6 | + = f.input :full_name, label: 'Full name' | |
|
7 | + = f.input :password | |
|
8 | + = f.input :password_confirmation | |
|
9 | + = f.input :email | |
|
10 | + = f.input :alias | |
|
11 | + = f.input :remark | |
|
12 | + = f.button :submit, class: 'btn btn-success' | |
|
13 | + = link_to 'Cancel', :back, class: 'btn btn-default' | |
|
14 | + |
@@ -1,13 +1,4 | |||
|
1 | 1 | %h1 Editing user |
|
2 | + = simple_form_for @user, url: user_admin_path(@user) do |f| | |
|
3 | + = render partial: 'form', local: f | |
|
2 | 4 | |
|
3 | - = form_tag( {:action => 'update', :id => @user}, {class: 'form-horizontal'}) do | |
|
4 | - = error_messages_for 'user' | |
|
5 | - = render partial: "form" | |
|
6 | - .form-group | |
|
7 | - .col-md-offset-2.col-md-4 | |
|
8 | - = submit_tag "Edit", class: 'btn btn-primary' | |
|
9 | - | |
|
10 | - | |
|
11 | - = link_to 'Show', :action => 'show', :id => @user | |
|
12 | - | | |
|
13 | - = link_to 'Back', :action => 'index' |
@@ -1,7 +1,3 | |||
|
1 | 1 | %h1 New user |
|
2 | - = form_tag( {action: 'create'}, { class: 'form-horizontal'}) do | |
|
3 |
- = render |
|
|
4 | - .form-group | |
|
5 | - .col-md-offset-2.col-md-10 | |
|
6 | - = submit_tag "Create", class: 'btn btn-primary' | |
|
7 | - = link_to 'Back', :action => 'index' | |
|
2 | + = simple_form_for @user, url: user_admin_index_path do |f| | |
|
3 | + = render partial: 'form', local: f |
@@ -96,17 +96,17 | |||
|
96 | 96 | match 'bulk_manage', via: [:get, :post] |
|
97 | 97 | get 'bulk_mail' |
|
98 | 98 | get 'user_stat' |
|
99 | 99 | get 'import' |
|
100 | 100 | get 'new_list' |
|
101 | 101 | get 'admin' |
|
102 | - get 'random_all_passwords' | |
|
103 | 102 | get 'active' |
|
104 | 103 | get 'mass_mailing' |
|
104 | + post 'grant_admin' | |
|
105 | 105 | match 'create_from_list', via: [:get, :post] |
|
106 | - post 'grant_admin' | |
|
106 | + match 'random_all_passwords', via: [:get, :post] | |
|
107 | 107 | end |
|
108 | 108 | member do |
|
109 | 109 | get 'clear_last_ip' |
|
110 | 110 | end |
|
111 | 111 | end |
|
112 | 112 |
You need to be logged in to leave comments.
Login now