diff options
author | Rémy Coutable <remy@rymai.me> | 2018-08-08 19:05:13 +0200 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2018-08-20 10:52:24 +0200 |
commit | 98ba19b5f2c08a1c0a60be5f4137feeaa0b81f88 (patch) | |
tree | 3ed08418cf012a87a60730d3c0e88826a8b8db42 /qa/qa/factory/resource/user.rb | |
parent | 0a630e5e3ac41b95c4ff9045668f006c9fe116c0 (diff) | |
download | gitlab-ce-98ba19b5f2c08a1c0a60be5f4137feeaa0b81f88.tar.gz |
[QA] Improve the fork scenario to take a username and password instead of always creating a new userqa-staging-2
Fixes https://gitlab.com/gitlab-org/quality/staging/issues/2.
Signed-off-by: Rémy Coutable <remy@rymai.me>
Diffstat (limited to 'qa/qa/factory/resource/user.rb')
-rw-r--r-- | qa/qa/factory/resource/user.rb | 48 |
1 files changed, 36 insertions, 12 deletions
diff --git a/qa/qa/factory/resource/user.rb b/qa/qa/factory/resource/user.rb index e08df9e0cd0..eac2a873bd5 100644 --- a/qa/qa/factory/resource/user.rb +++ b/qa/qa/factory/resource/user.rb @@ -4,28 +4,52 @@ module QA module Factory module Resource class User < Factory::Base - attr_accessor :name, :username, :email, :password + attr_reader :unique_id + attr_writer :username, :password, :name, :email def initialize - @name = "name-#{SecureRandom.hex(8)}" - @username = "username-#{SecureRandom.hex(8)}" - @email = "mail#{SecureRandom.hex(8)}@mail.com" - @password = 'password' + @unique_id = SecureRandom.hex(8) end - product(:name) { |factory| factory.name } + def username + @username ||= "qa-user-#{unique_id}" + end - product(:username) { |factory| factory.username } + def password + @password ||= 'password' + end - product(:email) { |factory| factory.email } + def name + @name ||= username + end + + def email + @email ||= "#{username}@example.com" + end + + def credentials_given? + defined?(@username) && defined?(@password) + end + product(:name) { |factory| factory.name } + product(:username) { |factory| factory.username } + product(:email) { |factory| factory.email } product(:password) { |factory| factory.password } def fabricate! - Page::Menu::Main.act { sign_out } - Page::Main::Login.act { switch_to_register_tab } - Page::Main::SignUp.perform do |page| - page.sign_up!(name: name, username: username, email: email, password: password) + Page::Menu::Main.perform { |main| main.sign_out } + + if credentials_given? + Page::Main::Login.perform do |login| + login.sign_in_using_credentials(self) + end + else + Page::Main::Login.perform do |login| + login.switch_to_register_tab + end + Page::Main::SignUp.perform do |signup| + signup.sign_up!(self) + end end end end |