Skip to content

Commit

Permalink
Remove ability to inject ID sets via arguments
Browse files Browse the repository at this point in the history
This was introduced solely for testing -- replace with stubbing :site_nct_ids in the spec.
  • Loading branch information
machinehum committed Jan 9, 2024
1 parent 5057661 commit e792a2e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
10 changes: 4 additions & 6 deletions lib/connectors/ctgov.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,12 @@ def site_nct_ids
nct_ids_for_location(SystemInfo.search_term)
end

def stray_trials(nct_ids = nil)
nct_ids ||= site_nct_ids
Trial.where(parser_id: @parser_id).where.not(nct_id: nct_ids)
def stray_trials
Trial.where(parser_id: @parser_id).where.not(nct_id: self.site_nct_ids)
end

def cleanup_stray_trials(nct_ids = nil)
nct_ids ||= site_nct_ids
stray_trials(nct_ids).update!(visible: false)
def cleanup_stray_trials
stray_trials.update_all(visible: false)
end

def nct_ids_for_location(location, page_token = nil)
Expand Down
10 changes: 7 additions & 3 deletions spec/connectors/ctgov_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@
expect(will_hide.visible).to be_truthy
expect(wont_hide.first.visible).to be_truthy

strays = ctgov.stray_trials(remaining_ids)
allow(ctgov).to receive(:site_nct_ids).and_return(remaining_ids)

strays = ctgov.stray_trials
expect(strays.map { |e| e.nct_id }).to include(will_hide.nct_id)

ctgov.cleanup_stray_trials(remaining_ids)
ctgov.cleanup_stray_trials
will_hide.reload
expect(will_hide.visible).to be_falsey
expect(wont_hide.first.visible).to be_truthy
Expand All @@ -36,7 +38,9 @@
expect(will_hide.visible).to be_truthy
expect(wont_hide_2.visible).to be_truthy

ctgov.cleanup_stray_trials(remaining_ids)
allow(ctgov).to receive(:site_nct_ids).and_return(remaining_ids)

ctgov.cleanup_stray_trials
will_hide.reload

expect(will_hide.visible).to be_falsey
Expand Down

0 comments on commit e792a2e

Please sign in to comment.