Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
29955c9c
Commit
29955c9c
authored
Jul 12, 2018
by
Mykhailo Formus
Committed by
Rémy Coutable
Jul 12, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding spec to test basic forking functionalities
parent
fc4c7956
Changes
17
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
229 additions
and
22 deletions
+229
-22
qa/README.md
qa/README.md
+1
-1
qa/qa.rb
qa/qa.rb
+12
-0
qa/qa/factory/repository/project_push.rb
qa/qa/factory/repository/project_push.rb
+2
-0
qa/qa/factory/repository/push.rb
qa/qa/factory/repository/push.rb
+14
-2
qa/qa/factory/resource/fork.rb
qa/qa/factory/resource/fork.rb
+24
-0
qa/qa/factory/resource/merge_request_from_fork.rb
qa/qa/factory/resource/merge_request_from_fork.rb
+24
-0
qa/qa/factory/resource/project.rb
qa/qa/factory/resource/project.rb
+1
-0
qa/qa/factory/resource/user.rb
qa/qa/factory/resource/user.rb
+34
-0
qa/qa/page/layout/banner.rb
qa/qa/page/layout/banner.rb
+17
-0
qa/qa/page/main/login.rb
qa/qa/page/main/login.rb
+17
-2
qa/qa/page/main/sign_up.rb
qa/qa/page/main/sign_up.rb
+27
-0
qa/qa/page/menu/main.rb
qa/qa/page/menu/main.rb
+2
-2
qa/qa/page/project/fork/new.rb
qa/qa/page/project/fork/new.rb
+17
-0
qa/qa/page/project/new.rb
qa/qa/page/project/new.rb
+5
-0
qa/qa/page/project/show.rb
qa/qa/page/project/show.rb
+9
-0
qa/qa/specs/features/login/standard_spec.rb
qa/qa/specs/features/login/standard_spec.rb
+0
-15
qa/qa/specs/features/project/fork_project_spec.rb
qa/qa/specs/features/project/fork_project_spec.rb
+23
-0
No files found.
qa/README.md
View file @
29955c9c
...
...
@@ -55,7 +55,7 @@ Since the arguments would be passed to `rspec`, you could use all `rspec`
options there. For example, passing
`--backtrace`
and also line number:
```
bin/qa Test::Instance http://localhost qa/specs/features/
login/standard
_spec.rb:3 --backtrace
bin/qa Test::Instance http://localhost qa/specs/features/
project/create
_spec.rb:3 --backtrace
```
### Overriding the authenticated user
...
...
qa/qa.rb
View file @
29955c9c
...
...
@@ -41,14 +41,17 @@ module QA
autoload
:Project
,
'qa/factory/resource/project'
autoload
:MergeRequest
,
'qa/factory/resource/merge_request'
autoload
:ProjectImportedFromGithub
,
'qa/factory/resource/project_imported_from_github'
autoload
:MergeRequestFromFork
,
'qa/factory/resource/merge_request_from_fork'
autoload
:DeployKey
,
'qa/factory/resource/deploy_key'
autoload
:Branch
,
'qa/factory/resource/branch'
autoload
:SecretVariable
,
'qa/factory/resource/secret_variable'
autoload
:Runner
,
'qa/factory/resource/runner'
autoload
:PersonalAccessToken
,
'qa/factory/resource/personal_access_token'
autoload
:KubernetesCluster
,
'qa/factory/resource/kubernetes_cluster'
autoload
:User
,
'qa/factory/resource/user'
autoload
:ProjectMilestone
,
'qa/factory/resource/project_milestone'
autoload
:Wiki
,
'qa/factory/resource/wiki'
autoload
:Fork
,
'qa/factory/resource/fork'
end
module
Repository
...
...
@@ -107,6 +110,7 @@ module QA
module
Main
autoload
:Login
,
'qa/page/main/login'
autoload
:OAuth
,
'qa/page/main/oauth'
autoload
:SignUp
,
'qa/page/main/sign_up'
end
module
Settings
...
...
@@ -167,6 +171,10 @@ module QA
autoload
:Index
,
'qa/page/project/issue/index'
end
module
Fork
autoload
:New
,
'qa/page/project/fork/new'
end
module
Milestone
autoload
:New
,
'qa/page/project/milestone/new'
autoload
:Index
,
'qa/page/project/milestone/index'
...
...
@@ -200,6 +208,10 @@ module QA
autoload
:Sidebar
,
'qa/page/issuable/sidebar'
end
module
Layout
autoload
:Banner
,
'qa/page/layout/banner'
end
module
MergeRequest
autoload
:New
,
'qa/page/merge_request/new'
autoload
:Show
,
'qa/page/merge_request/show'
...
...
qa/qa/factory/repository/project_push.rb
View file @
29955c9c
...
...
@@ -11,6 +11,8 @@ module QA
factory
.
output
end
product
(
:project
)
{
|
factory
|
factory
.
project
}
def
initialize
@file_name
=
'file.txt'
@file_content
=
'# This is test project'
...
...
qa/qa/factory/repository/push.rb
View file @
29955c9c
...
...
@@ -5,7 +5,8 @@ module QA
module
Repository
class
Push
<
Factory
::
Base
attr_accessor
:file_name
,
:file_content
,
:commit_message
,
:branch_name
,
:new_branch
,
:output
,
:repository_uri
:branch_name
,
:new_branch
,
:output
,
:repository_uri
,
:user
attr_writer
:remote_branch
...
...
@@ -31,9 +32,20 @@ module QA
def
fabricate!
Git
::
Repository
.
perform
do
|
repository
|
repository
.
uri
=
repository_uri
repository
.
use_default_credentials
username
=
'GitLab QA'
email
=
'root@gitlab.com'
if
user
repository
.
username
=
user
.
username
repository
.
password
=
user
.
password
username
=
user
.
name
email
=
user
.
email
end
repository
.
clone
repository
.
configure_identity
(
'GitLab QA'
,
'root@gitlab.com'
)
repository
.
configure_identity
(
username
,
email
)
if
new_branch
repository
.
checkout_new_branch
(
branch_name
)
...
...
qa/qa/factory/resource/fork.rb
0 → 100644
View file @
29955c9c
module
QA
module
Factory
module
Resource
class
Fork
<
Factory
::
Base
dependency
Factory
::
Repository
::
ProjectPush
,
as: :push
dependency
Factory
::
Resource
::
User
,
as: :user
product
(
:user
)
{
|
factory
|
factory
.
user
}
def
fabricate!
push
.
project
.
visit!
Page
::
Project
::
Show
.
act
{
fork_project
}
Page
::
Project
::
Fork
::
New
.
perform
do
|
fork_new
|
fork_new
.
choose_namespace
(
user
.
name
)
end
Page
::
Layout
::
Banner
.
act
{
has_notice?
(
'The project was successfully forked.'
)
}
end
end
end
end
end
qa/qa/factory/resource/merge_request_from_fork.rb
0 → 100644
View file @
29955c9c
module
QA
module
Factory
module
Resource
class
MergeRequestFromFork
<
MergeRequest
attr_accessor
:fork_branch
dependency
Factory
::
Resource
::
Fork
,
as: :fork
dependency
Factory
::
Repository
::
ProjectPush
,
as: :push
do
|
push
,
factory
|
push
.
project
=
factory
.
fork
push
.
branch_name
=
factory
.
fork_branch
push
.
file_name
=
'file2.txt'
push
.
user
=
factory
.
fork
.
user
end
def
fabricate!
fork
.
visit!
Page
::
Project
::
Show
.
act
{
new_merge_request
}
Page
::
MergeRequest
::
New
.
act
{
create_merge_request
}
end
end
end
end
end
qa/qa/factory/resource/project.rb
View file @
29955c9c
...
...
@@ -37,6 +37,7 @@ module QA
page
.
choose_test_namespace
page
.
choose_name
(
@name
)
page
.
add_description
(
@description
)
page
.
set_visibility
(
'Public'
)
page
.
create_new_project
end
end
...
...
qa/qa/factory/resource/user.rb
0 → 100644
View file @
29955c9c
require
'securerandom'
module
QA
module
Factory
module
Resource
class
User
<
Factory
::
Base
attr_accessor
:name
,
:username
,
:email
,
:password
def
initialize
@name
=
"name-
#{
SecureRandom
.
hex
(
8
)
}
"
@username
=
"username-
#{
SecureRandom
.
hex
(
8
)
}
"
@email
=
"mail
#{
SecureRandom
.
hex
(
8
)
}
@mail.com"
@password
=
'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
)
end
end
end
end
end
end
qa/qa/page/layout/banner.rb
0 → 100644
View file @
29955c9c
module
QA
module
Page
module
Layout
class
Banner
<
Page
::
Base
view
'app/views/layouts/header/_read_only_banner.html.haml'
do
element
:flash_notice
,
".flash-notice"
end
def
has_notice?
(
message
)
page
.
within
(
'.flash-notice'
)
do
!!
find
(
'span'
,
text:
message
)
end
end
end
end
end
end
qa/qa/page/main/login.rb
View file @
29955c9c
...
...
@@ -25,19 +25,24 @@ module QA
element
:standard_tab
,
"link_to 'Standard'"
end
view
'app/views/devise/shared/_tabs_normal.html.haml'
do
element
:sign_in_tab
,
/nav-link.*login-pane.*Sign in/
element
:register_tab
,
/nav-link.*register-pane.*Register/
end
def
initialize
# The login page is usually the entry point for all the scenarios so
# we need to wait for the instance to start. That said, in some cases
# we are already logged-in so we check both cases here.
wait
(
max:
500
)
do
page
.
has_css?
(
'.login-page'
)
||
Page
::
Menu
::
Main
.
act
{
has_personal_area?
}
Page
::
Menu
::
Main
.
act
{
has_personal_area?
(
wait:
0
)
}
end
end
def
sign_in_using_credentials
# Don't try to log-in if we're already logged-in
return
if
Page
::
Menu
::
Main
.
act
{
has_personal_area?
}
return
if
Page
::
Menu
::
Main
.
act
{
has_personal_area?
(
wait:
0
)
}
using_wait_time
0
do
set_initial_password_if_present
...
...
@@ -48,12 +53,22 @@ module QA
sign_in_using_gitlab_credentials
end
end
Page
::
Menu
::
Main
.
act
{
has_personal_area?
}
end
def
self
.
path
'/users/sign_in'
end
def
switch_to_sign_in_tab
click_on
'Sign in'
end
def
switch_to_register_tab
click_on
'Register'
end
private
def
sign_in_using_ldap_credentials
...
...
qa/qa/page/main/sign_up.rb
0 → 100644
View file @
29955c9c
module
QA
module
Page
module
Main
class
SignUp
<
Page
::
Base
view
'app/views/devise/shared/_signup_box.html.haml'
do
element
:name
,
'text_field :name'
element
:username
,
'text_field :username'
element
:email_field
,
'email_field :email'
element
:email_confirmation
,
'email_field :email_confirmation'
element
:password
,
'password_field :password'
element
:register_button
,
'submit "Register"'
end
def
sign_up!
(
name
:,
username
:,
email
:,
password
:)
fill_in
:new_user_name
,
with:
name
fill_in
:new_user_username
,
with:
username
fill_in
:new_user_email
,
with:
email
fill_in
:new_user_email_confirmation
,
with:
email
fill_in
:new_user_password
,
with:
password
click_button
'Register'
Page
::
Menu
::
Main
.
act
{
has_personal_area?
}
end
end
end
end
end
qa/qa/page/menu/main.rb
View file @
29955c9c
...
...
@@ -60,9 +60,9 @@ module QA
end
end
def
has_personal_area?
def
has_personal_area?
(
wait:
Capybara
.
default_max_wait_time
)
# No need to wait, either we're logged-in, or not.
using_wait_time
(
0
)
{
page
.
has_selector?
(
'.qa-user-avatar'
)
}
using_wait_time
(
wait
)
{
page
.
has_selector?
(
'.qa-user-avatar'
)
}
end
private
...
...
qa/qa/page/project/fork/new.rb
0 → 100644
View file @
29955c9c
module
QA
module
Page
module
Project
module
Fork
class
New
<
Page
::
Base
view
'app/views/projects/forks/_fork_button.html.haml'
do
element
:namespace
,
'link_to project_forks_path'
end
def
choose_namespace
(
namespace
=
Runtime
::
Namespace
.
path
)
click_on
namespace
end
end
end
end
end
end
qa/qa/page/project/new.rb
View file @
29955c9c
...
...
@@ -14,6 +14,7 @@ module QA
element
:project_path
,
'text_field :path'
element
:project_description
,
'text_area :description'
element
:project_create_button
,
"submit 'Create project'"
element
:visibility_radios
,
'visibility_level:'
end
view
'app/views/projects/_import_project_pane.html.haml'
do
...
...
@@ -42,6 +43,10 @@ module QA
click_on
'Create project'
end
def
set_visibility
(
visibility
)
choose
visibility
end
def
go_to_github_import
click_link
'GitHub'
end
...
...
qa/qa/page/project/show.rb
View file @
29955c9c
...
...
@@ -22,6 +22,11 @@ module QA
element
:branches_dropdown
end
view
'app/views/projects/buttons/_fork.html.haml'
do
element
:fork_label
,
"%span= s_('GoToYourFork|Fork')"
element
:fork_link
,
"link_to new_project_fork_path(@project)"
end
view
'app/views/projects/_files.html.haml'
do
element
:tree_holder
,
'.tree-holder'
end
...
...
@@ -61,6 +66,10 @@ module QA
click_link
'New issue'
end
def
fork_project
click_on
'Fork'
end
end
end
end
...
...
qa/qa/specs/features/login/standard_spec.rb
deleted
100644 → 0
View file @
fc4c7956
module
QA
describe
'standard user login'
,
:core
do
it
'user logs in using credentials'
do
Runtime
::
Browser
.
visit
(
:gitlab
,
Page
::
Main
::
Login
)
Page
::
Main
::
Login
.
act
{
sign_in_using_credentials
}
# TODO, since `Signed in successfully` message was removed
# this is the only way to tell if user is signed in correctly.
#
Page
::
Menu
::
Main
.
perform
do
|
menu
|
expect
(
menu
).
to
have_personal_area
end
end
end
end
qa/qa/specs/features/project/fork_project_spec.rb
0 → 100644
View file @
29955c9c
module
QA
describe
'Project fork'
,
:core
do
it
'can submit merge requests to upstream master'
do
Runtime
::
Browser
.
visit
(
:gitlab
,
Page
::
Main
::
Login
)
Page
::
Main
::
Login
.
act
{
sign_in_using_credentials
}
merge_request
=
Factory
::
Resource
::
MergeRequestFromFork
.
fabricate!
do
|
merge_request
|
merge_request
.
fork_branch
=
'feature-branch'
end
Page
::
Menu
::
Main
.
act
{
sign_out
}
Page
::
Main
::
Login
.
act
do
switch_to_sign_in_tab
sign_in_using_credentials
end
merge_request
.
visit!
Page
::
MergeRequest
::
Show
.
act
{
merge!
}
expect
(
page
).
to
have_content
(
'The changes were merged'
)
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment