diff options
author | Eric Wong <normalperson@yhbt.net> | 2009-11-13 01:01:58 -0800 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2009-11-13 01:01:58 -0800 |
commit | eead1a80dd5fdca57cc8aa0333d249415ba2d85a (patch) | |
tree | 34578a70f39dc6627831c1fa73031fedfacba15d /examples/rails_app-2.3.4/app | |
parent | f4b44763fa6802543f7d1590719e5aed21e120cd (diff) | |
download | upr-eead1a80dd5fdca57cc8aa0333d249415ba2d85a.tar.gz |
example/rails_app-2.3.4: UprStatus unit tests
UprStatus.incr now returns the value incremented to be compatible with Upr::Monitor.incr
Diffstat (limited to 'examples/rails_app-2.3.4/app')
-rw-r--r-- | examples/rails_app-2.3.4/app/models/upr_status.rb | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/examples/rails_app-2.3.4/app/models/upr_status.rb b/examples/rails_app-2.3.4/app/models/upr_status.rb index a8afc30..871b49f 100644 --- a/examples/rails_app-2.3.4/app/models/upr_status.rb +++ b/examples/rails_app-2.3.4/app/models/upr_status.rb @@ -16,8 +16,14 @@ class UprStatus < ActiveRecord::Base end def incr(upid, nr) - update_all("seen = seen + #{nr.to_i}, time = #{Time.now.to_i}", - [ "upid = ? AND seen >= 0", upid ]) + transaction do + if rv = find_by_upid(upid) + rv.time = Time.now.to_i + rv.seen += nr if rv.seen >= 0 + rv.save + rv + end + end end def error!(upid) |