-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
now can round trip queries from a case to a book and back again by pr…
…eserving all query attributes on query_doc_pairs
- Loading branch information
Showing
15 changed files
with
167 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
db/migrate/20231222115905_add_all_query_attributes_to_query_docs.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
class AddAllQueryAttributesToQueryDocs < ActiveRecord::Migration[7.1] | ||
# As we do more automatic syncing of books and cases it becomes more | ||
# apparent that having "query" and "ratings" as seperate tables for supporting Cases, | ||
# while having "query_doc_pair" and "judgements" for supporting Books is | ||
# maybe not the right way. | ||
# | ||
# Here we are adding some columns to "query_doc_pair" that exist on "query" | ||
# so that when we have a Case, and we populate the Book, and then | ||
# create a NEW Case, we have these fields from the original Case. | ||
def change | ||
add_column :query_doc_pairs, :information_need, :string | ||
add_column :query_doc_pairs, :notes, :text | ||
add_column :query_doc_pairs, :options, :text | ||
end | ||
end |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'test_helper' | ||
|
||
class CaseToBookToCaseFlowTest < ActionDispatch::IntegrationTest | ||
include ActionMailer::TestHelper | ||
|
||
let(:kase) { cases(:random_case) } | ||
let(:book) { books(:empty_book) } | ||
let(:team) { teams(:shared) } | ||
let(:user) { users(:doug) } | ||
|
||
test 'Create a book from a case, and then create a new case from that book' do | ||
post users_login_url params: { user: { email: user.email, password: 'password' }, format: :json } | ||
|
||
kase.owner = user | ||
kase.save! | ||
|
||
book.owner = user | ||
book.save! | ||
|
||
# populate the book | ||
data = { | ||
book_id: book.id, | ||
case_id: kase.id, | ||
query_doc_pairs: [ | ||
{ | ||
query_text: 'Best Bond Ever', | ||
doc_id: 'https://www.themoviedb.org/movie/708-the-living-daylights', | ||
position: 0, | ||
document_fields: { | ||
title: 'The Living Daylights', | ||
year: '1987', | ||
}, | ||
} | ||
], | ||
} | ||
|
||
put api_book_populate_url book, params: data | ||
|
||
assert_response :no_content | ||
|
||
response.parsed_body | ||
|
||
# the new Case that we will populate from a book... | ||
new_case = Case.create(case_name: 'test case', owner: user) | ||
|
||
put api_book_case_refresh_url book, new_case, params: { create_missing_queries: true } | ||
|
||
response.parsed_body | ||
|
||
new_case.reload | ||
assert_not_empty new_case.queries | ||
|
||
old_query = kase.queries.find_by(query_text: 'Best Bond Ever') | ||
new_query = new_case.queries.find_by(query_text: 'Best Bond Ever') | ||
|
||
assert_not_equal old_query.arranged_next, new_query.arranged_next | ||
|
||
assert_equal old_query.information_need, new_query.information_need | ||
assert_equal old_query.notes, new_query.notes | ||
assert_equal old_query.options, new_query.options | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters