From 7f4c4e68296e9c93cfb5ecb57f75e7f061b41925 Mon Sep 17 00:00:00 2001 From: Aleksandar Petrushev Date: Thu, 3 Feb 2022 17:27:28 +0100 Subject: [PATCH 1/4] Add Names to Users --- app/views/spree/admin/users/_form.html.erb | 44 +++++++++++++++------- spec/features/admin/users_spec.rb | 11 ++++++ 2 files changed, 42 insertions(+), 13 deletions(-) diff --git a/app/views/spree/admin/users/_form.html.erb b/app/views/spree/admin/users/_form.html.erb index d643155b0c..8a907901aa 100644 --- a/app/views/spree/admin/users/_form.html.erb +++ b/app/views/spree/admin/users/_form.html.erb @@ -1,35 +1,53 @@
<%= f.field_container :email do %> - <%= f.label :email, Spree.t(:email) %> + <%= f.label :email, raw(Spree.t(:email) + required_span_tag) %> <%= f.email_field :email, class: 'form-control' %> <%= f.error_message_on :email %> <% end %> +
-
- <%= Spree.t(:roles) %> - <%= f.collection_check_boxes :spree_role_ids, Spree::Role.all, :id, :name do |role_form| %> -
- <%= role_form.label for: "user_spree_role_#{role_form.object.name}" do %> - <%= role_form.check_box id: "user_spree_role_#{role_form.object.name}" %> - <%= role_form.object.name %> - <% end %> -
- <% end %> -
+
+ <%= Spree.t(:roles) %> + <%= f.collection_check_boxes :spree_role_ids, Spree::Role.all, :id, :name do |role_form| %> +
+ <%= role_form.label for: "user_spree_role_#{role_form.object.name}" do %> + <%= role_form.check_box id: "user_spree_role_#{role_form.object.name}" %> + <%= role_form.object.name %> + <% end %> +
+ <% end %>
-
+
<%= f.field_container :password do %> <%= f.label :password, Spree.t(:password) %> <%= f.password_field :password, class: 'form-control' %> <%= f.error_message_on :password %> <% end %> +
+
<%= f.field_container :password_confirmation do %> <%= f.label :password_confirmation, Spree.t(:confirm_password) %> <%= f.password_field :password_confirmation, class: 'form-control' %> <%= f.error_message_on :password_confirmation %> <% end %>
+ +
+ <%= f.field_container :first_name do %> + <%= f.label :first_name, Spree.t(:first_name) %> + <%= f.text_field :first_name, class: 'form-control' %> + <%= f.error_message_on :first_name %> + <% end %> +
+ +
+ <%= f.field_container :last_name do %> + <%= f.label :last_name, Spree.t(:last_name) %> + <%= f.text_field :last_name, class: 'form-control' %> + <%= f.error_message_on :last_name %> + <% end %> +
diff --git a/spec/features/admin/users_spec.rb b/spec/features/admin/users_spec.rb index 945b527571..abfb3d1c73 100644 --- a/spec/features/admin/users_spec.rb +++ b/spec/features/admin/users_spec.rb @@ -183,6 +183,17 @@ expect(page).to have_checked_field('user_spree_role_admin') end + it 'can edit first and last name' do + fill_in 'user_first_name', with: 'John' + fill_in 'user_last_name', with: 'Doe' + click_button 'Update' + + expect(page).to have_text 'Account updated' + user_a.reload + expect(user_a.first_name).to eq 'John' + expect(user_a.last_name).to eq 'Doe' + end + it 'can edit user shipping address' do click_link 'Addresses' From 32e2758a3b9396ac8abf56f5a6bd8b30724cb63c Mon Sep 17 00:00:00 2001 From: Aleksandar Petrushev Date: Fri, 4 Feb 2022 16:07:09 +0100 Subject: [PATCH 2/4] Add HTML required validations for new User --- app/views/spree/admin/users/_form.html.erb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/views/spree/admin/users/_form.html.erb b/app/views/spree/admin/users/_form.html.erb index 8a907901aa..ab7146659a 100644 --- a/app/views/spree/admin/users/_form.html.erb +++ b/app/views/spree/admin/users/_form.html.erb @@ -2,7 +2,7 @@
<%= f.field_container :email do %> <%= f.label :email, raw(Spree.t(:email) + required_span_tag) %> - <%= f.email_field :email, class: 'form-control' %> + <%= f.email_field :email, class: 'form-control', required: true %> <%= f.error_message_on :email %> <% end %>
@@ -22,7 +22,7 @@
<%= f.field_container :password do %> <%= f.label :password, Spree.t(:password) %> - <%= f.password_field :password, class: 'form-control' %> + <%= f.password_field :password, class: 'form-control', required: true %> <%= f.error_message_on :password %> <% end %>
@@ -30,7 +30,7 @@
<%= f.field_container :password_confirmation do %> <%= f.label :password_confirmation, Spree.t(:confirm_password) %> - <%= f.password_field :password_confirmation, class: 'form-control' %> + <%= f.password_field :password_confirmation, class: 'form-control', required: true %> <%= f.error_message_on :password_confirmation %> <% end %>
From 675fe04200168afaa2c7e43bc12903ecd600cab6 Mon Sep 17 00:00:00 2001 From: Aleksandar Petrushev Date: Thu, 3 Feb 2022 17:27:28 +0100 Subject: [PATCH 3/4] Add Names to Users --- app/views/spree/admin/users/_form.html.erb | 44 +++++++++++++++------- spec/features/admin/users_spec.rb | 11 ++++++ 2 files changed, 42 insertions(+), 13 deletions(-) diff --git a/app/views/spree/admin/users/_form.html.erb b/app/views/spree/admin/users/_form.html.erb index d643155b0c..8a907901aa 100644 --- a/app/views/spree/admin/users/_form.html.erb +++ b/app/views/spree/admin/users/_form.html.erb @@ -1,35 +1,53 @@
<%= f.field_container :email do %> - <%= f.label :email, Spree.t(:email) %> + <%= f.label :email, raw(Spree.t(:email) + required_span_tag) %> <%= f.email_field :email, class: 'form-control' %> <%= f.error_message_on :email %> <% end %> +
-
- <%= Spree.t(:roles) %> - <%= f.collection_check_boxes :spree_role_ids, Spree::Role.all, :id, :name do |role_form| %> -
- <%= role_form.label for: "user_spree_role_#{role_form.object.name}" do %> - <%= role_form.check_box id: "user_spree_role_#{role_form.object.name}" %> - <%= role_form.object.name %> - <% end %> -
- <% end %> -
+
+ <%= Spree.t(:roles) %> + <%= f.collection_check_boxes :spree_role_ids, Spree::Role.all, :id, :name do |role_form| %> +
+ <%= role_form.label for: "user_spree_role_#{role_form.object.name}" do %> + <%= role_form.check_box id: "user_spree_role_#{role_form.object.name}" %> + <%= role_form.object.name %> + <% end %> +
+ <% end %>
-
+
<%= f.field_container :password do %> <%= f.label :password, Spree.t(:password) %> <%= f.password_field :password, class: 'form-control' %> <%= f.error_message_on :password %> <% end %> +
+
<%= f.field_container :password_confirmation do %> <%= f.label :password_confirmation, Spree.t(:confirm_password) %> <%= f.password_field :password_confirmation, class: 'form-control' %> <%= f.error_message_on :password_confirmation %> <% end %>
+ +
+ <%= f.field_container :first_name do %> + <%= f.label :first_name, Spree.t(:first_name) %> + <%= f.text_field :first_name, class: 'form-control' %> + <%= f.error_message_on :first_name %> + <% end %> +
+ +
+ <%= f.field_container :last_name do %> + <%= f.label :last_name, Spree.t(:last_name) %> + <%= f.text_field :last_name, class: 'form-control' %> + <%= f.error_message_on :last_name %> + <% end %> +
diff --git a/spec/features/admin/users_spec.rb b/spec/features/admin/users_spec.rb index 945b527571..abfb3d1c73 100644 --- a/spec/features/admin/users_spec.rb +++ b/spec/features/admin/users_spec.rb @@ -183,6 +183,17 @@ expect(page).to have_checked_field('user_spree_role_admin') end + it 'can edit first and last name' do + fill_in 'user_first_name', with: 'John' + fill_in 'user_last_name', with: 'Doe' + click_button 'Update' + + expect(page).to have_text 'Account updated' + user_a.reload + expect(user_a.first_name).to eq 'John' + expect(user_a.last_name).to eq 'Doe' + end + it 'can edit user shipping address' do click_link 'Addresses' From 9aaa837af8fbcb6e11e16d14ac7b9087bd46ea08 Mon Sep 17 00:00:00 2001 From: Aleksandar Petrushev Date: Fri, 4 Feb 2022 16:07:09 +0100 Subject: [PATCH 4/4] Add HTML required validations for new User --- app/views/spree/admin/users/_form.html.erb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/views/spree/admin/users/_form.html.erb b/app/views/spree/admin/users/_form.html.erb index 8a907901aa..ab7146659a 100644 --- a/app/views/spree/admin/users/_form.html.erb +++ b/app/views/spree/admin/users/_form.html.erb @@ -2,7 +2,7 @@
<%= f.field_container :email do %> <%= f.label :email, raw(Spree.t(:email) + required_span_tag) %> - <%= f.email_field :email, class: 'form-control' %> + <%= f.email_field :email, class: 'form-control', required: true %> <%= f.error_message_on :email %> <% end %>
@@ -22,7 +22,7 @@
<%= f.field_container :password do %> <%= f.label :password, Spree.t(:password) %> - <%= f.password_field :password, class: 'form-control' %> + <%= f.password_field :password, class: 'form-control', required: true %> <%= f.error_message_on :password %> <% end %>
@@ -30,7 +30,7 @@
<%= f.field_container :password_confirmation do %> <%= f.label :password_confirmation, Spree.t(:confirm_password) %> - <%= f.password_field :password_confirmation, class: 'form-control' %> + <%= f.password_field :password_confirmation, class: 'form-control', required: true %> <%= f.error_message_on :password_confirmation %> <% end %>