Give purpose to previously unused on_budget_investments scope
The "on_budget_investments" scope in Activity has never been used
anywhere in the codebase. It was introduced in commit d9d38482b3
("extends Activity to include Investment valuations") but no references
were ever added.
Instead of removing it, we make use of the scope by adding the missing
"Budget investments" filter to the admin Activity section. This aligns
it with the rest of the activity filters and gives the scope the purpose
it was originally intended for.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
class Admin::ActivityController < Admin::BaseController
|
||||
has_filters %w[all on_users on_proposals on_debates on_comments on_system_emails]
|
||||
has_filters %w[all on_users on_proposals on_debates on_comments on_budget_investments on_system_emails]
|
||||
|
||||
def show
|
||||
@activity = Activity.for_render.send(@current_filter)
|
||||
|
||||
@@ -62,6 +62,7 @@ en:
|
||||
filter: Show
|
||||
filters:
|
||||
all: All
|
||||
on_budget_investments: Investment projects
|
||||
on_comments: Comments
|
||||
on_debates: Debates
|
||||
on_proposals: Proposals
|
||||
|
||||
@@ -62,6 +62,7 @@ es:
|
||||
filter: Mostrar
|
||||
filters:
|
||||
all: Todos
|
||||
on_budget_investments: Proyectos de gasto
|
||||
on_comments: Comentarios
|
||||
on_debates: Debates
|
||||
on_proposals: Propuestas
|
||||
|
||||
@@ -378,4 +378,75 @@ describe "Admin activity" do
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "Budget investments" do
|
||||
scenario "Shows moderation activity on budget investments" do
|
||||
investment = create(:budget_investment, description: "<p>Investment description</p>")
|
||||
|
||||
visit budget_investment_path(investment.budget, investment)
|
||||
|
||||
within "#budget_investment_#{investment.id}" do
|
||||
accept_confirm("Are you sure? Hide") { click_button "Hide" }
|
||||
end
|
||||
|
||||
expect(page).to have_css "#budget_investment_#{investment.id}.faded"
|
||||
|
||||
visit admin_activity_path
|
||||
|
||||
within first("tbody tr") do
|
||||
expect(page).to have_content(investment.title)
|
||||
expect(page).to have_content("Hidden")
|
||||
expect(page).to have_content(admin.user.username)
|
||||
expect(page).to have_css("p", exact_text: "Investment description")
|
||||
end
|
||||
end
|
||||
|
||||
scenario "Shows moderation activity from moderation screen" do
|
||||
investment1 = create(:budget_investment)
|
||||
investment2 = create(:budget_investment)
|
||||
investment3 = create(:budget_investment)
|
||||
|
||||
visit moderation_budget_investments_path(filter: "all")
|
||||
|
||||
within "#investment_#{investment1.id}" do
|
||||
check "budget_investment_#{investment1.id}_check"
|
||||
end
|
||||
|
||||
within "#investment_#{investment3.id}" do
|
||||
check "budget_investment_#{investment3.id}_check"
|
||||
end
|
||||
|
||||
accept_confirm("Are you sure? Hide budget investments") do
|
||||
click_button "Hide budget investments"
|
||||
end
|
||||
|
||||
expect(page).not_to have_content(investment1.title)
|
||||
|
||||
visit admin_activity_path(filter: "on_budget_investments")
|
||||
|
||||
expect(page).to have_content(investment1.title)
|
||||
expect(page).not_to have_content(investment2.title)
|
||||
expect(page).to have_content(investment3.title)
|
||||
end
|
||||
|
||||
scenario "Shows admin restores" do
|
||||
investment = create(:budget_investment, :hidden)
|
||||
|
||||
visit admin_hidden_budget_investments_path
|
||||
|
||||
within "#budget_investment_#{investment.id}" do
|
||||
accept_confirm("Are you sure? Restore") { click_button "Restore" }
|
||||
end
|
||||
|
||||
expect(page).to have_content "There are no hidden budget investments"
|
||||
|
||||
visit admin_activity_path
|
||||
|
||||
within first("tbody tr") do
|
||||
expect(page).to have_content(investment.title)
|
||||
expect(page).to have_content("Restored")
|
||||
expect(page).to have_content(admin.user.username)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user