From dbe723079e10f7eca493c44fa73a824153ee185e Mon Sep 17 00:00:00 2001 From: Bertocq Date: Mon, 26 Feb 2018 09:57:04 +0100 Subject: [PATCH] Disable guide page when Budget is not accepting Why: When there is not Budget accepting (Investment creation) the guide page doesn't have much sense as it will give the user an option that can't be used (creating an Investment). How: Using `Budget.current&.accepting?` conditional at GuidesHelper to link to new proposal link instead of guide page, and adding an scenario to guides feature spec for it. --- app/helpers/guides_helper.rb | 6 +++--- spec/features/guides_spec.rb | 26 +++++++++++++++++++------- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/app/helpers/guides_helper.rb b/app/helpers/guides_helper.rb index 67658f52a..dd504d7d6 100644 --- a/app/helpers/guides_helper.rb +++ b/app/helpers/guides_helper.rb @@ -1,7 +1,7 @@ module GuidesHelper def new_proposal_guide - if feature?("guides") + if feature?('guides') && Budget.current&.accepting? new_guide_path else new_proposal_path @@ -9,11 +9,11 @@ module GuidesHelper end def new_budget_investment_guide - if feature?("guides") + if feature?('guides') new_guide_path else new_budget_investment_path(current_budget) end end -end \ No newline at end of file +end diff --git a/spec/features/guides_spec.rb b/spec/features/guides_spec.rb index 438c5abf7..e03d69c92 100644 --- a/spec/features/guides_spec.rb +++ b/spec/features/guides_spec.rb @@ -13,14 +13,26 @@ feature 'Guide the user to create the correct resource' do Setting['feature.guides'] = nil end - scenario "Proposal" do - login_as(user) - visit proposals_path + context "Proposals" do + scenario "Proposal creation" do + login_as(user) + visit proposals_path - click_link "Create a proposal" - click_link "I want to create a proposal" + click_link "Create a proposal" + click_link "I want to create a proposal" - expect(page).to have_current_path(new_proposal_path) + expect(page).to have_current_path(new_proposal_path) + end + + scenario "Proposal creation when Budget is not accepting" do + budget.update_attribute(:phase, :reviewing) + login_as(user) + visit proposals_path + + click_link "Create a proposal" + + expect(page).to have_current_path(new_proposal_path) + end end scenario "Budget Investment" do @@ -51,4 +63,4 @@ feature 'Guide the user to create the correct resource' do expect(page).to have_current_path(new_budget_investment_path(budget)) end -end \ No newline at end of file +end