Skip to content

Commit

Permalink
ActiveAdmin: Allow for both singular and plural model names
Browse files Browse the repository at this point in the history
  • Loading branch information
vfonic committed May 8, 2020
1 parent 508d06a commit c1ad378
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
5 changes: 4 additions & 1 deletion lib/annotate/annotate_models/file_patterns.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ def generate(root_directory, pattern_type, options)
when 'controller'
[File.join(root_directory, CONTROLLER_DIR, '%PLURALIZED_MODEL_NAME%_controller.rb')]
when 'admin'
[File.join(root_directory, ACTIVEADMIN_DIR, '%MODEL_NAME%.rb')]
[
File.join(root_directory, ACTIVEADMIN_DIR, '%MODEL_NAME%.rb'),
File.join(root_directory, ACTIVEADMIN_DIR, '%PLURALIZED_MODEL_NAME%.rb')
]
when 'helper'
[File.join(root_directory, HELPER_DIR, '%PLURALIZED_MODEL_NAME%_helper.rb')]
else
Expand Down
6 changes: 2 additions & 4 deletions spec/lib/annotate/annotate_models/file_patterns_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,8 @@
context 'when pattern_type is "admin"' do
let(:pattern_type) { 'admin' }

it 'returns patterns of admin files' do
is_expected.to eq([
'/root/app/admin/%MODEL_NAME%.rb'
])
it 'returns both singular and pluralized model names' do
is_expected.to eq(['/root/app/admin/%MODEL_NAME%.rb', '/root/app/admin/%PLURALIZED_MODEL_NAME%.rb'])
end
end

Expand Down

0 comments on commit c1ad378

Please sign in to comment.