-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathscenario_helpers.rb
59 lines (49 loc) · 2.38 KB
/
scenario_helpers.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# This gives us the ability to recalculate some DB values:
include EOL::Data
# This gives us the ability to build taxon concepts:
include EOL::Builders
# Add some comments for testing re-harvesting preserves such things:
def add_comments_to_reharvested_data_objects(tc)
user = User.first
# 1) create comments on text (and all the same for image)
# 1a) one is visible, second with visible_at = NULL
text_dato = tc.data_objects.select{ |d| d.is_text? }.first # TODO - this doesn't seem to ACTAULLY be the overview. Fix it?
text_dato.comment(user, 'this is a comment applied to the old overview')
invis_comment = text_dato.comment(user, 'this is an invisible comment applied to the old overview')
invis_comment.hide user
image_dato = tc.data_objects.select{ |d| d.is_image? }.first
image_dato.comment(user, 'this is a comment applied to the old image')
invis_image = image_dato.comment(user, 'this is an invisible comment applied to the old image')
invis_image.hide user
# 2) create new dato with the same guid
new_text_dato = DataObject.build_reharvested_dato(text_dato)
new_image_dato = DataObject.build_reharvested_dato(image_dato)
# 2b) a new harvest_event
# 2c) new links in data_objects_harvest_events (should happen automatically)
old_image_harvest_event = image_dato.harvest_events.first
new_image_harvest_event = HarvestEvent.gen(
:resource => old_image_harvest_event.resource
)
# 2d)
DataObjectsHarvestEvent.gen(
:data_object => image_dato,
:harvest_event => new_image_harvest_event,
:guid => image_dato.data_objects_harvest_events.first.guid
)
old_text_harvest_event = text_dato.harvest_events.first
new_text_harvest_event = HarvestEvent.gen(
:resource => old_text_harvest_event.resource
)
DataObjectsHarvestEvent.gen(
:data_object => text_dato,
:harvest_event => new_text_harvest_event,
:guid => text_dato.data_objects_harvest_events.first.guid
)
# 4) create comments on new version
new_text_dato.comment(user, 'brand new comment on the re-harvested overview')
invis_comment = new_text_dato.comment(user, 'and an invisible comment on the re-harvested overview')
invis_comment.hide user
new_image_dato.comment(user, 'lovely comment added after re-harvesting to the image')
invis_image = new_image_dato.comment(user, 'even wittier invisible comments on image after the harvest was redone.')
invis_image.hide user
end