Skip to content

Commit d1efc1f

Browse files
committed
Merge remote-tracking branch 'upstream/pr/986' into community-maintained
2 parents ba13601 + f9d640e commit d1efc1f

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

lib/annotate/annotate_models.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ def annotate_one_file(file_name, info_block, position, options = {})
433433
old_header = old_content.match(header_pattern).to_s
434434
new_header = info_block.match(header_pattern).to_s
435435

436-
column_pattern = /^#[\t ]+[\w\*\.`]+[\t ]+.+$/
436+
column_pattern = /^#[\t ]+[^\t ]+[\t ]+.+$/
437437
old_columns = old_header && old_header.scan(column_pattern).sort
438438
new_columns = new_header && new_header.scan(column_pattern).sort
439439

spec/lib/annotate/annotate_models_spec.rb

+28
Original file line numberDiff line numberDiff line change
@@ -2949,6 +2949,34 @@ def annotate_one_file(options = {})
29492949
expect(File.read(@model_file_name)).to eq("#{@schema_info}#{@file_content}")
29502950
end
29512951
end
2952+
2953+
context 'of multibyte comments' do
2954+
before do
2955+
klass = mock_class(:users,
2956+
:id,
2957+
[
2958+
mock_column(:id, :integer, comment: 'ID'),
2959+
],
2960+
[],
2961+
[])
2962+
@schema_info = AnnotateModels.get_schema_info(klass, '== Schema Info', with_comment: true)
2963+
annotate_one_file
2964+
end
2965+
2966+
it 'should update columns' do
2967+
klass = mock_class(:users,
2968+
:id,
2969+
[
2970+
mock_column(:id, :integer, comment: 'ID'),
2971+
mock_column(:active, :boolean, limit: 1, comment: 'ACTIVE'),
2972+
],
2973+
[],
2974+
[])
2975+
@schema_info = AnnotateModels.get_schema_info(klass, '== Schema Info', with_comment: true)
2976+
annotate_one_file
2977+
expect(File.read(@model_file_name)).to eq("#{@schema_info}#{@file_content}")
2978+
end
2979+
end
29522980
end
29532981

29542982
describe 'with existing annotation => :before' do

0 commit comments

Comments
 (0)