diff --git a/Gemfile b/Gemfile index 8fcafc23e..3a86d15f7 100644 --- a/Gemfile +++ b/Gemfile @@ -6,6 +6,7 @@ group :test do gem "mocha", :require => "mocha/setup" gem "ffaker", :git => "http://github.com/EmmanuelOga/ffaker.git" gem "simplecov", :require => false + gem "testrbl" end group :assets do diff --git a/Gemfile.lock b/Gemfile.lock index 92351e8b3..09ff60c5d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -178,6 +178,7 @@ GEM rack (~> 1.0) tilt (~> 1.1, != 1.3.0) term-ansicolor (1.1.4) + testrbl (0.2.0) therubyracer (0.11.4) libv8 (~> 3.11.8.12) ref @@ -235,6 +236,7 @@ DEPENDENCIES simple_form simplecov term-ansicolor + testrbl therubyracer uglifier (>= 1.0.3) unicorn diff --git a/app/logical/post_query_builder.rb b/app/logical/post_query_builder.rb index 33f14007b..3bdb4b077 100644 --- a/app/logical/post_query_builder.rb +++ b/app/logical/post_query_builder.rb @@ -120,7 +120,7 @@ class PostQueryBuilder 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[:date], "posts.created_at", relation) - relation = add_range_relation(q[:age], "extract(epoch from (CURRENT_TIMESTAMP - posts.created_at))", relation) + relation = add_range_relation(q[:age], "extract(epoch from (posts.created_at - CURRENT_TIMESTAMP))", 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[:copyright_tag_count], "posts.tag_count_copyright", relation) diff --git a/test/unit/post_test.rb b/test/unit/post_test.rb index 2a53a0942..8ded9febc 100644 --- a/test/unit/post_test.rb +++ b/test/unit/post_test.rb @@ -839,6 +839,12 @@ class PostTest < ActiveSupport::TestCase end context "Searching:" do + should "return posts for the age:<1m tag" do + post1 = FactoryGirl.create(:post, :tag_string => "aaa") + count = Post.tag_match("age:<1m").count + assert_equal(1, count) + end + should "return posts for the ' tag" do post1 = FactoryGirl.create(:post, :tag_string => "'") post2 = FactoryGirl.create(:post, :tag_string => "aaa bbb")