Skip to content

Commit cd6a0b1

Browse files
cmersds
authored andcommitted
Support schema.rb generated by Rails 5.2
1 parent 8451e00 commit cd6a0b1

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

lib/overcommit/hook/pre_commit/rails_schema_up_to_date.rb

+1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ def schema_files
4646

4747
def schema
4848
@schema ||= schema_files.map { |file| File.read(file) }.join
49+
@schema.tr('_', '')
4950
end
5051

5152
def non_zero_schema_version?

spec/overcommit/hook/pre_commit/rails_schema_up_to_date_spec.rb

+24
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,30 @@
9494
it { should pass }
9595
end
9696

97+
context 'when a Ruby schema file with the latest version in Rails 5.2 format and migrations are added' do
98+
before do
99+
subject.stub(:applicable_files).and_return(migration_files << ruby_schema_file)
100+
end
101+
102+
around do |example|
103+
repo do
104+
FileUtils.mkdir_p('db/migrate')
105+
106+
File.open(ruby_schema_file, 'w') { |f| f.write('2014_03_05_123456') }
107+
`git add #{ruby_schema_file}`
108+
109+
migration_files.each do |migration_file|
110+
File.open(migration_file, 'w') { |f| f.write('migration') }
111+
`git add #{migration_file}`
112+
end
113+
114+
example.run
115+
end
116+
end
117+
118+
it { should pass }
119+
end
120+
97121
context 'when a Ruby schema file which is not at the latest version and migrations are added' do
98122
before do
99123
subject.stub(:applicable_files).and_return(migration_files << ruby_schema_file)

0 commit comments

Comments
 (0)