fixes #1354
This commit is contained in:
@@ -120,7 +120,7 @@ class PostQueryBuilder
|
|||||||
relation = add_range_relation(q[:fav_count], "posts.fav_count", relation)
|
relation = add_range_relation(q[:fav_count], "posts.fav_count", relation)
|
||||||
relation = add_range_relation(q[:filesize], "posts.file_size", relation)
|
relation = add_range_relation(q[:filesize], "posts.file_size", relation)
|
||||||
relation = add_range_relation(q[:date], "posts.created_at", relation)
|
relation = add_range_relation(q[:date], "posts.created_at", relation)
|
||||||
relation = add_range_relation(q[:age], "extract(epoch from (posts.created_at - CURRENT_TIMESTAMP))", relation)
|
relation = add_range_relation(q[:age], "posts.created_at", relation)
|
||||||
relation = add_range_relation(q[:general_tag_count], "posts.tag_count_general", relation)
|
relation = add_range_relation(q[:general_tag_count], "posts.tag_count_general", relation)
|
||||||
relation = add_range_relation(q[:artist_tag_count], "posts.tag_count_artist", relation)
|
relation = add_range_relation(q[:artist_tag_count], "posts.tag_count_artist", relation)
|
||||||
relation = add_range_relation(q[:copyright_tag_count], "posts.tag_count_copyright", relation)
|
relation = add_range_relation(q[:copyright_tag_count], "posts.tag_count_copyright", relation)
|
||||||
|
|||||||
@@ -195,27 +195,25 @@ class Tag < ActiveRecord::Base
|
|||||||
size = $1.to_i
|
size = $1.to_i
|
||||||
unit = $2
|
unit = $2
|
||||||
|
|
||||||
conversion_factor = case unit
|
case unit
|
||||||
when /^s/i
|
when /^s/i
|
||||||
1.second
|
size.seconds.ago
|
||||||
when /^mi/i
|
when /^mi/i
|
||||||
1.minute
|
size.minutes.ago
|
||||||
when /^h/i
|
when /^h/i
|
||||||
1.hour
|
size.hours.ago
|
||||||
when /^d/i
|
when /^d/i
|
||||||
1.day
|
size.days.ago
|
||||||
when /^w/i
|
when /^w/i
|
||||||
1.week
|
size.weeks.ago
|
||||||
when /^mo/i
|
when /^mo/i
|
||||||
1.month
|
size.months.ago
|
||||||
when /^y/i
|
when /^y/i
|
||||||
1.year
|
size.years.ago
|
||||||
else
|
else
|
||||||
1.second
|
size.seconds.ago
|
||||||
end
|
end
|
||||||
|
|
||||||
(size * conversion_factor).to_i
|
|
||||||
|
|
||||||
when :filesize
|
when :filesize
|
||||||
object =~ /\A(\d+(?:\.\d*)?|\d*\.\d+)([kKmM]?)[bB]?\Z/
|
object =~ /\A(\d+(?:\.\d*)?|\d*\.\d+)([kKmM]?)[bB]?\Z/
|
||||||
|
|
||||||
|
|||||||
@@ -839,12 +839,28 @@ class PostTest < ActiveSupport::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
context "Searching:" do
|
context "Searching:" do
|
||||||
should "return posts for the age:<1m tag" do
|
should "return posts for the age:>1m tag" do
|
||||||
post1 = FactoryGirl.create(:post, :tag_string => "aaa")
|
post1 = FactoryGirl.create(:post, :tag_string => "aaa")
|
||||||
count = Post.tag_match("age:<1m").count
|
count = Post.tag_match("age:>1m").count
|
||||||
assert_equal(1, count)
|
assert_equal(1, count)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
should "return posts for the age:>1m tag when the user is in Pacific time zone" do
|
||||||
|
post1 = FactoryGirl.create(:post, :tag_string => "aaa")
|
||||||
|
Time.zone = "Pacific Time (US & Canada)"
|
||||||
|
count = Post.tag_match("age:>1m").count
|
||||||
|
assert_equal(1, count)
|
||||||
|
Time.zone = "Eastern Time (US & Canada)"
|
||||||
|
end
|
||||||
|
|
||||||
|
should "return posts for the age:>1m tag when the user is in Tokyo time zone" do
|
||||||
|
post1 = FactoryGirl.create(:post, :tag_string => "aaa")
|
||||||
|
Time.zone = "Asia/Tokyo"
|
||||||
|
count = Post.tag_match("age:>1m").count
|
||||||
|
assert_equal(1, count)
|
||||||
|
Time.zone = "Eastern Time (US & Canada)"
|
||||||
|
end
|
||||||
|
|
||||||
should "return posts for the ' tag" do
|
should "return posts for the ' tag" do
|
||||||
post1 = FactoryGirl.create(:post, :tag_string => "'")
|
post1 = FactoryGirl.create(:post, :tag_string => "'")
|
||||||
post2 = FactoryGirl.create(:post, :tag_string => "aaa bbb")
|
post2 = FactoryGirl.create(:post, :tag_string => "aaa bbb")
|
||||||
|
|||||||
Reference in New Issue
Block a user