Skip to content

Commit

Permalink
Follow-up for #3189
Browse files Browse the repository at this point in the history
  • Loading branch information
mshibuya committed Dec 26, 2021
1 parent 7cdbe13 commit b377106
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/views/rails_admin/main/dashboard.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
</tbody>
</table>
<% end %>
<% if @auditing_adapter && authorized?(:history_index) %>
<% if @history && authorized?(:history_index) %>
<div class="block" id="block-tables">
<div class="content">
<h2>
Expand Down
2 changes: 1 addition & 1 deletion lib/rails_admin/config/actions/dashboard.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Dashboard < RailsAdmin::Config::Actions::Base

register_instance_option :controller do
proc do
@history = @auditing_adapter&.latest(@action.auditing_versions_limit) || [] if @action.history?
@history = @auditing_adapter&.latest(@action.auditing_versions_limit) if @action.history?
if @action.statistics?
@abstract_models = RailsAdmin::Config.visible_models(controller: self).collect(&:abstract_model)

Expand Down
22 changes: 22 additions & 0 deletions spec/integration/actions/dashboard_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,28 @@
visit dashboard_path
end

it 'does not show history if turned off', active_record: true do
RailsAdmin.config do |c|
c.audit_with :paper_trail, 'User', 'PaperTrail::Version'
c.included_models = [PaperTrailTest]
c.actions do
dashboard do
history false
end
index # mandatory
new
history_index
end
end
with_versioning do
visit new_path(model_name: 'paper_trail_test')
fill_in 'paper_trail_test[name]', with: 'Jackie Robinson'
click_button 'Save'
end
visit dashboard_path
is_expected.not_to have_content 'Jackie Robinson'
end

it 'counts are different for same-named models in different modules' do
allow(RailsAdmin.config(User::Confirmed).abstract_model).to receive(:count).and_return(10)
allow(RailsAdmin.config(Comment::Confirmed).abstract_model).to receive(:count).and_return(0)
Expand Down

0 comments on commit b377106

Please sign in to comment.