Commit 5a2b8a93 authored by Sanad Liaquat's avatar Sanad Liaquat

Some refactoring done

parent dedacada
......@@ -76,6 +76,17 @@ module QA
}
end
def self.fabricate_or_use(username, password)
if !Runtime::Env.signup_disabled?
self.fabricate!
else
self.new.tap do |user|
user.username = username
user.password = password
end
end
end
private
def fetch_id(username)
......
......@@ -7,7 +7,7 @@ module QA
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.perform(&:sign_in_using_credentials)
user = create_or_use_existing_user(Runtime::Env.gitlab_qa_username_1, Runtime::Env.gitlab_qa_password_1)
user = Resource::User.fabricate_or_use(Runtime::Env.gitlab_qa_username_1, Runtime::Env.gitlab_qa_password_1)
project = Resource::Project.fabricate! do |resource|
resource.name = 'add-member-project'
......@@ -21,17 +21,6 @@ module QA
expect(page).to have_content("#{user.name} @#{user.username} Given access")
end
def create_or_use_existing_user(username, password)
if Runtime::Env.signup_disabled?
Resource::User.new.tap do |user|
user.username = username
user.password = password
end
else
Resource::User.fabricate!
end
end
end
end
end
......@@ -21,8 +21,8 @@ module QA
Runtime::Browser.visit(:gitlab, Page::Main::Login)
Page::Main::Login.perform(&:sign_in_using_credentials)
@user = create_or_use_existing_user(Runtime::Env.gitlab_qa_username_1, Runtime::Env.gitlab_qa_password_1)
@user2 = create_or_use_existing_user(Runtime::Env.gitlab_qa_username_2, Runtime::Env.gitlab_qa_password_2)
@user = Resource::User.fabricate_or_use(Runtime::Env.gitlab_qa_username_1, Runtime::Env.gitlab_qa_password_1)
@user2 = Resource::User.fabricate_or_use(Runtime::Env.gitlab_qa_username_2, Runtime::Env.gitlab_qa_password_2)
@project = Resource::Project.fabricate! do |project|
project.name = "codeowners"
......@@ -73,17 +73,6 @@ module QA
expect(page).to have_content(@user2.name)
expect(page).not_to have_content(@user.name)
end
def create_or_use_existing_user(username, password)
if Runtime::Env.signup_disabled?
Resource::User.new.tap do |user|
user.username = username
user.password = password
end
else
Resource::User.fabricate!
end
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment