diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 975a566d..e10f8c1a 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -29,7 +29,6 @@ def current_partner def verify_status_in_diaper_base if current_partner.status_in_diaper_base == "deactivated" flash[:alert] = 'Your account has been disabled, contact the organization via their email to reactivate' - redirect_to partner_requests_path end end diff --git a/app/controllers/dashboard_controller.rb b/app/controllers/dashboard_controller.rb index e3934f69..98c932f6 100644 --- a/app/controllers/dashboard_controller.rb +++ b/app/controllers/dashboard_controller.rb @@ -1,5 +1,6 @@ # Prepares data to be shown to the users for their dashboard. class DashboardController < ApplicationController + before_action :verify_status_in_diaper_base respond_to :html, :js def index diff --git a/app/controllers/family_requests_controller.rb b/app/controllers/family_requests_controller.rb index babd4d68..6e687ff8 100644 --- a/app/controllers/family_requests_controller.rb +++ b/app/controllers/family_requests_controller.rb @@ -1,8 +1,8 @@ class FamilyRequestsController < ApplicationController before_action :authenticate_user! + before_action :verify_status_in_diaper_base def new - verify_status_in_diaper_base @filterrific = initialize_filterrific( current_partner.children .order(last_name: :asc) @@ -13,7 +13,6 @@ def new end def create - verify_status_in_diaper_base children = current_partner.children.active children_grouped_by_diaperid = children.group_by(&:item_needed_diaperid) api_response = DiaperBankClient.send_family_request( diff --git a/app/controllers/partner_requests_controller.rb b/app/controllers/partner_requests_controller.rb index 53948c34..f2ca2521 100644 --- a/app/controllers/partner_requests_controller.rb +++ b/app/controllers/partner_requests_controller.rb @@ -1,5 +1,6 @@ class PartnerRequestsController < ApplicationController before_action :authenticate_user! + before_action :verify_status_in_diaper_base def index @partner = current_partner @@ -7,7 +8,6 @@ def index end def new - verify_status_in_diaper_base if current_partner.partner_status.casecmp("verified").zero? @partner_request = PartnerRequest.new @partner_request.item_requests.build # required to render the empty items form @@ -17,7 +17,6 @@ def new end def create - verify_status_in_diaper_base @partner_request = PartnerRequest.new(partner_request_params.merge(partner_id: current_partner.id)) @partner_request.item_requests << create_item_requests respond_to do |format| diff --git a/spec/features/family_requests_feature_spec.rb b/spec/features/family_requests_feature_spec.rb index a2de3f0b..0ad47258 100644 --- a/spec/features/family_requests_feature_spec.rb +++ b/spec/features/family_requests_feature_spec.rb @@ -112,9 +112,7 @@ scenario "it don't create because partner status in diaper base is deactivated" do partner.update(status_in_diaper_base: "deactivated") visit partner_requests_path - find_link("Create New Family Diaper Request").click expect(page).to have_text("Your account has been disabled, contact the organization via their email to reactivate") - expect(current_path).to eq(partner_requests_path) end end end