Skip to content

Commit b377106

Browse files
committed
Follow-up for #3189
1 parent 7cdbe13 commit b377106

3 files changed

Lines changed: 24 additions & 2 deletions

File tree

app/views/rails_admin/main/dashboard.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
</tbody>
5353
</table>
5454
<% end %>
55-
<% if @auditing_adapter && authorized?(:history_index) %>
55+
<% if @history && authorized?(:history_index) %>
5656
<div class="block" id="block-tables">
5757
<div class="content">
5858
<h2>

lib/rails_admin/config/actions/dashboard.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class Dashboard < RailsAdmin::Config::Actions::Base
1818

1919
register_instance_option :controller do
2020
proc do
21-
@history = @auditing_adapter&.latest(@action.auditing_versions_limit) || [] if @action.history?
21+
@history = @auditing_adapter&.latest(@action.auditing_versions_limit) if @action.history?
2222
if @action.statistics?
2323
@abstract_models = RailsAdmin::Config.visible_models(controller: self).collect(&:abstract_model)
2424

spec/integration/actions/dashboard_spec.rb

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,28 @@
2424
visit dashboard_path
2525
end
2626

27+
it 'does not show history if turned off', active_record: true do
28+
RailsAdmin.config do |c|
29+
c.audit_with :paper_trail, 'User', 'PaperTrail::Version'
30+
c.included_models = [PaperTrailTest]
31+
c.actions do
32+
dashboard do
33+
history false
34+
end
35+
index # mandatory
36+
new
37+
history_index
38+
end
39+
end
40+
with_versioning do
41+
visit new_path(model_name: 'paper_trail_test')
42+
fill_in 'paper_trail_test[name]', with: 'Jackie Robinson'
43+
click_button 'Save'
44+
end
45+
visit dashboard_path
46+
is_expected.not_to have_content 'Jackie Robinson'
47+
end
48+
2749
it 'counts are different for same-named models in different modules' do
2850
allow(RailsAdmin.config(User::Confirmed).abstract_model).to receive(:count).and_return(10)
2951
allow(RailsAdmin.config(Comment::Confirmed).abstract_model).to receive(:count).and_return(0)

0 commit comments

Comments
 (0)