From 1744769af22e069eefdf185ad776150717df1fd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juanjo=20Baz=C3=A1n?= Date: Sat, 17 Oct 2015 13:17:47 +0200 Subject: [PATCH 1/2] cleans document number in management verification --- .../management/document_verifications_controller.rb | 5 +++++ config/locales/management.en.yml | 8 ++++---- spec/features/management/document_verifications_spec.rb | 9 +++++++++ 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/app/controllers/management/document_verifications_controller.rb b/app/controllers/management/document_verifications_controller.rb index 32d38c748..1b8fabcc2 100644 --- a/app/controllers/management/document_verifications_controller.rb +++ b/app/controllers/management/document_verifications_controller.rb @@ -1,5 +1,6 @@ class Management::DocumentVerificationsController < Management::BaseController + before_action :clean_document_number, only: :check before_action :set_document, only: :check def index @@ -41,4 +42,8 @@ class Management::DocumentVerificationsController < Management::BaseController session[:document_number] = params[:document_verification][:document_number] end + def clean_document_number + params[:document_verification][:document_number] = params[:document_verification][:document_number].gsub(/[^a-z0-9]+/i, "").upcase unless params[:document_verification][:document_number].blank? + end + end \ No newline at end of file diff --git a/config/locales/management.en.yml b/config/locales/management.en.yml index 1718c80d5..73b7ed608 100644 --- a/config/locales/management.en.yml +++ b/config/locales/management.en.yml @@ -17,10 +17,10 @@ en: title: "Management" account_info: identified_label: "Identified as:" - username_label: "Username" - email_label: "Email" - document_number_label: "Document number" - document_type_label: "Document type" + username_label: "Username:" + email_label: "Email:" + document_number_label: "Document number:" + document_type_label: "Document type:" change_user: "Change user" sessions: signed_out: "Signed out successfully." diff --git a/spec/features/management/document_verifications_spec.rb b/spec/features/management/document_verifications_spec.rb index 6e43dc1cf..4a437a661 100644 --- a/spec/features/management/document_verifications_spec.rb +++ b/spec/features/management/document_verifications_spec.rb @@ -53,4 +53,13 @@ feature 'DocumentVerifications' do expect(page).to have_content "Please introduce the email used on the account" end + scenario 'Document number is format-standarized' do + + visit management_document_verifications_path + fill_in 'document_verification_document_number', with: '12345 - h' + click_button 'Check' + + expect(page).to have_content "Document number: 12345H" + end + end \ No newline at end of file From c54341dd070283e828ebbc31e1fb049e88889d70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juanjo=20Baz=C3=A1n?= Date: Sat, 17 Oct 2015 13:18:42 +0200 Subject: [PATCH 2/2] changes link to root in management layout --- app/views/layouts/management.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/layouts/management.html.erb b/app/views/layouts/management.html.erb index 0f641ad13..354fae1a1 100644 --- a/app/views/layouts/management.html.erb +++ b/app/views/layouts/management.html.erb @@ -27,7 +27,7 @@