Commit 5d7026de3dc80177724ed91a471f857ba9199c09
1 parent
a7c0a5e1
Exists in
master
and in
28 other branches
Adding acceptance test infrastructure
Showing
2 changed files
with
72 additions
and
6 deletions
Show diff stats
features/step_definitions/noosfero_steps.rb
... | ... | @@ -19,16 +19,37 @@ Given /^the following enterprises$/ do |table| |
19 | 19 | end |
20 | 20 | end |
21 | 21 | |
22 | -Given /^the following (articles|events)$/ do |content, table| | |
22 | +Given /^the following blocks$/ do |table| | |
23 | + table.hashes.map{|item| item.dup}.each do |item| | |
24 | + klass = item.delete('type') | |
25 | + owner = Profile[item.delete('owner')] | |
26 | + box_id = owner.boxes.last.id | |
27 | + klass.constantize.create!(item.merge(:box_id => box_id)) | |
28 | + end | |
29 | +end | |
30 | + | |
31 | +Given /^the following (articles|events|blogs)$/ do |content, table| | |
23 | 32 | klass = { |
24 | 33 | 'articles' => TextileArticle, |
25 | 34 | 'events' => Event, |
35 | + 'blogs' => Blog, | |
26 | 36 | }[content] || raise("Don't know how to build %s" % content) |
27 | - table.hashes.each do |item| | |
28 | - data = item.dup | |
29 | - owner_identifier = data.delete("owner") | |
37 | + table.hashes.map{|item| item.dup}.each do |item| | |
38 | + owner_identifier = item.delete("owner") | |
30 | 39 | owner = Profile[owner_identifier] |
31 | - TextileArticle.create!(data.merge(:profile => owner)) | |
40 | + klass.create!(item.merge(:profile => owner)) | |
41 | + end | |
42 | +end | |
43 | + | |
44 | +Given /^the following files$/ do |table| | |
45 | + table.hashes.each do |item| | |
46 | + owner = Profile[item[:owner]] | |
47 | + file = "/files/#{item[:file]}" | |
48 | + article = UploadedFile.create!(:profile => owner, :uploaded_data => fixture_file_upload(file, item[:mime])) | |
49 | + if item[:homepage] | |
50 | + owner.home_page = article | |
51 | + owner.save! | |
52 | + end | |
32 | 53 | end |
33 | 54 | end |
34 | 55 | |
... | ... | @@ -40,3 +61,39 @@ Given /^the following products$/ do |table| |
40 | 61 | end |
41 | 62 | end |
42 | 63 | |
64 | +Given /^I am logged in as "(.+)"$/ do |username| | |
65 | + visit('/account/login') | |
66 | + fill_in("Username", :with => username) | |
67 | + fill_in("Password", :with => '123456') | |
68 | + click_button("Log in") | |
69 | +end | |
70 | + | |
71 | +Given /^I am logged in as admin$/ do | |
72 | + user = User.create!(:login => 'admin_user', :password => '123456', :password_confirmation => '123456', :email => 'admin_user@example.com') | |
73 | + e = Environment.default | |
74 | + e.add_admin(user.person) | |
75 | + visit('/account/login') | |
76 | + fill_in("Username", :with => user.login) | |
77 | + fill_in("Password", :with => '123456') | |
78 | + click_button("Log in") | |
79 | +end | |
80 | + | |
81 | +Given /^I am not logged in$/ do | |
82 | + visit('/account/logout') | |
83 | +end | |
84 | + | |
85 | +Given /^feature "(.+)" is enabled on environment$/ do |feature| | |
86 | + e = Environment.default | |
87 | + e.enable(feature) | |
88 | + e.save | |
89 | +end | |
90 | + | |
91 | +Given /^feature "(.+)" is disabled on environment$/ do |feature| | |
92 | + e = Environment.default | |
93 | + e.disable(feature) | |
94 | + e.save | |
95 | +end | |
96 | + | |
97 | +Given /^"(.+)" should be a member of "(.+)"$/ do |person,profile| | |
98 | + Profile.find_by_name(profile).members.should include(Person.find_by_name(person)) | |
99 | +end | ... | ... |
features/support/paths.rb
... | ... | @@ -13,7 +13,16 @@ module NavigationHelpers |
13 | 13 | |
14 | 14 | when /^\// |
15 | 15 | page_name |
16 | - | |
16 | + | |
17 | + when /^(.*)'s homepage$/ | |
18 | + '/%s' % Profile.find_by_name($1).identifier | |
19 | + | |
20 | + when /^login page$/ | |
21 | + '/account/login' | |
22 | + | |
23 | + when /^(.*)'s control panel$/ | |
24 | + '/myprofile/%s' % Profile.find_by_name($1).identifier | |
25 | + | |
17 | 26 | # Add more mappings here. |
18 | 27 | # Here is a more fancy example: |
19 | 28 | # | ... | ... |