Simplify tests for audits
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
<% if resource.audits.empty? %>
|
||||
<p><%= t("admin.audits.empty") %></p>
|
||||
<% else %>
|
||||
<table>
|
||||
<table id="audits">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><%= t("admin.audits.id") %></th>
|
||||
|
||||
38
spec/features/admin/audits_spec.rb
Normal file
38
spec/features/admin/audits_spec.rb
Normal file
@@ -0,0 +1,38 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe "Admin change log" do
|
||||
let(:administrator) { create(:administrator, user: create(:user, username: "Ana")) }
|
||||
before { login_as(administrator.user) }
|
||||
|
||||
context "Investments Participatory Budgets" do
|
||||
scenario "Changes" do
|
||||
investment = create(:budget_investment, title: "Good old times")
|
||||
|
||||
visit admin_budget_budget_investment_path(investment.budget, investment)
|
||||
|
||||
expect(page).to have_content "There are no changes logged"
|
||||
|
||||
click_link "Edit"
|
||||
fill_in "Title", with: "Modern times"
|
||||
click_button "Update"
|
||||
|
||||
expect(page).not_to have_content "There are no changes logged"
|
||||
expect(page).to have_content "Change Log"
|
||||
|
||||
within("#audits thead") do
|
||||
expect(page).to have_content "Field"
|
||||
expect(page).to have_content "Old Value"
|
||||
expect(page).to have_content "New Value"
|
||||
expect(page).to have_content "Edited at"
|
||||
expect(page).to have_content "Edited by"
|
||||
end
|
||||
|
||||
within("#audits tbody") do
|
||||
expect(page).to have_content "Title"
|
||||
expect(page).to have_content "Good old times"
|
||||
expect(page).to have_content "Modern times"
|
||||
expect(page).to have_content "Ana"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,66 +0,0 @@
|
||||
require "rails_helper"
|
||||
|
||||
describe "Admin change log" do
|
||||
let(:budget) { create(:budget) }
|
||||
let(:administrator) do
|
||||
create(:administrator, user: create(:user, username: "Ana", email: "ana@admins.org"))
|
||||
end
|
||||
|
||||
context "Investments Participatory Budgets" do
|
||||
before do
|
||||
login_as(create(:administrator).user)
|
||||
end
|
||||
|
||||
scenario "No changes" do
|
||||
budget_investment = create(:budget_investment,
|
||||
:unfeasible,
|
||||
unfeasibility_explanation: "It is impossible",
|
||||
price: 1234,
|
||||
price_first_year: 1000,
|
||||
administrator: administrator)
|
||||
|
||||
visit admin_budget_budget_investments_path(budget_investment.budget)
|
||||
|
||||
click_link budget_investment.title
|
||||
|
||||
expect(page).to have_content(budget_investment.title)
|
||||
expect(page).to have_content(budget_investment.description)
|
||||
expect(page).to have_content(budget_investment.author.name)
|
||||
expect(page).to have_content(budget_investment.heading.name)
|
||||
expect(page).to have_content("There are no changes logged")
|
||||
end
|
||||
|
||||
scenario "Changes" do
|
||||
budget_investment = create(:budget_investment,
|
||||
:unfeasible,
|
||||
unfeasibility_explanation: "It is impossible",
|
||||
price: 1234,
|
||||
price_first_year: 1000,
|
||||
administrator: administrator)
|
||||
|
||||
visit admin_budget_budget_investments_path(budget_investment.budget)
|
||||
|
||||
click_link budget_investment.title
|
||||
|
||||
expect(page).to have_content(budget_investment.title)
|
||||
expect(page).to have_content(budget_investment.description)
|
||||
expect(page).to have_content(budget_investment.author.name)
|
||||
expect(page).to have_content(budget_investment.heading.name)
|
||||
expect(page).to have_content("There are no changes logged")
|
||||
|
||||
click_link "Edit"
|
||||
fill_in "Title", with: "test"
|
||||
click_button "Update"
|
||||
|
||||
expect(page).not_to have_content("There are no changes logged")
|
||||
expect(page).to have_content("Change Log")
|
||||
expect(page).to have_content("Title")
|
||||
expect(page).to have_content("test")
|
||||
expect(page).to have_content("Field")
|
||||
expect(page).to have_content("Old Value")
|
||||
expect(page).to have_content("New Value")
|
||||
expect(page).to have_content("Edited at")
|
||||
expect(page).to have_content("Edited by")
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user