Skip to content

Commit a6dd3fb

Browse files
committed
add test cases using bookmarked or my project filters
1 parent d7b7cfb commit a6dd3fb

File tree

1 file changed

+91
-0
lines changed

1 file changed

+91
-0
lines changed

test/unit/full_text_search/issue_query_any_searchable_test.rb

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ class IssueQueryAnySearchableTest < ActiveSupport::TestCase
66
unless IssueQuery.method_defined?(:sql_for_any_searchable_field)
77
skip("Required feature 'sql_for_any_searchable_field' does not exist.")
88
end
9+
User.current = nil
910
end
1011

1112
def test_or_one_word
@@ -65,5 +66,95 @@ def test_and_two_words
6566
]
6667
assert_equal(expected_issues, query.issues)
6768
end
69+
70+
def test_and_two_words_within_my_projects
71+
Issue.destroy_all
72+
User.current = User.find_by(login: 'dlopper')
73+
project = Project.generate!
74+
User.add_to_project(User.current, project)
75+
76+
# User's project issues.
77+
subject_groonga_description_pgroonga =
78+
Issue.generate!(project: project,
79+
subject: "ぐるんが",
80+
description: "ぴーじーるんが")
81+
without_keywords = Issue.generate!(project: project,
82+
subject: "no-keyword",
83+
description: "no-keyword")
84+
subject_pgroonga_journal_groonga =
85+
Issue.generate!(project: project, subject: "ぴーじーるんが")
86+
.journals.create!(notes: "ぐるんが")
87+
# Another project issue.
88+
subject_pgroonga_description_groonga =
89+
Issue.generate!(subject: "ぴーじーるんが",
90+
description: "ぐるんが")
91+
92+
query = IssueQuery.new(
93+
:name => "_",
94+
:filters => {
95+
"any_searchable" => {
96+
:operator => "~",
97+
:values => ["ぐるんが ぴーじーるんが"]
98+
},
99+
"project_id" => {
100+
:operator => "=",
101+
:values => ['mine']
102+
},
103+
},
104+
:sort_criteria => [["id", "asc"]]
105+
)
106+
expected_issues = [
107+
subject_groonga_description_pgroonga,
108+
subject_pgroonga_journal_groonga.issue
109+
]
110+
assert_equal(expected_issues, query.issues)
111+
end
112+
113+
def test_and_two_words_within_bookmarks
114+
Issue.destroy_all
115+
bookmark_user = User.find(1)
116+
bookmarked_project =
117+
Project.where(id: [bookmark_user.bookmarked_project_ids])
118+
.first
119+
no_bookmarked_project = Project.generate!
120+
121+
# User's bookmarked project issues.
122+
subject_groonga_description_pgroonga =
123+
Issue.generate!(project: bookmarked_project,
124+
subject: "ぐるんが",
125+
description: "ぴーじーるんが")
126+
without_keywords = Issue.generate!(project: bookmarked_project,
127+
subject: "no-keyword",
128+
description: "no-keyword")
129+
subject_pgroonga_journal_groonga =
130+
Issue.generate!(project: bookmarked_project, subject: "ぴーじーるんが")
131+
.journals.create!(notes: "ぐるんが")
132+
# Another project issue.
133+
subject_pgroonga_description_groonga =
134+
Issue.generate!(project: no_bookmarked_project,
135+
subject: "ぴーじーるんが",
136+
description: "ぐるんが")
137+
138+
User.current = bookmark_user
139+
query = IssueQuery.new(
140+
:name => "_",
141+
:filters => {
142+
"any_searchable" => {
143+
:operator => "~",
144+
:values => ["ぐるんが ぴーじーるんが"]
145+
},
146+
"project_id" => {
147+
:operator => "=",
148+
:values => ["bookmarks"]
149+
},
150+
},
151+
:sort_criteria => [["id", "asc"]]
152+
)
153+
expected_issues = [
154+
subject_groonga_description_pgroonga,
155+
subject_pgroonga_journal_groonga.issue
156+
]
157+
assert_equal(expected_issues, query.issues)
158+
end
68159
end
69160
end

0 commit comments

Comments
 (0)