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
cfd475a4
Commit
cfd475a4
authored
Aug 15, 2017
by
Tiago Botelho
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removes default scope from sortable
parent
d1b60cbc
Changes
38
Show whitespace changes
Inline
Side-by-side
Showing
38 changed files
with
67 additions
and
53 deletions
+67
-53
app/controllers/admin/broadcast_messages_controller.rb
app/controllers/admin/broadcast_messages_controller.rb
+1
-1
app/controllers/admin/dashboard_controller.rb
app/controllers/admin/dashboard_controller.rb
+3
-3
app/controllers/admin/users_controller.rb
app/controllers/admin/users_controller.rb
+1
-1
app/controllers/dashboard/groups_controller.rb
app/controllers/dashboard/groups_controller.rb
+3
-1
app/controllers/profiles/emails_controller.rb
app/controllers/profiles/emails_controller.rb
+1
-1
app/controllers/profiles/keys_controller.rb
app/controllers/profiles/keys_controller.rb
+1
-1
app/controllers/projects/merge_requests/diffs_controller.rb
app/controllers/projects/merge_requests/diffs_controller.rb
+1
-1
app/controllers/projects/project_members_controller.rb
app/controllers/projects/project_members_controller.rb
+4
-0
app/finders/move_to_project_finder.rb
app/finders/move_to_project_finder.rb
+1
-0
app/finders/projects_finder.rb
app/finders/projects_finder.rb
+1
-1
app/finders/todos_finder.rb
app/finders/todos_finder.rb
+1
-1
app/helpers/issues_helper.rb
app/helpers/issues_helper.rb
+1
-1
app/helpers/search_helper.rb
app/helpers/search_helper.rb
+2
-2
app/models/broadcast_message.rb
app/models/broadcast_message.rb
+1
-1
app/models/concerns/sortable.rb
app/models/concerns/sortable.rb
+0
-4
app/models/user.rb
app/models/user.rb
+6
-4
app/services/quick_actions/interpret_service.rb
app/services/quick_actions/interpret_service.rb
+1
-1
app/views/projects/project_members/import.html.haml
app/views/projects/project_members/import.html.haml
+1
-1
changelogs/unreleased/23079-remove-default-scope-in-sortable.yml
...ogs/unreleased/23079-remove-default-scope-in-sortable.yml
+5
-0
features/steps/project/fork.rb
features/steps/project/fork.rb
+1
-1
lib/api/broadcast_messages.rb
lib/api/broadcast_messages.rb
+1
-1
lib/api/merge_request_diffs.rb
lib/api/merge_request_diffs.rb
+1
-1
lib/api/milestone_responses.rb
lib/api/milestone_responses.rb
+1
-1
lib/api/v3/merge_request_diffs.rb
lib/api/v3/merge_request_diffs.rb
+1
-1
lib/api/v3/milestones.rb
lib/api/v3/milestones.rb
+1
-0
lib/api/v3/projects.rb
lib/api/v3/projects.rb
+1
-1
spec/features/projects/import_export/import_file_spec.rb
spec/features/projects/import_export/import_file_spec.rb
+3
-4
spec/finders/group_members_finder_spec.rb
spec/finders/group_members_finder_spec.rb
+2
-2
spec/finders/members_finder_spec.rb
spec/finders/members_finder_spec.rb
+1
-1
spec/models/namespace_spec.rb
spec/models/namespace_spec.rb
+1
-1
spec/models/user_spec.rb
spec/models/user_spec.rb
+1
-1
spec/requests/api/merge_request_diffs_spec.rb
spec/requests/api/merge_request_diffs_spec.rb
+1
-1
spec/requests/api/projects_spec.rb
spec/requests/api/projects_spec.rb
+2
-2
spec/requests/api/v3/merge_request_diffs_spec.rb
spec/requests/api/v3/merge_request_diffs_spec.rb
+1
-1
spec/requests/projects/cycle_analytics_events_spec.rb
spec/requests/projects/cycle_analytics_events_spec.rb
+1
-1
spec/services/notification_service_spec.rb
spec/services/notification_service_spec.rb
+2
-2
spec/support/controllers/githubish_import_controller_shared_examples.rb
...ontrollers/githubish_import_controller_shared_examples.rb
+8
-6
spec/workers/post_receive_spec.rb
spec/workers/post_receive_spec.rb
+2
-0
No files found.
app/controllers/admin/broadcast_messages_controller.rb
View file @
cfd475a4
...
@@ -2,7 +2,7 @@ class Admin::BroadcastMessagesController < Admin::ApplicationController
...
@@ -2,7 +2,7 @@ class Admin::BroadcastMessagesController < Admin::ApplicationController
before_action
:finder
,
only:
[
:edit
,
:update
,
:destroy
]
before_action
:finder
,
only:
[
:edit
,
:update
,
:destroy
]
def
index
def
index
@broadcast_messages
=
BroadcastMessage
.
reorder
(
"ends_at DESC"
).
page
(
params
[
:page
])
@broadcast_messages
=
BroadcastMessage
.
order
(
ends_at: :desc
).
page
(
params
[
:page
])
@broadcast_message
=
BroadcastMessage
.
new
@broadcast_message
=
BroadcastMessage
.
new
end
end
...
...
app/controllers/admin/dashboard_controller.rb
View file @
cfd475a4
class
Admin::DashboardController
<
Admin
::
ApplicationController
class
Admin::DashboardController
<
Admin
::
ApplicationController
def
index
def
index
@projects
=
Project
.
without_deleted
.
with_route
.
limit
(
10
)
@projects
=
Project
.
order_id_desc
.
without_deleted
.
with_route
.
limit
(
10
)
@users
=
User
.
limit
(
10
)
@users
=
User
.
order_id_desc
.
limit
(
10
)
@groups
=
Group
.
with_route
.
limit
(
10
)
@groups
=
Group
.
order_id_desc
.
with_route
.
limit
(
10
)
end
end
end
end
app/controllers/admin/users_controller.rb
View file @
cfd475a4
...
@@ -17,7 +17,7 @@ class Admin::UsersController < Admin::ApplicationController
...
@@ -17,7 +17,7 @@ class Admin::UsersController < Admin::ApplicationController
end
end
def
keys
def
keys
@keys
=
user
.
keys
@keys
=
user
.
keys
.
order_id_desc
end
end
def
new
def
new
...
...
app/controllers/dashboard/groups_controller.rb
View file @
cfd475a4
class
Dashboard::GroupsController
<
Dashboard
::
ApplicationController
class
Dashboard::GroupsController
<
Dashboard
::
ApplicationController
def
index
def
index
@sort
=
params
[
:sort
]
||
'id_desc'
@groups
=
@groups
=
if
params
[
:parent_id
]
&&
Group
.
supports_nested_groups?
if
params
[
:parent_id
]
&&
Group
.
supports_nested_groups?
parent
=
Group
.
find_by
(
id:
params
[
:parent_id
])
parent
=
Group
.
find_by
(
id:
params
[
:parent_id
])
...
@@ -15,7 +17,7 @@ class Dashboard::GroupsController < Dashboard::ApplicationController
...
@@ -15,7 +17,7 @@ class Dashboard::GroupsController < Dashboard::ApplicationController
@groups
=
@groups
.
search
(
params
[
:filter_groups
])
if
params
[
:filter_groups
].
present?
@groups
=
@groups
.
search
(
params
[
:filter_groups
])
if
params
[
:filter_groups
].
present?
@groups
=
@groups
.
includes
(
:route
)
@groups
=
@groups
.
includes
(
:route
)
@groups
=
@groups
.
sort
(
@sort
=
params
[
:sort
]
)
@groups
=
@groups
.
sort
(
@sort
)
@groups
=
@groups
.
page
(
params
[
:page
])
@groups
=
@groups
.
page
(
params
[
:page
])
respond_to
do
|
format
|
respond_to
do
|
format
|
...
...
app/controllers/profiles/emails_controller.rb
View file @
cfd475a4
class
Profiles::EmailsController
<
Profiles
::
ApplicationController
class
Profiles::EmailsController
<
Profiles
::
ApplicationController
def
index
def
index
@primary
=
current_user
.
email
@primary
=
current_user
.
email
@emails
=
current_user
.
emails
@emails
=
current_user
.
emails
.
order_id_desc
end
end
def
create
def
create
...
...
app/controllers/profiles/keys_controller.rb
View file @
cfd475a4
...
@@ -2,7 +2,7 @@ class Profiles::KeysController < Profiles::ApplicationController
...
@@ -2,7 +2,7 @@ class Profiles::KeysController < Profiles::ApplicationController
skip_before_action
:authenticate_user!
,
only:
[
:get_keys
]
skip_before_action
:authenticate_user!
,
only:
[
:get_keys
]
def
index
def
index
@keys
=
current_user
.
keys
@keys
=
current_user
.
keys
.
order_id_desc
@key
=
Key
.
new
@key
=
Key
.
new
end
end
...
...
app/controllers/projects/merge_requests/diffs_controller.rb
View file @
cfd475a4
...
@@ -27,7 +27,7 @@ class Projects::MergeRequests::DiffsController < Projects::MergeRequests::Applic
...
@@ -27,7 +27,7 @@ class Projects::MergeRequests::DiffsController < Projects::MergeRequests::Applic
@merge_request
.
merge_request_diff
@merge_request
.
merge_request_diff
end
end
@merge_request_diffs
=
@merge_request
.
merge_request_diffs
.
viewable
.
select_without_diff
@merge_request_diffs
=
@merge_request
.
merge_request_diffs
.
viewable
.
select_without_diff
.
order_id_desc
@comparable_diffs
=
@merge_request_diffs
.
select
{
|
diff
|
diff
.
id
<
@merge_request_diff
.
id
}
@comparable_diffs
=
@merge_request_diffs
.
select
{
|
diff
|
diff
.
id
<
@merge_request_diff
.
id
}
if
params
[
:start_sha
].
present?
if
params
[
:start_sha
].
present?
...
...
app/controllers/projects/project_members_controller.rb
View file @
cfd475a4
...
@@ -47,6 +47,10 @@ class Projects::ProjectMembersController < Projects::ApplicationController
...
@@ -47,6 +47,10 @@ class Projects::ProjectMembersController < Projects::ApplicationController
end
end
end
end
def
import
@projects
=
current_user
.
authorized_projects
.
order_id_desc
end
def
apply_import
def
apply_import
source_project
=
Project
.
find
(
params
[
:source_project_id
])
source_project
=
Project
.
find
(
params
[
:source_project_id
])
...
...
app/finders/move_to_project_finder.rb
View file @
cfd475a4
...
@@ -9,6 +9,7 @@ class MoveToProjectFinder
...
@@ -9,6 +9,7 @@ class MoveToProjectFinder
projects
=
@user
.
projects_where_can_admin_issues
projects
=
@user
.
projects_where_can_admin_issues
projects
=
projects
.
search
(
search
)
if
search
.
present?
projects
=
projects
.
search
(
search
)
if
search
.
present?
projects
=
projects
.
excluding_project
(
from_project
)
projects
=
projects
.
excluding_project
(
from_project
)
projects
=
projects
.
order_id_desc
# infinite scroll using offset
# infinite scroll using offset
projects
=
projects
.
where
(
'projects.id < ?'
,
offset_id
)
if
offset_id
.
present?
projects
=
projects
.
where
(
'projects.id < ?'
,
offset_id
)
if
offset_id
.
present?
...
...
app/finders/projects_finder.rb
View file @
cfd475a4
...
@@ -121,7 +121,7 @@ class ProjectsFinder < UnionFinder
...
@@ -121,7 +121,7 @@ class ProjectsFinder < UnionFinder
end
end
def
sort
(
items
)
def
sort
(
items
)
params
[
:sort
].
present?
?
items
.
sort
(
params
[
:sort
])
:
items
params
[
:sort
].
present?
?
items
.
sort
(
params
[
:sort
])
:
items
.
order_id_desc
end
end
def
by_archived
(
projects
)
def
by_archived
(
projects
)
...
...
app/finders/todos_finder.rb
View file @
cfd475a4
...
@@ -118,7 +118,7 @@ class TodosFinder
...
@@ -118,7 +118,7 @@ class TodosFinder
end
end
def
sort
(
items
)
def
sort
(
items
)
params
[
:sort
]
?
items
.
sort
(
params
[
:sort
])
:
items
.
reorder
(
id: :desc
)
params
[
:sort
]
?
items
.
sort
(
params
[
:sort
])
:
items
.
order_id_desc
end
end
def
by_action
(
items
)
def
by_action
(
items
)
...
...
app/helpers/issues_helper.rb
View file @
cfd475a4
...
@@ -56,7 +56,7 @@ module IssuesHelper
...
@@ -56,7 +56,7 @@ module IssuesHelper
end
end
def
project_options
(
issuable
,
current_user
,
ability: :read_project
)
def
project_options
(
issuable
,
current_user
,
ability: :read_project
)
projects
=
current_user
.
authorized_projects
projects
=
current_user
.
authorized_projects
.
order_id_desc
projects
=
projects
.
select
do
|
project
|
projects
=
projects
.
select
do
|
project
|
current_user
.
can?
(
ability
,
project
)
current_user
.
can?
(
ability
,
project
)
end
end
...
...
app/helpers/search_helper.rb
View file @
cfd475a4
...
@@ -85,7 +85,7 @@ module SearchHelper
...
@@ -85,7 +85,7 @@ module SearchHelper
# Autocomplete results for the current user's groups
# Autocomplete results for the current user's groups
def
groups_autocomplete
(
term
,
limit
=
5
)
def
groups_autocomplete
(
term
,
limit
=
5
)
current_user
.
authorized_groups
.
search
(
term
).
limit
(
limit
).
map
do
|
group
|
current_user
.
authorized_groups
.
order_id_desc
.
search
(
term
).
limit
(
limit
).
map
do
|
group
|
{
{
category:
"Groups"
,
category:
"Groups"
,
id:
group
.
id
,
id:
group
.
id
,
...
@@ -97,7 +97,7 @@ module SearchHelper
...
@@ -97,7 +97,7 @@ module SearchHelper
# Autocomplete results for the current user's projects
# Autocomplete results for the current user's projects
def
projects_autocomplete
(
term
,
limit
=
5
)
def
projects_autocomplete
(
term
,
limit
=
5
)
current_user
.
authorized_projects
.
search_by_title
(
term
)
current_user
.
authorized_projects
.
order_id_desc
.
search_by_title
(
term
)
.
sorted_by_stars
.
non_archived
.
limit
(
limit
).
map
do
|
p
|
.
sorted_by_stars
.
non_archived
.
limit
(
limit
).
map
do
|
p
|
{
{
category:
"Projects"
,
category:
"Projects"
,
...
...
app/models/broadcast_message.rb
View file @
cfd475a4
...
@@ -33,7 +33,7 @@ class BroadcastMessage < ActiveRecord::Base
...
@@ -33,7 +33,7 @@ class BroadcastMessage < ActiveRecord::Base
end
end
def
self
.
current_and_future_messages
def
self
.
current_and_future_messages
where
(
'ends_at > :now'
,
now:
Time
.
zone
.
now
).
reorder
(
id: :asc
)
where
(
'ends_at > :now'
,
now:
Time
.
zone
.
now
).
order_id_asc
end
end
def
active?
def
active?
...
...
app/models/concerns/sortable.rb
View file @
cfd475a4
...
@@ -6,10 +6,6 @@ module Sortable
...
@@ -6,10 +6,6 @@ module Sortable
extend
ActiveSupport
::
Concern
extend
ActiveSupport
::
Concern
included
do
included
do
# By default all models should be ordered
# by created_at field starting from newest
default_scope
{
order_id_desc
}
scope
:order_id_desc
,
->
{
reorder
(
id: :desc
)
}
scope
:order_id_desc
,
->
{
reorder
(
id: :desc
)
}
scope
:order_id_asc
,
->
{
reorder
(
id: :asc
)
}
scope
:order_id_asc
,
->
{
reorder
(
id: :asc
)
}
scope
:order_created_desc
,
->
{
reorder
(
created_at: :desc
)
}
scope
:order_created_desc
,
->
{
reorder
(
created_at: :desc
)
}
...
...
app/models/user.rb
View file @
cfd475a4
...
@@ -70,7 +70,7 @@ class User < ActiveRecord::Base
...
@@ -70,7 +70,7 @@ class User < ActiveRecord::Base
#
#
# Namespace for personal projects
# Namespace for personal projects
has_one
:namespace
,
->
{
where
type:
nil
},
dependent: :destroy
,
foreign_key: :owner_id
,
autosave:
true
# rubocop:disable Cop/ActiveRecordDependent
has_one
:namespace
,
->
{
where
(
type:
nil
)
},
dependent: :destroy
,
foreign_key: :owner_id
,
autosave:
true
# rubocop:disable Cop/ActiveRecordDependent
# Profile
# Profile
has_many
:keys
,
->
do
has_many
:keys
,
->
do
...
@@ -255,11 +255,13 @@ class User < ActiveRecord::Base
...
@@ -255,11 +255,13 @@ class User < ActiveRecord::Base
end
end
def
sort
(
method
)
def
sort
(
method
)
case
method
.
to_s
order_method
=
method
||
'id_desc'
case
order_method
.
to_s
when
'recent_sign_in'
then
order_recent_sign_in
when
'recent_sign_in'
then
order_recent_sign_in
when
'oldest_sign_in'
then
order_oldest_sign_in
when
'oldest_sign_in'
then
order_oldest_sign_in
else
else
order_by
(
method
)
order_by
(
order_
method
)
end
end
end
end
...
@@ -367,7 +369,7 @@ class User < ActiveRecord::Base
...
@@ -367,7 +369,7 @@ class User < ActiveRecord::Base
# Returns a user for the given SSH key.
# Returns a user for the given SSH key.
def
find_by_ssh_key_id
(
key_id
)
def
find_by_ssh_key_id
(
key_id
)
find_by
(
id:
Key
.
unscoped
.
select
(
:user_id
).
where
(
id:
key_id
))
Key
.
find_by
(
id:
key_id
)
&
.
user
end
end
def
find_by_full_path
(
path
,
follow_redirects:
false
)
def
find_by_full_path
(
path
,
follow_redirects:
false
)
...
...
app/services/quick_actions/interpret_service.rb
View file @
cfd475a4
...
@@ -115,7 +115,7 @@ module QuickActions
...
@@ -115,7 +115,7 @@ module QuickActions
if
issuable
.
allows_multiple_assignees?
if
issuable
.
allows_multiple_assignees?
issuable
.
assignees
.
pluck
(
:id
)
+
users
.
map
(
&
:id
)
issuable
.
assignees
.
pluck
(
:id
)
+
users
.
map
(
&
:id
)
else
else
[
users
.
la
st
.
id
]
[
users
.
fir
st
.
id
]
end
end
end
end
...
...
app/views/projects/project_members/import.html.haml
View file @
cfd475a4
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
=
form_tag
apply_import_project_project_members_path
(
@project
),
method:
'post'
,
class:
'form-horizontal'
do
=
form_tag
apply_import_project_project_members_path
(
@project
),
method:
'post'
,
class:
'form-horizontal'
do
.form-group
.form-group
=
label_tag
:source_project_id
,
"Project"
,
class:
'control-label'
=
label_tag
:source_project_id
,
"Project"
,
class:
'control-label'
.col-sm-10
=
select_tag
(
:source_project_id
,
options_from_collection_for_select
(
current_user
.
authorized_
projects
,
:id
,
:name_with_namespace
),
prompt:
"Select project"
,
class:
"select2 lg"
,
required:
true
)
.col-sm-10
=
select_tag
(
:source_project_id
,
options_from_collection_for_select
(
@
projects
,
:id
,
:name_with_namespace
),
prompt:
"Select project"
,
class:
"select2 lg"
,
required:
true
)
.form-actions
.form-actions
=
button_tag
'Import project members'
,
class:
"btn btn-create"
=
button_tag
'Import project members'
,
class:
"btn btn-create"
...
...
changelogs/unreleased/23079-remove-default-scope-in-sortable.yml
0 → 100644
View file @
cfd475a4
---
title
:
Removes Sortable default scope.
merge_request
:
13558
author
:
type
:
fixed
features/steps/project/fork.rb
View file @
cfd475a4
...
@@ -52,7 +52,7 @@ class Spinach::Features::ProjectFork < Spinach::FeatureSteps
...
@@ -52,7 +52,7 @@ class Spinach::Features::ProjectFork < Spinach::FeatureSteps
end
end
step
'I visit the forks page of the "Shop" project'
do
step
'I visit the forks page of the "Shop" project'
do
@project
=
Project
.
where
(
name:
'Shop'
).
la
st
@project
=
Project
.
where
(
name:
'Shop'
).
fir
st
visit
project_forks_path
(
@project
)
visit
project_forks_path
(
@project
)
end
end
...
...
lib/api/broadcast_messages.rb
View file @
cfd475a4
...
@@ -20,7 +20,7 @@ module API
...
@@ -20,7 +20,7 @@ module API
use
:pagination
use
:pagination
end
end
get
do
get
do
messages
=
BroadcastMessage
.
all
messages
=
BroadcastMessage
.
all
.
order_id_desc
present
paginate
(
messages
),
with:
Entities
::
BroadcastMessage
present
paginate
(
messages
),
with:
Entities
::
BroadcastMessage
end
end
...
...
lib/api/merge_request_diffs.rb
View file @
cfd475a4
...
@@ -21,7 +21,7 @@ module API
...
@@ -21,7 +21,7 @@ module API
get
":id/merge_requests/:merge_request_iid/versions"
do
get
":id/merge_requests/:merge_request_iid/versions"
do
merge_request
=
find_merge_request_with_access
(
params
[
:merge_request_iid
])
merge_request
=
find_merge_request_with_access
(
params
[
:merge_request_iid
])
present
paginate
(
merge_request
.
merge_request_diffs
),
with:
Entities
::
MergeRequestDiff
present
paginate
(
merge_request
.
merge_request_diffs
.
order_id_desc
),
with:
Entities
::
MergeRequestDiff
end
end
desc
'Get a single merge request diff version'
do
desc
'Get a single merge request diff version'
do
...
...
lib/api/milestone_responses.rb
View file @
cfd475a4
...
@@ -28,7 +28,7 @@ module API
...
@@ -28,7 +28,7 @@ module API
end
end
def
list_milestones_for
(
parent
)
def
list_milestones_for
(
parent
)
milestones
=
parent
.
milestones
milestones
=
parent
.
milestones
.
order_id_desc
milestones
=
Milestone
.
filter_by_state
(
milestones
,
params
[
:state
])
milestones
=
Milestone
.
filter_by_state
(
milestones
,
params
[
:state
])
milestones
=
filter_by_iid
(
milestones
,
params
[
:iids
])
if
params
[
:iids
].
present?
milestones
=
filter_by_iid
(
milestones
,
params
[
:iids
])
if
params
[
:iids
].
present?
milestones
=
filter_by_search
(
milestones
,
params
[
:search
])
if
params
[
:search
]
milestones
=
filter_by_search
(
milestones
,
params
[
:search
])
if
params
[
:search
]
...
...
lib/api/v3/merge_request_diffs.rb
View file @
cfd475a4
...
@@ -20,7 +20,7 @@ module API
...
@@ -20,7 +20,7 @@ module API
get
":id/merge_requests/:merge_request_id/versions"
do
get
":id/merge_requests/:merge_request_id/versions"
do
merge_request
=
find_merge_request_with_access
(
params
[
:merge_request_id
])
merge_request
=
find_merge_request_with_access
(
params
[
:merge_request_id
])
present
merge_request
.
merge_request_diffs
,
with:
::
API
::
Entities
::
MergeRequestDiff
present
merge_request
.
merge_request_diffs
.
order_id_desc
,
with:
::
API
::
Entities
::
MergeRequestDiff
end
end
desc
'Get a single merge request diff version'
do
desc
'Get a single merge request diff version'
do
...
...
lib/api/v3/milestones.rb
View file @
cfd475a4
...
@@ -34,6 +34,7 @@ module API
...
@@ -34,6 +34,7 @@ module API
milestones
=
user_project
.
milestones
milestones
=
user_project
.
milestones
milestones
=
filter_milestones_state
(
milestones
,
params
[
:state
])
milestones
=
filter_milestones_state
(
milestones
,
params
[
:state
])
milestones
=
filter_by_iid
(
milestones
,
params
[
:iid
])
if
params
[
:iid
].
present?
milestones
=
filter_by_iid
(
milestones
,
params
[
:iid
])
if
params
[
:iid
].
present?
milestones
=
milestones
.
order_id_desc
present
paginate
(
milestones
),
with:
::
API
::
Entities
::
Milestone
present
paginate
(
milestones
),
with:
::
API
::
Entities
::
Milestone
end
end
...
...
lib/api/v3/projects.rb
View file @
cfd475a4
...
@@ -119,7 +119,7 @@ module API
...
@@ -119,7 +119,7 @@ module API
get
do
get
do
authenticate!
authenticate!
present_projects
current_user
.
authorized_projects
,
present_projects
current_user
.
authorized_projects
.
order_id_desc
,
with:
::
API
::
V3
::
Entities
::
ProjectWithAccess
with:
::
API
::
V3
::
Entities
::
ProjectWithAccess
end
end
...
...
spec/features/projects/import_export/import_file_spec.rb
View file @
cfd475a4
...
@@ -18,7 +18,7 @@ feature 'Import/Export - project import integration test', js: true do
...
@@ -18,7 +18,7 @@ feature 'Import/Export - project import integration test', js: true do
context
'when selecting the namespace'
do
context
'when selecting the namespace'
do
let
(
:user
)
{
create
(
:admin
)
}
let
(
:user
)
{
create
(
:admin
)
}
let!
(
:namespace
)
{
create
(
:namespace
,
name:
'asd'
,
owner:
user
)
}
let!
(
:namespace
)
{
user
.
namespace
}
let
(
:project_path
)
{
'test-project-path'
+
SecureRandom
.
hex
}
let
(
:project_path
)
{
'test-project-path'
+
SecureRandom
.
hex
}
context
'prefilled the path'
do
context
'prefilled the path'
do
...
@@ -66,12 +66,11 @@ feature 'Import/Export - project import integration test', js: true do
...
@@ -66,12 +66,11 @@ feature 'Import/Export - project import integration test', js: true do
end
end
scenario
'invalid project'
do
scenario
'invalid project'
do
namespace
=
create
(
:namespace
,
name:
'asdf'
,
owner:
user
)
project
=
create
(
:project
,
namespace:
user
.
namespace
)
project
=
create
(
:project
,
namespace:
namespace
)
visit
new_project_path
visit
new_project_path
select2
(
namespace
.
id
,
from:
'#project_namespace_id'
)
select2
(
user
.
namespace
.
id
,
from:
'#project_namespace_id'
)
fill_in
:project_path
,
with:
project
.
name
,
visible:
true
fill_in
:project_path
,
with:
project
.
name
,
visible:
true
click_link
'GitLab export'
click_link
'GitLab export'
attach_file
(
'file'
,
file
)
attach_file
(
'file'
,
file
)
...
...
spec/finders/group_members_finder_spec.rb
View file @
cfd475a4
...
@@ -15,7 +15,7 @@ describe GroupMembersFinder, '#execute' do
...
@@ -15,7 +15,7 @@ describe GroupMembersFinder, '#execute' do
result
=
described_class
.
new
(
group
).
execute
result
=
described_class
.
new
(
group
).
execute
expect
(
result
.
to_a
).
to
eq
([
member3
,
member2
,
member1
])
expect
(
result
.
to_a
).
to
match_array
([
member3
,
member2
,
member1
])
end
end
it
'returns members for nested group'
,
:nested_groups
do
it
'returns members for nested group'
,
:nested_groups
do
...
@@ -27,6 +27,6 @@ describe GroupMembersFinder, '#execute' do
...
@@ -27,6 +27,6 @@ describe GroupMembersFinder, '#execute' do
result
=
described_class
.
new
(
nested_group
).
execute
result
=
described_class
.
new
(
nested_group
).
execute
expect
(
result
.
to_a
).
to
eq
([
member4
,
member3
,
member1
])
expect
(
result
.
to_a
).
to
match_array
([
member1
,
member3
,
member4
])
end
end
end
end
spec/finders/members_finder_spec.rb
View file @
cfd475a4
...
@@ -17,6 +17,6 @@ describe MembersFinder, '#execute' do
...
@@ -17,6 +17,6 @@ describe MembersFinder, '#execute' do
result
=
described_class
.
new
(
project
,
user2
).
execute
result
=
described_class
.
new
(
project
,
user2
).
execute
expect
(
result
.
to_a
).
to
eq
([
member3
,
member2
,
member1
])
expect
(
result
.
to_a
).
to
match_array
([
member1
,
member2
,
member3
])
end
end
end
end
spec/models/namespace_spec.rb
View file @
cfd475a4
...
@@ -404,6 +404,6 @@ describe Namespace do
...
@@ -404,6 +404,6 @@ describe Namespace do
let!
(
:project1
)
{
create
(
:project_empty_repo
,
namespace:
group
)
}
let!
(
:project1
)
{
create
(
:project_empty_repo
,
namespace:
group
)
}
let!
(
:project2
)
{
create
(
:project_empty_repo
,
namespace:
child
)
}
let!
(
:project2
)
{
create
(
:project_empty_repo
,
namespace:
child
)
}
it
{
expect
(
group
.
all_projects
.
to_a
).
to
eq
([
project2
,
project1
])
}
it
{
expect
(
group
.
all_projects
.
to_a
).
to
match_array
([
project2
,
project1
])
}
end
end
end
end
spec/models/user_spec.rb
View file @
cfd475a4
...
@@ -1517,7 +1517,7 @@ describe User do
...
@@ -1517,7 +1517,7 @@ describe User do
developer_project
=
create
(
:project
)
{
|
p
|
p
.
add_developer
(
user
)
}
developer_project
=
create
(
:project
)
{
|
p
|
p
.
add_developer
(
user
)
}
master_project
=
create
(
:project
)
{
|
p
|
p
.
add_master
(
user
)
}
master_project
=
create
(
:project
)
{
|
p
|
p
.
add_master
(
user
)
}
expect
(
user
.
projects_where_can_admin_issues
.
to_a
).
to
eq
([
master_project
,
developer_project
,
reporter_project
])
expect
(
user
.
projects_where_can_admin_issues
.
to_a
).
to
match_array
([
master_project
,
developer_project
,
reporter_project
])
expect
(
user
.
can?
(
:admin_issue
,
master_project
)).
to
eq
(
true
)
expect
(
user
.
can?
(
:admin_issue
,
master_project
)).
to
eq
(
true
)
expect
(
user
.
can?
(
:admin_issue
,
developer_project
)).
to
eq
(
true
)
expect
(
user
.
can?
(
:admin_issue
,
developer_project
)).
to
eq
(
true
)
expect
(
user
.
can?
(
:admin_issue
,
reporter_project
)).
to
eq
(
true
)
expect
(
user
.
can?
(
:admin_issue
,
reporter_project
)).
to
eq
(
true
)
...
...
spec/requests/api/merge_request_diffs_spec.rb
View file @
cfd475a4
...
@@ -14,7 +14,7 @@ describe API::MergeRequestDiffs, 'MergeRequestDiffs' do
...
@@ -14,7 +14,7 @@ describe API::MergeRequestDiffs, 'MergeRequestDiffs' do
describe
'GET /projects/:id/merge_requests/:merge_request_iid/versions'
do
describe
'GET /projects/:id/merge_requests/:merge_request_iid/versions'
do
it
'returns 200 for a valid merge request'
do
it
'returns 200 for a valid merge request'
do
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/versions"
,
user
)
get
api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
iid
}
/versions"
,
user
)
merge_request_diff
=
merge_request
.
merge_request_diffs
.
fir
st
merge_request_diff
=
merge_request
.
merge_request_diffs
.
la
st
expect
(
response
.
status
).
to
eq
200
expect
(
response
.
status
).
to
eq
200
expect
(
response
).
to
include_pagination_headers
expect
(
response
).
to
include_pagination_headers
...
...
spec/requests/api/projects_spec.rb
View file @
cfd475a4
...
@@ -574,7 +574,7 @@ describe API::Projects do
...
@@ -574,7 +574,7 @@ describe API::Projects do
expect
{
post
api
(
"/projects/user/
#{
user
.
id
}
"
,
admin
),
name:
'Foo Project'
}.
to
change
{
Project
.
count
}.
by
(
1
)
expect
{
post
api
(
"/projects/user/
#{
user
.
id
}
"
,
admin
),
name:
'Foo Project'
}.
to
change
{
Project
.
count
}.
by
(
1
)
expect
(
response
).
to
have_http_status
(
201
)
expect
(
response
).
to
have_http_status
(
201
)
project
=
Project
.
fir
st
project
=
Project
.
la
st
expect
(
project
.
name
).
to
eq
(
'Foo Project'
)
expect
(
project
.
name
).
to
eq
(
'Foo Project'
)
expect
(
project
.
path
).
to
eq
(
'foo-project'
)
expect
(
project
.
path
).
to
eq
(
'foo-project'
)
...
@@ -585,7 +585,7 @@ describe API::Projects do
...
@@ -585,7 +585,7 @@ describe API::Projects do
.
to
change
{
Project
.
count
}.
by
(
1
)
.
to
change
{
Project
.
count
}.
by
(
1
)
expect
(
response
).
to
have_http_status
(
201
)
expect
(
response
).
to
have_http_status
(
201
)
project
=
Project
.
fir
st
project
=
Project
.
la
st
expect
(
project
.
name
).
to
eq
(
'Foo Project'
)
expect
(
project
.
name
).
to
eq
(
'Foo Project'
)
expect
(
project
.
path
).
to
eq
(
'path-project-Foo'
)
expect
(
project
.
path
).
to
eq
(
'path-project-Foo'
)
...
...
spec/requests/api/v3/merge_request_diffs_spec.rb
View file @
cfd475a4
...
@@ -14,7 +14,7 @@ describe API::V3::MergeRequestDiffs, 'MergeRequestDiffs' do
...
@@ -14,7 +14,7 @@ describe API::V3::MergeRequestDiffs, 'MergeRequestDiffs' do
describe
'GET /projects/:id/merge_requests/:merge_request_id/versions'
do
describe
'GET /projects/:id/merge_requests/:merge_request_id/versions'
do
it
'returns 200 for a valid merge request'
do
it
'returns 200 for a valid merge request'
do
get
v3_api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
id
}
/versions"
,
user
)
get
v3_api
(
"/projects/
#{
project
.
id
}
/merge_requests/
#{
merge_request
.
id
}
/versions"
,
user
)
merge_request_diff
=
merge_request
.
merge_request_diffs
.
fir
st
merge_request_diff
=
merge_request
.
merge_request_diffs
.
la
st
expect
(
response
.
status
).
to
eq
200
expect
(
response
.
status
).
to
eq
200
expect
(
json_response
.
size
).
to
eq
(
merge_request
.
merge_request_diffs
.
size
)
expect
(
json_response
.
size
).
to
eq
(
merge_request
.
merge_request_diffs
.
size
)
...
...
spec/requests/projects/cycle_analytics_events_spec.rb
View file @
cfd475a4
...
@@ -93,7 +93,7 @@ describe 'cycle analytics events' do
...
@@ -93,7 +93,7 @@ describe 'cycle analytics events' do
context
'with private project and builds'
do
context
'with private project and builds'
do
before
do
before
do
project
.
members
.
fir
st
.
update
(
access_level:
Gitlab
::
Access
::
GUEST
)
project
.
members
.
la
st
.
update
(
access_level:
Gitlab
::
Access
::
GUEST
)
end
end
it
'does not list the test events'
do
it
'does not list the test events'
do
...
...
spec/services/notification_service_spec.rb
View file @
cfd475a4
...
@@ -1237,7 +1237,7 @@ describe NotificationService, :mailer do
...
@@ -1237,7 +1237,7 @@ describe NotificationService, :mailer do
end
end
it
do
it
do
group_member
=
group
.
members
.
fir
st
group_member
=
group
.
members
.
la
st
expect
do
expect
do
notification
.
decline_group_invite
(
group_member
)
notification
.
decline_group_invite
(
group_member
)
...
@@ -1285,7 +1285,7 @@ describe NotificationService, :mailer do
...
@@ -1285,7 +1285,7 @@ describe NotificationService, :mailer do
end
end
it
do
it
do
project_member
=
project
.
members
.
fir
st
project_member
=
project
.
members
.
la
st
expect
do
expect
do
notification
.
decline_project_invite
(
project_member
)
notification
.
decline_project_invite
(
project_member
)
...
...
spec/support/controllers/githubish_import_controller_shared_examples.rb
View file @
cfd475a4
...
@@ -140,9 +140,14 @@ shared_examples 'a GitHub-ish import controller: POST create' do
...
@@ -140,9 +140,14 @@ shared_examples 'a GitHub-ish import controller: POST create' do
end
end
context
"when a namespace with the provider user's username already exists"
do
context
"when a namespace with the provider user's username already exists"
do
let!
(
:existing_namespace
)
{
create
(
:namespace
,
name:
other_username
,
owner:
user
)
}
let!
(
:existing_namespace
)
{
user
.
namespace
}
context
"when the namespace is owned by the GitLab user"
do
context
"when the namespace is owned by the GitLab user"
do
before
do
user
.
username
=
other_username
user
.
save
end
it
"takes the existing namespace"
do
it
"takes the existing namespace"
do
expect
(
Gitlab
::
GithubImport
::
ProjectCreator
)
expect
(
Gitlab
::
GithubImport
::
ProjectCreator
)
.
to
receive
(
:new
).
with
(
provider_repo
,
provider_repo
.
name
,
existing_namespace
,
user
,
access_params
,
type:
provider
)
.
to
receive
(
:new
).
with
(
provider_repo
,
provider_repo
.
name
,
existing_namespace
,
user
,
access_params
,
type:
provider
)
...
@@ -153,12 +158,9 @@ shared_examples 'a GitHub-ish import controller: POST create' do
...
@@ -153,12 +158,9 @@ shared_examples 'a GitHub-ish import controller: POST create' do
end
end
context
"when the namespace is not owned by the GitLab user"
do
context
"when the namespace is not owned by the GitLab user"
do
before
do
existing_namespace
.
owner
=
create
(
:user
)
existing_namespace
.
save
end
it
"creates a project using user's namespace"
do
it
"creates a project using user's namespace"
do
create
(
:user
,
username:
other_username
)
expect
(
Gitlab
::
GithubImport
::
ProjectCreator
)
expect
(
Gitlab
::
GithubImport
::
ProjectCreator
)
.
to
receive
(
:new
).
with
(
provider_repo
,
provider_repo
.
name
,
user
.
namespace
,
user
,
access_params
,
type:
provider
)
.
to
receive
(
:new
).
with
(
provider_repo
,
provider_repo
.
name
,
user
.
namespace
,
user
,
access_params
,
type:
provider
)
.
and_return
(
double
(
execute:
true
))
.
and_return
(
double
(
execute:
true
))
...
...
spec/workers/post_receive_spec.rb
View file @
cfd475a4
...
@@ -127,6 +127,7 @@ describe PostReceive do
...
@@ -127,6 +127,7 @@ describe PostReceive do
it
"asks the project to trigger all hooks"
do
it
"asks the project to trigger all hooks"
do
allow
(
Project
).
to
receive
(
:find_by
).
and_return
(
project
)
allow
(
Project
).
to
receive
(
:find_by
).
and_return
(
project
)
expect
(
project
).
to
receive
(
:execute_hooks
).
twice
expect
(
project
).
to
receive
(
:execute_hooks
).
twice
expect
(
project
).
to
receive
(
:execute_services
).
twice
expect
(
project
).
to
receive
(
:execute_services
).
twice
...
@@ -135,6 +136,7 @@ describe PostReceive do
...
@@ -135,6 +136,7 @@ describe PostReceive do
it
"enqueues a UpdateMergeRequestsWorker job"
do
it
"enqueues a UpdateMergeRequestsWorker job"
do
allow
(
Project
).
to
receive
(
:find_by
).
and_return
(
project
)
allow
(
Project
).
to
receive
(
:find_by
).
and_return
(
project
)
expect
(
UpdateMergeRequestsWorker
).
to
receive
(
:perform_async
).
with
(
project
.
id
,
project
.
owner
.
id
,
any_args
)
expect
(
UpdateMergeRequestsWorker
).
to
receive
(
:perform_async
).
with
(
project
.
id
,
project
.
owner
.
id
,
any_args
)
described_class
.
new
.
perform
(
gl_repository
,
key_id
,
base64_changes
)
described_class
.
new
.
perform
(
gl_repository
,
key_id
,
base64_changes
)
...
...
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