From 0812807a536ba31c50fb33e69b69b19f9a8fb61d Mon Sep 17 00:00:00 2001 From: Guo Xiang Tan Date: Mon, 18 Jan 2016 10:38:40 +0800 Subject: [PATCH] FIX: Use declared constant. --- app/models/concerns/category_hashtag.rb | 2 +- spec/components/concern/category_hashtag_spec.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models/concerns/category_hashtag.rb b/app/models/concerns/category_hashtag.rb index fe97b0252..8f2d807fb 100644 --- a/app/models/concerns/category_hashtag.rb +++ b/app/models/concerns/category_hashtag.rb @@ -5,7 +5,7 @@ module CategoryHashtag class_methods do def query_from_hashtag_slug(category_slug) - parent_slug, child_slug = category_slug.split(":", 2) + parent_slug, child_slug = category_slug.split(SEPARATOR, 2) category = Category.where(slug: parent_slug, parent_category_id: nil) diff --git a/spec/components/concern/category_hashtag_spec.rb b/spec/components/concern/category_hashtag_spec.rb index 3fe10ba84..be60931f7 100644 --- a/spec/components/concern/category_hashtag_spec.rb +++ b/spec/components/concern/category_hashtag_spec.rb @@ -11,7 +11,7 @@ describe CategoryHashtag do end it "should return the right result for a parent and child category slug" do - expect(Category.query_from_hashtag_slug("#{parent_category.slug}:#{child_category.slug}")) + expect(Category.query_from_hashtag_slug("#{parent_category.slug}#{CategoryHashtag::SEPARATOR}#{child_category.slug}")) .to eq(child_category) end @@ -20,7 +20,7 @@ describe CategoryHashtag do end it "should return nil for incorrect parent and child category slug" do - expect(Category.query_from_hashtag_slug("random-slug:random-slug")).to eq(nil) + expect(Category.query_from_hashtag_slug("random-slug#{CategoryHashtag::SEPARATOR}random-slug")).to eq(nil) end end end