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 1 commit
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 /^"(.*?)" has a bookmark of a work titled "(.*?)"$/ 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,
Copy link
Contributor Author

@potpotkettle potpotkettle Oct 29, 2023

Choose a reason for hiding this comment

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

This will make it inconsistent with other similar lines with FactoryBot.create in the same file. Should I change them as well? I think the substrings "bookmark" look aligned in the current (apparently illegal) style.

Copy link
Contributor

@ceithir ceithir Oct 29, 2023

Choose a reason for hiding this comment

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

https://github.com/otwcode/otwarchive/wiki/Coding-Standards#user-content-Previewing_Hound_comments

You can (and should!) ignore anything that isn't related to the lines you've changed.

I thus guess there is no issue leaving the other calls as they are, for them to be fixed bit by bit in future PRs.

Also, this is not something Hound detects (dunno if that would be easy to add?), but the standard syntax for Cucumber expressions has changed, moving away from (explicit) regex:
https://github.com/otwcode/otwarchive/wiki/Automated-Testing#user-content-Our_Cucumber_Standards

pseud_id: user_pseud.id)

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