From 21a6d3495a4ba6154a97ef7d4276826ef54763b2 Mon Sep 17 00:00:00 2001 From: iagirre Date: Mon, 2 Apr 2018 13:03:09 +0200 Subject: [PATCH] Update PR with master Rebase master branch so that this PR can be updated with the latest changes. Conflicts has been solved and some specs updated to fit the new changes. dev_seeds has been also adapted to the new format. --- db/dev_seeds.rb | 6 ---- db/dev_seeds/budgets.rb | 6 ++++ .../valuation/budget_investments_spec.rb | 30 +++++++++---------- spec/support/common_actions.rb | 6 ---- 4 files changed, 21 insertions(+), 27 deletions(-) diff --git a/db/dev_seeds.rb b/db/dev_seeds.rb index 9d72cdffb..217047426 100644 --- a/db/dev_seeds.rb +++ b/db/dev_seeds.rb @@ -31,11 +31,5 @@ require_relative 'dev_seeds/communities' require_relative 'dev_seeds/legislation_processes' require_relative 'dev_seeds/newsletters' require_relative 'dev_seeds/notifications' -section "Marking investments as visible to valuators" do - (1..50).to_a.sample.times do - Budget::Investment.reorder("RANDOM()").first.update(visible_to_valuators: true) - end -end - log "All dev seeds created successfuly 👍" diff --git a/db/dev_seeds/budgets.rb b/db/dev_seeds/budgets.rb index 243785e0a..4740ed407 100644 --- a/db/dev_seeds/budgets.rb +++ b/db/dev_seeds/budgets.rb @@ -56,6 +56,12 @@ section "Creating Investments" do end end +section "Marking investments as visible to valuators" do + (1..50).to_a.sample.times do + Budget::Investment.reorder("RANDOM()").first.update(visible_to_valuators: true) + end +end + section "Geolocating Investments" do Budget.all.each do |budget| budget.investments.each do |investment| diff --git a/spec/features/valuation/budget_investments_spec.rb b/spec/features/valuation/budget_investments_spec.rb index 35c4d0400..5d9b4fa4a 100644 --- a/spec/features/valuation/budget_investments_spec.rb +++ b/spec/features/valuation/budget_investments_spec.rb @@ -69,11 +69,11 @@ feature 'Valuation budget investments' do scenario 'Index displays investments paginated' do per_page = Kaminari.config.default_per_page (per_page + 2).times do - investment = create(:budget_investment, :visible_to_valuators, budget: @budget) - investment.valuators << @valuator + investment = create(:budget_investment, :visible_to_valuators, budget: budget) + investment.valuators << valuator end - visit valuation_budget_budget_investments_path(@budget) + visit valuation_budget_budget_investments_path(budget) expect(page).to have_css('.budget_investment', count: per_page) @@ -92,34 +92,26 @@ feature 'Valuation budget investments' do valuating_heading = create(:budget_heading, name: "Only Valuating", group: group) valuating_finished_heading = create(:budget_heading, name: "Valuating&Finished", group: group) finished_heading = create(:budget_heading, name: "Only Finished", group: group) - create(:budget_investment, title: "Valuating Investment ONE", + create(:budget_investment, :visible_to_valuators, title: "Valuating Investment ONE", heading: valuating_heading, group: group, budget: budget, valuators: [valuator]) - create(:budget_investment, title: "Valuating Investment TWO", + create(:budget_investment, :visible_to_valuators, title: "Valuating Investment TWO", heading: valuating_finished_heading, group: group, budget: budget, valuators: [valuator]) - create(:budget_investment, :finished, title: "Finished ONE", + create(:budget_investment, :finished, :visible_to_valuators, title: "Finished ONE", heading: valuating_finished_heading, group: group, budget: budget, valuators: [valuator]) - create(:budget_investment, :finished, title: "Finished TWO", + create(:budget_investment, :finished, :visible_to_valuators, title: "Finished TWO", heading: finished_heading, group: group, budget: budget, valuators: [valuator]) - # heading1 = create(:budget_heading, name: "District 9", group: group) - # heading2 = create(:budget_heading, name: "Down to the river", group: group) - # investment1 = create(:budget_investment, :visible_to_valuators, title: "Realocate visitors", - # heading: heading1, group: group, budget: budget) - # investment2 = create(:budget_investment, :visible_to_valuators, title: "Destroy the city", - # heading: heading2, group: group, budget: budget) - investment1.valuators << valuator - investment2.valuators << valuator visit valuation_budget_budget_investments_path(budget) @@ -299,6 +291,8 @@ feature 'Valuation budget investments' do end scenario 'Dossier empty by default' do + investment.update(visible_to_valuators: true) + visit valuation_budget_budget_investments_path(budget) click_link investment.title @@ -310,6 +304,7 @@ feature 'Valuation budget investments' do end scenario 'Edit dossier' do + investment.update(visible_to_valuators: true) visit valuation_budget_budget_investments_path(budget) within("#budget_investment_#{investment.id}") do click_link "Edit dossier" @@ -411,6 +406,8 @@ feature 'Valuation budget investments' do end scenario 'Finish valuation' do + investment.update(visible_to_valuators: true) + visit valuation_budget_budget_investment_path(budget, investment) click_link 'Edit dossier' @@ -468,7 +465,10 @@ feature 'Valuation budget investments' do end scenario 'Validates price formats' do + investment.update(visible_to_valuators: true) + visit valuation_budget_budget_investments_path(budget) + within("#budget_investment_#{investment.id}") do click_link "Edit dossier" end diff --git a/spec/support/common_actions.rb b/spec/support/common_actions.rb index 4ce415b26..fb077c264 100644 --- a/spec/support/common_actions.rb +++ b/spec/support/common_actions.rb @@ -362,12 +362,6 @@ module CommonActions fill_in "newsletter_from", with: (options[:from] || "no-reply@consul.dev") fill_in "newsletter_body", with: (options[:body] || "This is a different body") end - def wait_for_ajax - Timeout.timeout(Capybara.default_max_wait_time) do - loop until page.evaluate_script('jQuery.active').zero? - end - end - def click_notifications_icon find("#notifications a").click