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
0
Merge Requests
0
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
Jérome Perrin
gitlab-ce
Commits
959e6d22
Commit
959e6d22
authored
Aug 30, 2017
by
Ashley Dumaine
Committed by
Sean McGivern
Sep 06, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add unit tests for new collapse_outdated_diff_comments toggle
parent
ef4b3a39
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
132 additions
and
0 deletions
+132
-0
spec/features/merge_requests/collapse_outdated_diff_comments.rb
...eatures/merge_requests/collapse_outdated_diff_comments.rb
+76
-0
spec/requests/api/projects_spec.rb
spec/requests/api/projects_spec.rb
+30
-0
spec/requests/api/v3/projects_spec.rb
spec/requests/api/v3/projects_spec.rb
+26
-0
No files found.
spec/features/merge_requests/collapse_outdated_diff_comments.rb
0 → 100644
View file @
959e6d22
require
'spec_helper'
feature
'Collapse outdated diff comments'
,
js:
true
do
let
(
:merge_request
)
{
create
(
:merge_request
,
importing:
true
)
}
let
(
:project
)
{
merge_request
.
source_project
}
let!
(
:outdated_discussion
)
{
create
(
:diff_note_on_merge_request
,
project:
project
,
noteable:
merge_request
,
position:
outdated_position
).
to_discussion
}
let!
(
:active_discussion
)
{
create
(
:diff_note_on_merge_request
,
noteable:
merge_request
,
project:
project
).
to_discussion
}
let
(
:outdated_position
)
do
Gitlab
::
Diff
::
Position
.
new
(
old_path:
"files/ruby/popen.rb"
,
new_path:
"files/ruby/popen.rb"
,
old_line:
nil
,
new_line:
9
,
diff_refs:
outdated_diff_refs
)
end
let
(
:outdated_diff_refs
)
{
project
.
commit
(
"874797c3a73b60d2187ed6e2fcabd289ff75171e"
).
diff_refs
}
before
do
sign_in
(
create
(
:admin
))
end
context
'when project.collapse_outdated_diff_comments == true'
do
before
do
project
.
update_column
(
:collapse_outdated_diff_comments
,
true
)
end
context
'with unresolved outdated discussions'
do
it
'does not show outdated discussion'
do
visit_merge_request
(
merge_request
)
within
(
".discussion[data-discussion-id='
#{
outdated_discussion
.
id
}
']"
)
do
expect
(
page
).
to
have_css
(
'.discussion-body .hide .js-toggle-content'
,
visible:
false
)
end
end
end
context
'with unresolved active discussions'
do
it
'shows active discussion'
do
visit_merge_request
(
merge_request
)
within
(
".discussion[data-discussion-id='
#{
active_discussion
.
id
}
']"
)
do
expect
(
page
).
to
have_css
(
'.discussion-body .hide .js-toggle-content'
,
visible:
true
)
end
end
end
end
context
'when project.collapse_outdated_diff_comments == false'
do
before
do
project
.
update_column
(
:collapse_outdated_diff_comments
,
false
)
end
context
'with unresolved outdated discussions'
do
it
'shows outdated discussion'
do
visit_merge_request
(
merge_request
)
within
(
".discussion[data-discussion-id='
#{
outdated_discussion
.
id
}
']"
)
do
expect
(
page
).
to
have_css
(
'.discussion-body .hide .js-toggle-content'
,
visible:
true
)
end
end
end
context
'with unresolved active discussions'
do
it
'shows active discussion'
do
visit_merge_request
(
merge_request
)
within
(
".discussion[data-discussion-id='
#{
active_discussion
.
id
}
']"
)
do
expect
(
page
).
to
have_css
(
'.discussion-body .hide .js-toggle-content'
,
visible:
true
)
end
end
end
end
def
visit_merge_request
(
merge_request
)
visit
project_merge_request_path
(
project
,
merge_request
)
end
end
spec/requests/api/projects_spec.rb
View file @
959e6d22
...
@@ -414,6 +414,7 @@ describe API::Projects do
...
@@ -414,6 +414,7 @@ describe API::Projects do
jobs_enabled:
false
,
jobs_enabled:
false
,
merge_requests_enabled:
false
,
merge_requests_enabled:
false
,
wiki_enabled:
false
,
wiki_enabled:
false
,
collapse_outdated_diff_comments:
false
,
only_allow_merge_if_pipeline_succeeds:
false
,
only_allow_merge_if_pipeline_succeeds:
false
,
request_access_enabled:
true
,
request_access_enabled:
true
,
only_allow_merge_if_all_discussions_are_resolved:
false
,
only_allow_merge_if_all_discussions_are_resolved:
false
,
...
@@ -477,6 +478,18 @@ describe API::Projects do
...
@@ -477,6 +478,18 @@ describe API::Projects do
expect
(
json_response
[
'avatar_url'
]).
to
eq
(
"http://localhost/uploads/-/system/project/avatar/
#{
project_id
}
/banana_sample.gif"
)
expect
(
json_response
[
'avatar_url'
]).
to
eq
(
"http://localhost/uploads/-/system/project/avatar/
#{
project_id
}
/banana_sample.gif"
)
end
end
it
'sets a project as allowing outdated diff comments to collapse regardless of discussion resolution'
do
project
=
attributes_for
(
:project
,
{
collapse_outdated_diff_comments:
false
})
post
api
(
'/projects'
,
user
),
project
expect
(
json_response
[
'collapse_outdated_diff_comments'
]).
to
be_falsey
end
it
'sets a project as allowing outdated diff comments to collapse if collapse_outdated_diff_comments'
do
project
=
attributes_for
(
:project
,
{
collapse_outdated_diff_comments:
true
})
post
api
(
'/projects'
,
user
),
project
expect
(
json_response
[
'collapse_outdated_diff_comments'
]).
to
be_truthy
end
it
'sets a project as allowing merge even if build fails'
do
it
'sets a project as allowing merge even if build fails'
do
project
=
attributes_for
(
:project
,
{
only_allow_merge_if_pipeline_succeeds:
false
})
project
=
attributes_for
(
:project
,
{
only_allow_merge_if_pipeline_succeeds:
false
})
post
api
(
'/projects'
,
user
),
project
post
api
(
'/projects'
,
user
),
project
...
@@ -642,6 +655,22 @@ describe API::Projects do
...
@@ -642,6 +655,22 @@ describe API::Projects do
expect
(
json_response
[
'visibility'
]).
to
eq
(
'private'
)
expect
(
json_response
[
'visibility'
]).
to
eq
(
'private'
)
end
end
it
'sets a project as allowing outdated diff comments to collapse regardless of discussion resolution'
do
project
=
attributes_for
(
:project
,
{
collapse_outdated_diff_comments:
false
})
post
api
(
"/projects/user/
#{
user
.
id
}
"
,
admin
),
project
expect
(
json_response
[
'collapse_outdated_diff_comments'
]).
to
be_falsey
end
it
'sets a project as allowing outdated diff comments to collapse only if collapse_outdated_diff_comments'
do
project
=
attributes_for
(
:project
,
{
collapse_outdated_diff_comments:
true
})
post
api
(
"/projects/user/
#{
user
.
id
}
"
,
admin
),
project
expect
(
json_response
[
'collapse_outdated_diff_comments'
]).
to
be_truthy
end
it
'sets a project as allowing merge even if build fails'
do
it
'sets a project as allowing merge even if build fails'
do
project
=
attributes_for
(
:project
,
{
only_allow_merge_if_pipeline_succeeds:
false
})
project
=
attributes_for
(
:project
,
{
only_allow_merge_if_pipeline_succeeds:
false
})
post
api
(
"/projects/user/
#{
user
.
id
}
"
,
admin
),
project
post
api
(
"/projects/user/
#{
user
.
id
}
"
,
admin
),
project
...
@@ -732,6 +761,7 @@ describe API::Projects do
...
@@ -732,6 +761,7 @@ describe API::Projects do
expect
(
json_response
[
'wiki_enabled'
]).
to
be_present
expect
(
json_response
[
'wiki_enabled'
]).
to
be_present
expect
(
json_response
[
'jobs_enabled'
]).
to
be_present
expect
(
json_response
[
'jobs_enabled'
]).
to
be_present
expect
(
json_response
[
'snippets_enabled'
]).
to
be_present
expect
(
json_response
[
'snippets_enabled'
]).
to
be_present
expect
(
json_response
[
'collapse_outdated_diff_comments'
]).
to
eq
(
project
.
collapse_outdated_diff_comments
)
expect
(
json_response
[
'container_registry_enabled'
]).
to
be_present
expect
(
json_response
[
'container_registry_enabled'
]).
to
be_present
expect
(
json_response
[
'created_at'
]).
to
be_present
expect
(
json_response
[
'created_at'
]).
to
be_present
expect
(
json_response
[
'last_activity_at'
]).
to
be_present
expect
(
json_response
[
'last_activity_at'
]).
to
be_present
...
...
spec/requests/api/v3/projects_spec.rb
View file @
959e6d22
...
@@ -394,6 +394,7 @@ describe API::V3::Projects do
...
@@ -394,6 +394,7 @@ describe API::V3::Projects do
issues_enabled:
false
,
issues_enabled:
false
,
merge_requests_enabled:
false
,
merge_requests_enabled:
false
,
wiki_enabled:
false
,
wiki_enabled:
false
,
collapse_outdated_diff_comments:
false
,
only_allow_merge_if_build_succeeds:
false
,
only_allow_merge_if_build_succeeds:
false
,
request_access_enabled:
true
,
request_access_enabled:
true
,
only_allow_merge_if_all_discussions_are_resolved:
false
only_allow_merge_if_all_discussions_are_resolved:
false
...
@@ -455,6 +456,18 @@ describe API::V3::Projects do
...
@@ -455,6 +456,18 @@ describe API::V3::Projects do
expect
(
json_response
[
'visibility_level'
]).
to
eq
(
Gitlab
::
VisibilityLevel
::
PRIVATE
)
expect
(
json_response
[
'visibility_level'
]).
to
eq
(
Gitlab
::
VisibilityLevel
::
PRIVATE
)
end
end
it
'sets a project as allowing outdated diff comments to collapse regardless of discussion resolution'
do
project
=
attributes_for
(
:project
,
{
collapse_outdated_diff_comments:
false
})
post
v3_api
(
'/projects'
,
user
),
project
expect
(
json_response
[
'collapse_outdated_diff_comments'
]).
to
be_falsey
end
it
'sets a project as allowing outdated diff comments to collapse if collapse_outdated_diff_comments'
do
project
=
attributes_for
(
:project
,
{
collapse_outdated_diff_comments:
true
})
post
v3_api
(
'/projects'
,
user
),
project
expect
(
json_response
[
'collapse_outdated_diff_comments'
]).
to
be_truthy
end
it
'sets a project as allowing merge even if build fails'
do
it
'sets a project as allowing merge even if build fails'
do
project
=
attributes_for
(
:project
,
{
only_allow_merge_if_build_succeeds:
false
})
project
=
attributes_for
(
:project
,
{
only_allow_merge_if_build_succeeds:
false
})
post
v3_api
(
'/projects'
,
user
),
project
post
v3_api
(
'/projects'
,
user
),
project
...
@@ -599,6 +612,18 @@ describe API::V3::Projects do
...
@@ -599,6 +612,18 @@ describe API::V3::Projects do
expect
(
json_response
[
'visibility_level'
]).
to
eq
(
Gitlab
::
VisibilityLevel
::
PRIVATE
)
expect
(
json_response
[
'visibility_level'
]).
to
eq
(
Gitlab
::
VisibilityLevel
::
PRIVATE
)
end
end
it
'sets a project as allowing outdated diff comments to collapse regardless of discussion resolution'
do
project
=
attributes_for
(
:project
,
{
collapse_outdated_diff_comments:
false
})
post
v3_api
(
"/projects/user/
#{
user
.
id
}
"
,
admin
),
project
expect
(
json_response
[
'collapse_outdated_diff_comments'
]).
to
be_falsey
end
it
'sets a project as allowing outdated diff comments to collapse only if collapse_outdated_diff_comments'
do
project
=
attributes_for
(
:project
,
{
collapse_outdated_diff_comments:
true
})
post
v3_api
(
"/projects/user/
#{
user
.
id
}
"
,
admin
),
project
expect
(
json_response
[
'collapse_outdated_diff_comments'
]).
to
be_truthy
end
it
'sets a project as allowing merge even if build fails'
do
it
'sets a project as allowing merge even if build fails'
do
project
=
attributes_for
(
:project
,
{
only_allow_merge_if_build_succeeds:
false
})
project
=
attributes_for
(
:project
,
{
only_allow_merge_if_build_succeeds:
false
})
post
v3_api
(
"/projects/user/
#{
user
.
id
}
"
,
admin
),
project
post
v3_api
(
"/projects/user/
#{
user
.
id
}
"
,
admin
),
project
...
@@ -687,6 +712,7 @@ describe API::V3::Projects do
...
@@ -687,6 +712,7 @@ describe API::V3::Projects do
expect
(
json_response
[
'wiki_enabled'
]).
to
be_present
expect
(
json_response
[
'wiki_enabled'
]).
to
be_present
expect
(
json_response
[
'builds_enabled'
]).
to
be_present
expect
(
json_response
[
'builds_enabled'
]).
to
be_present
expect
(
json_response
[
'snippets_enabled'
]).
to
be_present
expect
(
json_response
[
'snippets_enabled'
]).
to
be_present
expect
(
json_response
[
'collapse_outdated_diff_comments'
]).
to
eq
(
project
.
collapse_outdated_diff_comments
)
expect
(
json_response
[
'container_registry_enabled'
]).
to
be_present
expect
(
json_response
[
'container_registry_enabled'
]).
to
be_present
expect
(
json_response
[
'created_at'
]).
to
be_present
expect
(
json_response
[
'created_at'
]).
to
be_present
expect
(
json_response
[
'last_activity_at'
]).
to
be_present
expect
(
json_response
[
'last_activity_at'
]).
to
be_present
...
...
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