Skip to content

Commit

Permalink
Merge pull request #1266 from datacite/add_data_import_exclusion
Browse files Browse the repository at this point in the history
Fix check for data import exclusion
  • Loading branch information
richardhallett authored Oct 18, 2024
2 parents 0d5b6e6 + efa6fa3 commit 6c80cb8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/models/concerns/indexable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ module Indexable
if aasm_state == "findable"
changed_attributes = saved_changes
relevant_changes = changed_attributes.keys & %w[related_identifiers creators funding_references aasm_state]
if relevant_changes.any? || (created == updated) && !ENV["EXCLUDE_PREFIXES_FROM_DATA_IMPORT"].to_s.split(",").include?(prefix)
if (relevant_changes.any? || (created == updated)) && !ENV["EXCLUDE_PREFIXES_FROM_DATA_IMPORT"].to_s.split(",").include?(prefix)
send_import_message(to_jsonapi)
Rails.logger.info "[Event Data Import Message] State: #{aasm_state} Params: #{to_jsonapi} message sent to Event Data service."
end
Expand Down
7 changes: 7 additions & 0 deletions spec/models/doi_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,13 @@

expect(new_doi).not_to receive(:send_import_message)
end

it "does not send import message when environment variable EXCLUDE_PREFIXES_FROM_DATA_IMPORT is set to prefix of doi" do
ENV["EXCLUDE_PREFIXES_FROM_DATA_IMPORT"] = "10.18730"
new_doi = create(:doi, doi: "10.18730/nvb5=", aasm_state: "findable")

expect(new_doi).not_to receive(:send_import_message)
end
end

context "On Create event" do
Expand Down

0 comments on commit 6c80cb8

Please sign in to comment.