fixes specs

This commit is contained in:
rgarcia
2016-07-28 14:06:40 +02:00
parent f21fda0898
commit e28c5c5010

View File

@@ -2,12 +2,12 @@ require 'rails_helper'
feature 'Budget Investments' do feature 'Budget Investments' do
let(:author) { create(:user, :level_two, username: 'Isabel') } let(:author) { create(:user, :level_two, username: 'Isabel') }
let(:budget) { create(:budget) } let(:budget) { create(:budget) }
let(:group) { create(:budget_group, budget: budget) } let(:group) { create(:budget_group, budget: budget) }
let(:heading) { create(:budget_heading, group: group) }
scenario 'Index' do scenario 'Index' do
heading = create(:budget_heading, group: group)
investments = [create(:budget_investment, heading: heading), create(:budget_investment, heading: heading), create(:budget_investment, :feasible, heading: heading)] investments = [create(:budget_investment, heading: heading), create(:budget_investment, heading: heading), create(:budget_investment, :feasible, heading: heading)]
unfeasible_investment = create(:budget_investment, :unfeasible, heading: heading) unfeasible_investment = create(:budget_investment, :unfeasible, heading: heading)
@@ -25,9 +25,9 @@ feature 'Budget Investments' do
context("Search") do context("Search") do
scenario 'Search by text' do scenario 'Search by text' do
investment1 = create(:budget_investment, budget: budget, title: "Get Schwifty") investment1 = create(:budget_investment, heading: heading, title: "Get Schwifty")
investment2 = create(:budget_investment, budget: budget, title: "Schwifty Hello") investment2 = create(:budget_investment, heading: heading, title: "Schwifty Hello")
investment3 = create(:budget_investment, budget: budget, title: "Do not show me") investment3 = create(:budget_investment, heading: heading, title: "Do not show me")
visit budget_investments_path(budget_id: budget.id) visit budget_investments_path(budget_id: budget.id)
@@ -48,10 +48,10 @@ feature 'Budget Investments' do
context("Filters") do context("Filters") do
scenario 'by unfeasibility' do scenario 'by unfeasibility' do
investment1 = create(:budget_investment, :unfeasible, budget: budget, valuation_finished: true) investment1 = create(:budget_investment, :unfeasible, heading: heading, valuation_finished: true)
investment2 = create(:budget_investment, :feasible, budget: budget) investment2 = create(:budget_investment, :feasible, heading: heading)
investment3 = create(:budget_investment, budget: budget) investment3 = create(:budget_investment, heading: heading)
investment4 = create(:budget_investment, :feasible, budget: budget) investment4 = create(:budget_investment, :feasible, heading: heading)
visit budget_investments_path(budget_id: budget.id, unfeasible: 1) visit budget_investments_path(budget_id: budget.id, unfeasible: 1)
@@ -99,7 +99,7 @@ feature 'Budget Investments' do
scenario 'Random order maintained with pagination', :js do scenario 'Random order maintained with pagination', :js do
per_page = Kaminari.config.default_per_page per_page = Kaminari.config.default_per_page
(per_page + 2).times { create(:budget_investment, budget: budget) } (per_page + 2).times { create(:budget_investment, heading: heading) }
visit budget_investments_path(budget_id: budget.id) visit budget_investments_path(budget_id: budget.id)
@@ -116,9 +116,9 @@ feature 'Budget Investments' do
end end
scenario 'Proposals are ordered by confidence_score', :js do scenario 'Proposals are ordered by confidence_score', :js do
create(:budget_investment, budget: budget, title: 'Best proposal').update_column(:confidence_score, 10) create(:budget_investment, heading: heading, title: 'Best proposal').update_column(:confidence_score, 10)
create(:budget_investment, budget: budget, title: 'Worst proposal').update_column(:confidence_score, 2) create(:budget_investment, heading: heading, title: 'Worst proposal').update_column(:confidence_score, 2)
create(:budget_investment, budget: budget, title: 'Medium proposal').update_column(:confidence_score, 5) create(:budget_investment, heading: heading, title: 'Medium proposal').update_column(:confidence_score, 5)
visit budget_investments_path(budget_id: budget.id) visit budget_investments_path(budget_id: budget.id)
click_link 'highest rated' click_link 'highest rated'
@@ -135,10 +135,10 @@ feature 'Budget Investments' do
end end
xscenario 'Create with invisible_captcha honeypot field' do scenario 'Create with invisible_captcha honeypot field' do
login_as(author) login_as(author)
visit new_budget_investment_path(budget_id: budget.id) visit new_budget_investment_path(budget_id: budget.id)
fill_in 'investment_title', with: 'I am a bot' fill_in 'investment_title', with: 'I am a bot'
fill_in 'investment_subtitle', with: 'This is the honeypot' fill_in 'investment_subtitle', with: 'This is the honeypot'
fill_in 'investment_description', with: 'This is the description' fill_in 'investment_description', with: 'This is the description'
@@ -203,7 +203,7 @@ feature 'Budget Investments' do
user = create(:user) user = create(:user)
login_as(user) login_as(user)
investment = create(:budget_investment, heading: create(:budget_heading), budget: budget) investment = create(:budget_investment, heading: create(:budget_heading), heading: heading)
visit budget_investment_path(budget_id: budget.id, id: investment.id) visit budget_investment_path(budget_id: budget.id, id: investment.id)
@@ -223,7 +223,7 @@ feature 'Budget Investments' do
investment = create(:budget_investment, investment = create(:budget_investment,
:feasible, :feasible,
:finished, :finished,
budget: budget, heading: heading,
price: 16, price: 16,
price_explanation: 'Every wheel is 4 euros, so total is 16') price_explanation: 'Every wheel is 4 euros, so total is 16')
@@ -240,7 +240,7 @@ feature 'Budget Investments' do
investment = create(:budget_investment, investment = create(:budget_investment,
:unfeasible, :unfeasible,
:finished, :finished,
budget: budget, heading: heading,
unfeasibility_explanation: 'Local government is not competent in this matter') unfeasibility_explanation: 'Local government is not competent in this matter')
visit budget_investment_path(budget_id: budget.id, id: investment.id) visit budget_investment_path(budget_id: budget.id, id: investment.id)
@@ -254,7 +254,7 @@ feature 'Budget Investments' do
xscenario "Admin cannot destroy spending proposals" do xscenario "Admin cannot destroy spending proposals" do
admin = create(:administrator) admin = create(:administrator)
user = create(:user, :level_two) user = create(:user, :level_two)
investment = create(:budget_investment, budget: budget, author: user) investment = create(:budget_investment, heading: heading, author: user)
login_as(admin.user) login_as(admin.user)
visit user_path(user) visit user_path(user)
@@ -270,7 +270,7 @@ feature 'Budget Investments' do
scenario "Spending proposal created by a User" do scenario "Spending proposal created by a User" do
user = create(:user) user = create(:user)
user_investment = create(:budget_investment, budget: budget) user_investment = create(:budget_investment, heading: heading)
visit budget_investment_path(budget_id: budget.id, id: user_investment.id) visit budget_investment_path(budget_id: budget.id, id: user_investment.id)
expect(page).to_not have_css "is-forum" expect(page).to_not have_css "is-forum"
@@ -291,8 +291,8 @@ feature 'Budget Investments' do
xscenario "Index" do xscenario "Index" do
user = create(:user, :level_two) user = create(:user, :level_two)
sp1 = create(:budget_investment, :feasible, :finished, budget: budget, price: 10000) sp1 = create(:budget_investment, :feasible, :finished, heading: heading, price: 10000)
sp2 = create(:budget_investment, :feasible, :finished, budget: budget, price: 20000) sp2 = create(:budget_investment, :feasible, :finished, heading: heading, price: 20000)
login_as(user) login_as(user)
visit root_path visit root_path
@@ -313,9 +313,9 @@ feature 'Budget Investments' do
end end
xscenario 'Order by cost (only in phase3)' do xscenario 'Order by cost (only in phase3)' do
create(:budget_investment, :feasible, :finished, budget: budget, title: 'Build a nice house', price: 1000).update_column(:confidence_score, 10) create(:budget_investment, :feasible, :finished, heading: heading, title: 'Build a nice house', price: 1000).update_column(:confidence_score, 10)
create(:budget_investment, :feasible, :finished, budget: budget, title: 'Build an ugly house', price: 1000).update_column(:confidence_score, 5) create(:budget_investment, :feasible, :finished, heading: heading, title: 'Build an ugly house', price: 1000).update_column(:confidence_score, 5)
create(:budget_investment, :feasible, :finished, budget: budget, title: 'Build a skyscraper', price: 20000) create(:budget_investment, :feasible, :finished, heading: heading, title: 'Build a skyscraper', price: 20000)
visit budget_investments_path(budget_id: budget.id) visit budget_investments_path(budget_id: budget.id)
@@ -333,7 +333,7 @@ feature 'Budget Investments' do
scenario "Show" do scenario "Show" do
user = create(:user, :level_two) user = create(:user, :level_two)
sp1 = create(:budget_investment, :feasible, :finished, budget: budget, price: 10000) sp1 = create(:budget_investment, :feasible, :finished, heading: heading, price: 10000)
login_as(user) login_as(user)
visit root_path visit root_path
@@ -353,15 +353,15 @@ feature 'Budget Investments' do
carabanchel = create(:geozone, name: "Carabanchel") carabanchel = create(:geozone, name: "Carabanchel")
new_york = create(:geozone, name: "New York") new_york = create(:geozone, name: "New York")
carabanchel_heading = create(:budget_heading, budget: budget, geozone: carabanchel, name: carabanchel.name) carabanchel_heading = create(:budget_heading, heading: heading, geozone: carabanchel, name: carabanchel.name)
new_york_heading = create(:budget_heading, budget: budget, geozone: new_york, name: new_york.name) new_york_heading = create(:budget_heading, heading: heading, geozone: new_york, name: new_york.name)
sp1 = create(:budget_investment, :feasible, :finished, budget: budget, price: 1, heading: nil) sp1 = create(:budget_investment, :feasible, :finished, heading: heading, price: 1, heading: nil)
sp2 = create(:budget_investment, :feasible, :finished, budget: budget, price: 10, heading: nil) sp2 = create(:budget_investment, :feasible, :finished, heading: heading, price: 10, heading: nil)
sp3 = create(:budget_investment, :feasible, :finished, budget: budget, price: 100, heading: nil) sp3 = create(:budget_investment, :feasible, :finished, heading: heading, price: 100, heading: nil)
sp4 = create(:budget_investment, :feasible, :finished, budget: budget, price: 1000, heading: carabanchel_heading) sp4 = create(:budget_investment, :feasible, :finished, heading: heading, price: 1000, heading: carabanchel_heading)
sp5 = create(:budget_investment, :feasible, :finished, budget: budget, price: 10000, heading: carabanchel_heading) sp5 = create(:budget_investment, :feasible, :finished, heading: heading, price: 10000, heading: carabanchel_heading)
sp6 = create(:budget_investment, :feasible, :finished, budget: budget, price: 100000, heading: new_york_heading) sp6 = create(:budget_investment, :feasible, :finished, heading: heading, price: 100000, heading: new_york_heading)
login_as(user) login_as(user)
visit root_path visit root_path