Skip to content

Commit

Permalink
Updates other tests taking snapshots to have creators
Browse files Browse the repository at this point in the history
  • Loading branch information
fherreazcue authored and stuzart committed Sep 28, 2023
1 parent e3c253d commit 7ad3ac6
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 14 deletions.
2 changes: 1 addition & 1 deletion test/functional/admin_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ def setup

test 'snapshot and doi stats' do
investigation = FactoryBot.create(:investigation, title: 'i1', description: 'not blank',
policy: FactoryBot.create(:downloadable_public_policy))
policy: FactoryBot.create(:downloadable_public_policy), creators: [FactoryBot.create(:person)])
snapshot = investigation.create_snapshot
snapshot.update_column(:doi, '10.5072/testytest')
AssetDoiLog.create(asset_type: 'investigation',
Expand Down
9 changes: 6 additions & 3 deletions test/functional/homes_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,10 @@ class HomesControllerTest < ActionController::TestCase

test 'recently added and download should include snapshot' do
person = FactoryBot.create(:person)
snapshot1 = FactoryBot.create(:investigation, policy: FactoryBot.create(:publicly_viewable_policy), title: 'inv with snap', contributor: person).create_snapshot
snapshot2 = FactoryBot.create(:assay, policy: FactoryBot.create(:publicly_viewable_policy), title: 'assay with snap', contributor: person).create_snapshot
snapshot1 = FactoryBot.create(:investigation, policy: FactoryBot.create(:publicly_viewable_policy),
title: 'inv with snap', contributor: person, creators: [person]).create_snapshot
snapshot2 = FactoryBot.create(:assay, policy: FactoryBot.create(:publicly_viewable_policy),
title: 'assay with snap', contributor: person, creators: [person]).create_snapshot
assert_difference 'ActivityLog.count', 2 do
FactoryBot.create(:activity_log, action: 'create', activity_loggable: snapshot1, created_at: 1.day.ago, culprit: person.user)
FactoryBot.create(:activity_log, action: 'download', activity_loggable: snapshot2, created_at: 1.day.ago, culprit: person.user)
Expand Down Expand Up @@ -374,7 +376,8 @@ class HomesControllerTest < ActionController::TestCase

df = FactoryBot.create :data_file, title: 'A new data file', contributor: person, policy: FactoryBot.create(:public_policy)
sop = FactoryBot.create :sop, title: 'A new sop', contributor: person, policy: FactoryBot.create(:public_policy)
assay = FactoryBot.create :assay, title: 'A new assay', contributor: person, policy: FactoryBot.create(:public_policy)
assay = FactoryBot.create :assay, title: 'A new assay', contributor: person,
policy: FactoryBot.create(:public_policy), creators: [person]
snapshot = assay.create_snapshot

FactoryBot.create :activity_log, activity_loggable: df, controller_name: 'data_files', culprit: person.user
Expand Down
5 changes: 3 additions & 2 deletions test/functional/investigations_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,7 @@ def test_title
test 'shows how to get a citation for a snapshotted investigation' do
study = FactoryBot.create(:study)
investigation = FactoryBot.create(:investigation, policy: FactoryBot.create(:publicly_viewable_policy),
studies: [study], contributor:study.contributor)
studies: [study], contributor:study.contributor, creators: [study.contributor])

login_as(investigation.contributor)
investigation.create_snapshot
Expand All @@ -473,7 +473,8 @@ def test_title
another_person = FactoryBot.create(:person,project:person.projects.first)
study = FactoryBot.create(:study,contributor:another_person)
investigation = FactoryBot.create(:investigation, projects:another_person.projects, contributor:another_person,
policy: FactoryBot.create(:publicly_viewable_policy), studies: [study])
policy: FactoryBot.create(:publicly_viewable_policy), studies: [study],
creators: [another_person])

login_as(person)
investigation.create_snapshot
Expand Down
3 changes: 2 additions & 1 deletion test/unit/activity_log_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ class ActivityLogTest < ActiveSupport::TestCase

refute public_log.reload.can_render_link?

assay = FactoryBot.create(:assay, policy: FactoryBot.create(:publicly_viewable_policy))
assay = FactoryBot.create(:assay, policy: FactoryBot.create(:publicly_viewable_policy),
creators: [FactoryBot.create(:person)])
snapshot = assay.create_snapshot
snapshot_log = FactoryBot.create(:activity_log, activity_loggable: snapshot, action: 'create', created_at: 2.hour.ago)

Expand Down
7 changes: 4 additions & 3 deletions test/unit/datacite_metadata_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ class DataciteMetadataTest < ActiveSupport::TestCase
User.current_user = contributor.user

@investigation = FactoryBot.create(:investigation, title: 'i1', description: 'not blank',
policy: FactoryBot.create(:downloadable_public_policy), contributor:contributor)
policy: FactoryBot.create(:downloadable_public_policy),
contributor: contributor, creators: [contributor])
@study = FactoryBot.create(:study, title: 's1', investigation: @investigation, contributor: @investigation.contributor,
policy: FactoryBot.create(:downloadable_public_policy))
policy: FactoryBot.create(:downloadable_public_policy), creators: [contributor])
@assay = FactoryBot.create(:assay, title: 'a1', study: @study, contributor: @investigation.contributor,
policy: FactoryBot.create(:downloadable_public_policy))
policy: FactoryBot.create(:downloadable_public_policy), creators: [contributor])
@assay2 = FactoryBot.create(:assay, title: 'a2', study: @study, contributor: @investigation.contributor,
policy: FactoryBot.create(:downloadable_public_policy))
@data_file = FactoryBot.create(:data_file, title: 'df1', contributor: @investigation.contributor,
Expand Down
6 changes: 4 additions & 2 deletions test/unit/helpers/homes_helper_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,10 @@ def setup

test 'should handle snapshots for download and recently added' do
person = FactoryBot.create(:person)
snapshot1 = FactoryBot.create(:investigation, policy: FactoryBot.create(:publicly_viewable_policy), contributor: person).create_snapshot
snapshot2 = FactoryBot.create(:assay, policy: FactoryBot.create(:publicly_viewable_policy), contributor: person).create_snapshot
snapshot1 = FactoryBot.create(:investigation, policy: FactoryBot.create(:publicly_viewable_policy),
contributor: person, creators: [person]).create_snapshot
snapshot2 = FactoryBot.create(:assay, policy: FactoryBot.create(:publicly_viewable_policy),
contributor: person, creators: [person]).create_snapshot
FactoryBot.create(:activity_log, action: 'create', activity_loggable: snapshot1, created_at: 1.day.ago, culprit: person.user)
FactoryBot.create(:activity_log, action: 'download', activity_loggable: snapshot2, created_at: 1.day.ago, culprit: person.user)

Expand Down
4 changes: 3 additions & 1 deletion test/unit/investigation_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,9 @@ class InvestigationTest < ActiveSupport::TestCase
end

test 'can create snapshot of investigation' do
investigation = FactoryBot.create(:investigation, policy: FactoryBot.create(:publicly_viewable_policy))
person = FactoryBot.create(:person)
investigation = FactoryBot.create(:investigation, policy: FactoryBot.create(:publicly_viewable_policy),
contributor: person, creators: [person])
FactoryBot.create(:study, contributor: investigation.contributor)
snapshot = nil

Expand Down
2 changes: 1 addition & 1 deletion test/unit/jobs/regular_maintenace_job_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def setup
travel_to(9.hours.ago) do
to_go = FactoryBot.create(:content_blob)
keep1 = FactoryBot.create(:data_file).content_blob
keep2 = FactoryBot.create(:investigation).create_snapshot.content_blob
keep2 = FactoryBot.create(:investigation, creators: [FactoryBot.create(:person)]).create_snapshot.content_blob
keep3 = FactoryBot.create(:strain_sample_type).content_blob
end

Expand Down

0 comments on commit 7ad3ac6

Please sign in to comment.