Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion lib/annotate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ module Annotate
:timestamp, :exclude_serializers, :classified_sort, :show_foreign_keys,
]
OTHER_OPTIONS=[
:ignore_columns, :skip_on_db_migrate
:ignore_columns, :skip_on_db_migrate, :wrapper_open, :wrapper_close
]
PATH_OPTIONS=[
:require, :model_dir
Expand Down Expand Up @@ -78,6 +78,12 @@ def self.setup_options(options = {})
return options
end

def self.reset_options
[POSITION_OPTIONS, FLAG_OPTIONS, PATH_OPTIONS, OTHER_OPTIONS].flatten.each do |key|
ENV[key.to_s] = nil
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the reason to set these to nil?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's needed for the tests - ENV wasn't cleared between tests, so after wrapper attributes were set in one of the tests, the others also had it set, which resulted in incorrect annotations being generated.

end
end

def self.skip_on_migration?
ENV['skip_on_db_migrate'] =~ TRUE_RE
end
Expand Down
2 changes: 2 additions & 0 deletions lib/generators/annotate/templates/auto_annotate_models.rake
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ if Rails.env.development?
'sort' => "false",
'force' => "false",
'trace' => "false",
'wrapper_open' => nil,
'wrapper_close' => nil,
})
end

Expand Down
1 change: 1 addition & 0 deletions spec/annotate/annotate_models_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,7 @@ class User < ActiveRecord::Base
mock_column(:name, :string, :limit => 50)
])
@schema_info = AnnotateModels.get_schema_info(@klass, "== Schema Info")
Annotate.reset_options
end

def write_model file_name, file_content
Expand Down