Move exception tests to controller specs

System tests are used to test the application from the user's point of
view. To test for specific exceptions, particularly regarding
authorization permissions, controller tests fit better.

Another option would be to test the page displayed shows a certain text,
like "Internal server error". I'm choosing controller tests because
they're faster and we're basically testing the same scenario many times
and we've already got a test checking what happens when users access a
page raising an exception.
This commit is contained in:
Javi Martín
2021-03-30 13:28:49 +02:00
parent abd6a1971f
commit 02981324ab
53 changed files with 509 additions and 379 deletions

View File

@@ -0,0 +1,41 @@
require "rails_helper"
describe Admin::BudgetGroupsController, :admin do
describe "GET index" do
it "raises an exception when the feature is disabled" do
Setting["process.budgets"] = false
expect do
get :index, params: { budget_id: create(:budget).id }
end.to raise_exception(FeatureFlags::FeatureDisabled)
end
end
describe "GET edit" do
let(:group) { create(:budget_group) }
it "raises an error if budget slug is not found" do
expect do
get :edit, params: { budget_id: "wrong_budget", id: group.id }
end.to raise_error ActiveRecord::RecordNotFound
end
it "raises an error if budget id is not found" do
expect do
get :edit, params: { budget_id: 0, id: group.id }
end.to raise_error ActiveRecord::RecordNotFound
end
it "raises an error if group slug is not found" do
expect do
get :edit, params: { budget_id: group.budget.id, id: "wrong_group" }
end.to raise_error ActiveRecord::RecordNotFound
end
it "raises an error if group id is not found" do
expect do
get :edit, params: { budget_id: 0, id: "wrong_group" }
end.to raise_error ActiveRecord::RecordNotFound
end
end
end

View File

@@ -0,0 +1,54 @@
require "rails_helper"
describe Admin::BudgetHeadingsController, :admin do
context "processes disabled" do
it "raises feature disabled for budgets" do
Setting["process.budgets"] = nil
group = create(:budget_group)
expect do
get :index, params: { budget_id: group.budget.id, group_id: group.id }
end.to raise_exception(FeatureFlags::FeatureDisabled)
end
end
describe "GET edit" do
let(:heading) { create(:budget_heading) }
it "raises an error if budget slug is not found" do
expect do
get :edit, params: { budget_id: "wrong_budget", group_id: heading.group.id, id: heading.id }
end.to raise_error ActiveRecord::RecordNotFound
end
it "raises an error if budget id is not found" do
expect do
get :edit, params: { budget_id: 0, group_id: heading.group.id, id: heading.id }
end.to raise_error ActiveRecord::RecordNotFound
end
it "raises an error if group slug is not found" do
expect do
get :edit, params: { budget_id: heading.budget.id, group_id: "wrong group", id: heading.id }
end.to raise_error ActiveRecord::RecordNotFound
end
it "raises an error if group id is not found" do
expect do
get :edit, params: { budget_id: heading.budget.id, group_id: 0, id: heading.id }
end.to raise_error ActiveRecord::RecordNotFound
end
it "raises an error if heading slug is not found" do
expect do
get :edit, params: { budget_id: heading.budget.id, group_id: heading.group.id, id: "wrong heading" }
end.to raise_error ActiveRecord::RecordNotFound
end
it "raises an error if heading id is not found" do
expect do
get :edit, params: { budget_id: heading.budget.id, group_id: heading.group.id, id: 0 }
end.to raise_error ActiveRecord::RecordNotFound
end
end
end

View File

@@ -1,6 +1,20 @@
require "rails_helper"
describe Admin::BudgetInvestmentsController, :admin do
describe "GET index" do
it "raises an error if budget slug is not found" do
expect do
get :index, params: { budget_id: "wrong_budget" }
end.to raise_error ActiveRecord::RecordNotFound
end
it "raises an error if budget id is not found" do
expect do
get :index, params: { budget_id: 0 }
end.to raise_error ActiveRecord::RecordNotFound
end
end
describe "PATCH update" do
it "does not redirect on AJAX requests" do
investment = create(:budget_investment)

View File

@@ -0,0 +1,25 @@
require "rails_helper"
describe Admin::BudgetsController, :admin do
describe "GET index" do
it "raises an exception when the feature is disabled" do
Setting["process.budgets"] = false
expect { get :index }.to raise_exception(FeatureFlags::FeatureDisabled)
end
end
describe "GET edit" do
it "raises an error if budget slug is not found" do
expect do
get :edit, params: { id: "wrong_budget" }
end.to raise_error ActiveRecord::RecordNotFound
end
it "raises an error if budget id is not found" do
expect do
get :edit, params: { id: 0 }
end.to raise_error ActiveRecord::RecordNotFound
end
end
end

View File

@@ -0,0 +1,11 @@
require "rails_helper"
describe Admin::HiddenBudgetInvestmentsController, :admin do
describe "GET index" do
it "raises an exception when the feature is disabled" do
Setting["process.budgets"] = nil
expect { get :index }.to raise_exception(FeatureFlags::FeatureDisabled)
end
end
end

View File

@@ -1,6 +1,14 @@
require "rails_helper"
describe Admin::HiddenDebatesController, :admin do
describe "GET index" do
it "raises an exception when the feature is disabled" do
Setting["process.debates"] = false
expect { get :index }.to raise_exception(FeatureFlags::FeatureDisabled)
end
end
describe "PUT confirm_hide" do
it "keeps query parameters while using protected redirects" do
debate = create(:debate, :hidden)

View File

@@ -0,0 +1,11 @@
require "rails_helper"
describe Admin::HiddenProposalsController, :admin do
describe "GET index" do
it "raises an exception when the feature is disabled" do
Setting["process.proposals"] = false
expect { get :index }.to raise_exception(FeatureFlags::FeatureDisabled)
end
end
end

View File

@@ -0,0 +1,13 @@
require "rails_helper"
describe Admin::Legislation::DraftVersionsController, :admin do
describe "GET index" do
it "raises an exception when the feature is disabled" do
Setting["process.legislation"] = false
expect do
get :index, params: { process_id: create(:legislation_process).id }
end.to raise_exception(FeatureFlags::FeatureDisabled)
end
end
end

View File

@@ -0,0 +1,11 @@
require "rails_helper"
describe Admin::Legislation::ProcessesController, :admin do
describe "GET index" do
it "raises an exception when the feature is disabled" do
Setting["process.legislation"] = false
expect { get :index }.to raise_exception(FeatureFlags::FeatureDisabled)
end
end
end

View File

@@ -0,0 +1,13 @@
require "rails_helper"
describe Admin::Legislation::QuestionsController, :admin do
describe "GET index" do
it "raises an exception when the feature is disabled" do
Setting["process.legislation"] = nil
expect do
get :index, params: { process_id: create(:legislation_process).id }
end.to raise_exception(FeatureFlags::FeatureDisabled)
end
end
end

View File

@@ -0,0 +1,11 @@
require "rails_helper"
describe Admin::Poll::PollsController, :admin do
describe "GET index" do
it "raises an exception when the feature is disabled" do
Setting["process.polls"] = false
expect { get :index }.to raise_exception(FeatureFlags::FeatureDisabled)
end
end
end

View File

@@ -0,0 +1,19 @@
require "rails_helper"
describe Budgets::BallotsController do
before { sign_in(create(:user, :level_two)) }
describe "GET show" do
it "raises an error if budget slug is not found" do
expect do
get :show, params: { budget_id: "wrong_budget" }
end.to raise_error ActiveRecord::RecordNotFound
end
it "raises an error if budget id is not found" do
expect do
get :show, params: { budget_id: 0 }
end.to raise_error ActiveRecord::RecordNotFound
end
end
end

View File

@@ -0,0 +1,31 @@
require "rails_helper"
describe Budgets::GroupsController do
describe "GET show" do
let(:group) { create(:budget_group) }
it "raises an error if budget slug is not found" do
expect do
get :show, params: { budget_id: "wrong_budget", id: group.id }
end.to raise_error ActiveRecord::RecordNotFound
end
it "raises an error if budget id is not found" do
expect do
get :show, params: { budget_id: 0, id: group.id }
end.to raise_error ActiveRecord::RecordNotFound
end
it "raises an error if group slug is not found" do
expect do
get :show, params: { budget_id: group.budget.id, id: "wrong group" }
end.to raise_error ActiveRecord::RecordNotFound
end
it "raises an error if group id is not found" do
expect do
get :show, params: { budget_id: group.budget.id, id: 0 }
end.to raise_error ActiveRecord::RecordNotFound
end
end
end

View File

@@ -0,0 +1,31 @@
require "rails_helper"
describe Budgets::InvestmentsController do
describe "GET show" do
let(:investment) { create(:budget_investment) }
it "raises an error if budget slug is not found" do
expect do
get :show, params: { budget_id: "wrong_budget", id: investment.id }
end.to raise_error ActiveRecord::RecordNotFound
end
it "raises an error if budget id is not found" do
expect do
get :show, params: { budget_id: 0, id: investment.id }
end.to raise_error ActiveRecord::RecordNotFound
end
it "raises an error if heading slug is not found" do
expect do
get :show, params: { budget_id: investment.budget.id, id: investment.id, heading_id: "wrong_heading" }
end.to raise_error ActiveRecord::RecordNotFound
end
it "raises an error if heading id is not found" do
expect do
get :show, params: { budget_id: investment.budget.id, id: investment.id, heading_id: 0 }
end.to raise_error ActiveRecord::RecordNotFound
end
end
end

View File

@@ -0,0 +1,17 @@
require "rails_helper"
describe Budgets::StatsController do
describe "GET show" do
it "raises an error if budget slug is not found" do
expect do
get :show, params: { budget_id: "wrong_budget" }
end.to raise_error ActiveRecord::RecordNotFound
end
it "raises an error if budget id is not found" do
expect do
get :show, params: { budget_id: 0 }
end.to raise_error ActiveRecord::RecordNotFound
end
end
end

View File

@@ -0,0 +1,41 @@
require "rails_helper"
describe BudgetsController do
describe "GET show" do
it "raises an error if budget slug is not found" do
expect do
get :show, params: { id: "wrong_budget" }
end.to raise_error ActiveRecord::RecordNotFound
end
it "raises an error if budget id is not found" do
expect do
get :show, params: { id: 0 }
end.to raise_error ActiveRecord::RecordNotFound
end
context "drafting budget" do
let(:budget) { create(:budget, published: false) }
it "is not accesible to guest users" do
expect do
get :show, params: { id: budget.id }
end.to raise_error(ActionController::RoutingError)
end
it "is not accesible to logged users" do
sign_in(create(:user, :level_two))
expect do
get :show, params: { id: budget.id }
end.to raise_error(ActionController::RoutingError)
end
it "is accesible to admin users", :admin do
get :show, params: { id: budget.id }
expect(response).to be_successful
end
end
end
end

View File

@@ -0,0 +1,15 @@
require "rails_helper"
describe CommunitiesController do
describe "GET show" do
it "raises an exception accessing a community without associated communitable" do
proposal = create(:proposal)
community = proposal.community
proposal.really_destroy!
expect do
get :show, params: { id: community.id }
end.to raise_error(ActionController::RoutingError)
end
end
end

View File

@@ -1,6 +1,14 @@
require "rails_helper"
describe DebatesController do
describe "GET index" do
it "raises an exception when the feature is disabled" do
Setting["process.debates"] = false
expect { get :index }.to raise_exception(FeatureFlags::FeatureDisabled)
end
end
describe "POST create" do
before do
InvisibleCaptcha.timestamp_enabled = false

View File

@@ -0,0 +1,26 @@
require "rails_helper"
describe Management::Budgets::InvestmentsController do
before do
manager = create(:manager)
sign_in(manager.user)
session[:manager] = { login: "manager_user_#{manager.user.id}" }
login_managed_user(create(:user, :level_two))
end
describe "GET show" do
let(:investment) { create(:budget_investment) }
it "raises an error if budget slug is not found" do
expect do
get :show, params: { budget_id: "wrong_budget", id: investment.id }
end.to raise_error ActiveRecord::RecordNotFound
end
it "raises an error if budget id is not found" do
expect do
get :show, params: { budget_id: 0, id: investment.id }
end.to raise_error ActiveRecord::RecordNotFound
end
end
end

View File

@@ -3,6 +3,14 @@ require "rails_helper"
describe Moderation::Budgets::InvestmentsController do
before { sign_in create(:moderator).user }
describe "GET index" do
it "raises an exception when the feature is disabled" do
Setting["process.budgets"] = nil
expect { get :index }.to raise_exception(FeatureFlags::FeatureDisabled)
end
end
describe "PUT moderate" do
it "keeps query parameters while using protected redirects" do
id = create(:budget_investment).id

View File

@@ -0,0 +1,13 @@
require "rails_helper"
describe Moderation::DebatesController do
before { sign_in(create(:moderator).user) }
describe "GET index" do
it "raises an exception when the feature is disabled" do
Setting["process.debates"] = false
expect { get :index }.to raise_exception(FeatureFlags::FeatureDisabled)
end
end
end

View File

@@ -0,0 +1,13 @@
require "rails_helper"
describe Moderation::ProposalsController do
before { sign_in(create(:moderator).user) }
describe "GET index" do
it "raises an exception when the feature is disabled" do
Setting["process.proposals"] = false
expect { get :index }.to raise_exception(FeatureFlags::FeatureDisabled)
end
end
end

View File

@@ -0,0 +1,11 @@
require "rails_helper"
describe PollsController do
describe "GET index" do
it "raises an exception when the feature is disabled" do
Setting["process.polls"] = false
expect { get :index }.to raise_exception(FeatureFlags::FeatureDisabled)
end
end
end

View File

@@ -0,0 +1,11 @@
require "rails_helper"
describe ProposalsController do
describe "GET index" do
it "raises an exception when the feature is disabled" do
Setting["process.proposals"] = false
expect { get :index }.to raise_exception(FeatureFlags::FeatureDisabled)
end
end
end

View File

@@ -0,0 +1,40 @@
require "rails_helper"
describe Valuation::BudgetInvestmentsController do
let(:valuator) { create(:valuator) }
let(:budget) { create(:budget, valuators: [valuator]) }
before { sign_in(valuator.user) }
describe "GET index" do
it "raises an exception when the feature is disabled" do
Setting["process.budgets"] = false
expect do
get :index, params: { budget_id: budget.id }
end.to raise_exception(FeatureFlags::FeatureDisabled)
end
it "raises an error if budget slug is not found" do
expect do
get :index, params: { budget_id: "wrong_budget" }
end.to raise_error ActiveRecord::RecordNotFound
end
it "raises an error if budget id is not found" do
expect do
get :index, params: { budget_id: 0 }
end.to raise_error ActiveRecord::RecordNotFound
end
end
describe "GET show" do
it "is not visible for not assigned valuators" do
investment = create(:budget_investment, budget: budget)
login_as create(:valuator).user
expect do
get :show, params: { budget_id: budget.id, id: investment.id }
end.to raise_error ActionController::RoutingError
end
end
end

View File

@@ -0,0 +1,13 @@
require "rails_helper"
describe Valuation::BudgetsController do
before { sign_in(create(:valuator).user) }
describe "GET index" do
it "raises an exception when the feature is disabled" do
Setting["process.budgets"] = false
expect { get :index }.to raise_exception(FeatureFlags::FeatureDisabled)
end
end
end

View File

@@ -3,18 +3,6 @@ require "rails_helper"
describe "Admin budget groups", :admin do
let(:budget) { create(:budget, :drafting) }
context "Feature flag" do
before do
Setting["process.budgets"] = nil
end
scenario "Disabled with a feature flag" do
expect do
visit admin_budget_groups_path(budget)
end.to raise_exception(FeatureFlags::FeatureDisabled)
end
end
context "Load" do
let!(:budget) { create(:budget, slug: "budget_slug") }
let!(:group) { create(:budget_group, slug: "group_slug", budget: budget) }
@@ -24,30 +12,6 @@ describe "Admin budget groups", :admin do
expect(page).to have_content(budget.name)
expect(page).to have_field "Group name", with: group.name
end
scenario "raises an error if budget slug is not found" do
expect do
visit edit_admin_budget_group_path("wrong_budget", group)
end.to raise_error ActiveRecord::RecordNotFound
end
scenario "raises an error if budget id is not found" do
expect do
visit edit_admin_budget_group_path(0, group)
end.to raise_error ActiveRecord::RecordNotFound
end
scenario "raises an error if group slug is not found" do
expect do
visit edit_admin_budget_group_path(budget, "wrong_group")
end.to raise_error ActiveRecord::RecordNotFound
end
scenario "raises an error if group id is not found" do
expect do
visit edit_admin_budget_group_path(budget, 0)
end.to raise_error ActiveRecord::RecordNotFound
end
end
context "Index" do

View File

@@ -4,18 +4,6 @@ describe "Admin budget headings", :admin do
let(:budget) { create(:budget, :drafting) }
let(:group) { create(:budget_group, budget: budget) }
context "Feature flag" do
before do
Setting["process.budgets"] = nil
end
scenario "Disabled with a feature flag" do
expect do
visit admin_budget_group_headings_path(budget, group)
end.to raise_exception(FeatureFlags::FeatureDisabled)
end
end
context "Load" do
let!(:budget) { create(:budget, slug: "budget_slug") }
let!(:group) { create(:budget_group, slug: "group_slug", budget: budget) }
@@ -27,42 +15,6 @@ describe "Admin budget headings", :admin do
expect(page).to have_content(group.name)
expect(page).to have_field "Heading name", with: heading.name
end
scenario "raises an error if budget slug is not found" do
expect do
visit edit_admin_budget_group_heading_path("wrong_budget", group, heading)
end.to raise_error ActiveRecord::RecordNotFound
end
scenario "raises an error if budget id is not found" do
expect do
visit edit_admin_budget_group_heading_path(0, group, heading)
end.to raise_error ActiveRecord::RecordNotFound
end
scenario "raises an error if group slug is not found" do
expect do
visit edit_admin_budget_group_heading_path(budget, "wrong_group", heading)
end.to raise_error ActiveRecord::RecordNotFound
end
scenario "raises an error if group id is not found" do
expect do
visit edit_admin_budget_group_heading_path(budget, 0, heading)
end.to raise_error ActiveRecord::RecordNotFound
end
scenario "raises an error if heading slug is not found" do
expect do
visit edit_admin_budget_group_heading_path(budget, group, "wrong_heading")
end.to raise_error ActiveRecord::RecordNotFound
end
scenario "raises an error if heading id is not found" do
expect do
visit edit_admin_budget_group_heading_path(budget, group, 0)
end.to raise_error ActiveRecord::RecordNotFound
end
end
context "Index" do

View File

@@ -10,16 +10,6 @@ describe "Admin budget investments", :admin do
:budget_investment,
"admin_polymorphic_path"
context "Feature flag" do
before do
Setting["process.budgets"] = nil
end
scenario "Disabled with a feature flag" do
expect { visit admin_budgets_path }.to raise_exception(FeatureFlags::FeatureDisabled)
end
end
context "Load" do
let!(:investment) { create(:budget_investment, budget: budget) }
@@ -30,18 +20,6 @@ describe "Admin budget investments", :admin do
expect(page).to have_link investment.title
end
scenario "raises an error if budget slug is not found" do
expect do
visit admin_budget_budget_investments_path("wrong_budget", investment)
end.to raise_error ActiveRecord::RecordNotFound
end
scenario "raises an error if budget id is not found" do
expect do
visit admin_budget_budget_investments_path(0, investment)
end.to raise_error ActiveRecord::RecordNotFound
end
end
context "Index" do

View File

@@ -1,16 +1,6 @@
require "rails_helper"
describe "Admin budgets", :admin do
context "Feature flag" do
before do
Setting["process.budgets"] = nil
end
scenario "Disabled with a feature flag" do
expect { visit admin_budgets_path }.to raise_exception(FeatureFlags::FeatureDisabled)
end
end
context "Load" do
let!(:budget) { create(:budget, slug: "budget_slug") }
@@ -19,18 +9,6 @@ describe "Admin budgets", :admin do
expect(page).to have_content("Edit Participatory budget")
end
scenario "raises an error if budget slug is not found" do
expect do
visit edit_admin_budget_path("wrong_budget")
end.to raise_error ActiveRecord::RecordNotFound
end
scenario "raises an error if budget id is not found" do
expect do
visit edit_admin_budget_path(0)
end.to raise_error ActiveRecord::RecordNotFound
end
end
context "Index" do

View File

@@ -4,12 +4,6 @@ describe "Admin hidden budget investments", :admin do
let(:budget) { create(:budget) }
let(:heading) { create(:budget_heading, budget: budget, price: 666666) }
scenario "Disabled with a feature flag" do
Setting["process.budgets"] = nil
expect { visit admin_hidden_budget_investments_path }.to raise_exception(FeatureFlags::FeatureDisabled)
end
scenario "List shows all relevant info" do
investment = create(:budget_investment, :hidden, heading: heading)

View File

@@ -1,12 +1,6 @@
require "rails_helper"
describe "Admin hidden debates", :admin do
scenario "Disabled with a feature flag" do
Setting["process.debates"] = nil
expect { visit admin_hidden_debates_path }.to raise_exception(FeatureFlags::FeatureDisabled)
end
scenario "Restore" do
debate = create(:debate, :hidden)
visit admin_hidden_debates_path

View File

@@ -1,12 +1,6 @@
require "rails_helper"
describe "Admin hidden proposals", :admin do
scenario "Disabled with a feature flag" do
Setting["process.proposals"] = nil
expect { visit admin_hidden_proposals_path }.to raise_exception(FeatureFlags::FeatureDisabled)
end
scenario "List shows all relevant info" do
proposal = create(:proposal, :hidden)
visit admin_hidden_proposals_path

View File

@@ -1,14 +1,6 @@
require "rails_helper"
describe "Admin legislation draft versions", :admin do
context "Feature flag" do
scenario "Disabled with a feature flag" do
Setting["process.legislation"] = nil
process = create(:legislation_process)
expect { visit admin_legislation_process_draft_versions_path(process) }.to raise_exception(FeatureFlags::FeatureDisabled)
end
end
context "Index" do
scenario "Displaying legislation process draft versions" do
process = create(:legislation_process, title: "An example legislation process")

View File

@@ -5,14 +5,6 @@ describe "Admin collaborative legislation", :admin do
:legislation_process,
"admin_legislation_process_milestones_path"
context "Feature flag" do
scenario "Disabled with a feature flag" do
Setting["process.legislation"] = nil
expect { visit admin_legislation_processes_path }
.to raise_exception(FeatureFlags::FeatureDisabled)
end
end
context "Index" do
scenario "Displaying collaborative legislation" do
process_1 = create(:legislation_process, title: "Process open")

View File

@@ -3,16 +3,6 @@ require "rails_helper"
describe "Admin legislation questions", :admin do
let!(:process) { create(:legislation_process, title: "An example legislation process") }
context "Feature flag" do
before do
Setting["process.legislation"] = nil
end
scenario "Disabled with a feature flag" do
expect { visit admin_legislation_process_questions_path(process) }.to raise_exception(FeatureFlags::FeatureDisabled)
end
end
context "Index" do
scenario "Displaying legislation process questions" do
create(:legislation_question, process: process, title: "Question 1")

View File

@@ -1,11 +1,6 @@
require "rails_helper"
describe "Admin polls", :admin do
scenario "Disabled with a feature flag" do
Setting["process.polls"] = nil
expect { visit admin_polls_path }.to raise_exception(FeatureFlags::FeatureDisabled)
end
scenario "Index empty", :js do
visit admin_root_path

View File

@@ -23,18 +23,6 @@ describe "Ballots" do
expect(page).to have_content("You have voted one investment")
end
scenario "raises an error if budget slug is not found" do
expect do
visit budget_ballot_path("wrong_budget")
end.to raise_error ActiveRecord::RecordNotFound
end
scenario "raises an error if budget id is not found" do
expect do
visit budget_ballot_path(0)
end.to raise_error ActiveRecord::RecordNotFound
end
end
context "Lines Load" do

View File

@@ -13,18 +13,6 @@ describe "Budgets" do
expect(page).to have_content budget.name
end
scenario "raises an error if budget slug is not found" do
expect do
visit budget_path("wrong_budget")
end.to raise_error ActiveRecord::RecordNotFound
end
scenario "raises an error if budget id is not found" do
expect do
visit budget_path(0)
end.to raise_error ActiveRecord::RecordNotFound
end
end
context "Index" do
@@ -412,10 +400,7 @@ describe "Budgets" do
end
context "In Drafting phase" do
let(:admin) { create(:administrator).user }
before do
logout
budget.update!(published: false)
create(:budget)
end
@@ -427,25 +412,6 @@ describe "Budgets" do
expect(page).not_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

View File

@@ -14,30 +14,6 @@ describe "Budget Groups" do
visit budget_group_path(budget, group)
expect(page).to have_content "Select an option"
end
scenario "raises an error if budget slug is not found" do
expect do
visit budget_group_path("wrong_budget", group)
end.to raise_error ActiveRecord::RecordNotFound
end
scenario "raises an error if budget id is not found" do
expect do
visit budget_group_path(0, group)
end.to raise_error ActiveRecord::RecordNotFound
end
scenario "raises an error if group slug is not found" do
expect do
visit budget_group_path(budget, "wrong_group")
end.to raise_error ActiveRecord::RecordNotFound
end
scenario "raises an error if group id is not found" do
expect do
visit budget_group_path(budget, 0)
end.to raise_error ActiveRecord::RecordNotFound
end
end
context "Show" do

View File

@@ -39,35 +39,11 @@ describe "Budget Investments" do
expect(page).to have_content investment.title
end
scenario "raises an error if budget slug is not found" do
expect do
visit budget_investment_path("wrong_budget", investment)
end.to raise_error ActiveRecord::RecordNotFound
end
scenario "raises an error if budget id is not found" do
expect do
visit budget_investment_path(0, investment)
end.to raise_error ActiveRecord::RecordNotFound
end
scenario "finds investment using heading slug" do
visit budget_investment_path(budget, investment, heading_id: "heading_slug")
expect(page).to have_content investment.title
end
scenario "raises an error if heading slug is not found" do
expect do
visit budget_investment_path(budget, investment, heading_id: "wrong_heading")
end.to raise_error ActiveRecord::RecordNotFound
end
scenario "raises an error if heading id is not found" do
expect do
visit budget_investment_path(budget, investment, heading_id: 0)
end.to raise_error ActiveRecord::RecordNotFound
end
end
scenario "Index" do

View File

@@ -12,18 +12,6 @@ describe "Stats" do
expect(page).to have_content budget.name
end
scenario "raises an error if budget slug is not found" do
expect do
visit budget_stats_path("wrong_budget")
end.to raise_error ActiveRecord::RecordNotFound
end
scenario "raises an error if budget id is not found" do
expect do
visit budget_stats_path(0)
end.to raise_error ActiveRecord::RecordNotFound
end
end
describe "Show" do

View File

@@ -135,14 +135,5 @@ describe "Communities" do
expect(page).to have_current_path(root_path)
end
scenario "Accesing a community without associated communitable" do
proposal = create(:proposal)
community = proposal.community
proposal.really_destroy!
community.reload
expect { visit community_path(community) }.to raise_error(ActionController::RoutingError)
end
end
end

View File

@@ -1,11 +1,6 @@
require "rails_helper"
describe "Debates" do
scenario "Disabled with a feature flag" do
Setting["process.debates"] = nil
expect { visit debates_path }.to raise_exception(FeatureFlags::FeatureDisabled)
end
context "Concerns" do
it_behaves_like "notifiable in-app", :debate
it_behaves_like "relationable", Debate

View File

@@ -28,18 +28,6 @@ describe "Budget Investments" do
expect(page).to have_content investment.title
end
scenario "raises an error if budget slug is not found" do
expect do
visit management_budget_investment_path("wrong_budget", investment)
end.to raise_error ActiveRecord::RecordNotFound
end
scenario "raises an error if budget id is not found" do
expect do
visit management_budget_investment_path(0, investment)
end.to raise_error ActiveRecord::RecordNotFound
end
end
context "Create" do

View File

@@ -6,13 +6,6 @@ describe "Moderate budget investments" do
let(:mod) { create(:moderator) }
let!(:investment) { create(:budget_investment, heading: heading, author: create(:user)) }
scenario "Disabled with a feature flag" do
Setting["process.budgets"] = nil
login_as(mod.user)
expect { visit moderation_budget_investments_path }.to raise_exception(FeatureFlags::FeatureDisabled)
end
scenario "Hiding an investment", :js do
login_as(mod.user)
visit budget_investment_path(budget, investment)

View File

@@ -1,14 +1,6 @@
require "rails_helper"
describe "Moderate debates" do
scenario "Disabled with a feature flag" do
Setting["process.debates"] = nil
moderator = create(:moderator)
login_as(moderator.user)
expect { visit moderation_debates_path }.to raise_exception(FeatureFlags::FeatureDisabled)
end
scenario "Hide", :js do
citizen = create(:user)
moderator = create(:moderator)

View File

@@ -1,14 +1,6 @@
require "rails_helper"
describe "Moderate proposals" do
scenario "Disabled with a feature flag" do
Setting["process.proposals"] = nil
moderator = create(:moderator)
login_as(moderator.user)
expect { visit moderation_proposals_path }.to raise_exception(FeatureFlags::FeatureDisabled)
end
scenario "Hide", :js do
citizen = create(:user)
proposal = create(:proposal)

View File

@@ -5,11 +5,6 @@ describe "Polls" do
it_behaves_like "notifiable in-app", :poll
end
scenario "Disabled with a feature flag" do
Setting["process.polls"] = nil
expect { visit polls_path }.to raise_exception(FeatureFlags::FeatureDisabled)
end
describe "Index" do
scenario "Shows description for open polls" do
visit polls_path

View File

@@ -3,11 +3,6 @@ require "rails_helper"
describe "Proposals" do
it_behaves_like "milestoneable", :proposal
scenario "Disabled with a feature flag" do
Setting["process.proposals"] = nil
expect { visit proposals_path }.to raise_exception(FeatureFlags::FeatureDisabled)
end
context "Concerns" do
it_behaves_like "notifiable in-app", :proposal
it_behaves_like "relationable", Proposal

View File

@@ -23,9 +23,5 @@ describe "SDG Management" do
expect(page).not_to have_link "SDG content"
end
scenario "does not allow visits to the SDG content" do
expect { visit sdg_management_root_path }.to raise_exception(FeatureFlags::FeatureDisabled)
end
end
end

View File

@@ -18,25 +18,6 @@ describe "Valuation budget investments" do
expect(page).to have_content budget.name
end
scenario "raises an error if budget slug is not found" do
expect do
visit valuation_budget_budget_investments_path("wrong_budget")
end.to raise_error ActiveRecord::RecordNotFound
end
scenario "raises an error if budget id is not found" do
expect do
visit valuation_budget_budget_investments_path(0)
end.to raise_error ActiveRecord::RecordNotFound
end
end
scenario "Disabled with a feature flag" do
Setting["process.budgets"] = nil
expect do
visit valuation_budget_budget_investments_path(create(:budget))
end.to raise_exception(FeatureFlags::FeatureDisabled)
end
scenario "Display link to valuation section" do
@@ -275,15 +256,6 @@ describe "Valuation budget investments" do
expect(page).to have_content("Rick (rick@valuators.org)")
end
end
scenario "not visible for not assigned valuators" do
logout
login_as create(:valuator).user
expect do
visit valuation_budget_budget_investment_path(budget, investment)
end.to raise_error "Not Found"
end
end
describe "Valuate" do

View File

@@ -6,11 +6,6 @@ describe "Valuation budgets" do
login_as(valuator.user)
end
scenario "Disabled with a feature flag" do
Setting["process.budgets"] = nil
expect { visit valuation_budgets_path }.to raise_exception(FeatureFlags::FeatureDisabled)
end
context "Index" do
scenario "Displaying budgets" do
budget = create(:budget)