Cross Reference: 070-oops.rb
xref
: /
ontohub
/
db
/
seeds
/
070-oops.rb
Home
History
Annotate
Line#
Navigate
Download
Search
only in
./
070-oops.rb revision 6f8248a4d5a940787999b9eb3387d8014c64ef0f
# Add OOPS! requests and responses to pizza ontology.
ontology
=
Ontology.where
(
name
:
"Pizza"
)
.
first
!
version
=
ontology.versions.first
if
version
request
=
version.build
_request
({
state
:
'done'
},
without_protection
:
true
)
request.save
!
responses
= %w
(
Pitfall
Warning
Warning
Suggestion
)
.
map
do
|
type
|
request.responses.create
! \
name
:
Faker
::
Name.name
,
code
:
0
,
description
:
Faker
::
Lorem.paragraph
,
element_type
:
type
end
end
ontology.entities.all.select
do
|
entity
|
entity.oops
_responses
=
responses.sample
(
rand
(
responses.count
)
)
end