Skip to content

Commit

Permalink
Test cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
fbacall committed Sep 26, 2024
1 parent 7a8c373 commit f97633f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
9 changes: 3 additions & 6 deletions test/functional/homes_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -260,11 +260,9 @@ 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, creators: [person]).create_snapshot
snapshot1.update_attribute(:title, 'My snapshot')
title: 'inv with snap', contributor: person, creators: [person]).create_snapshot(title: 'My snapshot')
snapshot2 = FactoryBot.create(:assay, policy: FactoryBot.create(:publicly_viewable_policy),
title: 'assay with snap', contributor: person, creators: [person]).create_snapshot
snapshot2.update_attribute(:title, 'My other snapshot')
title: 'assay with snap', contributor: person, creators: [person]).create_snapshot(title: 'My other 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 @@ -380,8 +378,7 @@ class HomesControllerTest < ActionController::TestCase
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), creators: [person]
snapshot = assay.create_snapshot
snapshot.update_attribute(:title, 'My snapshot')
snapshot = assay.create_snapshot(title: 'My snapshot')

FactoryBot.create :activity_log, activity_loggable: df, controller_name: 'data_files', culprit: person.user
FactoryBot.create :activity_log, activity_loggable: sop, controller_name: 'sops', culprit: person.user
Expand Down
8 changes: 2 additions & 6 deletions test/unit/helpers/homes_helper_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,9 @@ 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, creators: [person]).create_snapshot
snapshot1.update_attribute(:title, 'My snapshot')
contributor: person, creators: [person]).create_snapshot(title: 'My snapshot')
snapshot2 = FactoryBot.create(:assay, policy: FactoryBot.create(:publicly_viewable_policy),
contributor: person, creators: [person]).create_snapshot
snapshot2.update_attribute(:title, 'My other snapshot')
contributor: person, creators: [person]).create_snapshot(title: 'My other 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 All @@ -74,8 +72,6 @@ def setup

assert_equal 1, added_hash.count
added = added_hash.first
pp added_hash
pp added
assert_equal 'Snapshot', added[:type]
assert_equal snapshot1.title.to_s, added[:title]
assert_equal investigation_snapshot_path(snapshot1.resource, snapshot1), added[:url]
Expand Down

0 comments on commit f97633f

Please sign in to comment.