Skip to content
This repository has been archived by the owner on Mar 5, 2020. It is now read-only.

Commit

Permalink
Serial number updates for more than 10 changes per day [#57 state:res…
Browse files Browse the repository at this point in the history
…olved]

Thanks to Ask Bjørn Hansen for the initial patch
  • Loading branch information
kennethkalmer committed Feb 11, 2009
1 parent a512f10 commit 576ecca
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
2 changes: 1 addition & 1 deletion app/models/soa.rb
Expand Up @@ -64,7 +64,7 @@ def update_serial

date_serial = Time.now.strftime( "%Y%m%d00" ).to_i

self.serial = if date_serial > self.serial
self.serial = if self.serial.nil? || date_serial > self.serial
date_serial
else
self.serial + 1
Expand Down
2 changes: 1 addition & 1 deletion spec/models/record_spec.rb
Expand Up @@ -88,7 +88,7 @@
# Our serial should have move just one position, not three
@soa.reload
@soa.serial.should_not be( serial )
@soa.serial.to_s.should eql( Time.now.strftime( "%Y%m%d" ) + '01' )
@soa.serial.to_s.should eql( Time.now.strftime( "%Y%m%d" ) + '00' )
end

end
Expand Down
12 changes: 5 additions & 7 deletions spec/models/soa_spec.rb
Expand Up @@ -184,13 +184,11 @@
date_segment = Time.now.strftime( "%Y%m%d" )

@soa.update_serial!
@soa.serial.to_s.should eql( date_segment + '01' )

@soa.update_serial!
@soa.serial.to_s.should eql( date_segment + '02' )

@soa.update_serial!
@soa.serial.to_s.should eql( date_segment + '03' )
@soa.serial.to_s.should eql( date_segment + '00' )

10.times { @soa.update_serial! }

@soa.serial.to_s.should eql( date_segment + '10' )
end
end

Expand Down

0 comments on commit 576ecca

Please sign in to comment.