Skip to content

Commit 84ec0f3

Browse files
committed
make announcement search consistent with discussions
test plan: - have a multi-word title in an announcement (e.g. "Announcement 1") - have another announcement that shares one word but not the entire phrase (e.g. "Announcement 2") - on the announcements page, search for the entire phrase. only the announcement matching the entire phrase should result ("Announcement 1" should not match "Announcement 2"). fixes CNVS-28657 Change-Id: If8962b396394ebaf38596bd4164c67576680f32f Reviewed-on: https://gerrit.instructure.com/77832 Tested-by: Jenkins Reviewed-by: Joel Hough <joel@instructure.com> QA-Review: Deepeeca Soundarrajan <dsoundarrajan@instructure.com> Product-Review: Jeremy Stanley <jeremy@instructure.com>
1 parent 84b3dd9 commit 84ec0f3

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

app/coffeescripts/views/announcements/IndexView.coffee

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,10 +183,8 @@ define [
183183
onlyGraded: -> @get 'assignment_id'
184184
onlyUnread: -> (@get('read_state') is 'unread') or @get('unread_count')
185185
searchTerm: (term) ->
186-
words = term.match(/\w+/ig)
187-
pattern = "(#{_.uniq(words).join('|')})"
188-
regexp = new RegExp(pattern, "igm")
189-
186+
return unless term
187+
regexp = new RegExp(term, "ig")
190188
@get('author')?.display_name?.match(regexp) ||
191189
@get('title').match(regexp) ||
192190
@summary().match(regexp)

spec/selenium/announcements/announcements_teacher_spec.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@
5959
refresh_and_filter(:string, 'jake', user_name)
6060
end
6161

62+
it "should search an entire phrase" do
63+
replace_content(f('#searchTerm'), 'new 001')
64+
expect(ff('.discussionTopicIndexList .discussion-topic').count).to eq 1
65+
end
66+
6267
it "should return multiple items in the search", priority: "1", test_id: 220362 do
6368
new_title = 'updated'
6469
what_to_create.first.update_attributes(:title => "#{new_title} first")

0 commit comments

Comments
 (0)