Skip to content

Commit bbde2a7

Browse files
committed
ActiveAdmin: Allow for both singular and plural model names
1 parent 42b4127 commit bbde2a7

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

lib/annotate/annotate_models/file_patterns.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,10 @@ def generate(root_directory, pattern_type, options)
5959
when 'controller'
6060
[File.join(root_directory, CONTROLLER_DIR, '%PLURALIZED_MODEL_NAME%_controller.rb')]
6161
when 'admin'
62-
[File.join(root_directory, ACTIVEADMIN_DIR, '%MODEL_NAME%.rb')]
62+
[
63+
File.join(root_directory, ACTIVEADMIN_DIR, '%MODEL_NAME%.rb'),
64+
File.join(root_directory, ACTIVEADMIN_DIR, '%PLURALIZED_MODEL_NAME%.rb')
65+
]
6366
when 'helper'
6467
[File.join(root_directory, HELPER_DIR, '%PLURALIZED_MODEL_NAME%_helper.rb')]
6568
else

spec/lib/annotate/annotate_models/file_patterns_spec.rb

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,8 @@
119119
context 'when pattern_type is "admin"' do
120120
let(:pattern_type) { 'admin' }
121121

122-
it 'returns patterns of admin files' do
123-
is_expected.to eq([
124-
'/root/app/admin/%MODEL_NAME%.rb'
125-
])
122+
it 'returns both singular and pluralized model names' do
123+
is_expected.to eq(['/root/app/admin/%MODEL_NAME%.rb', '/root/app/admin/%PLURALIZED_MODEL_NAME%.rb'])
126124
end
127125
end
128126

0 commit comments

Comments
 (0)