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
5d5457c2
Commit
5d5457c2
authored
May 10, 2018
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'upstream/master' into ce-to-ee-2018-05-10
parents
aa689b23
93498185
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
330 additions
and
79 deletions
+330
-79
app/assets/javascripts/cycle_analytics/cycle_analytics_bundle.js
...ets/javascripts/cycle_analytics/cycle_analytics_bundle.js
+0
-2
app/assets/javascripts/cycle_analytics/cycle_analytics_service.js
...ts/javascripts/cycle_analytics/cycle_analytics_service.js
+17
-13
app/models/repository.rb
app/models/repository.rb
+8
-2
changelogs/unreleased/blackst0ne-replace-spinach-project-issues-references-feature.yml
...0ne-replace-spinach-project-issues-references-feature.yml
+5
-0
features/project/issues/references.feature
features/project/issues/references.feature
+0
-33
features/steps/shared/issuable.rb
features/steps/shared/issuable.rb
+0
-28
lib/gitlab/file_detector.rb
lib/gitlab/file_detector.rb
+1
-0
spec/features/issuables/markdown_references/internal_references_spec.rb
...issuables/markdown_references/internal_references_spec.rb
+80
-0
spec/features/issuables/markdown_references/jira_spec.rb
spec/features/issuables/markdown_references/jira_spec.rb
+187
-0
spec/models/repository_spec.rb
spec/models/repository_spec.rb
+32
-1
No files found.
app/assets/javascripts/cycle_analytics/cycle_analytics_bundle.js
View file @
5d5457c2
...
...
@@ -82,7 +82,6 @@ export default () => {
this
.
service
.
fetchCycleAnalyticsData
(
fetchOptions
)
.
then
(
resp
=>
resp
.
json
())
.
then
((
response
)
=>
{
this
.
store
.
setCycleAnalyticsData
(
response
);
this
.
selectDefaultStage
();
...
...
@@ -116,7 +115,6 @@ export default () => {
stage
,
startDate
:
this
.
startDate
,
})
.
then
(
resp
=>
resp
.
json
())
.
then
((
response
)
=>
{
this
.
isEmptyStage
=
!
response
.
events
.
length
;
this
.
store
.
setStageEvents
(
response
.
events
,
stage
);
...
...
app/assets/javascripts/cycle_analytics/cycle_analytics_service.js
View file @
5d5457c2
import
Vue
from
'
vue
'
;
import
VueResource
from
'
vue-resource
'
;
Vue
.
use
(
VueResource
);
import
axios
from
'
~/lib/utils/axios_utils
'
;
export
default
class
CycleAnalyticsService
{
constructor
(
options
)
{
this
.
requestPath
=
options
.
requestPath
;
this
.
cycleAnalytics
=
Vue
.
resource
(
this
.
requestPath
);
this
.
axios
=
axios
.
create
({
baseURL
:
options
.
requestPath
,
});
}
fetchCycleAnalyticsData
(
options
=
{
startDate
:
30
})
{
return
this
.
cycleAnalytics
.
get
({
cycle_analytics
:
{
start_date
:
options
.
startDate
}
});
return
this
.
axios
.
get
(
''
,
{
params
:
{
'
cycle_analytics[start_date]
'
:
options
.
startDate
,
},
})
.
then
(
x
=>
x
.
data
);
}
fetchStageData
(
options
)
{
...
...
@@ -19,12 +23,12 @@ export default class CycleAnalyticsService {
startDate
,
}
=
options
;
return
Vue
.
http
.
get
(
`
${
this
.
requestPath
}
/events/
${
stage
.
name
}
.json`
,
{
return
this
.
axios
.
get
(
`events/
${
stage
.
name
}
.json`
,
{
params
:
{
cycle_analytics
:
{
start_date
:
startDate
,
},
'
cycle_analytics[start_date]
'
:
startDate
,
},
});
})
.
then
(
x
=>
x
.
data
);
}
}
app/models/repository.rb
View file @
5d5457c2
...
...
@@ -44,7 +44,7 @@ class Repository
changelog license_blob license_key gitignore koding_yml
gitlab_ci_yml branch_names tag_names branch_count
tag_count avatar exists? root_ref has_visible_content?
issue_template_names merge_request_template_names)
.
freeze
issue_template_names merge_request_template_names
xcode_project?
)
.
freeze
# Methods that use cache_method but only memoize the value
MEMOIZED_CACHED_METHODS
=
%i(license)
.
freeze
...
...
@@ -62,7 +62,8 @@ class Repository
gitlab_ci: :gitlab_ci_yml
,
avatar: :avatar
,
issue_template: :issue_template_names
,
merge_request_template: :merge_request_template_names
merge_request_template: :merge_request_template_names
,
xcode_config: :xcode_project?
}.
freeze
def
initialize
(
full_path
,
project
,
disk_path:
nil
,
is_wiki:
false
)
...
...
@@ -601,6 +602,11 @@ class Repository
end
cache_method
:gitlab_ci_yml
def
xcode_project?
file_on_head
(
:xcode_config
).
present?
end
cache_method
:xcode_project?
def
head_commit
@head_commit
||=
commit
(
self
.
root_ref
)
end
...
...
changelogs/unreleased/blackst0ne-replace-spinach-project-issues-references-feature.yml
0 → 100644
View file @
5d5457c2
---
title
:
'
Replace
the
`project/issues/references.feature`
spinach
test
with
an
rspec
analog'
merge_request
:
18769
author
:
'
@blackst0ne'
type
:
other
features/project/issues/references.feature
deleted
100644 → 0
View file @
aa689b23
@project_issues
Feature
:
Project Issues References
Background
:
Given
I sign in as
"John Doe"
And
public project
"Community"
And
"John Doe"
owns public project
"Community"
And
project
"Community"
has
"Community issue"
open issue
And
I logout
And
I sign in as
"Mary Jane"
And
private project
"Enterprise"
And
"Mary Jane"
owns private project
"Enterprise"
And
project
"Enterprise"
has
"Enterprise issue"
open issue
And
project
"Enterprise"
has
"Enterprise fix"
open merge request
And
I visit issue page
"Enterprise issue"
And
I leave a comment referencing issue
"Community issue"
And
I visit merge request page
"Enterprise fix"
And
I leave a comment referencing issue
"Community issue"
And
I logout
@javascript
Scenario
:
Viewing the public issue as a "John Doe"
Given
I sign in as
"John Doe"
When
I visit issue page
"Community issue"
Then
I should not see any related merge requests
And
I should see no notes at all
@javascript
Scenario
:
Viewing the public issue as "Mary Jane"
Given
I sign in as
"Mary Jane"
When
I visit issue page
"Community issue"
Then
I should see the
"Enterprise fix"
related merge request
And
I should see a note linking to
"Enterprise fix"
merge request
And
I should see a note linking to
"Enterprise issue"
issue
features/steps/shared/issuable.rb
View file @
5d5457c2
...
...
@@ -6,13 +6,6 @@ module SharedIssuable
find
(
'.js-issuable-edit'
,
visible:
true
).
click
end
step
'project "Community" has "Community issue" open issue'
do
create_issuable_for_project
(
project_name:
'Community'
,
title:
'Community issue'
)
end
step
'project "Community" has "Community fix" open merge request'
do
create_issuable_for_project
(
project_name:
'Community'
,
...
...
@@ -61,32 +54,11 @@ module SharedIssuable
wait_for_requests
end
step
'I visit issue page "Community issue"'
do
issue
=
Issue
.
find_by
(
title:
'Community issue'
)
visit
project_issue_path
(
issue
.
project
,
issue
)
end
step
'I visit issue page "Community fix"'
do
mr
=
MergeRequest
.
find_by
(
title:
'Community fix'
)
visit
project_merge_request_path
(
mr
.
target_project
,
mr
)
end
step
'I should not see any related merge requests'
do
page
.
within
'.issue-details'
do
expect
(
page
).
not_to
have_content
(
'#merge-requests .merge-requests-title'
)
end
end
step
'I should see the "Enterprise fix" related merge request'
do
page
.
within
'#merge-requests .merge-requests-title'
do
expect
(
page
).
to
have_content
(
'1 Related Merge Request'
)
end
page
.
within
'#merge-requests ul'
do
expect
(
page
).
to
have_content
(
'Enterprise fix'
)
end
end
step
'I should see a note linking to "Enterprise fix" merge request'
do
visible_note
(
issuable:
MergeRequest
.
find_by
(
title:
'Enterprise fix'
),
...
...
lib/gitlab/file_detector.rb
View file @
5d5457c2
...
...
@@ -14,6 +14,7 @@ module Gitlab
avatar:
/\Alogo\.(png|jpg|gif)\z/
,
issue_template:
%r{
\A\.
gitlab/issue_templates/[^/]+
\.
md
\z
}
,
merge_request_template:
%r{
\A\.
gitlab/merge_request_templates/[^/]+
\.
md
\z
}
,
xcode_config:
%r{
\A
[^/]*
\.
(xcodeproj|xcworkspace)
\z
}
,
# Configuration files
gitignore:
'.gitignore'
,
...
...
spec/features/issuables/markdown_references/internal_references_spec.rb
0 → 100644
View file @
5d5457c2
require
"rails_helper"
describe
"Internal references"
,
:js
do
include
Spec
::
Support
::
Helpers
::
Features
::
NotesHelpers
let
(
:private_project_user
)
{
private_project
.
owner
}
let
(
:private_project
)
{
create
(
:project
,
:private
,
:repository
)
}
let
(
:private_project_issue
)
{
create
(
:issue
,
project:
private_project
)
}
let
(
:private_project_merge_request
)
{
create
(
:merge_request
,
source_project:
private_project
)
}
let
(
:public_project_user
)
{
public_project
.
owner
}
let
(
:public_project
)
{
create
(
:project
,
:public
,
:repository
)
}
let
(
:public_project_issue
)
{
create
(
:issue
,
project:
public_project
)
}
context
"when referencing to open issue"
do
context
"from private project"
do
context
"from issue"
do
before
do
sign_in
(
private_project_user
)
visit
(
project_issue_path
(
private_project
,
private_project_issue
))
add_note
(
"#
#{
public_project_issue
.
to_reference
(
private_project
)
}
"
)
end
context
"when user doesn't have access to private project"
do
before
do
sign_in
(
public_project_user
)
visit
(
project_issue_path
(
public_project
,
public_project_issue
))
end
it
{
expect
(
page
).
not_to
have_css
(
".note"
)
}
end
end
context
"from merge request"
do
before
do
sign_in
(
private_project_user
)
visit
(
project_merge_request_path
(
private_project
,
private_project_merge_request
))
add_note
(
"#
#{
public_project_issue
.
to_reference
(
private_project
)
}
"
)
end
context
"when user doesn't have access to private project"
do
before
do
sign_in
(
public_project_user
)
visit
(
project_issue_path
(
public_project
,
public_project_issue
))
end
it
"doesn't show any references"
do
page
.
within
(
".issue-details"
)
do
expect
(
page
).
not_to
have_content
(
"#merge-requests .merge-requests-title"
)
end
end
end
context
"when user has access to private project"
do
before
do
visit
(
project_issue_path
(
public_project
,
public_project_issue
))
end
it
"shows references"
do
page
.
within
(
"#merge-requests .merge-requests-title"
)
do
expect
(
page
).
to
have_content
(
"1 Related Merge Request"
)
end
page
.
within
(
"#merge-requests ul"
)
do
expect
(
page
).
to
have_content
(
private_project_merge_request
.
title
)
end
expect
(
page
).
to
have_content
(
"mentioned in merge request
#{
private_project_merge_request
.
to_reference
(
public_project
)
}
"
)
.
and
have_content
(
private_project_user
.
name
)
end
end
end
end
end
end
spec/features/issuables/markdown_references_spec.rb
→
spec/features/issuables/markdown_references
/jira
_spec.rb
View file @
5d5457c2
require
'rails_helper'
require
"rails_helper"
describe
'Markdown References'
,
:js
do
describe
"Jira"
,
:js
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:actual_project
)
{
create
(
:project
,
:public
,
:repository
)
}
let
(
:merge_request
)
{
create
(
:merge_request
,
target_project:
actual_project
,
source_project:
actual_project
)}
let
(
:merge_request
)
{
create
(
:merge_request
,
target_project:
actual_project
,
source_project:
actual_project
)
}
let
(
:issue_actual_project
)
{
create
(
:issue
,
project:
actual_project
)
}
let!
(
:other_project
)
{
create
(
:project
,
:public
)
}
let!
(
:issue_other_project
)
{
create
(
:issue
,
project:
other_project
)
}
let
(
:issues
)
{
[
issue_actual_project
,
issue_other_project
]
}
def
build_note
markdown
=
"Referencing internal issue
#{
issue_actual_project
.
to_reference
}
, "
+
"cross-project
#{
issue_other_project
.
to_reference
(
actual_project
)
}
external JIRA-5 "
+
"and non existing #999"
page
.
within
(
'#diff-notes-app'
)
do
fill_in
'note_note'
,
with:
markdown
end
end
shared_examples
'correct references'
do
shared_examples
"correct references"
do
before
do
remotelink
=
double
(
:remotelink
,
all:
[],
build:
double
(
save!:
true
))
...
...
@@ -28,110 +18,89 @@ describe 'Markdown References', :js do
allow_any_instance_of
(
JIRA
::
Resource
::
Issue
).
to
receive
(
:remotelink
).
and_return
(
remotelink
)
sign_in
(
user
)
visit
merge_request_path
(
merge_request
)
build_note
end
def
links_expectations
issues
.
each
do
|
issue
|
if
referenced_issues
.
include?
(
issue
)
expect
(
page
).
to
have_link
(
issue
.
to_reference
,
href:
issue_path
(
issue
))
else
expect
(
page
).
not_to
have_link
(
issue
.
to_reference
,
href:
issue_path
(
issue
))
end
end
visit
(
merge_request_path
(
merge_request
))
if
jira_referenced
expect
(
page
).
to
have_link
(
'JIRA-5'
,
href:
'https://jira.example.com/browse/JIRA-5'
)
else
expect
(
page
).
not_to
have_link
(
'JIRA-5'
,
href:
'https://jira.example.com/browse/JIRA-5'
)
build_note
end
expect
(
page
).
not_to
have_link
(
'#999'
)
end
it
"creates a link to the referenced issue on the preview"
do
find
(
".js-md-preview-button"
).
click
it
'creates a link to the referenced issue on the preview'
do
find
(
'.js-md-preview-button'
).
click
wait_for_requests
page
.
within
(
'.md-preview-holder'
)
do
page
.
within
(
".md-preview-holder"
)
do
links_expectations
end
end
it
'creates a link to the referenced issue after submit'
do
click_button
'Comment'
it
"creates a link to the referenced issue after submit"
do
click_button
(
"Comment"
)
wait_for_requests
page
.
within
(
'#diff-notes-app'
)
do
page
.
within
(
"#diff-notes-app"
)
do
links_expectations
end
end
it
'creates a note on the referenced issues'
do
click_button
'Comment'
it
"creates a note on the referenced issues"
do
click_button
(
"Comment"
)
wait_for_requests
if
referenced_issues
.
include?
(
issue_actual_project
)
visit
issue_path
(
issue_actual_project
)
visit
(
issue_path
(
issue_actual_project
)
)
page
.
within
(
'#notes'
)
do
expect
(
page
).
to
have_content
(
"
#{
user
.
to_reference
}
mentioned in merge request
#{
merge_request
.
to_reference
}
"
)
page
.
within
(
"#notes"
)
do
expect
(
page
).
to
have_content
(
"
#{
user
.
to_reference
}
mentioned in merge request
#{
merge_request
.
to_reference
}
"
)
end
end
if
referenced_issues
.
include?
(
issue_other_project
)
visit
issue_path
(
issue_other_project
)
visit
(
issue_path
(
issue_other_project
)
)
page
.
within
(
'#notes'
)
do
expect
(
page
).
to
have_content
(
"
#{
user
.
to_reference
}
mentioned in merge request
#{
merge_request
.
to_reference
(
other_project
)
}
"
)
page
.
within
(
"#notes"
)
do
expect
(
page
).
to
have_content
(
"
#{
user
.
to_reference
}
mentioned in merge request
#{
merge_request
.
to_reference
(
other_project
)
}
"
)
end
end
end
end
context
'when internal issues tracker is enabled for the other project'
do
context
'when only internal issues tracker is enabled for the actual project'
do
include_examples
'correct references'
do
context
"when internal issues tracker is enabled for the other project"
do
context
"when only internal issues tracker is enabled for the actual project"
do
include_examples
"correct references"
do
let
(
:referenced_issues
)
{
[
issue_actual_project
,
issue_other_project
]
}
let
(
:jira_referenced
)
{
false
}
end
end
context
'when both external and internal issues trackers are enabled for the actual project'
do
context
"when both external and internal issues trackers are enabled for the actual project"
do
before
do
create
(
:jira_service
,
project:
actual_project
)
end
include_examples
'correct references'
do
include_examples
"correct references"
do
let
(
:referenced_issues
)
{
[
issue_actual_project
,
issue_other_project
]
}
let
(
:jira_referenced
)
{
true
}
end
end
context
'when only external issues tracker is enabled for the actual project'
do
context
"when only external issues tracker is enabled for the actual project"
do
let
(
:actual_project
)
{
create
(
:project
,
:public
,
:repository
,
:issues_disabled
)
}
before
do
create
(
:jira_service
,
project:
actual_project
)
actual_project
.
issues_enabled
=
false
actual_project
.
save!
end
include_examples
'correct references'
do
include_examples
"correct references"
do
let
(
:referenced_issues
)
{
[
issue_other_project
]
}
let
(
:jira_referenced
)
{
true
}
end
end
context
'when no tracker is enabled for the actual project'
do
before
do
actual_project
.
issues_enabled
=
false
actual_project
.
save!
end
context
"when no tracker is enabled for the actual project"
do
let
(
:actual_project
)
{
create
(
:project
,
:public
,
:repository
,
:issues_disabled
)
}
include_examples
'correct references'
do
let
(
:referenced_issues
)
{
[
issue_other_project
]
}
...
...
@@ -140,54 +109,79 @@ describe 'Markdown References', :js do
end
end
context
'when internal issues tracker is disabled for the other project'
do
before
do
other_project
.
issues_enabled
=
false
other_project
.
save!
end
context
"when internal issues tracker is disabled for the other project"
do
let
(
:other_project
)
{
create
(
:project
,
:public
,
:repository
,
:issues_disabled
)
}
context
'when only internal issues tracker is enabled for the actual project'
do
include_examples
'correct references'
do
context
"when only internal issues tracker is enabled for the actual project"
do
include_examples
"correct references"
do
let
(
:referenced_issues
)
{
[
issue_actual_project
]
}
let
(
:jira_referenced
)
{
false
}
end
end
context
'when both external and internal issues trackers are enabled for the actual project'
do
context
"when both external and internal issues trackers are enabled for the actual project"
do
before
do
create
(
:jira_service
,
project:
actual_project
)
end
include_examples
'correct references'
do
include_examples
"correct references"
do
let
(
:referenced_issues
)
{
[
issue_actual_project
]
}
let
(
:jira_referenced
)
{
true
}
end
end
context
'when only external issues tracker is enabled for the actual project'
do
context
"when only external issues tracker is enabled for the actual project"
do
let
(
:actual_project
)
{
create
(
:project
,
:public
,
:repository
,
:issues_disabled
)
}
before
do
create
(
:jira_service
,
project:
actual_project
)
actual_project
.
issues_enabled
=
false
actual_project
.
save!
end
include_examples
'correct references'
do
include_examples
"correct references"
do
let
(
:referenced_issues
)
{
[]
}
let
(
:jira_referenced
)
{
true
}
end
end
context
'when no issues tracker is enabled for the actual project'
do
before
do
actual_project
.
issues_enabled
=
false
actual_project
.
save!
end
context
"when no issues tracker is enabled for the actual project"
do
let
(
:actual_project
)
{
create
(
:project
,
:public
,
:repository
,
:issues_disabled
)
}
include_examples
'correct references'
do
include_examples
"correct references"
do
let
(
:referenced_issues
)
{
[]
}
let
(
:jira_referenced
)
{
false
}
end
end
end
private
def
build_note
markdown
=
<<~
HEREDOC
Referencing internal issue
#{
issue_actual_project
.
to_reference
}
,
cross-project
#{
issue_other_project
.
to_reference
(
actual_project
)
}
external JIRA-5
and non existing #999
HEREDOC
page
.
within
(
"#diff-notes-app"
)
do
fill_in
(
"note_note"
,
with:
markdown
)
end
end
def
links_expectations
issues
.
each
do
|
issue
|
if
referenced_issues
.
include?
(
issue
)
expect
(
page
).
to
have_link
(
issue
.
to_reference
,
href:
issue_path
(
issue
))
else
expect
(
page
).
not_to
have_link
(
issue
.
to_reference
,
href:
issue_path
(
issue
))
end
end
if
jira_referenced
expect
(
page
).
to
have_link
(
"JIRA-5"
,
href:
"https://jira.example.com/browse/JIRA-5"
)
else
expect
(
page
).
not_to
have_link
(
"JIRA-5"
,
href:
"https://jira.example.com/browse/JIRA-5"
)
end
expect
(
page
).
not_to
have_link
(
"#999"
)
end
end
spec/models/repository_spec.rb
View file @
5d5457c2
...
...
@@ -1733,7 +1733,8 @@ describe Repository do
:gitlab_ci
,
:avatar
,
:issue_template
,
:merge_request_template
:merge_request_template
,
:xcode_config
])
repository
.
after_change_head
...
...
@@ -2058,6 +2059,36 @@ describe Repository do
end
end
describe
'#xcode_project?'
do
before
do
allow
(
repository
).
to
receive
(
:tree
).
with
(
:head
).
and_return
(
double
(
:tree
,
blobs:
[
blob
]))
end
context
'when the root contains a *.xcodeproj file'
do
let
(
:blob
)
{
double
(
:blob
,
path:
'Foo.xcodeproj'
)
}
it
'returns true'
do
expect
(
repository
.
xcode_project?
).
to
be_truthy
end
end
context
'when the root contains a *.xcworkspace file'
do
let
(
:blob
)
{
double
(
:blob
,
path:
'Foo.xcworkspace'
)
}
it
'returns true'
do
expect
(
repository
.
xcode_project?
).
to
be_truthy
end
end
context
'when the root contains no XCode config file'
do
let
(
:blob
)
{
double
(
:blob
,
path:
'subdir/Foo.xcworkspace'
)
}
it
'returns false'
do
expect
(
repository
.
xcode_project?
).
to
be_falsey
end
end
end
describe
"#keep_around"
do
it
"does not fail if we attempt to reference bad commit"
do
expect
(
repository
.
kept_around?
(
'abc1234'
)).
to
be_falsey
...
...
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