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
3cadffdd
Commit
3cadffdd
authored
Feb 19, 2019
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow users to compare branches on a read-only instance
parent
d3c6f9c4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
2 deletions
+33
-2
app/views/projects/branches/_branch.html.haml
app/views/projects/branches/_branch.html.haml
+1
-2
spec/features/projects/branches_spec.rb
spec/features/projects/branches_spec.rb
+32
-0
No files found.
app/views/projects/branches/_branch.html.haml
View file @
3cadffdd
...
...
@@ -53,9 +53,8 @@
=
_
(
'Merge request'
)
-
if
branch
.
name
!=
@repository
.
root_ref
=
link_to
project_compare_
index_path
(
@project
,
from:
@repository
.
root_ref
,
to:
branch
.
name
),
=
link_to
project_compare_
path
(
@project
,
@repository
.
root_ref
,
branch
.
name
),
class:
"btn btn-default
#{
'prepend-left-10'
unless
merge_project
}
"
,
method: :post
,
title:
s_
(
'Branches|Compare'
)
do
=
s_
(
'Branches|Compare'
)
...
...
spec/features/projects/branches_spec.rb
View file @
3cadffdd
...
...
@@ -229,6 +229,38 @@ describe 'Branches' do
end
end
describe
'comparing branches'
do
before
do
sign_in
(
user
)
project
.
add_developer
(
user
)
end
shared_examples
'compares branches'
do
it
'compares branches'
do
visit
project_branches_path
(
project
)
page
.
within
first
(
'.all-branches li'
)
do
click_link
'Compare'
end
expect
(
page
).
to
have_content
'Commits'
expect
(
page
).
to
have_link
'Create merge request'
end
end
context
'on a read-only instance'
do
before
do
allow
(
Gitlab
::
Database
).
to
receive
(
:read_only?
).
and_return
(
true
)
end
it_behaves_like
'compares branches'
end
context
'on a read-write instance'
do
it_behaves_like
'compares branches'
end
end
def
sorted_branches
(
repository
,
count
:,
sort_by
:,
state:
nil
)
branches
=
repository
.
branches_sorted_by
(
sort_by
)
branches
=
branches
.
select
{
|
b
|
state
==
'active'
?
b
.
active?
:
b
.
stale?
}
if
state
...
...
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