Skip to content

Commit ccffeb7

Browse files
committed
ActiveAdmin: Allow for both singular and plural model names
1 parent 5745034 commit ccffeb7

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

lib/annotate/annotate_models.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,10 @@ def files_by_pattern(root_directory, pattern_type, options)
173173
when 'controller'
174174
[File.join(root_directory, CONTROLLER_DIR, "%PLURALIZED_MODEL_NAME%_controller.rb")]
175175
when 'admin'
176-
[File.join(root_directory, ACTIVEADMIN_DIR, "%MODEL_NAME%.rb")]
176+
[
177+
File.join(root_directory, ACTIVEADMIN_DIR, "%MODEL_NAME%.rb"),
178+
File.join(root_directory, ACTIVEADMIN_DIR, "%PLURALIZED_MODEL_NAME%.rb")
179+
]
177180
when 'helper'
178181
[File.join(root_directory, HELPER_DIR, "%PLURALIZED_MODEL_NAME%_helper.rb")]
179182
else

spec/lib/annotate/annotate_models_spec.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1631,6 +1631,16 @@ def mock_column(name, type, options = {})
16311631
end
16321632
end
16331633
end
1634+
1635+
context 'when pattern_type is "admin"' do
1636+
let(:root_directory) { '/root' }
1637+
let(:pattern_type) { 'admin' }
1638+
let(:options) { {} }
1639+
1640+
it 'returns an empty array' do
1641+
is_expected.to eq(['/root/app/admin/%MODEL_NAME%.rb', '/root/app/admin/%PLURALIZED_MODEL_NAME%.rb'])
1642+
end
1643+
end
16341644
end
16351645

16361646
describe '.get_patterns' do

0 commit comments

Comments
 (0)