Audit changes in investment translations

Note the user interface could certainly be improved, as it doesn't show
which languages have changed.
This commit is contained in:
Javi Martín
2019-11-03 12:58:44 +01:00
parent e0c2468bd2
commit 04cd3b460e
5 changed files with 11 additions and 8 deletions

View File

@@ -1,7 +1,7 @@
class Admin::BudgetInvestmentAuditsController < Admin::BaseController
def show
investment = Budget::Investment.find(params[:budget_investment_id])
@audit = investment.audits.find(params[:id])
@audit = investment.own_and_associated_audits.find(params[:id])
render "admin/audits/show"
end

View File

@@ -33,6 +33,11 @@ class Budget
include Globalizable
audited on: [:update, :destroy]
has_associated_audits
translation_class.class_eval do
audited associated_with: :globalized_model,
only: Budget::Investment.translated_attribute_names
end
belongs_to :author, -> { with_hidden }, class_name: "User", inverse_of: :budget_investments
belongs_to :heading

View File

@@ -16,7 +16,7 @@
</tr>
</thead>
<tbody>
<% resource.audits.order(:created_at).each do |audit| %>
<% resource.own_and_associated_audits.order(:created_at).each do |audit| %>
<% audit.audited_changes.each do |field, (old_value, new_value)| %>
<tr>
<td class="text-center"><%= audit.id %></td>

View File

@@ -14,7 +14,7 @@ module ActionDispatch::Routing::UrlFor
when "ProgressBar"
[*resource_hierarchy_for(resource.progressable), resource]
when "Audit"
[*resource_hierarchy_for(resource.auditable), resource]
[*resource_hierarchy_for(resource.associated || resource.auditable), resource]
when "Legislation::Annotation"
[resource.draft_version.process, resource.draft_version, resource]
when "Legislation::Proposal", "Legislation::Question", "Legislation::DraftVersion"

View File

@@ -48,11 +48,9 @@ describe "Admin change log" do
expect(page).to have_content(budget_investment.heading.name)
expect(page).to have_content("There are not changes logged")
budget_investment.update!(title: "test")
visit admin_budget_budget_investments_path(budget_investment.budget)
click_link budget_investment.title
click_link "Edit"
fill_in "Title", with: "test"
click_button "Update"
expect(page).not_to have_content("There are not changes logged")
expect(page).to have_content("Change Log")