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 |
@@ -209,7 +209,7 | |||||
|
209 | @prefix = params[:prefix] || '' |
|
209 | @prefix = params[:prefix] || '' |
|
210 | @non_admin_users = User.find_non_admin_with_prefix(@prefix) |
|
210 | @non_admin_users = User.find_non_admin_with_prefix(@prefix) |
|
211 | @changed = false |
|
211 | @changed = false |
|
212 | - if request.request_method == 'POST' |
|
212 | + if params[:commit] == 'Go ahead' |
|
213 | @non_admin_users.each do |user| |
|
213 | @non_admin_users.each do |user| |
|
214 | password = random_password |
|
214 | password = random_password |
|
215 | user.password = password |
|
215 | user.password = password |
@@ -220,7 +220,6 | |||||
|
220 | end |
|
220 | end |
|
221 | end |
|
221 | end |
|
222 |
|
222 | ||
|
223 | - |
|
||
|
224 | # contest management |
|
223 | # contest management |
|
225 |
|
224 | ||
|
226 | def contests |
|
225 | def contests |
@@ -1,38 +1,14 | |||||
|
1 | - = error_messages_for 'user' |
|
1 | + = simple_form_for(@user) do |f| |
|
2 | - / [form:user] |
|
2 | + = f.error_notification |
|
3 | - .form-group |
|
3 | + .row |
|
4 | - %label.col-md-2.control-label{for: :login} Login |
|
4 | + .col-md-6.col-md-offset-2 |
|
5 | - .col-md-4 |
|
5 | + = f.input :login, label: 'Login' |
|
6 | - = text_field 'user', 'login', class: 'form-control' |
|
6 | + = f.input :full_name, label: 'Full name' |
|
7 | - .col-md-6 |
|
7 | + = f.input :password |
|
8 | - .form-group |
|
8 | + = f.input :password_confirmation |
|
9 | - %label.col-md-2.control-label{for: :full_name} Full name |
|
9 | + = f.input :email |
|
10 | - .col-md-4 |
|
10 | + = f.input :alias |
|
11 | - = text_field 'user', 'full_name', class: 'form-control' |
|
11 | + = f.input :remark |
|
12 | - .col-md-6 |
|
12 | + = f.button :submit, class: 'btn btn-success' |
|
13 | - .form-group |
|
13 | + = link_to 'Cancel', :back, class: 'btn btn-default' |
|
14 | - %label.col-md-2.control-label{for: :password} Password |
|
14 | + |
|
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,13 +1,4 | |||||
|
1 | %h1 Editing user |
|
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 | %h1 New user |
|
1 | %h1 New user |
|
2 | - = form_tag( {action: 'create'}, { class: 'form-horizontal'}) do |
|
2 | + = simple_form_for @user, url: user_admin_index_path do |f| |
|
3 |
- = render |
|
3 | + = render partial: 'form', local: f |
|
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' |
|
@@ -99,11 +99,11 | |||||
|
99 | get 'import' |
|
99 | get 'import' |
|
100 | get 'new_list' |
|
100 | get 'new_list' |
|
101 | get 'admin' |
|
101 | get 'admin' |
|
102 | - get 'random_all_passwords' |
|
||
|
103 | get 'active' |
|
102 | get 'active' |
|
104 | get 'mass_mailing' |
|
103 | get 'mass_mailing' |
|
|
104 | + post 'grant_admin' | ||
|
105 | match 'create_from_list', via: [:get, :post] |
|
105 | match 'create_from_list', via: [:get, :post] |
|
106 | - post 'grant_admin' |
|
106 | + match 'random_all_passwords', via: [:get, :post] |
|
107 | end |
|
107 | end |
|
108 | member do |
|
108 | member do |
|
109 | get 'clear_last_ip' |
|
109 | get 'clear_last_ip' |
You need to be logged in to leave comments.
Login now