Add test scenarios to check investment price showing rules

This commit is contained in:
Bertocq
2018-01-10 00:58:30 +01:00
parent baa3c5280f
commit 1d6c3034cb
2 changed files with 64 additions and 0 deletions

View File

@@ -326,6 +326,12 @@ FactoryBot.define do
incompatible true
end
trait :selected_with_price do
selected
price 1000
price_explanation 'Because of reasons'
end
trait :unselected do
selected false
feasibility "feasible"

View File

@@ -418,6 +418,64 @@ feature 'Budget Investments' do
end
end
context "Show Investment's price & cost explanation" do
let(:investment) { create(:budget_investment, :selected_with_price, heading: heading) }
context "When investment with price is selected" do
scenario "Price & explanation is shown when Budget is on published prices phase" do
Budget::PUBLISHED_PRICES_PHASES.each do |phase|
budget.update(phase: phase)
visit budget_investment_path(budget_id: budget.id, id: investment.id)
expect(page).to have_content(investment.formatted_price)
expect(page).to have_content(investment.price_explanation)
visit budget_investments_path(budget)
expect(page).to have_content(investment.formatted_price)
end
end
scenario "Price & explanation isn't shown when Budget is not on published prices phase" do
(Budget::PHASES - Budget::PUBLISHED_PRICES_PHASES).each do |phase|
budget.update(phase: phase)
visit budget_investment_path(budget_id: budget.id, id: investment.id)
expect(page).not_to have_content(investment.formatted_price)
expect(page).not_to have_content(investment.price_explanation)
visit budget_investments_path(budget)
expect(page).not_to have_content(investment.formatted_price)
end
end
end
context "When investment with price is unselected" do
background do
investment.update(selected: false)
end
scenario "Price & explanation isn't shown for any Budget's phase" do
Budget::PHASES.each do |phase|
budget.update(phase: phase)
visit budget_investment_path(budget_id: budget.id, id: investment.id)
expect(page).not_to have_content(investment.formatted_price)
expect(page).not_to have_content(investment.price_explanation)
visit budget_investments_path(budget)
expect(page).not_to have_content(investment.formatted_price)
end
end
end
end
scenario 'Can access the community' do
Setting['feature.community'] = true