add test case for RelatedTagQuery#other_wiki_category_tags
This commit is contained in:
@@ -2,11 +2,29 @@ require 'test_helper'
|
|||||||
|
|
||||||
class RelatedTagQueryTest < ActiveSupport::TestCase
|
class RelatedTagQueryTest < ActiveSupport::TestCase
|
||||||
setup do
|
setup do
|
||||||
|
User.any_instance.stubs(:validate_sock_puppets).returns(true)
|
||||||
user = FactoryGirl.create(:user)
|
user = FactoryGirl.create(:user)
|
||||||
CurrentUser.user = user
|
CurrentUser.user = user
|
||||||
CurrentUser.ip_addr = "127.0.0.1"
|
CurrentUser.ip_addr = "127.0.0.1"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "#other_wiki_category_tags" do
|
||||||
|
subject { RelatedTagQuery.new("copyright") }
|
||||||
|
|
||||||
|
setup do
|
||||||
|
@copyright = FactoryGirl.create(:copyright_tag, name: "copyright")
|
||||||
|
@wiki = FactoryGirl.create(:wiki_page, title: "copyright", body: "[[list_of_hoges]]")
|
||||||
|
@list_of_hoges = FactoryGirl.create(:wiki_page, title: "list_of_hoges", body: "[[alpha]] and [[beta]]")
|
||||||
|
end
|
||||||
|
|
||||||
|
should "return tags from the associated list wiki" do
|
||||||
|
result = subject.other_wiki_category_tags
|
||||||
|
assert_not_nil(result[0])
|
||||||
|
assert_not_nil(result[0]["wiki_page_tags"])
|
||||||
|
assert_equal(%w(alpha beta), result[0]["wiki_page_tags"].map(&:first))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context "a related tag query without a category constraint" do
|
context "a related tag query without a category constraint" do
|
||||||
setup do
|
setup do
|
||||||
@post_1 = FactoryGirl.create(:post, :tag_string => "aaa bbb")
|
@post_1 = FactoryGirl.create(:post, :tag_string => "aaa bbb")
|
||||||
@@ -24,7 +42,7 @@ class RelatedTagQueryTest < ActiveSupport::TestCase
|
|||||||
end
|
end
|
||||||
|
|
||||||
should "render the json" do
|
should "render the json" do
|
||||||
assert_equal("{\"query\":\"aaa\",\"category\":\"\",\"tags\":[[\"aaa\",0],[\"bbb\",0],[\"ccc\",0]],\"wiki_page_tags\":[]}", @query.to_json)
|
assert_equal("{\"query\":\"aaa\",\"category\":\"\",\"tags\":[[\"aaa\",0],[\"bbb\",0],[\"ccc\",0]],\"wiki_page_tags\":[],\"other_wikis\":[]}", @query.to_json)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user