From 6d64b6d39f864947ea1fa52985dc669cd324c481 Mon Sep 17 00:00:00 2001 From: Guo Xiang Tan Date: Mon, 28 Mar 2016 11:12:08 +0800 Subject: [PATCH] FIX: Query for category hashtag should be case sensitive. --- app/controllers/category_hashtags_controller.rb | 1 - spec/components/concern/category_hashtag_spec.rb | 8 ++++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app/controllers/category_hashtags_controller.rb b/app/controllers/category_hashtags_controller.rb index ca4a1f70062..e779391f374 100644 --- a/app/controllers/category_hashtags_controller.rb +++ b/app/controllers/category_hashtags_controller.rb @@ -3,7 +3,6 @@ class CategoryHashtagsController < ApplicationController def check category_slugs = params[:category_slugs] - category_slugs.each(&:downcase!) ids = category_slugs.map { |category_slug| Category.query_from_hashtag_slug(category_slug).try(:id) } diff --git a/spec/components/concern/category_hashtag_spec.rb b/spec/components/concern/category_hashtag_spec.rb index be60931f795..c57ac891633 100644 --- a/spec/components/concern/category_hashtag_spec.rb +++ b/spec/components/concern/category_hashtag_spec.rb @@ -22,5 +22,13 @@ describe CategoryHashtag do it "should return nil for incorrect parent and child category slug" do expect(Category.query_from_hashtag_slug("random-slug#{CategoryHashtag::SEPARATOR}random-slug")).to eq(nil) end + + it "should be case sensitive" do + parent_category.update_attributes!(slug: "ApPlE") + child_category.update_attributes!(slug: "OraNGE") + + expect(Category.query_from_hashtag_slug("apple")).to eq(nil) + expect(Category.query_from_hashtag_slug("apple:orange")).to eq(nil) + end end end