From cc8bb7c6a5730e9d7d0389e4efd4c896702f575f Mon Sep 17 00:00:00 2001 From: Andy Allan Date: Wed, 20 Jan 2021 12:02:41 +0000 Subject: [PATCH] Refactor user registration form to use bootstrap --- app/views/users/new.html.erb | 71 +++++------------------ test/controllers/users_controller_test.rb | 10 ++-- test/integration/user_creation_test.rb | 5 +- 3 files changed, 23 insertions(+), 63 deletions(-) diff --git a/app/views/users/new.html.erb b/app/views/users/new.html.erb index 6f97a284a..f8d3a7e8e 100644 --- a/app/views/users/new.html.erb +++ b/app/views/users/new.html.erb @@ -15,72 +15,31 @@
- <%= form_for current_user, :url => { :action => "create" }, :html => { :class => "standard-form" } do |f| %> + <%= bootstrap_form_for current_user, :url => { :action => "create" } do |f| %> <%= hidden_field_tag("referer", h(@referer)) unless @referer.nil? %> -
-
- - <%= f.email_field(:email, :tabindex => 1) %> - <%= f.error_message_on(:email) %> -
-
- - <%= f.email_field(:email_confirmation, :tabindex => 2) %> - <%= f.error_message_on(:email_confirmation) %> -
- <%= t(".not_displayed_publicly_html") %> -
+ <%= f.email_field :email, :label => t(".email address"), :tabindex => 1 %> + <%= f.email_field :email_confirmation, :label => t(".confirm email address"), :help => t(".not_displayed_publicly_html"), :tabindex => 2 %> -
-
- - <%= f.text_field(:display_name, :tabindex => 3) %> - <%= f.error_message_on(:display_name) %> -
- <%= t ".display name description" %> -
+ <%= f.text_field :display_name, :label => t(".display name"), :help => t(".display name description"), :tabindex => 3 %> -
-
- - <%= f.select(:auth_provider, Auth.providers, :default => "", :tabindex => 4) %> - <%= f.text_field(:auth_uid, :tabindex => 5) %> - <%= f.error_message_on(:auth_uid) %> +
+ +
+ <%= f.select(:auth_provider, Auth.providers, :default => "", :hide_label => "true", :wrapper => { :class => "col-auto mb-0" }, :tabindex => 4) %> + <%= f.text_field(:auth_uid, :hide_label => true, :wrapper => { :class => "col mb-0" }, :tabindex => 5) %>
- <%= t ".auth no password" %> + <%= t ".auth no password" %>
-
-
- - <%= f.password_field(:pass_crypt, :tabindex => 6) %> - <%= f.error_message_on(:pass_crypt) %> -
-
- - <%= f.password_field(:pass_crypt_confirmation, :tabindex => 7) %> - <%= f.error_message_on(:pass_crypt_confirmation) %> -
-
+ <%= f.password_field :pass_crypt, :tabindex => 6 %> + <%= f.password_field :pass_crypt_confirmation, :tabindex => 7 %> -
- <%= link_to t(".use external auth"), "#", :id => "auth_enable" %> +
+

<%= link_to t(".use external auth"), "#", :id => "auth_enable" %>

- <%= submit_tag t(".continue"), :tabindex => 8 %> + <%= f.primary t(".continue"), :tabindex => 8 %> <% end %>
diff --git a/test/controllers/users_controller_test.rb b/test/controllers/users_controller_test.rb index 12a804bc5..c21f82046 100644 --- a/test/controllers/users_controller_test.rb +++ b/test/controllers/users_controller_test.rb @@ -233,7 +233,7 @@ class UsersControllerTest < ActionDispatch::IntegrationTest assert_response :success assert_template "new" - assert_select "form > fieldset > div.standard-form-row > input.field_with_errors#user_email" + assert_select "form > div.form-group > input.is-invalid#user_email" end def test_save_duplicate_email @@ -262,7 +262,7 @@ class UsersControllerTest < ActionDispatch::IntegrationTest assert_response :success assert_template "new" - assert_select "form > fieldset > div.standard-form-row > input.field_with_errors#user_email" + assert_select "form > div.form-group > input.is-invalid#user_email" end def test_save_duplicate_email_uppercase @@ -291,7 +291,7 @@ class UsersControllerTest < ActionDispatch::IntegrationTest assert_response :success assert_template "new" - assert_select "form > fieldset > div.standard-form-row > input.field_with_errors#user_email" + assert_select "form > div.form-group > input.is-invalid#user_email" end def test_save_duplicate_name @@ -320,7 +320,7 @@ class UsersControllerTest < ActionDispatch::IntegrationTest assert_response :success assert_template "new" - assert_select "form > fieldset > div.standard-form-row > input.field_with_errors#user_display_name" + assert_select "form > div.form-group > input.is-invalid#user_display_name" end def test_save_duplicate_name_uppercase @@ -349,7 +349,7 @@ class UsersControllerTest < ActionDispatch::IntegrationTest assert_response :success assert_template "new" - assert_select "form > fieldset > div.standard-form-row > input.field_with_errors#user_display_name" + assert_select "form > div.form-group > input.is-invalid#user_display_name" end def test_save_blocked_domain diff --git a/test/integration/user_creation_test.rb b/test/integration/user_creation_test.rb index 8b6b3ef3c..f331a4b98 100644 --- a/test/integration/user_creation_test.rb +++ b/test/integration/user_creation_test.rb @@ -51,7 +51,8 @@ class UserCreationTest < ActionDispatch::IntegrationTest assert_response :success assert_template "users/new" assert_equal locale.to_s, response.headers["Content-Language"] - assert_select "form > fieldset > div.standard-form-row > input.field_with_errors#user_email" + assert_select "form" + assert_select "form > div.form-group > input.is-invalid#user_email" assert_no_missing_translations end end @@ -75,7 +76,7 @@ class UserCreationTest < ActionDispatch::IntegrationTest end assert_response :success assert_template "users/new" - assert_select "form > fieldset > div.standard-form-row > input.field_with_errors#user_display_name" + assert_select "form > div.form-group > input.is-invalid#user_display_name" assert_no_missing_translations end end -- 2.43.2