Skip to content

Commit c6baff7

Browse files
committed
add Unit to admin dashboard
1 parent 3fea949 commit c6baff7

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

app/models/rails_admin.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
config.included_models = [
55
'GuiUser',
66
'ApiUser',
7-
'Job'
7+
'Job',
8+
'Unit'
89
]
910
end

app/models/unit.rb

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,28 @@ class Unit < ApplicationRecord
77
validates :name, presence: true
88
validates :daily_page_limit, presence: true, numericality: { only_integer: true, greater_than_or_equal_to: 0 }
99
validates :overall_page_limit, presence: true, numericality: { only_integer: true, greater_than_or_equal_to: 0 }
10+
11+
RailsAdmin.config do |config|
12+
config.model 'Unit' do
13+
list do
14+
field :id
15+
field :name
16+
field :daily_page_limit
17+
field :overall_page_limit
18+
field :created_at
19+
end
20+
21+
edit do
22+
field :name
23+
field :daily_page_limit
24+
field :overall_page_limit
25+
field :created_at do
26+
read_only true
27+
end
28+
field :updated_at do
29+
read_only true
30+
end
31+
end
32+
end
33+
end
1034
end

spec/requests/admin/rails_admin_spec.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@
3333
get '/admin/job', headers: admin_headers
3434
expect(response).to have_http_status(:ok)
3535
end
36+
37+
it 'allows access to Unit model' do
38+
get '/admin/unit', headers: admin_headers
39+
expect(response).to have_http_status(:ok)
40+
end
3641
end
3742

3843
context 'when user is not an admin' do

0 commit comments

Comments
 (0)