Merge pull request #2285 from consul/feature/2278#budget_draft_phase
Feature/2278#budget draft phase
This commit is contained in:
@@ -223,6 +223,7 @@ FactoryBot.define do
|
||||
sequence(:name) { |n| "Budget #{n}" }
|
||||
currency_symbol "€"
|
||||
phase 'accepting'
|
||||
description_drafting "This budget is drafting"
|
||||
description_accepting "This budget is accepting"
|
||||
description_reviewing "This budget is reviewing"
|
||||
description_selecting "This budget is selecting"
|
||||
@@ -231,6 +232,10 @@ FactoryBot.define do
|
||||
description_reviewing_ballots "This budget is reviewing ballots"
|
||||
description_finished "This budget is finished"
|
||||
|
||||
trait :drafting do
|
||||
phase 'drafting'
|
||||
end
|
||||
|
||||
trait :accepting do
|
||||
phase 'accepting'
|
||||
end
|
||||
|
||||
@@ -34,32 +34,32 @@ feature 'Admin budgets' do
|
||||
end
|
||||
|
||||
scenario 'Filters by phase' do
|
||||
budget1 = create(:budget)
|
||||
budget2 = create(:budget, :accepting)
|
||||
budget3 = create(:budget, :selecting)
|
||||
budget4 = create(:budget, :balloting)
|
||||
budget5 = create(:budget, :finished)
|
||||
drafting_budget = create(:budget, :drafting)
|
||||
accepting_budget = create(:budget, :accepting)
|
||||
selecting_budget = create(:budget, :selecting)
|
||||
balloting_budget = create(:budget, :balloting)
|
||||
finished_budget = create(:budget, :finished)
|
||||
|
||||
visit admin_budgets_path
|
||||
expect(page).to have_content(budget1.name)
|
||||
expect(page).to have_content(budget2.name)
|
||||
expect(page).to have_content(budget3.name)
|
||||
expect(page).to have_content(budget4.name)
|
||||
expect(page).not_to have_content(budget5.name)
|
||||
expect(page).to have_content(drafting_budget.name)
|
||||
expect(page).to have_content(accepting_budget.name)
|
||||
expect(page).to have_content(selecting_budget.name)
|
||||
expect(page).to have_content(balloting_budget.name)
|
||||
expect(page).not_to have_content(finished_budget.name)
|
||||
|
||||
click_link 'Finished'
|
||||
expect(page).not_to have_content(budget1.name)
|
||||
expect(page).not_to have_content(budget2.name)
|
||||
expect(page).not_to have_content(budget3.name)
|
||||
expect(page).not_to have_content(budget4.name)
|
||||
expect(page).to have_content(budget5.name)
|
||||
expect(page).not_to have_content(drafting_budget.name)
|
||||
expect(page).not_to have_content(accepting_budget.name)
|
||||
expect(page).not_to have_content(selecting_budget.name)
|
||||
expect(page).not_to have_content(balloting_budget.name)
|
||||
expect(page).to have_content(finished_budget.name)
|
||||
|
||||
click_link 'Open'
|
||||
expect(page).to have_content(budget1.name)
|
||||
expect(page).to have_content(budget2.name)
|
||||
expect(page).to have_content(budget3.name)
|
||||
expect(page).to have_content(budget4.name)
|
||||
expect(page).not_to have_content(budget5.name)
|
||||
expect(page).to have_content(drafting_budget.name)
|
||||
expect(page).to have_content(accepting_budget.name)
|
||||
expect(page).to have_content(selecting_budget.name)
|
||||
expect(page).to have_content(balloting_budget.name)
|
||||
expect(page).not_to have_content(finished_budget.name)
|
||||
end
|
||||
|
||||
scenario 'Open filter is properly highlighted' do
|
||||
|
||||
@@ -2,6 +2,9 @@ require 'rails_helper'
|
||||
|
||||
feature 'Budgets' do
|
||||
|
||||
let(:budget) { create(:budget) }
|
||||
let(:level_two_user) { create(:user, :level_two) }
|
||||
|
||||
scenario 'Index' do
|
||||
budgets = create_list(:budget, 3)
|
||||
visit budgets_path
|
||||
@@ -11,7 +14,6 @@ feature 'Budgets' do
|
||||
context 'Show' do
|
||||
|
||||
scenario "List all groups" do
|
||||
budget = create(:budget)
|
||||
group1 = create(:budget_group, budget: budget)
|
||||
group2 = create(:budget_group, budget: budget)
|
||||
|
||||
@@ -61,9 +63,59 @@ feature 'Budgets' do
|
||||
|
||||
end
|
||||
|
||||
context 'Accepting' do
|
||||
context "In Drafting phase" do
|
||||
|
||||
let(:budget) { create(:budget) }
|
||||
let(:admin) { create(:administrator).user }
|
||||
|
||||
background do
|
||||
logout
|
||||
budget.update(phase: 'drafting')
|
||||
end
|
||||
|
||||
context "Listed" do
|
||||
scenario "Not listed to guest users at the public budgets list" do
|
||||
visit budgets_path
|
||||
|
||||
expect(page).not_to have_content(budget.name)
|
||||
end
|
||||
|
||||
scenario "Not listed to logged users at the public budgets list" do
|
||||
login_as(level_two_user)
|
||||
visit budgets_path
|
||||
|
||||
expect(page).not_to have_content(budget.name)
|
||||
end
|
||||
|
||||
scenario "Is listed to admins at the public budgets list" do
|
||||
login_as(admin)
|
||||
visit budgets_path
|
||||
|
||||
expect(page).to have_content(budget.name)
|
||||
end
|
||||
end
|
||||
|
||||
context "Shown" do
|
||||
scenario "Not accesible to guest users" do
|
||||
expect { visit budget_path(budget) }.to raise_error(ActionController::RoutingError)
|
||||
end
|
||||
|
||||
scenario "Not accesible to logged users" do
|
||||
login_as(level_two_user)
|
||||
|
||||
expect { visit budget_path(budget) }.to raise_error(ActionController::RoutingError)
|
||||
end
|
||||
|
||||
scenario "Is accesible to admin users" do
|
||||
login_as(admin)
|
||||
visit budget_path(budget)
|
||||
|
||||
expect(page.status_code).to eq(200)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context 'Accepting' do
|
||||
|
||||
background do
|
||||
budget.update(phase: 'accepting')
|
||||
@@ -72,8 +124,7 @@ feature 'Budgets' do
|
||||
context "Permissions" do
|
||||
|
||||
scenario "Verified user" do
|
||||
user = create(:user, :level_two)
|
||||
login_as(user)
|
||||
login_as(level_two_user)
|
||||
|
||||
visit budget_path(budget)
|
||||
|
||||
@@ -97,4 +148,4 @@ feature 'Budgets' do
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -65,7 +65,7 @@ feature 'Results' do
|
||||
end
|
||||
|
||||
scenario "If budget is in a phase different from finished results can't be accessed" do
|
||||
budget.update phase: (Budget::PHASES - ["finished"]).sample
|
||||
budget.update(phase: (Budget::PHASES - ['drafting', 'finished']).sample)
|
||||
visit budget_path(budget)
|
||||
expect(page).not_to have_link "See results"
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ feature 'Tags' do
|
||||
let!(:heading) { create(:budget_heading, name: "More hospitals", group: group) }
|
||||
let!(:tag_medio_ambiente) { create(:tag, :category, name: 'Medio Ambiente') }
|
||||
let!(:tag_economia) { create(:tag, :category, name: 'Economía') }
|
||||
let(:admin) { create(:administrator).user }
|
||||
|
||||
scenario 'Index' do
|
||||
earth = create(:budget_investment, heading: heading, tag_list: tag_medio_ambiente.name)
|
||||
@@ -185,6 +186,7 @@ feature 'Tags' do
|
||||
Budget::PHASES.each do |phase|
|
||||
budget.update(phase: phase)
|
||||
|
||||
login_as(admin) if budget.drafting?
|
||||
visit budget_investments_path(budget, heading_id: heading.id)
|
||||
|
||||
within "#tag-cloud" do
|
||||
@@ -204,6 +206,7 @@ feature 'Tags' do
|
||||
end
|
||||
end
|
||||
|
||||
login_as(admin) if budget.drafting?
|
||||
visit budget_path(budget)
|
||||
click_link group.name
|
||||
|
||||
@@ -230,6 +233,7 @@ feature 'Tags' do
|
||||
Budget::PHASES.each do |phase|
|
||||
budget.update(phase: phase)
|
||||
|
||||
login_as(admin) if budget.drafting?
|
||||
visit budget_investments_path(budget, heading_id: heading.id)
|
||||
|
||||
within "#categories" do
|
||||
@@ -249,6 +253,7 @@ feature 'Tags' do
|
||||
end
|
||||
end
|
||||
|
||||
login_as(admin) if budget.drafting?
|
||||
visit budget_path(budget)
|
||||
click_link group.name
|
||||
|
||||
@@ -282,8 +287,7 @@ feature 'Tags' do
|
||||
investment.set_tag_list_on(:valuation, 'Education')
|
||||
investment.save
|
||||
|
||||
admin = create(:administrator)
|
||||
login_as(admin.user)
|
||||
login_as(admin)
|
||||
|
||||
visit admin_budget_budget_investment_path(budget, investment)
|
||||
click_link 'Edit classification'
|
||||
|
||||
@@ -40,6 +40,9 @@ describe Budget do
|
||||
end
|
||||
|
||||
it "produces auxiliary methods" do
|
||||
budget.phase = "drafting"
|
||||
expect(budget).to be_drafting
|
||||
|
||||
budget.phase = "accepting"
|
||||
expect(budget).to be_accepting
|
||||
|
||||
@@ -63,6 +66,9 @@ describe Budget do
|
||||
end
|
||||
|
||||
it "on_hold?" do
|
||||
budget.phase = "drafting"
|
||||
expect(budget).not_to be_on_hold
|
||||
|
||||
budget.phase = "accepting"
|
||||
expect(budget).not_to be_on_hold
|
||||
|
||||
@@ -86,6 +92,9 @@ describe Budget do
|
||||
end
|
||||
|
||||
it "balloting_or_later?" do
|
||||
budget.phase = "drafting"
|
||||
expect(budget).not_to be_balloting_or_later
|
||||
|
||||
budget.phase = "accepting"
|
||||
expect(budget).not_to be_balloting_or_later
|
||||
|
||||
|
||||
Reference in New Issue
Block a user