-
Notifications
You must be signed in to change notification settings - Fork 11
/
seeds.rb
78 lines (63 loc) · 3.87 KB
/
seeds.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# frozen_string_literal: true
# rubocop:disable Rails/Output
require "factory_bot_rails"
begin
FactoryBot.find_definitions
rescue FactoryBot::DuplicateDefinitionError
# necessary to be able to use the rake db:seed task where we want, argh
Rails.logger.debug "Factory Girl definitions previously loaded"
end
organization = FactoryBot.create(:organization, name: "Acme Museum")
resource_groups = organization.resource_groups.create!([
{name: "collection"},
{name: "website"},
{name: "exhibitions"},
{name: "events"},
])
FactoryBot.factories[:license].defined_traits.to_a.map do |trait|
FactoryBot.create(:license, trait.name)
rescue ActiveRecord::RecordInvalid
end
resource = FactoryBot.create(:resource, {
name: "T.Y.F.F.S.H., 2011",
organization: organization,
resource_groups: [resource_groups.first],
source_uri: "https://coyote.pics/wp-content/uploads/2016/02/Screen-Shot-2016-02-29-at-10.05.14-AM-1024x683.png",
})
alt_text = "A red, white, and blue fabric canopy presses against walls of room; portable fans blow air into the room through a doorway."
long_text = <<~TEXT
This is an installation that viewers are invited to walk inside of. From this viewpoint you are looking through a doorway at a slight distance,
as if standing inside of a large cave and looking out of its narrow entrance at the world outside. The walls of this cave are alternating stripes of
red, white, and blue material that seems to be made of some kind of thin fabric. These colored stripes spiral around toward the entrance, as if
being sucked out of the opening. The inside of the cave is more shadowed and the area outside is brightly lit. Gradually you notice that there
are in fact two openings lined up in front of each other, straight ahead of you: the first one is a tall rectangle—the red, white and blue fabric
is wrapped through the edges of a standard doorway; beyond that it continues to spiral around toward another circular opening. The center of
this circle is much brighter, as if one had finally escape from the cave. At the center of that circular opening you see two large white fans
facing your direction, blowing air into the cave-like opening. Beyond the fans you see a brown, square form, which is the bottom of a
huge wicker basket. This basket, lying on its side, helps to reveal the truth about what you are seeing: You are standing inside of a huge
hot air balloon, which is lying on its side. Blown by the fans, the fabric billows out to press out against the existing walls of a large room,
the malleable shape of the balloon conforming to the rectangular surfaces of an existing building–the gallery that contains it.
TEXT
FactoryBot.create(:representation, resource: resource, metum: organization.meta.first, text: alt_text)
FactoryBot.create(:representation, resource: resource, metum: organization.meta.last, text: long_text)
undescribed_resource = FactoryBot.create(:resource, {
name: "Installation view, _The Making of A Fugitive_, MCA Chicago, Jul 16–Dec 4,2016",
organization: organization,
source_uri: "https://mcachicago.org/api/v1/attachment_images/thumbs/57c06fc6101f31476d000044.jpg",
})
# undescribed, unassigned resource
FactoryBot.create(:resource, {
name: "Unknown",
organization: organization,
source_uri: "https://mcachicago.org/api/v1/attachment_images/thumbs/55bb7af13164660b2f000a36.jpg",
})
Coyote::Membership.each_role do |_, role_id|
email = "#{role_id}@example.com"
user = FactoryBot.create(:user, organization: organization, role: role_id, email: email, password: "password")
Assignment.create(resource: undescribed_resource, user: user)
puts "Created #{role_id} user '#{email}' with password 'password'"
end
email = "staff@example.com"
FactoryBot.create(:user, :staff, email: email, password: "password")
puts "Created staff user '#{email}' with password 'password'"
# rubocop:enable Rails/Output