Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VEN-109 Add Names to Users #139

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 34 additions & 16 deletions app/views/spree/admin/users/_form.html.erb
Original file line number Diff line number Diff line change
@@ -1,35 +1,53 @@
<div data-hook="admin_user_form_fields" class="row">
<div class="col-12 col-md-6">
<%= f.field_container :email do %>
<%= f.label :email, Spree.t(:email) %>
<%= f.email_field :email, class: 'form-control' %>
<%= f.label :email, raw(Spree.t(:email) + required_span_tag) %>
<%= f.email_field :email, class: 'form-control', required: true %>
<%= f.error_message_on :email %>
<% end %>
</div>

<div data-hook="admin_user_form_roles" class="form-group">
<strong><%= Spree.t(:roles) %></strong>
<%= f.collection_check_boxes :spree_role_ids, Spree::Role.all, :id, :name do |role_form| %>
<div class="checkbox">
<%= 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 %>
</div>
<% end %>
</div>
<div data-hook="admin_user_form_roles" class="col-12 col-md-6 form-group">
<strong><%= Spree.t(:roles) %></strong>
<%= f.collection_check_boxes :spree_role_ids, Spree::Role.all, :id, :name do |role_form| %>
<div class="checkbox">
<%= 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 %>
</div>
<% end %>
</div>

<div data-hook="admin_user_form_password_fields" class="col-12 col-md-6">
<div class="col-12 col-md-6">
<%= 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 %>
</div>

<div class="col-12 col-md-6">
<%= 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 %>
</div>

<div class="col-12 col-md-6">
<%= 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 %>
</div>

<div class="col-12 col-md-6">
<%= 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 %>
</div>
</div>
11 changes: 11 additions & 0 deletions spec/features/admin/users_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down