From 99ef6136451e6545d0bc6851772582faf20cd290 Mon Sep 17 00:00:00 2001 From: kohrVid Date: Thu, 21 Jul 2016 20:55:48 +0100 Subject: [PATCH] Customer can now update their date of birth in their account details --- app/views/devise/registrations/edit.html.erb | 6 ++++++ app/views/devise/registrations/new.html.erb | 10 +++++----- app/views/profiles/show.html.erb | 2 +- .../edit_customer_account_details.feature | 12 +++++++++++ .../edit_customer_account_details_steps.rb | 20 +++++++++++++++++++ 5 files changed, 44 insertions(+), 6 deletions(-) create mode 100644 features/edit_customer_account_details.feature create mode 100644 features/step_definitions/edit_customer_account_details_steps.rb diff --git a/app/views/devise/registrations/edit.html.erb b/app/views/devise/registrations/edit.html.erb index 3ea40f0..6643354 100644 --- a/app/views/devise/registrations/edit.html.erb +++ b/app/views/devise/registrations/edit.html.erb @@ -26,6 +26,12 @@ <%= f.label :current_password %> (we need your current password to confirm your changes)
<%= f.password_field :current_password, autocomplete: "off" %> + +
+ <%= f.label :date_of_birth, "Date of Birth" %>
+ <%= f.date_field :date_of_birth, autofocus: true %> +
+
<%= f.submit "Update" %> diff --git a/app/views/devise/registrations/new.html.erb b/app/views/devise/registrations/new.html.erb index edb5449..58c5651 100644 --- a/app/views/devise/registrations/new.html.erb +++ b/app/views/devise/registrations/new.html.erb @@ -13,11 +13,6 @@ <%= f.email_field :email, autofocus: true %>
-
- <%= f.label :date_of_birth, "Date of Birth" %>
- <%= f.date_field :date_of_birth, autofocus: true %> -
-
<%= f.label :password %> <% if @minimum_password_length %> @@ -31,6 +26,11 @@ <%= f.password_field :password_confirmation, autocomplete: "off" %>
+
+ <%= f.label :date_of_birth, "Date of Birth" %>
+ <%= f.date_field :date_of_birth, autofocus: true %> +
+
<%= f.submit "Sign up" %>
diff --git a/app/views/profiles/show.html.erb b/app/views/profiles/show.html.erb index 01532ed..9ffff2e 100644 --- a/app/views/profiles/show.html.erb +++ b/app/views/profiles/show.html.erb @@ -4,8 +4,8 @@ <% for attribute in @profile.display_attribute_keys %>
  • <%= attribute.humanize %>: <%= @profile.attributes[attribute].to_s %>
  • <% end %> + <%= render 'profiles/search' %> -

    You weigh <%= @profile.weight %>

    diff --git a/features/edit_customer_account_details.feature b/features/edit_customer_account_details.feature new file mode 100644 index 0000000..473cd9e --- /dev/null +++ b/features/edit_customer_account_details.feature @@ -0,0 +1,12 @@ +Feature: A customer edits their account details + + Background: + Given they have a profile + And they have signed in + + Scenario: A customer edits their date of birth + When they visit the edit customer registration page + And they fill in their password + And they edit their date of birth + And they click Update + Then their changes are saved to their account diff --git a/features/step_definitions/edit_customer_account_details_steps.rb b/features/step_definitions/edit_customer_account_details_steps.rb new file mode 100644 index 0000000..b403cc9 --- /dev/null +++ b/features/step_definitions/edit_customer_account_details_steps.rb @@ -0,0 +1,20 @@ +When(/^they visit the edit customer registration page$/) do + visit edit_customer_registration_path +end + +When(/^they fill in their password$/) do + fill_in "Current password", with: "password" +end + +When(/^they edit their date of birth$/) do + fill_in "Date of Birth", with: 27.years.ago +end + +When(/^they click Update$/) do + click_on "Update" +end + +Then(/^their changes are saved to their account$/) do + expect(page).to have_content("Your account has been updated successfully.") +end +