Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
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