Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AO3-6522 Use standard analyzer for bookmarker and creators on bookmark search #4647

Merged
merged 3 commits into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/models/search/bookmark_indexer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def self.mapping
},
creators: {
type: "text",
analyzer: "simple"
analyzer: "standard"
},
work_types: {
type: "keyword"
Expand All @@ -45,7 +45,7 @@ def self.mapping
},
bookmarker: {
type: "text",
analyzer: "simple"
analyzer: "standard"
},
tag: {
type: "text",
Expand Down
13 changes: 13 additions & 0 deletions features/bookmarks/bookmark_search.feature
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,19 @@ Feature: Search Bookmarks
And I should see "german work"
And I should not see "english work"

Scenario: Search bookmarks by bookmarker
Given "testuser2" has a bookmark of a work titled "Test Title 2"
When I fill in "Bookmarker" with "testuser2"
And I press "Search Bookmarks"
Then I should see "You searched for: Bookmarker: testuser2"
And I should see "1 Found"
And I should see "Test Title 2"
When I follow "Edit Your Search"
And I fill in "Bookmarker" with "testuser"
And I press "Search Bookmarks"
Then I should see "You searched for: Bookmarker: testuser"
And I should see "No results found."

Scenario: Inputting bad queries
Given I have bookmarks to search
When I fill in "Any field on work" with "bad~query~~!!!"
Expand Down
12 changes: 12 additions & 0 deletions features/step_definitions/bookmark_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,18 @@
step %{all indexing jobs have been run}
end

Given "{string} has a bookmark of a work titled {string}" do |user, title|
step %{the user "#{user}" exists and is activated}

user_pseud = User.find_by(login: user).default_pseud
work1 = FactoryBot.create(:work, title: title)
FactoryBot.create(:bookmark,
bookmarkable_id: work1.id,
pseud_id: user_pseud.id)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: FactoryBot can automatically get the ID we just pass the object, which is IMO a bit clearer

Suggested change
bookmarkable_id: work1.id,
pseud_id: user_pseud.id)
bookmarkable: work1,
pseud: user_pseud)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this is now done.


step %{all indexing jobs have been run}
end

def submit_bookmark_form(pseud, note, tags)
select(pseud, from: "bookmark_pseud_id") unless pseud.nil?
fill_in("bookmark_notes", with: note) unless note.nil?
Expand Down
Loading