Files
nairobi/spec/controllers/admin/budget_headings_controller_spec.rb
Julian Herrero 2b709f1a36 Groups and headings CRUD from budget view
Before, users needed to navigate to the list of groups in order to
add, edit or delete a group.

Also, they need to navigate to the list of groups first, and then to
the list of headings for that group in order to add, edit or delete a
heading.

Now, it's possible to do all these actions for any group or heading
from the participatory budget view to bring simplicity and to reduce
the number of clicks from a user perspective.

Co-Authored-By: Javi Martín <javim@elretirao.net>
2021-10-25 18:01:47 +02:00

55 lines
1.8 KiB
Ruby

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 :new, 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