Skip to content

Commit 99a26ce

Browse files
authored
Merge pull request #273 from psu-libraries/269-admin-delete
Removes the delete buttons for users and jobs in rails admin
2 parents 5da3477 + ff40988 commit 99a26ce

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

.rubocop.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Metrics/BlockLength:
99
- 'config/routes.rb'
1010
- 'app/models/gui_user.rb'
1111
- 'app/models/unit.rb'
12+
- 'config/initializers/rails_admin.rb'
1213

1314
Metrics/CyclomaticComplexity:
1415
Exclude:

config/initializers/rails_admin.rb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,26 @@
1111
@current_gui_user ||= GUIUser.find_by(id: session[:user_id]) if session[:user_id]
1212
end
1313

14+
config.actions do
15+
dashboard # mandatory
16+
index # mandatory
17+
new
18+
export
19+
show
20+
edit
21+
show_in_app
22+
23+
delete do
24+
visible do
25+
bindings[:abstract_model].model == Unit
26+
end
27+
end
28+
29+
## With an audit adapter, you can add:
30+
# history_index
31+
# history_show
32+
end
33+
1434
config.navigation_static_label = 'Tools'
1535
config.navigation_static_links = {
1636
'Sidekiq' => '/sidekiq'

spec/requests/admin/rails_admin_content_spec.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
expect(response.body).to include('123')
5151
expect(response.body).to include('45678')
5252
expect(response.body).to include(unit.total_pages_processed.to_s)
53+
expect(response.body).to include('Delete')
5354
end
5455

5556
it 'shows GuiUser list and show content' do
@@ -62,6 +63,7 @@
6263
expect(response.body).to include('gui.user@example.com')
6364
expect(response.body).to include('Accessibility Services Unit')
6465
expect(response.body).to include(gui_user_record.total_pages_processed_last_24_hours.to_s)
66+
expect(response.body).not_to include('Delete')
6567
end
6668

6769
it 'shows ApiUser list and show content including' do
@@ -77,6 +79,7 @@
7779
expect(response.body).to include('https://example.com/webhook')
7880
expect(response.body).to include('Accessibility Services Unit')
7981
expect(response.body).to include(api_user_record.total_pages_processed_last_24_hours.to_s)
82+
expect(response.body).not_to include('Delete')
8083
end
8184

8285
it 'shows Job list and show content' do

0 commit comments

Comments
 (0)