-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #157 from ahcis-rds/ctgov-connector-study-expiry
Address expiry of studies from clinicaltrials.gov
- Loading branch information
Showing
5 changed files
with
119 additions
and
34 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
require 'rails_helper' | ||
require 'connectors/ctgov' | ||
|
||
describe Connectors::Ctgov do | ||
context "cleanup_stray_trials" do | ||
it "hides trials that are no longer actively recruiting at the given location(s)" do | ||
parser = create(:parser) | ||
system_info = create(:system_info, initials: 'TSTU') | ||
ctgov = Connectors::Ctgov.new | ||
will_hide = create(:trial, parser: parser) | ||
wont_hide = create_list(:trial, 5, parser: parser) | ||
remaining_ids = wont_hide.map { |e| e.nct_id } | ||
|
||
expect(will_hide.visible).to be_truthy | ||
expect(wont_hide.first.visible).to be_truthy | ||
|
||
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 | ||
will_hide.reload | ||
expect(will_hide.visible).to be_falsey | ||
expect(wont_hide.first.visible).to be_truthy | ||
end | ||
|
||
it "does not hide trials from a different parser" do | ||
parser = create(:parser) | ||
parser2 = create(:parser, name: 'foobar', klass: 'Parsers::Foobar') | ||
system_info = create(:system_info, initials: 'TSTU') | ||
ctgov = Connectors::Ctgov.new | ||
will_hide = create(:trial, parser: parser) | ||
wont_hide = create_list(:trial, 5, parser: parser) | ||
wont_hide_2 = create(:trial, parser: parser2) | ||
remaining_ids = wont_hide.map { |e| e.nct_id } | ||
|
||
expect(will_hide.visible).to be_truthy | ||
expect(wont_hide_2.visible).to be_truthy | ||
|
||
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 | ||
expect(wont_hide_2.visible).to be_truthy | ||
end | ||
end | ||
end |
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,6 @@ | ||
FactoryBot.define do | ||
factory :parser do | ||
name { 'clinicaltrials.gov' } | ||
klass { 'Parsers::Ctgov' } | ||
end | ||
end |
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