fixed unit tests

This commit is contained in:
albert
2011-01-22 03:01:15 -05:00
parent 6824e98af3
commit c5a9067e72
6 changed files with 157 additions and 100 deletions

View File

@@ -13,7 +13,7 @@ class Note < ActiveRecord::Base
validate :post_must_not_be_note_locked
attr_accessible :x, :y, :width, :height, :body, :updater_id, :updater_ip_addr, :is_active, :post_id
scope :active, where("is_active = TRUE")
scope :body_matches, lambda {|query| where("text_index @@ plainto_tsquery(?)", query)}
scope :body_matches, lambda {|query| where("text_index @@ plainto_tsquery(?)", query.scan(/\S+/).join(" & "))}
search_method :body_matches
def presenter
@@ -97,21 +97,4 @@ class Note < ActiveRecord::Base
end
end
end
def self.build_relation(params)
relation = where("TRUE")
if !params[:query].blank?
query = params[:query].scan(/\S+/).join(" & ")
relation = relation.where(["text_index @@ plainto_tsquery(?)", query])
end
if params[:status] == "Active"
relation = relation.where("is_active = TRUE")
elsif params[:status] == "Deleted"
relation = relation.where("is_active = FALSE")
end
relation
end
end