FIX: Use declared constant.

This commit is contained in:
Guo Xiang Tan 2016-01-18 10:38:40 +08:00
parent 61cc776fdd
commit 0812807a53
2 changed files with 3 additions and 3 deletions

View file

@ -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)

View file

@ -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