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:
@@ -1,7 +1,7 @@
|
|||||||
class Admin::BudgetInvestmentAuditsController < Admin::BaseController
|
class Admin::BudgetInvestmentAuditsController < Admin::BaseController
|
||||||
def show
|
def show
|
||||||
investment = Budget::Investment.find(params[:budget_investment_id])
|
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"
|
render "admin/audits/show"
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -33,6 +33,11 @@ class Budget
|
|||||||
include Globalizable
|
include Globalizable
|
||||||
|
|
||||||
audited on: [:update, :destroy]
|
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 :author, -> { with_hidden }, class_name: "User", inverse_of: :budget_investments
|
||||||
belongs_to :heading
|
belongs_to :heading
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<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)| %>
|
<% audit.audited_changes.each do |field, (old_value, new_value)| %>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="text-center"><%= audit.id %></td>
|
<td class="text-center"><%= audit.id %></td>
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ module ActionDispatch::Routing::UrlFor
|
|||||||
when "ProgressBar"
|
when "ProgressBar"
|
||||||
[*resource_hierarchy_for(resource.progressable), resource]
|
[*resource_hierarchy_for(resource.progressable), resource]
|
||||||
when "Audit"
|
when "Audit"
|
||||||
[*resource_hierarchy_for(resource.auditable), resource]
|
[*resource_hierarchy_for(resource.associated || resource.auditable), resource]
|
||||||
when "Legislation::Annotation"
|
when "Legislation::Annotation"
|
||||||
[resource.draft_version.process, resource.draft_version, resource]
|
[resource.draft_version.process, resource.draft_version, resource]
|
||||||
when "Legislation::Proposal", "Legislation::Question", "Legislation::DraftVersion"
|
when "Legislation::Proposal", "Legislation::Question", "Legislation::DraftVersion"
|
||||||
|
|||||||
@@ -48,11 +48,9 @@ describe "Admin change log" do
|
|||||||
expect(page).to have_content(budget_investment.heading.name)
|
expect(page).to have_content(budget_investment.heading.name)
|
||||||
expect(page).to have_content("There are not changes logged")
|
expect(page).to have_content("There are not changes logged")
|
||||||
|
|
||||||
budget_investment.update!(title: "test")
|
click_link "Edit"
|
||||||
|
fill_in "Title", with: "test"
|
||||||
visit admin_budget_budget_investments_path(budget_investment.budget)
|
click_button "Update"
|
||||||
|
|
||||||
click_link budget_investment.title
|
|
||||||
|
|
||||||
expect(page).not_to have_content("There are not changes logged")
|
expect(page).not_to have_content("There are not changes logged")
|
||||||
expect(page).to have_content("Change Log")
|
expect(page).to have_content("Change Log")
|
||||||
|
|||||||
Reference in New Issue
Block a user