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
bc009479
Commit
bc009479
authored
Jul 16, 2019
by
Peter Leitzen
Committed by
Grzegorz Bizon
Jul 16, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleanup usages of `JSON.parse` in specs
Prefer `json_response` where applicable.
parent
29d605f0
Changes
50
Show whitespace changes
Inline
Side-by-side
Showing
50 changed files
with
87 additions
and
158 deletions
+87
-158
ee/spec/controllers/boards/issues_controller_spec.rb
ee/spec/controllers/boards/issues_controller_spec.rb
+2
-6
ee/spec/controllers/boards/lists_controller_spec.rb
ee/spec/controllers/boards/lists_controller_spec.rb
+1
-3
ee/spec/controllers/boards/milestones_controller_spec.rb
ee/spec/controllers/boards/milestones_controller_spec.rb
+2
-4
ee/spec/controllers/boards/users_controller_spec.rb
ee/spec/controllers/boards/users_controller_spec.rb
+2
-4
ee/spec/controllers/groups/boards_controller_spec.rb
ee/spec/controllers/groups/boards_controller_spec.rb
+1
-3
ee/spec/controllers/groups/epic_issues_controller_spec.rb
ee/spec/controllers/groups/epic_issues_controller_spec.rb
+1
-1
ee/spec/controllers/groups/epics/notes_controller_spec.rb
ee/spec/controllers/groups/epics/notes_controller_spec.rb
+1
-1
ee/spec/controllers/groups/epics_controller_spec.rb
ee/spec/controllers/groups/epics_controller_spec.rb
+2
-2
ee/spec/controllers/groups/issues_analytics_controller_spec.rb
...ec/controllers/groups/issues_analytics_controller_spec.rb
+2
-2
ee/spec/controllers/operations_controller_spec.rb
ee/spec/controllers/operations_controller_spec.rb
+0
-1
ee/spec/controllers/projects/boards_controller_spec.rb
ee/spec/controllers/projects/boards_controller_spec.rb
+1
-3
ee/spec/controllers/projects/managed_licenses_controller_spec.rb
.../controllers/projects/managed_licenses_controller_spec.rb
+1
-1
ee/spec/controllers/projects/merge_requests_controller_spec.rb
...ec/controllers/projects/merge_requests_controller_spec.rb
+0
-4
ee/spec/controllers/projects/service_desk_controller_spec.rb
ee/spec/controllers/projects/service_desk_controller_spec.rb
+4
-8
ee/spec/requests/api/epic_links_spec.rb
ee/spec/requests/api/epic_links_spec.rb
+1
-1
ee/spec/requests/api/epics_spec.rb
ee/spec/requests/api/epics_spec.rb
+2
-2
ee/spec/requests/api/project_approvals_spec.rb
ee/spec/requests/api/project_approvals_spec.rb
+1
-1
spec/controllers/admin/application_settings_controller_spec.rb
...controllers/admin/application_settings_controller_spec.rb
+1
-1
spec/controllers/application_controller_spec.rb
spec/controllers/application_controller_spec.rb
+0
-2
spec/controllers/boards/issues_controller_spec.rb
spec/controllers/boards/issues_controller_spec.rb
+2
-6
spec/controllers/boards/lists_controller_spec.rb
spec/controllers/boards/lists_controller_spec.rb
+1
-3
spec/controllers/groups/boards_controller_spec.rb
spec/controllers/groups/boards_controller_spec.rb
+1
-3
spec/controllers/groups/milestones_controller_spec.rb
spec/controllers/groups/milestones_controller_spec.rb
+1
-1
spec/controllers/health_check_controller_spec.rb
spec/controllers/health_check_controller_spec.rb
+0
-1
spec/controllers/health_controller_spec.rb
spec/controllers/health_controller_spec.rb
+0
-1
spec/controllers/metrics_controller_spec.rb
spec/controllers/metrics_controller_spec.rb
+0
-1
spec/controllers/projects/blob_controller_spec.rb
spec/controllers/projects/blob_controller_spec.rb
+2
-2
spec/controllers/projects/boards_controller_spec.rb
spec/controllers/projects/boards_controller_spec.rb
+1
-3
spec/controllers/projects/branches_controller_spec.rb
spec/controllers/projects/branches_controller_spec.rb
+3
-6
spec/controllers/projects/commit_controller_spec.rb
spec/controllers/projects/commit_controller_spec.rb
+2
-2
spec/controllers/projects/compare_controller_spec.rb
spec/controllers/projects/compare_controller_spec.rb
+3
-6
spec/controllers/projects/deploy_keys_controller_spec.rb
spec/controllers/projects/deploy_keys_controller_spec.rb
+4
-6
spec/controllers/projects/discussions_controller_spec.rb
spec/controllers/projects/discussions_controller_spec.rb
+2
-2
spec/controllers/projects/find_file_controller_spec.rb
spec/controllers/projects/find_file_controller_spec.rb
+2
-3
spec/controllers/projects/issues_controller_spec.rb
spec/controllers/projects/issues_controller_spec.rb
+7
-13
spec/controllers/projects/merge_requests/diffs_controller_spec.rb
...trollers/projects/merge_requests/diffs_controller_spec.rb
+1
-1
spec/controllers/projects/merge_requests_controller_spec.rb
spec/controllers/projects/merge_requests_controller_spec.rb
+1
-3
spec/controllers/projects/notes_controller_spec.rb
spec/controllers/projects/notes_controller_spec.rb
+2
-2
spec/controllers/projects/templates_controller_spec.rb
spec/controllers/projects/templates_controller_spec.rb
+4
-5
spec/controllers/projects/wikis_controller_spec.rb
spec/controllers/projects/wikis_controller_spec.rb
+1
-1
spec/controllers/projects_controller_spec.rb
spec/controllers/projects_controller_spec.rb
+11
-18
spec/controllers/snippets/notes_controller_spec.rb
spec/controllers/snippets/notes_controller_spec.rb
+3
-3
spec/controllers/snippets_controller_spec.rb
spec/controllers/snippets_controller_spec.rb
+1
-1
spec/controllers/users_controller_spec.rb
spec/controllers/users_controller_spec.rb
+1
-1
spec/requests/api/search_spec.rb
spec/requests/api/search_spec.rb
+2
-2
spec/requests/lfs_http_spec.rb
spec/requests/lfs_http_spec.rb
+0
-4
spec/requests/lfs_locks_api_spec.rb
spec/requests/lfs_locks_api_spec.rb
+0
-4
spec/support/json_response.rb
spec/support/json_response.rb
+1
-1
spec/support/shared_examples/controllers/issuable_notes_filter_shared_examples.rb
...ples/controllers/issuable_notes_filter_shared_examples.rb
+2
-2
spec/support/shared_examples/update_invalid_issuable.rb
spec/support/shared_examples/update_invalid_issuable.rb
+1
-1
No files found.
ee/spec/controllers/boards/issues_controller_spec.rb
View file @
bc009479
...
@@ -43,10 +43,8 @@ describe Boards::IssuesController do
...
@@ -43,10 +43,8 @@ describe Boards::IssuesController do
list_issues
user:
user
,
board:
board
,
list:
list2
list_issues
user:
user
,
board:
board
,
list:
list2
parsed_response
=
JSON
.
parse
(
response
.
body
)
expect
(
response
).
to
match_response_schema
(
'issues'
)
expect
(
response
).
to
match_response_schema
(
'issues'
)
expect
(
parsed
_response
[
'issues'
].
length
).
to
eq
2
expect
(
json
_response
[
'issues'
].
length
).
to
eq
2
expect
(
development
.
issues
.
map
(
&
:relative_position
)).
not_to
include
(
nil
)
expect
(
development
.
issues
.
map
(
&
:relative_position
)).
not_to
include
(
nil
)
end
end
end
end
...
@@ -70,10 +68,8 @@ describe Boards::IssuesController do
...
@@ -70,10 +68,8 @@ describe Boards::IssuesController do
list_issues
user:
user
,
board:
board
list_issues
user:
user
,
board:
board
parsed_response
=
JSON
.
parse
(
response
.
body
)
expect
(
response
).
to
match_response_schema
(
'issues'
)
expect
(
response
).
to
match_response_schema
(
'issues'
)
expect
(
parsed
_response
[
'issues'
].
length
).
to
eq
2
expect
(
json
_response
[
'issues'
].
length
).
to
eq
2
end
end
end
end
...
...
ee/spec/controllers/boards/lists_controller_spec.rb
View file @
bc009479
...
@@ -24,10 +24,8 @@ describe Boards::ListsController do
...
@@ -24,10 +24,8 @@ describe Boards::ListsController do
read_board_list
user:
user
,
board:
board
read_board_list
user:
user
,
board:
board
parsed_response
=
JSON
.
parse
(
response
.
body
)
expect
(
response
).
to
match_response_schema
(
'lists'
,
dir:
'ee'
)
expect
(
response
).
to
match_response_schema
(
'lists'
,
dir:
'ee'
)
expect
(
parsed
_response
.
length
).
to
eq
3
expect
(
json
_response
.
length
).
to
eq
3
end
end
context
'with unauthorized user'
do
context
'with unauthorized user'
do
...
...
ee/spec/controllers/boards/milestones_controller_spec.rb
View file @
bc009479
...
@@ -20,11 +20,9 @@ describe Boards::MilestonesController do
...
@@ -20,11 +20,9 @@ describe Boards::MilestonesController do
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
parsed_response
=
JSON
.
parse
(
response
.
body
)
expect
(
response
.
content_type
).
to
eq
(
'application/json'
)
expect
(
response
.
content_type
).
to
eq
(
'application/json'
)
expect
(
parsed
_response
).
to
all
(
match_schema
(
'entities/milestone'
,
dir:
'ee'
))
expect
(
json
_response
).
to
all
(
match_schema
(
'entities/milestone'
,
dir:
'ee'
))
expect
(
parsed
_response
.
size
).
to
eq
(
1
)
expect
(
json
_response
.
size
).
to
eq
(
1
)
end
end
end
end
...
...
ee/spec/controllers/boards/users_controller_spec.rb
View file @
bc009479
...
@@ -22,12 +22,10 @@ describe Boards::UsersController do
...
@@ -22,12 +22,10 @@ describe Boards::UsersController do
},
},
format: :json
format: :json
parsed_response
=
JSON
.
parse
(
response
.
body
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
.
content_type
).
to
eq
'application/json'
expect
(
response
.
content_type
).
to
eq
'application/json'
expect
(
parsed
_response
).
to
all
(
match_schema
(
'entities/user'
))
expect
(
json
_response
).
to
all
(
match_schema
(
'entities/user'
))
expect
(
parsed
_response
.
length
).
to
eq
2
expect
(
json
_response
.
length
).
to
eq
2
end
end
end
end
...
...
ee/spec/controllers/groups/boards_controller_spec.rb
View file @
bc009479
...
@@ -23,10 +23,8 @@ describe Groups::BoardsController do
...
@@ -23,10 +23,8 @@ describe Groups::BoardsController do
list_boards
format: :json
list_boards
format: :json
parsed_response
=
JSON
.
parse
(
response
.
body
)
expect
(
response
).
to
match_response_schema
(
'boards'
)
expect
(
response
).
to
match_response_schema
(
'boards'
)
expect
(
parsed
_response
.
length
).
to
eq
2
expect
(
json
_response
.
length
).
to
eq
2
end
end
context
'with unauthorized user'
do
context
'with unauthorized user'
do
...
...
ee/spec/controllers/groups/epic_issues_controller_spec.rb
View file @
bc009479
...
@@ -47,7 +47,7 @@ describe Groups::EpicIssuesController do
...
@@ -47,7 +47,7 @@ describe Groups::EpicIssuesController do
end
end
it
'returns the correct json'
do
it
'returns the correct json'
do
expect
(
JSON
.
parse
(
response
.
body
)
).
to
match_schema
(
'related_issues'
,
dir:
'ee'
)
expect
(
json_response
).
to
match_schema
(
'related_issues'
,
dir:
'ee'
)
end
end
end
end
...
...
ee/spec/controllers/groups/epics/notes_controller_spec.rb
View file @
bc009479
...
@@ -5,7 +5,7 @@ describe Groups::Epics::NotesController do
...
@@ -5,7 +5,7 @@ describe Groups::Epics::NotesController do
let
(
:group
)
{
create
(
:group
)
}
let
(
:group
)
{
create
(
:group
)
}
let
(
:epic
)
{
create
(
:epic
,
group:
group
)
}
let
(
:epic
)
{
create
(
:epic
,
group:
group
)
}
let
(
:note
)
{
create
(
:note
,
noteable:
epic
)
}
let
(
:note
)
{
create
(
:note
,
noteable:
epic
)
}
let
(
:parsed_response
)
{
JSON
.
parse
(
response
.
body
)
.
with_indifferent_access
}
let
(
:parsed_response
)
{
json_response
.
with_indifferent_access
}
before
do
before
do
stub_licensed_features
(
epics:
true
)
stub_licensed_features
(
epics:
true
)
...
...
ee/spec/controllers/groups/epics_controller_spec.rb
View file @
bc009479
...
@@ -375,7 +375,7 @@ describe Groups::EpicsController do
...
@@ -375,7 +375,7 @@ describe Groups::EpicsController do
subject
subject
expect
(
response
.
content_type
).
to
eq
'application/json'
expect
(
response
.
content_type
).
to
eq
'application/json'
expect
(
JSON
.
parse
(
response
.
body
)
).
to
include
(
'title_text'
,
'title'
,
'description'
,
'description_text'
)
expect
(
json_response
).
to
include
(
'title_text'
,
'title'
,
'description'
,
'description_text'
)
end
end
context
'with unauthorized user'
do
context
'with unauthorized user'
do
...
@@ -421,7 +421,7 @@ describe Groups::EpicsController do
...
@@ -421,7 +421,7 @@ describe Groups::EpicsController do
it
'returns the correct json'
do
it
'returns the correct json'
do
subject
subject
expect
(
JSON
.
parse
(
response
.
body
)
).
to
eq
({
'web_url'
=>
group_epic_path
(
group
,
Epic
.
last
)
})
expect
(
json_response
).
to
eq
({
'web_url'
=>
group_epic_path
(
group
,
Epic
.
last
)
})
end
end
it_behaves_like
'disabled when using an external authorization service'
it_behaves_like
'disabled when using an external authorization service'
...
...
ee/spec/controllers/groups/issues_analytics_controller_spec.rb
View file @
bc009479
...
@@ -58,7 +58,7 @@ describe Groups::IssuesAnalyticsController do
...
@@ -58,7 +58,7 @@ describe Groups::IssuesAnalyticsController do
get
:show
,
params:
{
group_id:
group
.
to_param
},
format: :json
get
:show
,
params:
{
group_id:
group
.
to_param
},
format: :json
expect
(
JSON
.
parse
(
response
.
body
)
).
to
include
(
expected_result
)
expect
(
json_response
).
to
include
(
expected_result
)
end
end
context
'when user cannot view issues'
do
context
'when user cannot view issues'
do
...
@@ -74,7 +74,7 @@ describe Groups::IssuesAnalyticsController do
...
@@ -74,7 +74,7 @@ describe Groups::IssuesAnalyticsController do
get
:show
,
params:
{
group_id:
group
.
to_param
},
format: :json
get
:show
,
params:
{
group_id:
group
.
to_param
},
format: :json
expect
(
JSON
.
parse
(
response
.
body
)
).
to
include
(
expected_result
)
expect
(
json_response
).
to
include
(
expected_result
)
end
end
end
end
end
end
...
...
ee/spec/controllers/operations_controller_spec.rb
View file @
bc009479
...
@@ -6,7 +6,6 @@ describe OperationsController do
...
@@ -6,7 +6,6 @@ describe OperationsController do
include
Rails
.
application
.
routes
.
url_helpers
include
Rails
.
application
.
routes
.
url_helpers
let
(
:user
)
{
create
(
:user
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:json_response
)
{
JSON
.
parse
(
response
.
body
)
}
shared_examples
'unlicensed'
do
|
http_method
,
action
|
shared_examples
'unlicensed'
do
|
http_method
,
action
|
before
do
before
do
...
...
ee/spec/controllers/projects/boards_controller_spec.rb
View file @
bc009479
...
@@ -18,10 +18,8 @@ describe Projects::BoardsController do
...
@@ -18,10 +18,8 @@ describe Projects::BoardsController do
list_boards
list_boards
parsed_response
=
JSON
.
parse
(
response
.
body
)
expect
(
response
).
to
match_response_schema
(
'boards'
)
expect
(
response
).
to
match_response_schema
(
'boards'
)
expect
(
parsed
_response
.
length
).
to
eq
2
expect
(
json
_response
.
length
).
to
eq
2
end
end
it_behaves_like
'redirects to last visited board'
it_behaves_like
'redirects to last visited board'
...
...
ee/spec/controllers/projects/managed_licenses_controller_spec.rb
View file @
bc009479
...
@@ -396,7 +396,7 @@ describe Projects::ManagedLicensesController do
...
@@ -396,7 +396,7 @@ describe Projects::ManagedLicensesController do
subject
subject
expect
(
response
).
to
match_response_schema
(
'software_license_policy'
,
dir:
'ee'
)
expect
(
response
).
to
match_response_schema
(
'software_license_policy'
,
dir:
'ee'
)
expect
(
JSON
.
parse
(
response
.
body
)
).
to
eq
(
modified_software_license_policy_attributes
.
with_indifferent_access
)
expect
(
json_response
).
to
eq
(
modified_software_license_policy_attributes
.
with_indifferent_access
)
end
end
end
end
end
end
...
...
ee/spec/controllers/projects/merge_requests_controller_spec.rb
View file @
bc009479
require
'spec_helper'
require
'spec_helper'
shared_examples
'approvals'
do
shared_examples
'approvals'
do
def
json_response
JSON
.
parse
(
response
.
body
)
end
let!
(
:approver
)
{
create
(
:user
)
}
let!
(
:approver
)
{
create
(
:user
)
}
let!
(
:approval_rule
)
{
create
(
:approval_project_rule
,
project:
project
,
users:
[
approver
,
user
],
approvals_required:
2
)
}
let!
(
:approval_rule
)
{
create
(
:approval_project_rule
,
project:
project
,
users:
[
approver
,
user
],
approvals_required:
2
)
}
...
...
ee/spec/controllers/projects/service_desk_controller_spec.rb
View file @
bc009479
...
@@ -18,10 +18,8 @@ describe Projects::ServiceDeskController do
...
@@ -18,10 +18,8 @@ describe Projects::ServiceDeskController do
it
'returns service_desk JSON data'
do
it
'returns service_desk JSON data'
do
get
:show
,
params:
{
namespace_id:
project
.
namespace
.
to_param
,
project_id:
project
},
format: :json
get
:show
,
params:
{
namespace_id:
project
.
namespace
.
to_param
,
project_id:
project
},
format: :json
body
=
JSON
.
parse
(
response
.
body
)
expect
(
json_response
[
"service_desk_address"
]).
to
match
(
/\A[^@]+@[^@]+\z/
)
expect
(
json_response
[
"service_desk_enabled"
]).
to
be_truthy
expect
(
body
[
"service_desk_address"
]).
to
match
(
/\A[^@]+@[^@]+\z/
)
expect
(
body
[
"service_desk_enabled"
]).
to
be_truthy
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
response
.
status
).
to
eq
(
200
)
end
end
...
@@ -45,10 +43,8 @@ describe Projects::ServiceDeskController do
...
@@ -45,10 +43,8 @@ describe Projects::ServiceDeskController do
put
:update
,
params:
{
namespace_id:
project
.
namespace
.
to_param
,
project_id:
project
,
service_desk_enabled:
true
},
format: :json
put
:update
,
params:
{
namespace_id:
project
.
namespace
.
to_param
,
project_id:
project
,
service_desk_enabled:
true
},
format: :json
body
=
JSON
.
parse
(
response
.
body
)
expect
(
json_response
[
"service_desk_address"
]).
to
be_present
expect
(
json_response
[
"service_desk_enabled"
]).
to
be_truthy
expect
(
body
[
"service_desk_address"
]).
to
be_present
expect
(
body
[
"service_desk_enabled"
]).
to
be_truthy
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
response
.
status
).
to
eq
(
200
)
end
end
...
...
ee/spec/requests/api/epic_links_spec.rb
View file @
bc009479
...
@@ -53,7 +53,7 @@ describe API::EpicLinks do
...
@@ -53,7 +53,7 @@ describe API::EpicLinks do
it
'returns 200 status'
do
it
'returns 200 status'
do
subject
subject
epics
=
JSON
.
parse
(
response
.
body
)
epics
=
json_response
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
match_response_schema
(
'public_api/v4/epics'
,
dir:
'ee'
)
expect
(
response
).
to
match_response_schema
(
'public_api/v4/epics'
,
dir:
'ee'
)
...
...
ee/spec/requests/api/epics_spec.rb
View file @
bc009479
...
@@ -44,7 +44,7 @@ describe API::Epics do
...
@@ -44,7 +44,7 @@ describe API::Epics do
it
'returns epic with extra date fields'
do
it
'returns epic with extra date fields'
do
get
api
(
url
,
user
),
params:
params
get
api
(
url
,
user
),
params:
params
expect
(
Array
.
wrap
(
JSON
.
parse
(
response
.
body
)
)).
to
all
(
exclude
(
*
extra_date_fields
))
expect
(
Array
.
wrap
(
json_response
)).
to
all
(
exclude
(
*
extra_date_fields
))
end
end
end
end
...
@@ -56,7 +56,7 @@ describe API::Epics do
...
@@ -56,7 +56,7 @@ describe API::Epics do
it
'returns epic with extra date fields'
do
it
'returns epic with extra date fields'
do
get
api
(
url
,
user
),
params:
params
get
api
(
url
,
user
),
params:
params
expect
(
Array
.
wrap
(
JSON
.
parse
(
response
.
body
)
)).
to
all
(
include
(
*
extra_date_fields
))
expect
(
Array
.
wrap
(
json_response
)).
to
all
(
include
(
*
extra_date_fields
))
end
end
end
end
end
end
...
...
ee/spec/requests/api/project_approvals_spec.rb
View file @
bc009479
...
@@ -77,7 +77,7 @@ describe API::ProjectApprovals do
...
@@ -77,7 +77,7 @@ describe API::ProjectApprovals do
post
api
(
url
,
current_user
),
params:
settings
post
api
(
url
,
current_user
),
params:
settings
expect
(
JSON
.
parse
(
response
.
body
)
.
symbolize_keys
).
to
include
(
settings
)
expect
(
json_response
.
symbolize_keys
).
to
include
(
settings
)
end
end
it
'only shows approver groups that are visible to the current user'
do
it
'only shows approver groups that are visible to the current user'
do
...
...
spec/controllers/admin/application_settings_controller_spec.rb
View file @
bc009479
...
@@ -41,7 +41,7 @@ describe Admin::ApplicationSettingsController do
...
@@ -41,7 +41,7 @@ describe Admin::ApplicationSettingsController do
it
'returns JSON data'
do
it
'returns JSON data'
do
get
:usage_data
,
format: :json
get
:usage_data
,
format: :json
body
=
JSON
.
parse
(
response
.
body
)
body
=
json_response
expect
(
body
[
"version"
]).
to
eq
(
Gitlab
::
VERSION
)
expect
(
body
[
"version"
]).
to
eq
(
Gitlab
::
VERSION
)
expect
(
body
).
to
include
(
'counts'
)
expect
(
body
).
to
include
(
'counts'
)
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
response
.
status
).
to
eq
(
200
)
...
...
spec/controllers/application_controller_spec.rb
View file @
bc009479
...
@@ -63,8 +63,6 @@ describe ApplicationController do
...
@@ -63,8 +63,6 @@ describe ApplicationController do
sign_in
user
sign_in
user
end
end
let
(
:json_response
)
{
JSON
.
parse
(
response
.
body
)
}
controller
(
described_class
)
do
controller
(
described_class
)
do
def
index
def
index
render
json:
Gon
.
all_variables
render
json:
Gon
.
all_variables
...
...
spec/controllers/boards/issues_controller_spec.rb
View file @
bc009479
...
@@ -52,10 +52,8 @@ describe Boards::IssuesController do
...
@@ -52,10 +52,8 @@ describe Boards::IssuesController do
list_issues
user:
user
,
board:
board
,
list:
list2
list_issues
user:
user
,
board:
board
,
list:
list2
parsed_response
=
JSON
.
parse
(
response
.
body
)
expect
(
response
).
to
match_response_schema
(
'entities/issue_boards'
)
expect
(
response
).
to
match_response_schema
(
'entities/issue_boards'
)
expect
(
parsed
_response
[
'issues'
].
length
).
to
eq
2
expect
(
json
_response
[
'issues'
].
length
).
to
eq
2
expect
(
development
.
issues
.
map
(
&
:relative_position
)).
not_to
include
(
nil
)
expect
(
development
.
issues
.
map
(
&
:relative_position
)).
not_to
include
(
nil
)
end
end
...
@@ -123,10 +121,8 @@ describe Boards::IssuesController do
...
@@ -123,10 +121,8 @@ describe Boards::IssuesController do
list_issues
user:
user
,
board:
board
list_issues
user:
user
,
board:
board
parsed_response
=
JSON
.
parse
(
response
.
body
)
expect
(
response
).
to
match_response_schema
(
'entities/issue_boards'
)
expect
(
response
).
to
match_response_schema
(
'entities/issue_boards'
)
expect
(
parsed
_response
[
'issues'
].
length
).
to
eq
2
expect
(
json
_response
[
'issues'
].
length
).
to
eq
2
end
end
end
end
...
...
spec/controllers/boards/lists_controller_spec.rb
View file @
bc009479
...
@@ -26,10 +26,8 @@ describe Boards::ListsController do
...
@@ -26,10 +26,8 @@ describe Boards::ListsController do
read_board_list
user:
user
,
board:
board
read_board_list
user:
user
,
board:
board
parsed_response
=
JSON
.
parse
(
response
.
body
)
expect
(
response
).
to
match_response_schema
(
'lists'
)
expect
(
response
).
to
match_response_schema
(
'lists'
)
expect
(
parsed
_response
.
length
).
to
eq
3
expect
(
json
_response
.
length
).
to
eq
3
end
end
context
'with unauthorized user'
do
context
'with unauthorized user'
do
...
...
spec/controllers/groups/boards_controller_spec.rb
View file @
bc009479
...
@@ -63,10 +63,8 @@ describe Groups::BoardsController do
...
@@ -63,10 +63,8 @@ describe Groups::BoardsController do
list_boards
format: :json
list_boards
format: :json
parsed_response
=
JSON
.
parse
(
response
.
body
)
expect
(
response
).
to
match_response_schema
(
'boards'
)
expect
(
response
).
to
match_response_schema
(
'boards'
)
expect
(
parsed
_response
.
length
).
to
eq
1
expect
(
json
_response
.
length
).
to
eq
1
end
end
context
'with unauthorized user'
do
context
'with unauthorized user'
do
...
...
spec/controllers/groups/milestones_controller_spec.rb
View file @
bc009479
...
@@ -73,7 +73,7 @@ describe Groups::MilestonesController do
...
@@ -73,7 +73,7 @@ describe Groups::MilestonesController do
it
'lists legacy group milestones and group milestones'
do
it
'lists legacy group milestones and group milestones'
do
get
:index
,
params:
{
group_id:
group
.
to_param
},
format: :json
get
:index
,
params:
{
group_id:
group
.
to_param
},
format: :json
milestones
=
JSON
.
parse
(
response
.
body
)
milestones
=
json_response
expect
(
milestones
.
count
).
to
eq
(
2
)
expect
(
milestones
.
count
).
to
eq
(
2
)
expect
(
milestones
.
first
[
"title"
]).
to
eq
(
"group milestone"
)
expect
(
milestones
.
first
[
"title"
]).
to
eq
(
"group milestone"
)
...
...
spec/controllers/health_check_controller_spec.rb
View file @
bc009479
...
@@ -5,7 +5,6 @@ require 'spec_helper'
...
@@ -5,7 +5,6 @@ require 'spec_helper'
describe
HealthCheckController
do
describe
HealthCheckController
do
include
StubENV
include
StubENV
let
(
:json_response
)
{
JSON
.
parse
(
response
.
body
)
}
let
(
:xml_response
)
{
Hash
.
from_xml
(
response
.
body
)[
'hash'
]
}
let
(
:xml_response
)
{
Hash
.
from_xml
(
response
.
body
)[
'hash'
]
}
let
(
:token
)
{
Gitlab
::
CurrentSettings
.
health_check_access_token
}
let
(
:token
)
{
Gitlab
::
CurrentSettings
.
health_check_access_token
}
let
(
:whitelisted_ip
)
{
'127.0.0.1'
}
let
(
:whitelisted_ip
)
{
'127.0.0.1'
}
...
...
spec/controllers/health_controller_spec.rb
View file @
bc009479
...
@@ -5,7 +5,6 @@ require 'spec_helper'
...
@@ -5,7 +5,6 @@ require 'spec_helper'
describe
HealthController
do
describe
HealthController
do
include
StubENV
include
StubENV
let
(
:json_response
)
{
JSON
.
parse
(
response
.
body
)
}
let
(
:token
)
{
Gitlab
::
CurrentSettings
.
health_check_access_token
}
let
(
:token
)
{
Gitlab
::
CurrentSettings
.
health_check_access_token
}
let
(
:whitelisted_ip
)
{
'127.0.0.1'
}
let
(
:whitelisted_ip
)
{
'127.0.0.1'
}
let
(
:not_whitelisted_ip
)
{
'127.0.0.2'
}
let
(
:not_whitelisted_ip
)
{
'127.0.0.2'
}
...
...
spec/controllers/metrics_controller_spec.rb
View file @
bc009479
...
@@ -5,7 +5,6 @@ require 'spec_helper'
...
@@ -5,7 +5,6 @@ require 'spec_helper'
describe
MetricsController
do
describe
MetricsController
do
include
StubENV
include
StubENV
let
(
:json_response
)
{
JSON
.
parse
(
response
.
body
)
}
let
(
:metrics_multiproc_dir
)
{
Dir
.
mktmpdir
}
let
(
:metrics_multiproc_dir
)
{
Dir
.
mktmpdir
}
let
(
:whitelisted_ip
)
{
'127.0.0.1'
}
let
(
:whitelisted_ip
)
{
'127.0.0.1'
}
let
(
:whitelisted_ip_range
)
{
'10.0.0.0/24'
}
let
(
:whitelisted_ip_range
)
{
'10.0.0.0/24'
}
...
...
spec/controllers/projects/blob_controller_spec.rb
View file @
bc009479
...
@@ -160,7 +160,7 @@ describe Projects::BlobController do
...
@@ -160,7 +160,7 @@ describe Projects::BlobController do
it
'renders diff context lines Gitlab::Diff::Line array'
do
it
'renders diff context lines Gitlab::Diff::Line array'
do
do_get
(
since:
1
,
to:
2
,
offset:
0
,
from_merge_request:
true
)
do_get
(
since:
1
,
to:
2
,
offset:
0
,
from_merge_request:
true
)
lines
=
JSON
.
parse
(
response
.
body
)
lines
=
json_response
expect
(
lines
.
size
).
to
eq
(
diff_lines
.
size
)
expect
(
lines
.
size
).
to
eq
(
diff_lines
.
size
)
lines
.
each
do
|
line
|
lines
.
each
do
|
line
|
...
@@ -173,7 +173,7 @@ describe Projects::BlobController do
...
@@ -173,7 +173,7 @@ describe Projects::BlobController do
it
'handles full being true'
do
it
'handles full being true'
do
do_get
(
full:
true
,
from_merge_request:
true
)
do_get
(
full:
true
,
from_merge_request:
true
)
lines
=
JSON
.
parse
(
response
.
body
)
lines
=
json_response
expect
(
lines
.
size
).
to
eq
(
diff_lines
.
size
)
expect
(
lines
.
size
).
to
eq
(
diff_lines
.
size
)
end
end
...
...
spec/controllers/projects/boards_controller_spec.rb
View file @
bc009479
...
@@ -69,10 +69,8 @@ describe Projects::BoardsController do
...
@@ -69,10 +69,8 @@ describe Projects::BoardsController do
list_boards
format: :json
list_boards
format: :json
parsed_response
=
JSON
.
parse
(
response
.
body
)
expect
(
response
).
to
match_response_schema
(
'boards'
)
expect
(
response
).
to
match_response_schema
(
'boards'
)
expect
(
parsed
_response
.
length
).
to
eq
2
expect
(
json
_response
.
length
).
to
eq
2
end
end
context
'with unauthorized user'
do
context
'with unauthorized user'
do
...
...
spec/controllers/projects/branches_controller_spec.rb
View file @
bc009479
...
@@ -495,10 +495,8 @@ describe Projects::BranchesController do
...
@@ -495,10 +495,8 @@ describe Projects::BranchesController do
search:
'master'
search:
'master'
}
}
parsed_response
=
JSON
.
parse
(
response
.
body
)
expect
(
json_response
.
length
).
to
eq
1
expect
(
json_response
.
first
).
to
eq
'master'
expect
(
parsed_response
.
length
).
to
eq
1
expect
(
parsed_response
.
first
).
to
eq
'master'
end
end
end
end
...
@@ -591,8 +589,7 @@ describe Projects::BranchesController do
...
@@ -591,8 +589,7 @@ describe Projects::BranchesController do
end
end
it
'returns the commit counts behind and ahead of default branch'
do
it
'returns the commit counts behind and ahead of default branch'
do
parsed_response
=
JSON
.
parse
(
response
.
body
)
expect
(
json_response
).
to
eq
(
expect
(
parsed_response
).
to
eq
(
"fix"
=>
{
"behind"
=>
29
,
"ahead"
=>
2
},
"fix"
=>
{
"behind"
=>
29
,
"ahead"
=>
2
},
"branch-merged"
=>
{
"behind"
=>
1
,
"ahead"
=>
0
},
"branch-merged"
=>
{
"behind"
=>
1
,
"ahead"
=>
0
},
"add-pdf-file"
=>
{
"behind"
=>
0
,
"ahead"
=>
3
}
"add-pdf-file"
=>
{
"behind"
=>
0
,
"ahead"
=>
3
}
...
...
spec/controllers/projects/commit_controller_spec.rb
View file @
bc009479
...
@@ -378,8 +378,8 @@ describe Projects::CommitController do
...
@@ -378,8 +378,8 @@ describe Projects::CommitController do
get_pipelines
(
id:
commit
.
id
,
format: :json
)
get_pipelines
(
id:
commit
.
id
,
format: :json
)
expect
(
response
).
to
be_ok
expect
(
response
).
to
be_ok
expect
(
JSON
.
parse
(
response
.
body
)
[
'pipelines'
]).
not_to
be_empty
expect
(
json_response
[
'pipelines'
]).
not_to
be_empty
expect
(
JSON
.
parse
(
response
.
body
)
[
'count'
][
'all'
]).
to
eq
1
expect
(
json_response
[
'count'
][
'all'
]).
to
eq
1
expect
(
response
).
to
include_pagination_headers
expect
(
response
).
to
include_pagination_headers
end
end
end
end
...
...
spec/controllers/projects/compare_controller_spec.rb
View file @
bc009479
...
@@ -302,8 +302,7 @@ describe Projects::CompareController do
...
@@ -302,8 +302,7 @@ describe Projects::CompareController do
signatures_request
signatures_request
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
parsed_body
=
JSON
.
parse
(
response
.
body
)
signatures
=
json_response
[
'signatures'
]
signatures
=
parsed_body
[
'signatures'
]
expect
(
signatures
.
size
).
to
eq
(
1
)
expect
(
signatures
.
size
).
to
eq
(
1
)
expect
(
signatures
.
first
[
'commit_sha'
]).
to
eq
(
signature_commit
.
sha
)
expect
(
signatures
.
first
[
'commit_sha'
]).
to
eq
(
signature_commit
.
sha
)
...
@@ -332,8 +331,7 @@ describe Projects::CompareController do
...
@@ -332,8 +331,7 @@ describe Projects::CompareController do
signatures_request
signatures_request
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
parsed_body
=
JSON
.
parse
(
response
.
body
)
expect
(
json_response
[
'signatures'
]).
to
be_empty
expect
(
parsed_body
[
'signatures'
]).
to
be_empty
end
end
end
end
...
@@ -345,8 +343,7 @@ describe Projects::CompareController do
...
@@ -345,8 +343,7 @@ describe Projects::CompareController do
signatures_request
signatures_request
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
parsed_body
=
JSON
.
parse
(
response
.
body
)
expect
(
json_response
[
'signatures'
]).
to
be_empty
expect
(
parsed_body
[
'signatures'
]).
to
be_empty
end
end
end
end
end
end
...
...
spec/controllers/projects/deploy_keys_controller_spec.rb
View file @
bc009479
...
@@ -52,12 +52,10 @@ describe Projects::DeployKeysController do
...
@@ -52,12 +52,10 @@ describe Projects::DeployKeysController do
it
'returns json in a correct format'
do
it
'returns json in a correct format'
do
get
:index
,
params:
params
.
merge
(
format: :json
)
get
:index
,
params:
params
.
merge
(
format: :json
)
json
=
JSON
.
parse
(
response
.
body
)
expect
(
json_response
.
keys
).
to
match_array
(
%w(enabled_keys available_project_keys public_keys)
)
expect
(
json_response
[
'enabled_keys'
].
count
).
to
eq
(
1
)
expect
(
json
.
keys
).
to
match_array
(
%w(enabled_keys available_project_keys public_keys)
)
expect
(
json_response
[
'available_project_keys'
].
count
).
to
eq
(
1
)
expect
(
json
[
'enabled_keys'
].
count
).
to
eq
(
1
)
expect
(
json_response
[
'public_keys'
].
count
).
to
eq
(
1
)
expect
(
json
[
'available_project_keys'
].
count
).
to
eq
(
1
)
expect
(
json
[
'public_keys'
].
count
).
to
eq
(
1
)
end
end
end
end
end
end
...
...
spec/controllers/projects/discussions_controller_spec.rb
View file @
bc009479
...
@@ -112,7 +112,7 @@ describe Projects::DiscussionsController do
...
@@ -112,7 +112,7 @@ describe Projects::DiscussionsController do
it
"returns the name of the resolving user"
do
it
"returns the name of the resolving user"
do
post
:resolve
,
params:
request_params
post
:resolve
,
params:
request_params
expect
(
JSON
.
parse
(
response
.
body
)
[
'resolved_by'
][
'name'
]).
to
eq
(
user
.
name
)
expect
(
json_response
[
'resolved_by'
][
'name'
]).
to
eq
(
user
.
name
)
end
end
it
"returns status 200"
do
it
"returns status 200"
do
...
@@ -135,7 +135,7 @@ describe Projects::DiscussionsController do
...
@@ -135,7 +135,7 @@ describe Projects::DiscussionsController do
it
"returns truncated diff lines"
do
it
"returns truncated diff lines"
do
post
:resolve
,
params:
request_params
post
:resolve
,
params:
request_params
expect
(
JSON
.
parse
(
response
.
body
)
[
'truncated_diff_lines'
]).
to
be_present
expect
(
json_response
[
'truncated_diff_lines'
]).
to
be_present
end
end
end
end
end
end
...
...
spec/controllers/projects/find_file_controller_spec.rb
View file @
bc009479
...
@@ -53,10 +53,9 @@ describe Projects::FindFileController do
...
@@ -53,10 +53,9 @@ describe Projects::FindFileController do
it
'returns an array of file path list'
do
it
'returns an array of file path list'
do
go
go
json
=
JSON
.
parse
(
response
.
body
)
is_expected
.
to
respond_with
(
:success
)
is_expected
.
to
respond_with
(
:success
)
expect
(
json
).
not_to
eq
(
nil
)
expect
(
json
_response
).
not_to
eq
(
nil
)
expect
(
json
.
length
).
to
be
>=
0
expect
(
json
_response
.
length
).
to
be
>=
0
end
end
end
end
...
...
spec/controllers/projects/issues_controller_spec.rb
View file @
bc009479
...
@@ -444,7 +444,7 @@ describe Projects::IssuesController do
...
@@ -444,7 +444,7 @@ describe Projects::IssuesController do
it
'renders json with recaptcha_html'
do
it
'renders json with recaptcha_html'
do
subject
subject
expect
(
JSON
.
parse
(
response
.
body
)
).
to
have_key
(
'recaptcha_html'
)
expect
(
json_response
).
to
have_key
(
'recaptcha_html'
)
end
end
end
end
end
end
...
@@ -484,10 +484,8 @@ describe Projects::IssuesController do
...
@@ -484,10 +484,8 @@ describe Projects::IssuesController do
it
'returns last edited time'
do
it
'returns last edited time'
do
go
(
id:
issue
.
iid
)
go
(
id:
issue
.
iid
)
data
=
JSON
.
parse
(
response
.
body
)
expect
(
json_response
).
to
include
(
'updated_at'
)
expect
(
json_response
[
'updated_at'
]).
to
eq
(
issue
.
last_edited_at
.
to_time
.
iso8601
)
expect
(
data
).
to
include
(
'updated_at'
)
expect
(
data
[
'updated_at'
]).
to
eq
(
issue
.
last_edited_at
.
to_time
.
iso8601
)
end
end
end
end
...
@@ -520,10 +518,8 @@ describe Projects::IssuesController do
...
@@ -520,10 +518,8 @@ describe Projects::IssuesController do
it
'returns the necessary data'
do
it
'returns the necessary data'
do
go
(
id:
issue
.
iid
)
go
(
id:
issue
.
iid
)
data
=
JSON
.
parse
(
response
.
body
)
expect
(
json_response
).
to
include
(
'title_text'
,
'description'
,
'description_text'
)
expect
(
json_response
).
to
include
(
'task_status'
,
'lock_version'
)
expect
(
data
).
to
include
(
'title_text'
,
'description'
,
'description_text'
)
expect
(
data
).
to
include
(
'task_status'
,
'lock_version'
)
end
end
end
end
end
end
...
@@ -692,9 +688,7 @@ describe Projects::IssuesController do
...
@@ -692,9 +688,7 @@ describe Projects::IssuesController do
update_issue
(
issue_params:
{
assignee_ids:
[
assignee
.
id
]
})
update_issue
(
issue_params:
{
assignee_ids:
[
assignee
.
id
]
})
body
=
JSON
.
parse
(
response
.
body
)
expect
(
json_response
[
'assignees'
].
first
.
keys
)
expect
(
body
[
'assignees'
].
first
.
keys
)
.
to
match_array
(
%w(id name username avatar_url state web_url)
)
.
to
match_array
(
%w(id name username avatar_url state web_url)
)
end
end
end
end
...
@@ -1314,7 +1308,7 @@ describe Projects::IssuesController do
...
@@ -1314,7 +1308,7 @@ describe Projects::IssuesController do
it
'filters notes that the user should not see'
do
it
'filters notes that the user should not see'
do
get
:discussions
,
params:
{
namespace_id:
project
.
namespace
,
project_id:
project
,
id:
issue
.
iid
}
get
:discussions
,
params:
{
namespace_id:
project
.
namespace
,
project_id:
project
,
id:
issue
.
iid
}
expect
(
JSON
.
parse
(
response
.
body
)
.
count
).
to
eq
(
1
)
expect
(
json_response
.
count
).
to
eq
(
1
)
end
end
it
'does not result in N+1 queries'
do
it
'does not result in N+1 queries'
do
...
...
spec/controllers/projects/merge_requests/diffs_controller_spec.rb
View file @
bc009479
...
@@ -112,7 +112,7 @@ describe Projects::MergeRequests::DiffsController do
...
@@ -112,7 +112,7 @@ describe Projects::MergeRequests::DiffsController do
it
'only renders the diffs for the path given'
do
it
'only renders the diffs for the path given'
do
diff_for_path
(
old_path:
existing_path
,
new_path:
existing_path
)
diff_for_path
(
old_path:
existing_path
,
new_path:
existing_path
)
paths
=
JSON
.
parse
(
response
.
body
)
[
"diff_files"
].
map
{
|
file
|
file
[
'new_path'
]
}
paths
=
json_response
[
"diff_files"
].
map
{
|
file
|
file
[
'new_path'
]
}
expect
(
paths
).
to
include
(
existing_path
)
expect
(
paths
).
to
include
(
existing_path
)
end
end
...
...
spec/controllers/projects/merge_requests_controller_spec.rb
View file @
bc009479
...
@@ -242,9 +242,7 @@ describe Projects::MergeRequestsController do
...
@@ -242,9 +242,7 @@ describe Projects::MergeRequestsController do
update_merge_request
({
assignee_ids:
[
assignee
.
id
]
},
format: :json
)
update_merge_request
({
assignee_ids:
[
assignee
.
id
]
},
format: :json
)
body
=
JSON
.
parse
(
response
.
body
)
expect
(
json_response
[
'assignees'
]).
to
all
(
include
(
*
%w(name username avatar_url id state web_url)
))
expect
(
body
[
'assignees'
]).
to
all
(
include
(
*
%w(name username avatar_url id state web_url)
))
end
end
end
end
...
...
spec/controllers/projects/notes_controller_spec.rb
View file @
bc009479
...
@@ -29,7 +29,7 @@ describe Projects::NotesController do
...
@@ -29,7 +29,7 @@ describe Projects::NotesController do
}
}
end
end
let
(
:parsed_response
)
{
JSON
.
parse
(
response
.
body
)
.
with_indifferent_access
}
let
(
:parsed_response
)
{
json_response
.
with_indifferent_access
}
let
(
:note_json
)
{
parsed_response
[
:notes
].
first
}
let
(
:note_json
)
{
parsed_response
[
:notes
].
first
}
before
do
before
do
...
@@ -614,7 +614,7 @@ describe Projects::NotesController do
...
@@ -614,7 +614,7 @@ describe Projects::NotesController do
it
"returns the name of the resolving user"
do
it
"returns the name of the resolving user"
do
post
:resolve
,
params:
request_params
.
merge
(
html:
true
)
post
:resolve
,
params:
request_params
.
merge
(
html:
true
)
expect
(
JSON
.
parse
(
response
.
body
)
[
"resolved_by"
]).
to
eq
(
user
.
name
)
expect
(
json_response
[
"resolved_by"
]).
to
eq
(
user
.
name
)
end
end
it
"returns status 200"
do
it
"returns status 200"
do
...
...
spec/controllers/projects/templates_controller_spec.rb
View file @
bc009479
...
@@ -7,7 +7,6 @@ describe Projects::TemplatesController do
...
@@ -7,7 +7,6 @@ describe Projects::TemplatesController do
let
(
:user
)
{
create
(
:user
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:file_path_1
)
{
'.gitlab/issue_templates/issue_template.md'
}
let
(
:file_path_1
)
{
'.gitlab/issue_templates/issue_template.md'
}
let
(
:file_path_2
)
{
'.gitlab/merge_request_templates/merge_request_template.md'
}
let
(
:file_path_2
)
{
'.gitlab/merge_request_templates/merge_request_template.md'
}
let
(
:body
)
{
JSON
.
parse
(
response
.
body
)
}
let!
(
:file_1
)
{
project
.
repository
.
create_file
(
user
,
file_path_1
,
'issue content'
,
message:
'message'
,
branch_name:
'master'
)
}
let!
(
:file_1
)
{
project
.
repository
.
create_file
(
user
,
file_path_1
,
'issue content'
,
message:
'message'
,
branch_name:
'master'
)
}
let!
(
:file_2
)
{
project
.
repository
.
create_file
(
user
,
file_path_2
,
'merge request content'
,
message:
'message'
,
branch_name:
'master'
)
}
let!
(
:file_2
)
{
project
.
repository
.
create_file
(
user
,
file_path_2
,
'merge request content'
,
message:
'message'
,
branch_name:
'master'
)
}
...
@@ -17,8 +16,8 @@ describe Projects::TemplatesController do
...
@@ -17,8 +16,8 @@ describe Projects::TemplatesController do
get
(
:show
,
params:
{
namespace_id:
project
.
namespace
,
template_type:
'issue'
,
key:
'issue_template'
,
project_id:
project
},
format: :json
)
get
(
:show
,
params:
{
namespace_id:
project
.
namespace
,
template_type:
'issue'
,
key:
'issue_template'
,
project_id:
project
},
format: :json
)
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
body
[
'name'
]).
to
eq
(
'issue_template'
)
expect
(
json_response
[
'name'
]).
to
eq
(
'issue_template'
)
expect
(
body
[
'content'
]).
to
eq
(
'issue content'
)
expect
(
json_response
[
'content'
]).
to
eq
(
'issue content'
)
end
end
end
end
...
@@ -27,8 +26,8 @@ describe Projects::TemplatesController do
...
@@ -27,8 +26,8 @@ describe Projects::TemplatesController do
get
(
:show
,
params:
{
namespace_id:
project
.
namespace
,
template_type:
'merge_request'
,
key:
'merge_request_template'
,
project_id:
project
},
format: :json
)
get
(
:show
,
params:
{
namespace_id:
project
.
namespace
,
template_type:
'merge_request'
,
key:
'merge_request_template'
,
project_id:
project
},
format: :json
)
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
response
.
status
).
to
eq
(
200
)
expect
(
body
[
'name'
]).
to
eq
(
'merge_request_template'
)
expect
(
json_response
[
'name'
]).
to
eq
(
'merge_request_template'
)
expect
(
body
[
'content'
]).
to
eq
(
'merge request content'
)
expect
(
json_response
[
'content'
]).
to
eq
(
'merge request content'
)
end
end
end
end
...
...
spec/controllers/projects/wikis_controller_spec.rb
View file @
bc009479
...
@@ -103,7 +103,7 @@ describe Projects::WikisController do
...
@@ -103,7 +103,7 @@ describe Projects::WikisController do
it
'renders json in a correct format'
do
it
'renders json in a correct format'
do
post
:preview_markdown
,
params:
{
namespace_id:
project
.
namespace
,
project_id:
project
,
id:
'page/path'
,
text:
'*Markdown* text'
}
post
:preview_markdown
,
params:
{
namespace_id:
project
.
namespace
,
project_id:
project
,
id:
'page/path'
,
text:
'*Markdown* text'
}
expect
(
JSON
.
parse
(
response
.
body
)
.
keys
).
to
match_array
(
%w(body references)
)
expect
(
json_response
.
keys
).
to
match_array
(
%w(body references)
)
end
end
end
end
...
...
spec/controllers/projects_controller_spec.rb
View file @
bc009479
...
@@ -740,20 +740,18 @@ describe ProjectsController do
...
@@ -740,20 +740,18 @@ describe ProjectsController do
it
'gets a list of branches and tags'
do
it
'gets a list of branches and tags'
do
get
:refs
,
params:
{
namespace_id:
project
.
namespace
,
id:
project
,
sort:
'updated_desc'
}
get
:refs
,
params:
{
namespace_id:
project
.
namespace
,
id:
project
,
sort:
'updated_desc'
}
parsed_body
=
JSON
.
parse
(
response
.
body
)
expect
(
json_response
[
'Branches'
]).
to
include
(
'master'
)
expect
(
parsed_body
[
'Branches'
]).
to
include
(
'master'
)
expect
(
json_response
[
'Tags'
].
first
).
to
eq
(
'v1.1.0'
)
expect
(
parsed_body
[
'Tags'
].
first
).
to
eq
(
'v1.1.0'
)
expect
(
json_response
[
'Tags'
].
last
).
to
eq
(
'v1.0.0'
)
expect
(
parsed_body
[
'Tags'
].
last
).
to
eq
(
'v1.0.0'
)
expect
(
json_response
[
'Commits'
]).
to
be_nil
expect
(
parsed_body
[
'Commits'
]).
to
be_nil
end
end
it
"gets a list of branches, tags and commits"
do
it
"gets a list of branches, tags and commits"
do
get
:refs
,
params:
{
namespace_id:
project
.
namespace
,
id:
project
,
ref:
"123456"
}
get
:refs
,
params:
{
namespace_id:
project
.
namespace
,
id:
project
,
ref:
"123456"
}
parsed_body
=
JSON
.
parse
(
response
.
body
)
expect
(
json_response
[
"Branches"
]).
to
include
(
"master"
)
expect
(
parsed_body
[
"Branches"
]).
to
include
(
"master"
)
expect
(
json_response
[
"Tags"
]).
to
include
(
"v1.0.0"
)
expect
(
parsed_body
[
"Tags"
]).
to
include
(
"v1.0.0"
)
expect
(
json_response
[
"Commits"
]).
to
include
(
"123456"
)
expect
(
parsed_body
[
"Commits"
]).
to
include
(
"123456"
)
end
end
context
"when preferred language is Japanese"
do
context
"when preferred language is Japanese"
do
...
@@ -765,10 +763,9 @@ describe ProjectsController do
...
@@ -765,10 +763,9 @@ describe ProjectsController do
it
"gets a list of branches, tags and commits"
do
it
"gets a list of branches, tags and commits"
do
get
:refs
,
params:
{
namespace_id:
project
.
namespace
,
id:
project
,
ref:
"123456"
}
get
:refs
,
params:
{
namespace_id:
project
.
namespace
,
id:
project
,
ref:
"123456"
}
parsed_body
=
JSON
.
parse
(
response
.
body
)
expect
(
json_response
[
"Branches"
]).
to
include
(
"master"
)
expect
(
parsed_body
[
"Branches"
]).
to
include
(
"master"
)
expect
(
json_response
[
"Tags"
]).
to
include
(
"v1.0.0"
)
expect
(
parsed_body
[
"Tags"
]).
to
include
(
"v1.0.0"
)
expect
(
json_response
[
"Commits"
]).
to
include
(
"123456"
)
expect
(
parsed_body
[
"Commits"
]).
to
include
(
"123456"
)
end
end
end
end
...
@@ -797,7 +794,7 @@ describe ProjectsController do
...
@@ -797,7 +794,7 @@ describe ProjectsController do
it
'renders json in a correct format'
do
it
'renders json in a correct format'
do
post
:preview_markdown
,
params:
{
namespace_id:
public_project
.
namespace
,
id:
public_project
,
text:
'*Markdown* text'
}
post
:preview_markdown
,
params:
{
namespace_id:
public_project
.
namespace
,
id:
public_project
,
text:
'*Markdown* text'
}
expect
(
JSON
.
parse
(
response
.
body
)
.
keys
).
to
match_array
(
%w(body references)
)
expect
(
json_response
.
keys
).
to
match_array
(
%w(body references)
)
end
end
context
'when not authorized'
do
context
'when not authorized'
do
...
@@ -821,8 +818,6 @@ describe ProjectsController do
...
@@ -821,8 +818,6 @@ describe ProjectsController do
text:
issue
.
to_reference
text:
issue
.
to_reference
}
}
json_response
=
JSON
.
parse
(
response
.
body
)
expect
(
json_response
[
'body'
]).
to
match
(
/\#
#{
issue
.
iid
}
\(closed\)/
)
expect
(
json_response
[
'body'
]).
to
match
(
/\#
#{
issue
.
iid
}
\(closed\)/
)
end
end
...
@@ -833,8 +828,6 @@ describe ProjectsController do
...
@@ -833,8 +828,6 @@ describe ProjectsController do
text:
merge_request
.
to_reference
text:
merge_request
.
to_reference
}
}
json_response
=
JSON
.
parse
(
response
.
body
)
expect
(
json_response
[
'body'
]).
to
match
(
/\!
#{
merge_request
.
iid
}
\(closed\)/
)
expect
(
json_response
[
'body'
]).
to
match
(
/\!
#{
merge_request
.
iid
}
\(closed\)/
)
end
end
end
end
...
...
spec/controllers/snippets/notes_controller_spec.rb
View file @
bc009479
...
@@ -26,7 +26,7 @@ describe Snippets::NotesController do
...
@@ -26,7 +26,7 @@ describe Snippets::NotesController do
end
end
it
"returns not empty array of notes"
do
it
"returns not empty array of notes"
do
expect
(
JSON
.
parse
(
response
.
body
)
[
"notes"
].
empty?
).
to
be_falsey
expect
(
json_response
[
"notes"
].
empty?
).
to
be_falsey
end
end
end
end
...
@@ -97,7 +97,7 @@ describe Snippets::NotesController do
...
@@ -97,7 +97,7 @@ describe Snippets::NotesController do
it
"returns 1 note"
do
it
"returns 1 note"
do
get
:index
,
params:
{
snippet_id:
private_snippet
}
get
:index
,
params:
{
snippet_id:
private_snippet
}
expect
(
JSON
.
parse
(
response
.
body
)
[
'notes'
].
count
).
to
eq
(
1
)
expect
(
json_response
[
'notes'
].
count
).
to
eq
(
1
)
end
end
end
end
end
end
...
@@ -114,7 +114,7 @@ describe Snippets::NotesController do
...
@@ -114,7 +114,7 @@ describe Snippets::NotesController do
it
"does not return any note"
do
it
"does not return any note"
do
get
:index
,
params:
{
snippet_id:
public_snippet
}
get
:index
,
params:
{
snippet_id:
public_snippet
}
expect
(
JSON
.
parse
(
response
.
body
)
[
'notes'
].
count
).
to
eq
(
0
)
expect
(
json_response
[
'notes'
].
count
).
to
eq
(
0
)
end
end
end
end
end
end
...
...
spec/controllers/snippets_controller_spec.rb
View file @
bc009479
...
@@ -622,7 +622,7 @@ describe SnippetsController do
...
@@ -622,7 +622,7 @@ describe SnippetsController do
post
:preview_markdown
,
params:
{
id:
snippet
,
text:
'*Markdown* text'
}
post
:preview_markdown
,
params:
{
id:
snippet
,
text:
'*Markdown* text'
}
expect
(
JSON
.
parse
(
response
.
body
)
.
keys
).
to
match_array
(
%w(body references)
)
expect
(
json_response
.
keys
).
to
match_array
(
%w(body references)
)
end
end
end
end
end
end
spec/controllers/users_controller_spec.rb
View file @
bc009479
...
@@ -291,7 +291,7 @@ describe UsersController do
...
@@ -291,7 +291,7 @@ describe UsersController do
it
'response with snippets json data'
do
it
'response with snippets json data'
do
get
:snippets
,
params:
{
username:
user
.
username
},
format: :json
get
:snippets
,
params:
{
username:
user
.
username
},
format: :json
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
response
).
to
have_gitlab_http_status
(
200
)
expect
(
JSON
.
parse
(
response
.
body
)
).
to
have_key
(
'html'
)
expect
(
json_response
).
to
have_key
(
'html'
)
end
end
end
end
...
...
spec/requests/api/search_spec.rb
View file @
bc009479
...
@@ -89,7 +89,7 @@ describe API::Search do
...
@@ -89,7 +89,7 @@ describe API::Search do
it
'returns empty array'
do
it
'returns empty array'
do
get
api
(
'/search'
,
user
),
params:
{
scope:
'milestones'
,
search:
'awesome'
}
get
api
(
'/search'
,
user
),
params:
{
scope:
'milestones'
,
search:
'awesome'
}
milestones
=
JSON
.
parse
(
response
.
body
)
milestones
=
json_response
expect
(
milestones
).
to
be_empty
expect
(
milestones
).
to
be_empty
end
end
...
@@ -356,7 +356,7 @@ describe API::Search do
...
@@ -356,7 +356,7 @@ describe API::Search do
it
'returns empty array'
do
it
'returns empty array'
do
get
api
(
"/projects/
#{
project
.
id
}
/search"
,
user
),
params:
{
scope:
'milestones'
,
search:
'awesome'
}
get
api
(
"/projects/
#{
project
.
id
}
/search"
,
user
),
params:
{
scope:
'milestones'
,
search:
'awesome'
}
milestones
=
JSON
.
parse
(
response
.
body
)
milestones
=
json_response
expect
(
milestones
).
to
be_empty
expect
(
milestones
).
to
be_empty
end
end
...
...
spec/requests/lfs_http_spec.rb
View file @
bc009479
...
@@ -1439,8 +1439,4 @@ describe 'Git LFS API and storage' do
...
@@ -1439,8 +1439,4 @@ describe 'Git LFS API and storage' do
post
(
url
,
params:
params
,
headers:
headers
)
post
(
url
,
params:
params
,
headers:
headers
)
end
end
def
json_response
@json_response
||=
JSON
.
parse
(
response
.
body
)
end
end
end
spec/requests/lfs_locks_api_spec.rb
View file @
bc009479
...
@@ -163,8 +163,4 @@ describe 'Git LFS File Locking API' do
...
@@ -163,8 +163,4 @@ describe 'Git LFS File Locking API' do
def
do_get
(
url
,
params
=
nil
,
headers
=
nil
)
def
do_get
(
url
,
params
=
nil
,
headers
=
nil
)
get
(
url
,
params:
(
params
||
{}),
headers:
(
headers
||
{}).
merge
(
'Content-Type'
=>
LfsRequest
::
CONTENT_TYPE
))
get
(
url
,
params:
(
params
||
{}),
headers:
(
headers
||
{}).
merge
(
'Content-Type'
=>
LfsRequest
::
CONTENT_TYPE
))
end
end
def
json_response
@json_response
||=
JSON
.
parse
(
response
.
body
)
end
end
end
spec/support/json_response.rb
View file @
bc009479
RSpec
.
configure
do
|
config
|
RSpec
.
configure
do
|
config
|
config
.
include_context
'JSON response'
config
.
include_context
'JSON response'
,
type: :controller
config
.
include_context
'JSON response'
,
type: :request
config
.
include_context
'JSON response'
,
type: :request
config
.
include_context
'JSON response'
,
:api
config
.
include_context
'JSON response'
,
:api
end
end
spec/support/shared_examples/controllers/issuable_notes_filter_shared_examples.rb
View file @
bc009479
...
@@ -46,7 +46,7 @@ shared_examples 'issuable notes filter' do
...
@@ -46,7 +46,7 @@ shared_examples 'issuable notes filter' do
user
.
set_notes_filter
(
UserPreference
::
NOTES_FILTERS
[
:only_comments
],
issuable
)
user
.
set_notes_filter
(
UserPreference
::
NOTES_FILTERS
[
:only_comments
],
issuable
)
get
:discussions
,
params:
params
get
:discussions
,
params:
params
discussions
=
JSON
.
parse
(
response
.
body
)
discussions
=
json_response
expect
(
discussions
.
count
).
to
eq
(
1
)
expect
(
discussions
.
count
).
to
eq
(
1
)
expect
(
discussions
.
first
[
"notes"
].
first
[
"system"
]).
to
be
(
false
)
expect
(
discussions
.
first
[
"notes"
].
first
[
"system"
]).
to
be
(
false
)
...
@@ -56,7 +56,7 @@ shared_examples 'issuable notes filter' do
...
@@ -56,7 +56,7 @@ shared_examples 'issuable notes filter' do
user
.
set_notes_filter
(
UserPreference
::
NOTES_FILTERS
[
:only_activity
],
issuable
)
user
.
set_notes_filter
(
UserPreference
::
NOTES_FILTERS
[
:only_activity
],
issuable
)
get
:discussions
,
params:
params
get
:discussions
,
params:
params
discussions
=
JSON
.
parse
(
response
.
body
)
discussions
=
json_response
expect
(
discussions
.
count
).
to
eq
(
1
)
expect
(
discussions
.
count
).
to
eq
(
1
)
expect
(
discussions
.
first
[
"notes"
].
first
[
"system"
]).
to
be
(
true
)
expect
(
discussions
.
first
[
"notes"
].
first
[
"system"
]).
to
be
(
true
)
...
...
spec/support/shared_examples/update_invalid_issuable.rb
View file @
bc009479
...
@@ -38,7 +38,7 @@ shared_examples 'update invalid issuable' do |klass|
...
@@ -38,7 +38,7 @@ shared_examples 'update invalid issuable' do |klass|
put
:update
,
params:
params
put
:update
,
params:
params
expect
(
response
.
status
).
to
eq
(
409
)
expect
(
response
.
status
).
to
eq
(
409
)
expect
(
JSON
.
parse
(
response
.
body
)
).
to
have_key
(
'errors'
)
expect
(
json_response
).
to
have_key
(
'errors'
)
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