updated tag unit tests

This commit is contained in:
albert
2010-02-11 14:59:58 -05:00
parent 2f3a6e4a8b
commit bed94a4e30
21 changed files with 731 additions and 269 deletions

26
app/models/pool.rb Normal file
View File

@@ -0,0 +1,26 @@
class Pool < ActiveRecord::Base
validates_uniqueness_of :name
validates_presence_of :name
validates_format_of :name, :with => /\A[^\s;,]+\Z/, :on => :create, :message => "cannot have whitespace, commas, or semicolons"
belongs_to :creator, :class_name => "Person"
def self.create_anonymous(creator)
pool = Pool.create(:name => "TEMP - #{Time.now.to_f}.#{rand(1_000_000)}", :creator => creator)
pool.update_attribute(:name => "anonymous:#{pool.id}")
pool
end
def neighbor_posts(post)
post_ids =~ /\A#{post.id} (\d+)|(\d+) #{post.id} (\d+)|(\d+) #{post.id}\Z/
if $2 && $3
{:previous => $2.to_i, :next = $3.to_i}
elsif $1
{:previous => $1.to_i}
elsif $4
{:next => $4.to_i}
else
nil
end
end
end