Skip to content

Commit

Permalink
Merge pull request #1108 from MITLibraries/etd-588-bugfix-for-conflic…
Browse files Browse the repository at this point in the history
…t-status

Fix bug in consented_to_proquest scope ignoring null values
  • Loading branch information
jazairi authored Jan 18, 2023
2 parents b2d22bf + 044b7f5 commit 2212178
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 2 additions & 0 deletions app/models/thesis.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ class Thesis < ApplicationRecord
includes(authors: :user).where(authors: { proquest_allowed: true })
.excluding(includes(authors: :user)
.where(authors: { proquest_allowed: false }))
.excluding(includes(authors: :user)
.where(authors: { proquest_allowed: nil }))
}
scope :not_consented_to_proquest, lambda {
excluding(includes(authors: :user).where(authors: { proquest_allowed: true }))
Expand Down
19 changes: 18 additions & 1 deletion test/models/thesis_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1269,9 +1269,26 @@ def attach_file_with_purpose_to(thesis, purpose = 'thesis_pdf')
thesis = theses(:with_hold)
assert_not_includes Thesis.consented_to_proquest, thesis

# multi-author thesis with conflicting opt-in statuses is excluded
# multi-author thesis with conflicting opt-in statuses (true, false) is excluded
thesis = theses(:doctor)
assert_not_includes Thesis.consented_to_proquest, thesis

# multi-author thesis with conflicting opt-in statuses (true, nil) is excluded
first_author = thesis.authors.first
second_author = thesis.authors.second
assert_equal 2, thesis.authors.count
assert_equal true, first_author.proquest_allowed

second_author.proquest_allowed = nil
second_author.save
assert_nil second_author.proquest_allowed
assert_not_includes Thesis.consented_to_proquest, thesis

# multi-author thesis with conflicting opt-in statuses (false, nil) is excluded
first_author.proquest_allowed = false
thesis.save
assert_equal false, first_author.proquest_allowed
assert_not_includes Thesis.consented_to_proquest, thesis
end

test 'only certain proquest_exported values are valid' do
Expand Down

0 comments on commit 2212178

Please sign in to comment.