From c1ad378a359e23094030ae71d3fe897d664c9904 Mon Sep 17 00:00:00 2001 From: Viktor Fonic Date: Thu, 12 Mar 2020 20:37:59 +0100 Subject: [PATCH] ActiveAdmin: Allow for both singular and plural model names --- lib/annotate/annotate_models/file_patterns.rb | 5 ++++- spec/lib/annotate/annotate_models/file_patterns_spec.rb | 6 ++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/annotate/annotate_models/file_patterns.rb b/lib/annotate/annotate_models/file_patterns.rb index 262d3e0a2..f6cf3c0e7 100644 --- a/lib/annotate/annotate_models/file_patterns.rb +++ b/lib/annotate/annotate_models/file_patterns.rb @@ -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 diff --git a/spec/lib/annotate/annotate_models/file_patterns_spec.rb b/spec/lib/annotate/annotate_models/file_patterns_spec.rb index 9c3138625..eabc1c5da 100644 --- a/spec/lib/annotate/annotate_models/file_patterns_spec.rb +++ b/spec/lib/annotate/annotate_models/file_patterns_spec.rb @@ -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