fixes specs

This commit is contained in:
rgarcia
2016-09-10 16:19:51 +02:00
parent fdb1d4aac9
commit e38e89aea0
4 changed files with 21 additions and 41 deletions

View File

@@ -7,7 +7,9 @@
<main id="budget-investments-main"> <main id="budget-investments-main">
<% unless params[:search].present? %>
<%= render 'header' %> <%= render 'header' %>
<% end %>
<div class="wrap row"> <div class="wrap row">
<div id="budget-investments" class="budget-investments-list small-12 medium-9 column"> <div id="budget-investments" class="budget-investments-list small-12 medium-9 column">

View File

@@ -10,12 +10,11 @@ feature 'Budgets' do
scenario 'Show' do scenario 'Show' do
budget = create(:budget) budget = create(:budget)
group = create(:budget_group, budget: budget) group1 = create(:budget_group, budget: budget)
heading = create(:budget_heading, group: group) group2 = create(:budget_group, budget: budget)
visit budget_path(budget) visit budget_path(budget)
expect(page).to have_content(budget.name) budget.groups.each {|group| expect(page).to have_link(group.name)}
expect(page).to have_content(heading.name)
end end
end end

View File

@@ -11,7 +11,7 @@ feature 'Budget Investments' do
investments = [create(:budget_investment, budget: budget, group: group, heading: heading), create(:budget_investment, budget: budget, group: group, heading: heading), create(:budget_investment, :feasible, budget: budget, group: group, heading: heading)] investments = [create(:budget_investment, budget: budget, group: group, heading: heading), create(:budget_investment, budget: budget, group: group, heading: heading), create(:budget_investment, :feasible, budget: budget, group: group, heading: heading)]
unfeasible_investment = create(:budget_investment, :unfeasible, budget: budget, group: group, heading: heading) unfeasible_investment = create(:budget_investment, :unfeasible, budget: budget, group: group, heading: heading)
visit budget_investments_path(budget_id: budget.id) visit budget_investments_path(budget, heading_id: heading.id)
expect(page).to have_selector('#budget-investments .budget-investment', count: 3) expect(page).to have_selector('#budget-investments .budget-investment', count: 3)
investments.each do |investment| investments.each do |investment|
@@ -29,7 +29,7 @@ feature 'Budget Investments' do
investment2 = create(:budget_investment, budget: budget, group: group, heading: heading, title: "Schwifty Hello") investment2 = create(:budget_investment, budget: budget, group: group, heading: heading, title: "Schwifty Hello")
investment3 = create(:budget_investment, budget: budget, group: group, heading: heading, title: "Do not show me") investment3 = create(:budget_investment, budget: budget, group: group, heading: heading, title: "Do not show me")
visit budget_investments_path(budget_id: budget.id) visit budget_investments_path(budget, heading_id: heading.id)
within(".expanded #search_form") do within(".expanded #search_form") do
fill_in "search", with: "Schwifty" fill_in "search", with: "Schwifty"
@@ -53,7 +53,7 @@ feature 'Budget Investments' do
investment3 = create(:budget_investment, budget: budget, group: group, heading: heading) investment3 = create(:budget_investment, budget: budget, group: group, heading: heading)
investment4 = create(:budget_investment, :feasible, budget: budget, group: group, heading: heading) investment4 = create(:budget_investment, :feasible, budget: budget, group: group, heading: heading)
visit budget_investments_path(budget_id: budget.id, unfeasible: 1) visit budget_investments_path(budget_id: budget.id, heading_id: heading.id, unfeasible: 1)
within("#budget-investments") do within("#budget-investments") do
expect(page).to have_css('.budget-investment', count: 1) expect(page).to have_css('.budget-investment', count: 1)
@@ -72,10 +72,10 @@ feature 'Budget Investments' do
per_page = Kaminari.config.default_per_page per_page = Kaminari.config.default_per_page
(per_page + 2).times { create(:budget_investment) } (per_page + 2).times { create(:budget_investment) }
visit budget_investments_path(budget_id: budget.id) visit budget_investments_path(budget, heading_id: heading.id)
order = all(".budget-investment h3").collect {|i| i.text } order = all(".budget-investment h3").collect {|i| i.text }
visit budget_investments_path(budget_id: budget.id) visit budget_investments_path(budget, heading_id: heading.id)
new_order = eq(all(".budget-investment h3").collect {|i| i.text }) new_order = eq(all(".budget-investment h3").collect {|i| i.text })
expect(order).to_not eq(new_order) expect(order).to_not eq(new_order)
@@ -85,13 +85,13 @@ feature 'Budget Investments' do
per_page = Kaminari.config.default_per_page per_page = Kaminari.config.default_per_page
(per_page + 2).times { create(:budget_investment) } (per_page + 2).times { create(:budget_investment) }
visit budget_investments_path(budget_id: budget.id) visit budget_investments_path(budget, heading_id: heading.id)
click_link "highest rated" click_link "highest rated"
click_link "random" click_link "random"
order = all(".budget-investment h3").collect {|i| i.text } order = all(".budget-investment h3").collect {|i| i.text }
visit budget_investments_path(budget_id: budget.id) visit budget_investments_path(budget, heading_id: heading.id)
new_order = eq(all(".budget-investment h3").collect {|i| i.text }) new_order = eq(all(".budget-investment h3").collect {|i| i.text })
expect(order).to_not eq(new_order) expect(order).to_not eq(new_order)
@@ -101,7 +101,7 @@ feature 'Budget Investments' do
per_page = Kaminari.config.default_per_page per_page = Kaminari.config.default_per_page
(per_page + 2).times { create(:budget_investment, budget: budget, group: group, heading: heading) } (per_page + 2).times { create(:budget_investment, budget: budget, group: group, heading: heading) }
visit budget_investments_path(budget_id: budget.id) visit budget_investments_path(budget, heading_id: heading.id)
order = all(".budget-investment h3").collect {|i| i.text } order = all(".budget-investment h3").collect {|i| i.text }
@@ -120,7 +120,7 @@ feature 'Budget Investments' do
create(:budget_investment, budget: budget, group: group, heading: heading, title: 'Worst proposal').update_column(:confidence_score, 2) create(:budget_investment, budget: budget, group: group, heading: heading, title: 'Worst proposal').update_column(:confidence_score, 2)
create(:budget_investment, budget: budget, group: group, heading: heading, title: 'Medium proposal').update_column(:confidence_score, 5) create(:budget_investment, budget: budget, group: group, heading: heading, title: 'Medium proposal').update_column(:confidence_score, 5)
visit budget_investments_path(budget_id: budget.id) visit budget_investments_path(budget, heading_id: heading.id)
click_link 'highest rated' click_link 'highest rated'
expect(page).to have_selector('a.active', text: 'highest rated') expect(page).to have_selector('a.active', text: 'highest rated')
@@ -274,23 +274,6 @@ feature 'Budget Investments' do
end end
context "Badge" do
scenario "Spending proposal created by a User" do
user = create(:user)
user_investment = create(:budget_investment, budget: budget, group: group, heading: heading)
visit budget_investment_path(budget_id: budget.id, id: user_investment.id)
expect(page).to_not have_css "is-forum"
visit budget_investments_path(budget_id: budget.id, id: user_investment.id)
within "#budget_investment_#{user_investment.id}" do
expect(page).to_not have_css "is-forum"
end
end
end
context "Phase 3 - Final Voting" do context "Phase 3 - Final Voting" do
background do background do
@@ -325,7 +308,7 @@ feature 'Budget Investments' do
create(:budget_investment, :feasible, :finished, budget: budget, group: group, heading: heading, title: 'Build an ugly house', price: 1000).update_column(:confidence_score, 5) create(:budget_investment, :feasible, :finished, budget: budget, group: group, heading: heading, title: 'Build an ugly house', price: 1000).update_column(:confidence_score, 5)
create(:budget_investment, :feasible, :finished, budget: budget, group: group, heading: heading, title: 'Build a skyscraper', price: 20000) create(:budget_investment, :feasible, :finished, budget: budget, group: group, heading: heading, title: 'Build a skyscraper', price: 20000)
visit budget_investments_path(budget_id: budget.id) visit budget_investments_path(budget, heading_id: heading.id)
click_link 'by price' click_link 'by price'
expect(page).to have_selector('a.active', text: 'by price') expect(page).to have_selector('a.active', text: 'by price')
@@ -344,11 +327,7 @@ feature 'Budget Investments' do
sp1 = create(:budget_investment, :feasible, :finished, budget: budget, group: group, heading: heading, price: 10000) sp1 = create(:budget_investment, :feasible, :finished, budget: budget, group: group, heading: heading, price: 10000)
login_as(user) login_as(user)
visit root_path visit budget_investments_path(budget, heading_id: heading.id)
first(:link, "Participatory budgeting").click
click_link budget.name
click_link "No Heading"
click_link sp1.title click_link sp1.title

View File

@@ -22,7 +22,7 @@ feature 'Votes' do
investment3 = create(:budget_investment, heading: heading) investment3 = create(:budget_investment, heading: heading)
create(:vote, voter: @manuela, votable: investment1, vote_flag: true) create(:vote, voter: @manuela, votable: investment1, vote_flag: true)
visit budget_investments_path(budget_id: budget.id) visit budget_investments_path(budget, heading_id: heading.id)
within("#budget-investments") do within("#budget-investments") do
within("#budget_investment_#{investment1.id}_votes") do within("#budget_investment_#{investment1.id}_votes") do
@@ -42,7 +42,7 @@ feature 'Votes' do
scenario 'Create from spending proposal index', :js do scenario 'Create from spending proposal index', :js do
investment = create(:budget_investment, heading: heading, budget: budget) investment = create(:budget_investment, heading: heading, budget: budget)
visit budget_investments_path(budget_id: budget.id) visit budget_investments_path(budget, heading_id: heading.id)
within('.supports') do within('.supports') do
find('.in-favor a').click find('.in-favor a').click
@@ -89,9 +89,9 @@ feature 'Votes' do
scenario 'Disable voting on spending proposals', :js do scenario 'Disable voting on spending proposals', :js do
login_as(@manuela) login_as(@manuela)
budget.update(phase: "on_hold") budget.update(phase: "on_hold")
investment = create(:budget_investment, budget: budget) investment = create(:budget_investment, budget: budget, heading: heading)
visit budget_investments_path(budget) visit budget_investments_path(budget, heading_id: heading.id)
within("#budget_investment_#{investment.id}") do within("#budget_investment_#{investment.id}") do
find("div.supports").hover find("div.supports").hover