File tree 3 files changed +39
-1
lines changed
generators/annotate/templates
3 files changed +39
-1
lines changed Original file line number Diff line number Diff line change @@ -52,7 +52,8 @@ if Rails.env.development?
52
52
'trace' => 'false' ,
53
53
'wrapper_open' => nil ,
54
54
'wrapper_close' => nil ,
55
- 'with_comment' => 'true'
55
+ 'with_comment' => 'true' ,
56
+ 'with_comment_column' => 'false'
56
57
)
57
58
end
58
59
Original file line number Diff line number Diff line change @@ -52,6 +52,7 @@ task annotate_models: :environment do
52
52
options [ :hide_limit_column_types ] = Annotate ::Helpers . fallback ( ENV [ 'hide_limit_column_types' ] , '' )
53
53
options [ :hide_default_column_types ] = Annotate ::Helpers . fallback ( ENV [ 'hide_default_column_types' ] , '' )
54
54
options [ :with_comment ] = Annotate ::Helpers . true? ( ENV [ 'with_comment' ] )
55
+ options [ :with_comment_column ] = Annotate ::Helpers . true? ( ENV [ 'with_comment_column' ] )
55
56
options [ :ignore_unknown_models ] = Annotate ::Helpers . true? ( ENV . fetch ( 'ignore_unknown_models' , 'false' ) )
56
57
57
58
AnnotateModels . do_annotations ( options )
Original file line number Diff line number Diff line change
1
+ require_relative '../../spec_helper'
2
+
3
+ describe 'Annotate annotate_models rake task and Annotate.set_defaults' do # rubocop:disable RSpec/DescribeClass
4
+ before do
5
+ Rake . application = Rake ::Application . new
6
+ Rake ::Task . define_task ( 'environment' )
7
+ Rake . load_rakefile ( 'tasks/annotate_models.rake' )
8
+ end
9
+
10
+ after do
11
+ Annotate . instance_variable_set ( '@has_set_defaults' , false )
12
+ end
13
+
14
+ let ( :annotate_models_argument ) do
15
+ argument = nil
16
+ allow ( AnnotateModels ) . to receive ( :do_annotations ) { |arg | argument = arg }
17
+ Rake ::Task [ 'annotate_models' ] . invoke
18
+ argument
19
+ end
20
+
21
+ describe 'with_comment_column' do
22
+ subject { annotate_models_argument [ :with_comment_column ] }
23
+
24
+ after { ENV . delete ( 'with_comment_column' ) }
25
+
26
+ context 'when Annotate.set_defaults is not called (defaults)' do
27
+ it { is_expected . to be_falsey }
28
+ end
29
+
30
+ context 'when Annotate.set_defaults sets it to "true"' do
31
+ before { Annotate . set_defaults ( 'with_comment_column' => 'true' ) }
32
+
33
+ it { is_expected . to be_truthy }
34
+ end
35
+ end
36
+ end
You can’t perform that action at this time.
0 commit comments