Skip to content

Commit 841c3e7

Browse files
author
Jeremy McNevin
committed
Change expected Factory Girl factory filenames.
1 parent 98d0063 commit 841c3e7

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

lib/annotate/annotate_models.rb

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class << self
3939
def model_dir
4040
@model_dir || "app/models"
4141
end
42-
42+
4343
def model_dir=(dir)
4444
@model_dir = dir
4545
end
@@ -92,7 +92,7 @@ def get_schema_info(klass, header, options = {})
9292
col_type << "(#{col.limit})" unless NO_LIMIT_COL_TYPES.include?(col_type)
9393
end
9494
end
95-
95+
9696
# Check out if we got a geometric column
9797
# and print the type and SRID
9898
if col.respond_to?(:geometry_type)
@@ -180,7 +180,7 @@ def annotate_one_file(file_name, info_block, options={})
180180
if old_columns == new_columns && !options[:force]
181181
false
182182
else
183-
183+
184184
# todo: figure out if we need to extract any logic from this merge chunk
185185
# <<<<<<< HEAD
186186
# # Replace the old schema info with the new schema info
@@ -197,7 +197,7 @@ def annotate_one_file(file_name, info_block, options={})
197197
# Strip the old schema info, and insert new schema info.
198198
old_content.sub!(encoding, '')
199199
old_content.sub!(PATTERN, '')
200-
200+
201201
new_content = (options[:position] || 'before').to_s == 'after' ?
202202
(encoding_header + (old_content.rstrip + "\n\n" + info_block)) :
203203
(encoding_header + info_block + old_content)
@@ -207,7 +207,7 @@ def annotate_one_file(file_name, info_block, options={})
207207
end
208208
end
209209
end
210-
210+
211211
def remove_annotation_of_file(file_name)
212212
if File.exist?(file_name)
213213
content = File.read(file_name)
@@ -252,8 +252,8 @@ def annotate(klass, file, header, options={})
252252
File.join(EXEMPLARS_SPEC_DIR, "#{model_name}_exemplar.rb"), # Object Daddy
253253
File.join(BLUEPRINTS_TEST_DIR, "#{model_name}_blueprint.rb"), # Machinist Blueprints
254254
File.join(BLUEPRINTS_SPEC_DIR, "#{model_name}_blueprint.rb"), # Machinist Blueprints
255-
File.join(FACTORY_GIRL_TEST_DIR, "#{model_name}_factory.rb"), # Factory Girl Factories
256-
File.join(FACTORY_GIRL_SPEC_DIR, "#{model_name}_factory.rb"), # Factory Girl Factories
255+
File.join(FACTORY_GIRL_TEST_DIR, "#{klass.table_name}.rb"), # Factory Girl Factories
256+
File.join(FACTORY_GIRL_SPEC_DIR, "#{klass.table_name}.rb"), # Factory Girl Factories
257257
File.join(FABRICATORS_TEST_DIR, "#{model_name}_fabricator.rb"), # Fabrication Fabricators
258258
File.join(FABRICATORS_SPEC_DIR, "#{model_name}_fabricator.rb"), # Fabrication Fabricators
259259
].each do |file|
@@ -302,7 +302,7 @@ def get_model_files(options)
302302
end
303303
models
304304
end
305-
305+
306306
# Retrieve the classes belonging to the model names we're asked to process
307307
# Check for namespaced models in subdirectories as well as models
308308
# in subdirectories without namespacing.
@@ -320,7 +320,7 @@ def get_loaded_model(model_path)
320320
select do |c|
321321
Class === c and # note: we use === to avoid a bug in activesupport 2.3.14 OptionMerger vs. is_a?
322322
c.ancestors.respond_to?(:include?) and # to fix FactoryGirl bug, see https://github.com/ctran/annotate_models/pull/82
323-
c.ancestors.include?(ActiveRecord::Base)
323+
c.ancestors.include?(ActiveRecord::Base)
324324
end.
325325
detect { |c| ActiveSupport::Inflector.underscore(c) == model_path }
326326
end
@@ -342,9 +342,9 @@ def do_annotations(options={})
342342
version = ActiveRecord::Migrator.current_version rescue 0
343343
if version > 0
344344
header << "\n# Schema version: #{version}"
345-
end
345+
end
346346
end
347-
347+
348348
self.model_dir = options[:model_dir] if options[:model_dir]
349349

350350
annotated = []
@@ -394,8 +394,8 @@ def remove_annotations(options={})
394394
File.join(EXEMPLARS_SPEC_DIR, "#{model_name}_exemplar.rb"), # Object Daddy
395395
File.join(BLUEPRINTS_TEST_DIR, "#{model_name}_blueprint.rb"), # Machinist Blueprints
396396
File.join(BLUEPRINTS_SPEC_DIR, "#{model_name}_blueprint.rb"), # Machinist Blueprints
397-
File.join(FACTORY_GIRL_TEST_DIR, "#{model_name}_factory.rb"), # Factory Girl Factories
398-
File.join(FACTORY_GIRL_SPEC_DIR, "#{model_name}_factory.rb"), # Factory Girl Factories
397+
File.join(FACTORY_GIRL_TEST_DIR, "#{klass.table_name}.rb"), # Factory Girl Factories
398+
File.join(FACTORY_GIRL_SPEC_DIR, "#{klass.table_name}.rb"), # Factory Girl Factories
399399
File.join(FABRICATORS_TEST_DIR, "#{model_name}_fabricator.rb"), # Fabrication Fabricators
400400
File.join(FABRICATORS_SPEC_DIR, "#{model_name}_fabricator.rb"), # Fabrication Fabricators
401401
].each do |file|
@@ -405,7 +405,7 @@ def remove_annotations(options={})
405405
end
406406
rescue Exception => e
407407
puts "Unable to deannotate #{file}: #{e.message}"
408-
puts "\t" + e.backtrace.join("\n\t") if options[:trace]
408+
puts "\t" + e.backtrace.join("\n\t") if options[:trace]
409409
end
410410
end
411411
puts "Removed annotation from: #{deannotated.join(', ')}"

0 commit comments

Comments
 (0)