BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
0d2c68d5
Commit
0d2c68d5
authored
Jan 20, 2017
by
Toon Claes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Deduplicate tests for Merge Request buttons
Use shared examples to test the presence of the Merge Request button on the various pages.
parent
7ce39486
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
65 additions
and
165 deletions
+65
-165
merge_request_buttons_spec.rb
.../features/projects/branches/merge_request_buttons_spec.rb
+0
-62
merge_request_button_spec.rb
spec/features/projects/compare/merge_request_button_spec.rb
+0
-62
merge_request_button_spec.rb
spec/features/projects/merge_request_button_spec.rb
+65
-41
No files found.
spec/features/projects/branches/merge_request_buttons_spec.rb
deleted
100644 → 0
View file @
7ce39486
require
'spec_helper'
feature
'Merge Request buttons on branches page'
,
feature:
true
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:project
)
{
create
(
:project
)
}
context
'not logged in'
do
it
'does not show merge request buttons'
do
visit
namespace_project_branches_path
(
project
.
namespace
,
project
)
expect
(
page
).
to
have_no_link
(
'Merge Request'
)
end
end
context
'logged in a developer'
do
before
do
login_as
(
user
)
project
.
team
<<
[
user
,
:developer
]
end
it
'shows merge request buttons'
do
href
=
new_namespace_project_merge_request_path
(
project
.
namespace
,
project
,
merge_request:
{
source_branch:
'feature'
,
target_branch:
'master'
})
visit
namespace_project_branches_path
(
project
.
namespace
,
project
)
expect
(
page
).
to
have_link
(
'Merge Request'
,
href:
href
)
end
end
context
'logged in as non-member'
do
before
do
login_as
(
user
)
end
it
'does not show merge request buttons'
do
visit
namespace_project_branches_path
(
project
.
namespace
,
project
)
expect
(
page
).
to
have_no_link
(
'Merge Request'
)
end
context
'on own fork of project'
do
let
(
:forked_project
)
do
create
(
:project
,
forked_from_project:
project
)
end
let
(
:user
)
{
forked_project
.
owner
}
it
'shows merge request buttons'
do
href
=
new_namespace_project_merge_request_path
(
forked_project
.
namespace
,
forked_project
,
merge_request:
{
source_branch:
'feature'
,
target_branch:
'master'
})
visit
namespace_project_branches_path
(
forked_project
.
namespace
,
forked_project
)
expect
(
page
).
to
have_link
(
'Merge Request'
,
href:
href
)
end
end
end
end
spec/features/projects/compare/merge_request_button_spec.rb
deleted
100644 → 0
View file @
7ce39486
require
'spec_helper'
feature
'Merge Request button on commits page'
,
feature:
true
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:project
)
{
create
(
:project
)
}
context
'not logged in'
do
it
'does not show Create Merge Request button'
do
visit
namespace_project_compare_path
(
project
.
namespace
,
project
,
from:
'master'
,
to:
'feature'
)
expect
(
page
).
to
have_no_link
(
'Create Merge Request'
)
end
end
context
'logged in a developer'
do
before
do
login_as
(
user
)
project
.
team
<<
[
user
,
:developer
]
end
it
'shows Create Merge Request button'
do
href
=
new_namespace_project_merge_request_path
(
project
.
namespace
,
project
,
merge_request:
{
source_branch:
'feature'
,
target_branch:
'master'
})
visit
namespace_project_compare_path
(
project
.
namespace
,
project
,
from:
'master'
,
to:
'feature'
)
expect
(
page
).
to
have_link
(
'Create Merge Request'
,
href:
href
)
end
end
context
'logged in as non-member'
do
before
do
login_as
(
user
)
end
it
'does not show Create Merge Request button'
do
visit
namespace_project_compare_path
(
project
.
namespace
,
project
,
from:
'master'
,
to:
'feature'
)
expect
(
page
).
to
have_no_link
(
'Create Merge Request'
)
end
context
'on own fork of project'
do
let
(
:forked_project
)
do
create
(
:project
,
forked_from_project:
project
)
end
let
(
:user
)
{
forked_project
.
owner
}
it
'shows Create Merge Request button'
do
href
=
new_namespace_project_merge_request_path
(
forked_project
.
namespace
,
forked_project
,
merge_request:
{
source_branch:
'feature'
,
target_branch:
'master'
})
visit
namespace_project_compare_path
(
forked_project
.
namespace
,
forked_project
,
from:
'master'
,
to:
'feature'
)
expect
(
page
).
to
have_link
(
'Create Merge Request'
,
href:
href
)
end
end
end
end
spec/features/projects/
commits/
merge_request_button_spec.rb
→
spec/features/projects/merge_request_button_spec.rb
View file @
0d2c68d5
require
'spec_helper'
feature
'Merge Request button on commits page'
,
feature:
true
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:project
)
{
create
(
:project
)
}
feature
'Merge Request button'
,
feature:
true
do
shared_examples
'Merge Request button only shown when allowed'
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:project
)
{
create
(
:project
)
}
let
(
:forked_project
)
{
create
(
:project
,
forked_from_project:
project
)
}
context
'not logged in'
do
it
'does not show Create Merge Request button'
do
visit
namespace_project_commits_path
(
project
.
namespace
,
project
,
'feature'
)
context
'not logged in'
do
it
'does not show Create Merge Request button'
do
visit
url
expect
(
page
).
to
have_no_link
(
'Create Merge Request'
)
end
end
context
'logged in a developer'
do
before
do
login_as
(
user
)
project
.
team
<<
[
user
,
:developer
]
expect
(
page
).
not_to
have_link
(
label
)
end
end
it
'shows Create Merge Request button
'
do
href
=
new_namespace_project_merge_request_path
(
project
.
namespace
,
project
,
merge_request:
{
source_branch:
'feature'
,
target_branch:
'master'
})
context
'logged in as developer
'
do
before
do
login_as
(
user
)
project
.
team
<<
[
user
,
:developer
]
end
visit
namespace_project_commits_path
(
project
.
namespace
,
project
,
'feature'
)
it
'shows Create Merge Request button'
do
href
=
new_namespace_project_merge_request_path
(
project
.
namespace
,
project
,
merge_request:
{
source_branch:
'feature'
,
target_branch:
'master'
})
expect
(
page
).
to
have_link
(
'Create Merge Request'
,
href:
href
)
end
end
visit
url
context
'logged in as non-member'
do
before
do
login_as
(
user
)
expect
(
page
).
to
have_link
(
label
,
href:
href
)
end
end
it
'does not show Create Merge Request button'
do
visit
namespace_project_commits_path
(
project
.
namespace
,
project
,
'feature'
)
context
'logged in as non-member'
do
before
do
login_as
(
user
)
end
expect
(
page
).
to
have_no_link
(
'Create Merge Request'
)
end
it
'does not show Create Merge Request button'
do
visit
url
context
'on own fork of project'
do
let
(
:forked_project
)
do
create
(
:project
,
forked_from_project:
project
)
expect
(
page
).
not_to
have_link
(
label
)
end
let
(
:user
)
{
forked_project
.
owner
}
it
'shows Create Merge Request button'
do
href
=
new_namespace_project_merge_request_path
(
forked_project
.
namespace
,
forked_project
,
merge_request:
{
source_branch:
'feature'
,
target_branch:
'master'
})
context
'on own fork of project'
do
let
(
:user
)
{
forked_project
.
owner
}
it
'shows Create Merge Request button'
do
href
=
new_namespace_project_merge_request_path
(
forked_project
.
namespace
,
forked_project
,
merge_request:
{
source_branch:
'feature'
,
target_branch:
'master'
})
visit
namespace_project_commits_path
(
forked_project
.
namespace
,
forked_project
,
'feature'
)
visit
fork_url
expect
(
page
).
to
have_link
(
'Create Merge Request'
,
href:
href
)
expect
(
page
).
to
have_link
(
label
,
href:
href
)
end
end
end
end
context
'on branches page'
do
it_behaves_like
'Merge Request button only shown when allowed'
do
let
(
:label
)
{
'Merge Request'
}
let
(
:url
)
{
namespace_project_branches_path
(
project
.
namespace
,
project
)
}
let
(
:fork_url
)
{
namespace_project_branches_path
(
forked_project
.
namespace
,
forked_project
)
}
end
end
context
'on compare page'
do
it_behaves_like
'Merge Request button only shown when allowed'
do
let
(
:label
)
{
'Create Merge Request'
}
let
(
:url
)
{
namespace_project_compare_path
(
project
.
namespace
,
project
,
from:
'master'
,
to:
'feature'
)
}
let
(
:fork_url
)
{
namespace_project_compare_path
(
forked_project
.
namespace
,
forked_project
,
from:
'master'
,
to:
'feature'
)
}
end
end
context
'on commits page'
do
it_behaves_like
'Merge Request button only shown when allowed'
do
let
(
:label
)
{
'Create Merge Request'
}
let
(
:url
)
{
namespace_project_commits_path
(
project
.
namespace
,
project
,
'feature'
)
}
let
(
:fork_url
)
{
namespace_project_commits_path
(
forked_project
.
namespace
,
forked_project
,
'feature'
)
}
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