diff --git a/app/controllers/management/base_controller.rb b/app/controllers/management/base_controller.rb index d0180b0a7..5bba8fcad 100644 --- a/app/controllers/management/base_controller.rb +++ b/app/controllers/management/base_controller.rb @@ -32,9 +32,10 @@ class Management::BaseController < ActionController::Base end def check_verified_user(alert_msg) - unless managed_user.level_two_or_three_verified? - redirect_to management_document_verifications_path, alert: alert_msg - end + return if managed_user.persisted? && managed_user.level_two_or_three_verified? + + message = managed_user.persisted? ? alert_msg : t("management.sessions.need_managed_user") + redirect_to management_document_verifications_path, alert: message end def set_locale diff --git a/config/locales/en/management.yml b/config/locales/en/management.yml index 86d1635f0..bca638b98 100644 --- a/config/locales/en/management.yml +++ b/config/locales/en/management.yml @@ -106,6 +106,7 @@ en: one: " containing the term '%{search_term}'" other: " containing the term '%{search_term}'" sessions: + need_managed_user: To perform this action you must select a user signed_out: Signed out successfully. signed_out_managed_user: User session signed out successfully. username_label: Username diff --git a/config/locales/es/management.yml b/config/locales/es/management.yml index af88dd99f..fddaa42ee 100644 --- a/config/locales/es/management.yml +++ b/config/locales/es/management.yml @@ -106,6 +106,7 @@ es: one: " que contiene '%{search_term}'" other: " que contienen '%{search_term}'" sessions: + need_managed_user: Para realizar esta acción debes seleccionar un usuario. signed_out: Has cerrado la sesión correctamente. signed_out_managed_user: Se ha cerrado correctamente la sesión del usuario. username_label: Nombre de usuario diff --git a/spec/system/management/account_spec.rb b/spec/system/management/account_spec.rb index 7231c5cc2..9f5b08274 100644 --- a/spec/system/management/account_spec.rb +++ b/spec/system/management/account_spec.rb @@ -98,4 +98,28 @@ describe "Account" do expect(page).to have_css("a[href='javascript:window.print();']", text: "Print password") expect(page).to have_css("div.for-print-only", text: "another_new_password", visible: :hidden) end + + describe "When a user has not been selected" do + before do + Setting["feature.user.skip_verification"] = "true" + end + + scenario "we can't reset password via email" do + login_as_manager + + click_link "Reset password via email" + + expect(page).to have_content "To perform this action you must select a user" + expect(page).to have_current_path management_document_verifications_path + end + + scenario "we can't reset password manually" do + login_as_manager + + click_link "Reset password manually" + + expect(page).to have_content "To perform this action you must select a user" + expect(page).to have_current_path management_document_verifications_path + end + end end diff --git a/spec/system/management/budget_investments_spec.rb b/spec/system/management/budget_investments_spec.rb index cff61d317..53bf0f87a 100644 --- a/spec/system/management/budget_investments_spec.rb +++ b/spec/system/management/budget_investments_spec.rb @@ -100,6 +100,16 @@ describe "Budget Investments" do expect(page).not_to have_content "Plant trees" end end + + scenario "when user has not been selected we can't create a budget investment" do + Setting["feature.user.skip_verification"] = "true" + login_as_manager(manager) + + click_link "Create budget investment" + + expect(page).to have_content "To perform this action you must select a user" + expect(page).to have_current_path management_document_verifications_path + end end context "Searching" do @@ -286,6 +296,16 @@ describe "Budget Investments" do expect(page).to have_content "User is not verified" end + + scenario "when user has not been selected we can't support budget investments" do + Setting["feature.user.skip_verification"] = "true" + login_as_manager(manager) + + click_link "Support budget investments" + + expect(page).to have_content "To perform this action you must select a user" + expect(page).to have_current_path management_document_verifications_path + end end context "Printing" do diff --git a/spec/system/management/proposals_spec.rb b/spec/system/management/proposals_spec.rb index ead42a1c6..618251822 100644 --- a/spec/system/management/proposals_spec.rb +++ b/spec/system/management/proposals_spec.rb @@ -44,6 +44,16 @@ describe "Proposals" do expect(page).to have_content "User is not verified" end + + scenario "when user has not been selected we can't create a proposal" do + Setting["feature.user.skip_verification"] = "true" + login_as_manager + + click_link "Create proposal" + + expect(page).to have_content "To perform this action you must select a user" + expect(page).to have_current_path management_document_verifications_path + end end context "Show" do @@ -171,6 +181,16 @@ describe "Proposals" do expect(page).to have_content "User is not verified" end + + scenario "when user has not been selected we can't support proposals" do + Setting["feature.user.skip_verification"] = "true" + login_as_manager + + click_link "Support proposals" + + expect(page).to have_content "To perform this action you must select a user" + expect(page).to have_current_path management_document_verifications_path + end end context "Printing" do @@ -214,5 +234,19 @@ describe "Proposals" do expect(best_proposal.title).to appear_before(worst_proposal.title) end end + + scenario "when user has not been selected we can't support a proposal" do + create(:proposal) + Setting["feature.user.skip_verification"] = "true" + login_as_manager + + click_link "Print proposals" + within ".proposals-list" do + click_link "Support" + end + + expect(page).to have_content "To perform this action you must select a user" + expect(page).to have_current_path management_document_verifications_path + end end end