fixes #1427
This commit is contained in:
@@ -266,6 +266,25 @@ class Tag < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def reverse_parse_helper(array)
|
||||||
|
case array[0]
|
||||||
|
when :lte
|
||||||
|
[:gte, *array[1..-1]]
|
||||||
|
|
||||||
|
when :lt
|
||||||
|
[:gt, *array[1..-1]]
|
||||||
|
|
||||||
|
when :gte
|
||||||
|
[:lte, *array[1..-1]]
|
||||||
|
|
||||||
|
when :gt
|
||||||
|
[:lt, *array[1..-1]]
|
||||||
|
|
||||||
|
else
|
||||||
|
array
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def parse_tag(tag, output)
|
def parse_tag(tag, output)
|
||||||
if tag[0] == "-" && tag.size > 1
|
if tag[0] == "-" && tag.size > 1
|
||||||
output[:exclude] << tag[1..-1].mb_chars.downcase
|
output[:exclude] << tag[1..-1].mb_chars.downcase
|
||||||
@@ -386,7 +405,7 @@ class Tag < ActiveRecord::Base
|
|||||||
q[:date] = parse_helper($2, :date)
|
q[:date] = parse_helper($2, :date)
|
||||||
|
|
||||||
when "age"
|
when "age"
|
||||||
q[:age] = parse_helper($2, :age)
|
q[:age] = reverse_parse_helper(parse_helper($2, :age))
|
||||||
|
|
||||||
when "tagcount"
|
when "tagcount"
|
||||||
q[:post_tag_count] = parse_helper($2)
|
q[:post_tag_count] = parse_helper($2)
|
||||||
|
|||||||
@@ -42,7 +42,9 @@ class ArtistsControllerTest < ActionController::TestCase
|
|||||||
|
|
||||||
should "create an artist" do
|
should "create an artist" do
|
||||||
assert_difference("Artist.count", 1) do
|
assert_difference("Artist.count", 1) do
|
||||||
post :create, {:artist => FactoryGirl.attributes_for(:artist)}, {:user_id => @user.id}
|
attributes = FactoryGirl.attributes_for(:artist)
|
||||||
|
attributes.delete(:is_active)
|
||||||
|
post :create, {:artist => attributes}, {:user_id => @user.id}
|
||||||
end
|
end
|
||||||
artist = Artist.last
|
artist = Artist.last
|
||||||
assert_redirected_to(artist_path(artist))
|
assert_redirected_to(artist_path(artist))
|
||||||
|
|||||||
@@ -839,24 +839,24 @@ 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
|
should "return posts for the age:<1m tag when the user is in Pacific time zone" do
|
||||||
post1 = FactoryGirl.create(:post, :tag_string => "aaa")
|
post1 = FactoryGirl.create(:post, :tag_string => "aaa")
|
||||||
Time.zone = "Pacific Time (US & Canada)"
|
Time.zone = "Pacific Time (US & Canada)"
|
||||||
count = Post.tag_match("age:>1m").count
|
count = Post.tag_match("age:<1m").count
|
||||||
assert_equal(1, count)
|
assert_equal(1, count)
|
||||||
Time.zone = "Eastern Time (US & Canada)"
|
Time.zone = "Eastern Time (US & Canada)"
|
||||||
end
|
end
|
||||||
|
|
||||||
should "return posts for the age:>1m tag when the user is in Tokyo time zone" do
|
should "return posts for the age:<1m tag when the user is in Tokyo time zone" do
|
||||||
post1 = FactoryGirl.create(:post, :tag_string => "aaa")
|
post1 = FactoryGirl.create(:post, :tag_string => "aaa")
|
||||||
Time.zone = "Asia/Tokyo"
|
Time.zone = "Asia/Tokyo"
|
||||||
count = Post.tag_match("age:>1m").count
|
count = Post.tag_match("age:<1m").count
|
||||||
assert_equal(1, count)
|
assert_equal(1, count)
|
||||||
Time.zone = "Eastern Time (US & Canada)"
|
Time.zone = "Eastern Time (US & Canada)"
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user