Skip to content

Commit af4606a

Browse files
committed
Merge pull request #287 from djsegal/develop
Annotate non-model test files: #286
2 parents 3f85ded + 7ada4e1 commit af4606a

File tree

5 files changed

+22
-5
lines changed

5 files changed

+22
-5
lines changed

annotate.gemspec

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ Gem::Specification.new do |s|
2727

2828
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
2929
s.add_runtime_dependency(%q<rake>, ["~> 10.4"])
30-
s.add_runtime_dependency(%q<activerecord>, [">= 3.2", "<= 4.3"])
30+
s.add_runtime_dependency(%q<activerecord>, [">= 3.2", "< 6.0"])
3131
else
3232
s.add_dependency(%q<rake>, ["~> 10.4"])
33-
s.add_dependency(%q<activerecord>, [">= 3.2", "<= 4.3"])
33+
s.add_dependency(%q<activerecord>, [">= 3.2", "< 6.0"])
3434
end
3535
else
3636
s.add_dependency(%q<rake>, [">= 0.8.7"])
37-
s.add_dependency(%q<activerecord>, [">= 3.2", "<= 4.3"])
37+
s.add_dependency(%q<activerecord>, [">= 3.2", "< 6.0"])
3838
end
3939
end

lib/annotate.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ module Annotate
2727
:exclude_fixtures, :exclude_factories, :ignore_model_sub_dir,
2828
:format_bare, :format_rdoc, :format_markdown, :sort, :force, :trace,
2929
:timestamp, :exclude_serializers, :classified_sort, :show_foreign_keys,
30+
:exclude_scaffolds
3031
]
3132
OTHER_OPTIONS=[
3233
:ignore_columns, :skip_on_db_migrate, :wrapper_open, :wrapper_close, :wrapper

lib/annotate/annotate_models.rb

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ module AnnotateModels
1717
FIXTURE_TEST_DIR = File.join("test", "fixtures")
1818
FIXTURE_SPEC_DIR = File.join("spec", "fixtures")
1919

20+
# Other test files
21+
CONTROLLER_TEST_DIR = File.join("test", "controllers")
22+
CONTROLLER_SPEC_DIR = File.join("spec", "controllers")
23+
REQUEST_SPEC_DIR = File.join("spec", "requests")
24+
ROUTING_SPEC_DIR = File.join("spec", "routing")
25+
2026
# Object Daddy http://github.com/flogic/object_daddy/tree/master
2127
EXEMPLARS_TEST_DIR = File.join("test", "exemplars")
2228
EXEMPLARS_SPEC_DIR = File.join("spec", "exemplars")
@@ -52,6 +58,13 @@ module AnnotateModels
5258
File.join(FIXTURE_SPEC_DIR, "%PLURALIZED_MODEL_NAME%.yml"),
5359
]
5460

61+
SCAFFOLD_PATTERNS = [
62+
File.join(CONTROLLER_TEST_DIR, "%PLURALIZED_MODEL_NAME%_controller_test.rb"),
63+
File.join(CONTROLLER_SPEC_DIR, "%PLURALIZED_MODEL_NAME%_controller_spec.rb"),
64+
File.join(REQUEST_SPEC_DIR, "%PLURALIZED_MODEL_NAME%_spec.rb"),
65+
File.join(ROUTING_SPEC_DIR, "%PLURALIZED_MODEL_NAME%_routing_spec.rb"),
66+
]
67+
5568
FACTORY_PATTERNS = [
5669
File.join(EXEMPLARS_TEST_DIR, "%MODEL_NAME%_exemplar.rb"),
5770
File.join(EXEMPLARS_SPEC_DIR, "%MODEL_NAME%_exemplar.rb"),
@@ -344,6 +357,7 @@ def remove_annotation_of_file(file_name)
344357
# :exclude_fixtures<Symbol>:: whether to skip modification of fixture files
345358
# :exclude_factories<Symbol>:: whether to skip modification of factory files
346359
# :exclude_serializers<Symbol>:: whether to skip modification of serializer files
360+
# :exclude_scaffolds<Symbol>:: whether to skip modification of scaffold files
347361
#
348362
def annotate(klass, file, header, options={})
349363
begin
@@ -357,7 +371,7 @@ def annotate(klass, file, header, options={})
357371
did_annotate = true
358372
end
359373

360-
%w(test fixture factory serializer).each do |key|
374+
%w(test fixture factory serializer scaffold).each do |key|
361375
exclusion_key = "exclude_#{key.pluralize}".to_sym
362376
patterns_constant = "#{key.upcase}_PATTERNS".to_sym
363377
position_key = "position_in_#{key}".to_sym
@@ -510,7 +524,7 @@ def remove_annotations(options={})
510524
model_file_name = file
511525
deannotated_klass = true if(remove_annotation_of_file(model_file_name))
512526

513-
(TEST_PATTERNS + FIXTURE_PATTERNS + FACTORY_PATTERNS + SERIALIZER_PATTERNS).
527+
(TEST_PATTERNS + SCAFFOLD_PATTERNS + FIXTURE_PATTERNS + FACTORY_PATTERNS + SERIALIZER_PATTERNS).
514528
map { |file| resolve_filename(file, model_name, table_name) }.
515529
each do |file|
516530
if File.exist?(file)

lib/generators/annotate/templates/auto_annotate_models.rake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ if Rails.env.development?
2222
'exclude_fixtures' => "false",
2323
'exclude_factories' => "false",
2424
'exclude_serializers' => "false",
25+
'exclude_scaffolds' => "false",
2526
'ignore_model_sub_dir' => "false",
2627
'skip_on_db_migrate' => "false",
2728
'format_bare' => "true",

lib/tasks/annotate_models.rake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ task :annotate_models => :environment do
2727
options[:exclude_factories] = Annotate.true?(ENV['exclude_factories'])
2828
options[:exclude_fixtures] = Annotate.true?(ENV['exclude_fixtures'])
2929
options[:exclude_serializers] = Annotate.true?(ENV['exclude_serializers'])
30+
options[:exclude_scaffolds] = Annotate.true?(ENV['exclude_scaffolds'])
3031
options[:ignore_model_sub_dir] = Annotate.true?(ENV['ignore_model_sub_dir'])
3132
options[:format_bare] = Annotate.true?(ENV['format_bare'])
3233
options[:format_rdoc] = Annotate.true?(ENV['format_rdoc'])

0 commit comments

Comments
 (0)