Commit b6fa706b36146fc602d012b7779233550f53409c
1 parent
a778c261
Exists in
master
and in
28 other branches
Reduce friction to create a new user for testing
Showing
1 changed file
with
4 additions
and
2 deletions
Show diff stats
test/factories.rb
| @@ -71,7 +71,8 @@ module Noosfero::Factory | @@ -71,7 +71,8 @@ module Noosfero::Factory | ||
| 71 | # testing that passes through the actual user creation process. | 71 | # testing that passes through the actual user creation process. |
| 72 | # | 72 | # |
| 73 | # Be aware that this is slow, though. | 73 | # Be aware that this is slow, though. |
| 74 | - def create_user_full(name, options = {}, person_options = {}) | 74 | + def create_user_full(name = nil, options = {}, person_options = {}) |
| 75 | + name ||= 'user' + factory_num_seq.to_s | ||
| 75 | data = { | 76 | data = { |
| 76 | :login => name, | 77 | :login => name, |
| 77 | :email => name + '@noosfero.org', | 78 | :email => name + '@noosfero.org', |
| @@ -90,7 +91,8 @@ module Noosfero::Factory | @@ -90,7 +91,8 @@ module Noosfero::Factory | ||
| 90 | 91 | ||
| 91 | # This method knows way too much about the model. But since creating an | 92 | # This method knows way too much about the model. But since creating an |
| 92 | # actual user is really expensive, for tests we need a fast alternative. | 93 | # actual user is really expensive, for tests we need a fast alternative. |
| 93 | - def create_user(name, options = {}, person_options = {}) | 94 | + def create_user(name = nil, options = {}, person_options = {}) |
| 95 | + name ||= 'user' + factory_num_seq.to_s | ||
| 94 | environment_id = options.delete(:environment_id) || (options.delete(:environment) || Environment.default).id | 96 | environment_id = options.delete(:environment_id) || (options.delete(:environment) || Environment.default).id |
| 95 | 97 | ||
| 96 | password = options.delete(:password) | 98 | password = options.delete(:password) |