noosfero_steps.rb
1.15 KB
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
Given /^the following users$/ do |table|
# table is a Cucumber::Ast::Table
table.hashes.each do |item|
person_data = item.dup
person_data.delete("login")
User.create!(:login => item[:login], :password => '123456', :password_confirmation => '123456', :email => item[:login] + "@example.com", :person_data => person_data)
end
end
Given /^the following communities$/ do |table|
table.hashes.each do |item|
Community.create!(item)
end
end
Given /^the following enterprises$/ do |table|
table.hashes.each do |item|
Enterprise.create!(item)
end
end
Given /^the following (articles|events)$/ do |content, table|
klass = {
'articles' => TextileArticle,
'events' => Event,
}[content] || raise("Don't know how to build %s" % content)
table.hashes.each do |item|
data = item.dup
owner_identifier = data.delete("owner")
owner = Profile[owner_identifier]
TextileArticle.create!(data.merge(:profile => owner))
end
end
Given /^the following products$/ do |table|
table.hashes.each do |item|
data = item.dup
owner = Enterprise[data.delete("owner")]
Product.create!(data.merge(:enterprise => owner))
end
end