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
12bb8a8a
Commit
12bb8a8a
authored
Jul 12, 2019
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab-ce master
parents
ae7d799f
d8e642de
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
47 additions
and
8 deletions
+47
-8
app/helpers/blob_helper.rb
app/helpers/blob_helper.rb
+10
-1
changelogs/unreleased/51952-redirect-to-webide-in-fork.yml
changelogs/unreleased/51952-redirect-to-webide-in-fork.yml
+5
-0
spec/features/projects/files/user_edits_files_spec.rb
spec/features/projects/files/user_edits_files_spec.rb
+1
-0
spec/helpers/blob_helper_spec.rb
spec/helpers/blob_helper_spec.rb
+31
-7
No files found.
app/helpers/blob_helper.rb
View file @
12bb8a8a
...
...
@@ -18,7 +18,16 @@ module BlobHelper
end
def
ide_edit_path
(
project
=
@project
,
ref
=
@ref
,
path
=
@path
,
options
=
{})
segments
=
[
ide_path
,
'project'
,
project
.
full_path
,
'edit'
,
ref
]
project_path
=
if
!
current_user
||
can?
(
current_user
,
:push_code
,
project
)
project
.
full_path
else
# We currently always fork to the user's namespace
# in edit_fork_button_tag
"
#{
current_user
.
namespace
.
full_path
}
/
#{
project
.
path
}
"
end
segments
=
[
ide_path
,
'project'
,
project_path
,
'edit'
,
ref
]
segments
.
concat
([
'-'
,
encode_ide_path
(
path
)])
if
path
.
present?
File
.
join
(
segments
)
end
...
...
changelogs/unreleased/51952-redirect-to-webide-in-fork.yml
0 → 100644
View file @
12bb8a8a
---
title
:
Open WebIDE in fork when user doesn't have access
merge_request
:
30642
author
:
type
:
changed
spec/features/projects/files/user_edits_files_spec.rb
View file @
12bb8a8a
...
...
@@ -162,6 +162,7 @@ describe 'Projects > Files > User edits files', :js do
expect_fork_status
expect
(
page
).
to
have_css
(
'.ide-sidebar-project-title'
,
text:
"
#{
project2
.
name
}
#{
user
.
namespace
.
full_path
}
/
#{
project2
.
path
}
"
)
expect
(
page
).
to
have_css
(
'.ide .multi-file-tab'
,
text:
'.gitignore'
)
end
...
...
spec/helpers/blob_helper_spec.rb
View file @
12bb8a8a
...
...
@@ -29,14 +29,15 @@ describe BlobHelper do
let
(
:project
)
{
create
(
:project
,
:repository
,
namespace:
namespace
)
}
before
do
allow
(
self
).
to
receive
(
:current_user
).
and_return
(
nil
)
allow
(
self
).
to
receive
(
:can_collaborate_with_project?
).
and_return
(
true
)
allow
(
helper
).
to
receive
(
:current_user
).
and_return
(
nil
)
allow
(
helper
).
to
receive
(
:can?
).
and_return
(
true
)
allow
(
helper
).
to
receive
(
:can_collaborate_with_project?
).
and_return
(
true
)
end
it
'verifies blob is text'
do
expect
(
helper
).
not_to
receive
(
:blob_text_viewable?
)
button
=
edit_blob_button
(
project
,
'refs/heads/master'
,
'README.md'
)
button
=
helper
.
edit_blob_button
(
project
,
'refs/heads/master'
,
'README.md'
)
expect
(
button
).
to
start_with
(
'<button'
)
end
...
...
@@ -46,25 +47,25 @@ describe BlobHelper do
expect
(
project
.
repository
).
not_to
receive
(
:blob_at
)
edit_blob_button
(
project
,
'refs/heads/master'
,
'README.md'
,
blob:
blob
)
helper
.
edit_blob_button
(
project
,
'refs/heads/master'
,
'README.md'
,
blob:
blob
)
end
it
'returns a link with the proper route'
do
stub_feature_flags
(
web_ide_default:
false
)
link
=
edit_blob_button
(
project
,
'master'
,
'README.md'
)
link
=
helper
.
edit_blob_button
(
project
,
'master'
,
'README.md'
)
expect
(
Capybara
.
string
(
link
).
find_link
(
'Edit'
)[
:href
]).
to
eq
(
"/
#{
project
.
full_path
}
/edit/master/README.md"
)
end
it
'returns a link with a Web IDE route'
do
link
=
edit_blob_button
(
project
,
'master'
,
'README.md'
)
link
=
helper
.
edit_blob_button
(
project
,
'master'
,
'README.md'
)
expect
(
Capybara
.
string
(
link
).
find_link
(
'Edit'
)[
:href
]).
to
eq
(
"/-/ide/project/
#{
project
.
full_path
}
/edit/master/-/README.md"
)
end
it
'returns a link with the passed link_opts on the expected route'
do
stub_feature_flags
(
web_ide_default:
false
)
link
=
edit_blob_button
(
project
,
'master'
,
'README.md'
,
link_opts:
{
mr_id:
10
})
link
=
helper
.
edit_blob_button
(
project
,
'master'
,
'README.md'
,
link_opts:
{
mr_id:
10
})
expect
(
Capybara
.
string
(
link
).
find_link
(
'Edit'
)[
:href
]).
to
eq
(
"/
#{
project
.
full_path
}
/edit/master/README.md?mr_id=10"
)
end
...
...
@@ -203,6 +204,13 @@ describe BlobHelper do
describe
'#ide_edit_path'
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:current_user
)
{
create
(
:user
)
}
let
(
:can_push_code
)
{
true
}
before
do
allow
(
helper
).
to
receive
(
:current_user
).
and_return
(
current_user
)
allow
(
helper
).
to
receive
(
:can?
).
and_return
(
can_push_code
)
end
around
do
|
example
|
old_script_name
=
Rails
.
application
.
routes
.
default_url_options
[
:script_name
]
...
...
@@ -243,5 +251,21 @@ describe BlobHelper do
expect
(
helper
.
ide_edit_path
(
project
,
"testing/slashes"
,
"readme.md/"
)).
to
eq
(
"/-/ide/project/
#{
project
.
namespace
.
path
}
/
#{
project
.
path
}
/edit/testing/slashes/-/readme.md/"
)
end
context
'when user is not logged in'
do
let
(
:current_user
)
{
nil
}
it
'returns IDE path inside the project'
do
expect
(
helper
.
ide_edit_path
(
project
,
"master"
,
""
)).
to
eq
(
"/-/ide/project/
#{
project
.
namespace
.
path
}
/
#{
project
.
path
}
/edit/master"
)
end
end
context
'when user cannot push to the project'
do
let
(
:can_push_code
)
{
false
}
it
"returns IDE path with the user's fork"
do
expect
(
helper
.
ide_edit_path
(
project
,
"master"
,
""
)).
to
eq
(
"/-/ide/project/
#{
current_user
.
namespace
.
full_path
}
/
#{
project
.
path
}
/edit/master"
)
end
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