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
Boxiang Sun
gitlab-ce
Commits
34be1835
Commit
34be1835
authored
May 05, 2017
by
Valery Sizov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Multiple issue assignee] Fix a number of specs
parent
c4094b7e
Changes
11
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
32 additions
and
54 deletions
+32
-54
app/models/concerns/issuable.rb
app/models/concerns/issuable.rb
+0
-1
app/services/members/authorized_destroy_service.rb
app/services/members/authorized_destroy_service.rb
+11
-4
app/services/system_note_service.rb
app/services/system_note_service.rb
+1
-1
db/migrate/20170320171632_create_issue_assignees_table.rb
db/migrate/20170320171632_create_issue_assignees_table.rb
+1
-1
db/schema.rb
db/schema.rb
+1
-1
lib/github/import.rb
lib/github/import.rb
+1
-1
spec/features/dashboard/issuables_counter_spec.rb
spec/features/dashboard/issuables_counter_spec.rb
+2
-0
spec/finders/issues_finder_spec.rb
spec/finders/issues_finder_spec.rb
+11
-11
spec/requests/api/v3/issues_spec.rb
spec/requests/api/v3/issues_spec.rb
+0
-32
spec/services/system_note_service_spec.rb
spec/services/system_note_service_spec.rb
+3
-1
spec/services/users/destroy_service_spec.rb
spec/services/users/destroy_service_spec.rb
+1
-1
No files found.
app/models/concerns/issuable.rb
View file @
34be1835
...
@@ -94,7 +94,6 @@ module Issuable
...
@@ -94,7 +94,6 @@ module Issuable
acts_as_paranoid
acts_as_paranoid
after_save
:update_assignee_cache_counts
,
if: :assignee_id_changed?
after_save
:record_metrics
,
unless: :imported?
after_save
:record_metrics
,
unless: :imported?
# We want to use optimistic lock for cases when only title or description are involved
# We want to use optimistic lock for cases when only title or description are involved
...
...
app/services/members/authorized_destroy_service.rb
View file @
34be1835
...
@@ -26,15 +26,22 @@ module Members
...
@@ -26,15 +26,22 @@ module Members
def
unassign_issues_and_merge_requests
(
member
)
def
unassign_issues_and_merge_requests
(
member
)
if
member
.
is_a?
(
GroupMember
)
if
member
.
is_a?
(
GroupMember
)
IssuesFinder
.
new
(
user
,
group_id:
member
.
source_id
,
assignee_id:
member
.
user_id
).
issue_ids
=
IssuesFinder
.
new
(
user
,
group_id:
member
.
source_id
,
assignee_id:
member
.
user_id
).
execute
.
execute
.
pluck
(
:id
)
update_all
(
assignee_id:
nil
)
IssueAssignee
.
destroy_all
(
issue_id:
issue_ids
,
user_id:
member
.
user_id
)
MergeRequestsFinder
.
new
(
user
,
group_id:
member
.
source_id
,
assignee_id:
member
.
user_id
).
MergeRequestsFinder
.
new
(
user
,
group_id:
member
.
source_id
,
assignee_id:
member
.
user_id
).
execute
.
execute
.
update_all
(
assignee_id:
nil
)
update_all
(
assignee_id:
nil
)
else
else
project
=
member
.
source
project
=
member
.
source
project
.
issues
.
opened
.
assigned_to
(
member
.
user
).
update_all
(
assignee_id:
nil
)
IssueAssignee
.
destroy_all
(
user_id:
member
.
user_id
,
issue_id:
project
.
issues
.
opened
.
assigned_to
(
member
.
user
).
select
(
:id
)
)
project
.
merge_requests
.
opened
.
assigned_to
(
member
.
user
).
update_all
(
assignee_id:
nil
)
project
.
merge_requests
.
opened
.
assigned_to
(
member
.
user
).
update_all
(
assignee_id:
nil
)
member
.
user
.
update_cache_counts
member
.
user
.
update_cache_counts
end
end
...
...
app/services/system_note_service.rb
View file @
34be1835
...
@@ -84,7 +84,7 @@ module SystemNoteService
...
@@ -84,7 +84,7 @@ module SystemNoteService
"assigned to
#{
issue
.
assignees
.
map
(
&
:to_reference
).
to_sentence
}
"
"assigned to
#{
issue
.
assignees
.
map
(
&
:to_reference
).
to_sentence
}
"
end
end
NoteSummary
.
new
(
issue
,
project
,
author
,
body
,
action:
'assignee'
)
create_note
(
NoteSummary
.
new
(
issue
,
project
,
author
,
body
,
action:
'assignee'
)
)
end
end
# Called when one or more labels on a Noteable are added and/or removed
# Called when one or more labels on a Noteable are added and/or removed
...
...
db/migrate/20170320171632_create_issue_assignees_table.rb
View file @
34be1835
...
@@ -26,7 +26,7 @@ class CreateIssueAssigneesTable < ActiveRecord::Migration
...
@@ -26,7 +26,7 @@ class CreateIssueAssigneesTable < ActiveRecord::Migration
# disable_ddl_transaction!
# disable_ddl_transaction!
def
up
def
up
create_table
:issue_assignees
,
id:
false
do
|
t
|
create_table
:issue_assignees
do
|
t
|
t
.
references
:user
,
foreign_key:
{
on_delete: :cascade
},
index:
true
,
null:
false
t
.
references
:user
,
foreign_key:
{
on_delete: :cascade
},
index:
true
,
null:
false
t
.
references
:issue
,
foreign_key:
{
on_delete: :cascade
},
null:
false
t
.
references
:issue
,
foreign_key:
{
on_delete: :cascade
},
null:
false
end
end
...
...
db/schema.rb
View file @
34be1835
...
@@ -452,7 +452,7 @@ ActiveRecord::Schema.define(version: 20170502091007) do
...
@@ -452,7 +452,7 @@ ActiveRecord::Schema.define(version: 20170502091007) do
add_index
"identities"
,
[
"user_id"
],
name:
"index_identities_on_user_id"
,
using: :btree
add_index
"identities"
,
[
"user_id"
],
name:
"index_identities_on_user_id"
,
using: :btree
create_table
"issue_assignees"
,
id:
false
,
force: :cascade
do
|
t
|
create_table
"issue_assignees"
,
force: :cascade
do
|
t
|
t
.
integer
"user_id"
,
null:
false
t
.
integer
"user_id"
,
null:
false
t
.
integer
"issue_id"
,
null:
false
t
.
integer
"issue_id"
,
null:
false
end
end
...
...
lib/github/import.rb
View file @
34be1835
...
@@ -245,7 +245,7 @@ module Github
...
@@ -245,7 +245,7 @@ module Github
issue
.
label_ids
=
label_ids
(
representation
.
labels
)
issue
.
label_ids
=
label_ids
(
representation
.
labels
)
issue
.
milestone_id
=
milestone_id
(
representation
.
milestone
)
issue
.
milestone_id
=
milestone_id
(
representation
.
milestone
)
issue
.
author_id
=
author_id
issue
.
author_id
=
author_id
issue
.
assignee_id
=
user_id
(
representation
.
assignee
)
issue
.
assignee_id
s
=
[
user_id
(
representation
.
assignee
)]
issue
.
created_at
=
representation
.
created_at
issue
.
created_at
=
representation
.
created_at
issue
.
updated_at
=
representation
.
updated_at
issue
.
updated_at
=
representation
.
updated_at
issue
.
save!
(
validate:
false
)
issue
.
save!
(
validate:
false
)
...
...
spec/features/dashboard/issuables_counter_spec.rb
View file @
34be1835
...
@@ -19,6 +19,8 @@ describe 'Navigation bar counter', feature: true, caching: true do
...
@@ -19,6 +19,8 @@ describe 'Navigation bar counter', feature: true, caching: true do
issue
.
assignees
=
[]
issue
.
assignees
=
[]
user
.
update_cache_counts
Timecop
.
travel
(
3
.
minutes
.
from_now
)
do
Timecop
.
travel
(
3
.
minutes
.
from_now
)
do
visit
issues_path
visit
issues_path
...
...
spec/finders/issues_finder_spec.rb
View file @
34be1835
require
'spec_helper'
require
'spec_helper'
describe
IssuesFinder
do
describe
IssuesFinder
do
l
et
(
:user
)
{
create
(
:user
)
}
s
et
(
:user
)
{
create
(
:user
)
}
l
et
(
:user2
)
{
create
(
:user
)
}
s
et
(
:user2
)
{
create
(
:user
)
}
l
et
(
:project1
)
{
create
(
:empty_project
)
}
s
et
(
:project1
)
{
create
(
:empty_project
)
}
l
et
(
:project2
)
{
create
(
:empty_project
)
}
s
et
(
:project2
)
{
create
(
:empty_project
)
}
l
et
(
:milestone
)
{
create
(
:milestone
,
project:
project1
)
}
s
et
(
:milestone
)
{
create
(
:milestone
,
project:
project1
)
}
l
et
(
:label
)
{
create
(
:label
,
project:
project2
)
}
s
et
(
:label
)
{
create
(
:label
,
project:
project2
)
}
l
et
(
:issue1
)
{
create
(
:issue
,
author:
user
,
assignees:
[
user
],
project:
project1
,
milestone:
milestone
,
title:
'gitlab'
)
}
s
et
(
:issue1
)
{
create
(
:issue
,
author:
user
,
assignees:
[
user
],
project:
project1
,
milestone:
milestone
,
title:
'gitlab'
)
}
l
et
(
:issue2
)
{
create
(
:issue
,
author:
user
,
assignees:
[
user
],
project:
project2
,
description:
'gitlab'
)
}
s
et
(
:issue2
)
{
create
(
:issue
,
author:
user
,
assignees:
[
user
],
project:
project2
,
description:
'gitlab'
)
}
l
et
(
:issue3
)
{
create
(
:issue
,
author:
user2
,
assignees:
[
user2
],
project:
project2
,
title:
'tanuki'
,
description:
'tanuki'
)
}
s
et
(
:issue3
)
{
create
(
:issue
,
author:
user2
,
assignees:
[
user2
],
project:
project2
,
title:
'tanuki'
,
description:
'tanuki'
)
}
describe
'#execute'
do
describe
'#execute'
do
l
et
(
:closed_issue
)
{
create
(
:issue
,
author:
user2
,
assignees:
[
user2
],
project:
project2
,
state:
'closed'
)
}
s
et
(
:closed_issue
)
{
create
(
:issue
,
author:
user2
,
assignees:
[
user2
],
project:
project2
,
state:
'closed'
)
}
let!
(
:label_link
)
{
create
(
:label_link
,
label:
label
,
target:
issue2
)
}
set
(
:label_link
)
{
create
(
:label_link
,
label:
label
,
target:
issue2
)
}
let
(
:search_user
)
{
user
}
let
(
:search_user
)
{
user
}
let
(
:params
)
{
{}
}
let
(
:params
)
{
{}
}
let
(
:issues
)
{
described_class
.
new
(
search_user
,
params
.
reverse_merge
(
scope:
scope
,
state:
'opened'
)).
execute
}
let
(
:issues
)
{
described_class
.
new
(
search_user
,
params
.
reverse_merge
(
scope:
scope
,
state:
'opened'
)).
execute
}
...
...
spec/requests/api/v3/issues_spec.rb
View file @
34be1835
...
@@ -1157,38 +1157,6 @@ describe API::V3::Issues do
...
@@ -1157,38 +1157,6 @@ describe API::V3::Issues do
end
end
end
end
describe
'PUT /projects/:id/issues/:issue_id to update weight'
do
it
'updates an issue with no weight'
do
put
v3_api
(
"/projects/
#{
project
.
id
}
/issues/
#{
issue
.
id
}
"
,
user
),
weight:
5
expect
(
response
).
to
have_http_status
(
200
)
expect
(
json_response
[
'weight'
]).
to
eq
(
5
)
end
it
'removes a weight from an issue'
do
weighted_issue
=
create
(
:issue
,
project:
project
,
weight:
2
)
put
v3_api
(
"/projects/
#{
project
.
id
}
/issues/
#{
weighted_issue
.
id
}
"
,
user
),
weight:
nil
expect
(
response
).
to
have_http_status
(
200
)
expect
(
json_response
[
'weight'
]).
to
be_nil
end
it
'returns 400 if weight is less than minimum weight'
do
put
v3_api
(
"/projects/
#{
project
.
id
}
/issues/
#{
issue
.
id
}
"
,
user
),
weight:
-
1
expect
(
response
).
to
have_http_status
(
400
)
expect
(
json_response
[
'error'
]).
to
eq
(
'weight does not have a valid value'
)
end
it
'returns 400 if weight is more than maximum weight'
do
put
v3_api
(
"/projects/
#{
project
.
id
}
/issues/
#{
issue
.
id
}
"
,
user
),
weight:
10
expect
(
response
).
to
have_http_status
(
400
)
expect
(
json_response
[
'error'
]).
to
eq
(
'weight does not have a valid value'
)
end
end
describe
"DELETE /projects/:id/issues/:issue_id"
do
describe
"DELETE /projects/:id/issues/:issue_id"
do
it
"rejects a non member from deleting an issue"
do
it
"rejects a non member from deleting an issue"
do
delete
v3_api
(
"/projects/
#{
project
.
id
}
/issues/
#{
issue
.
id
}
"
,
non_member
)
delete
v3_api
(
"/projects/
#{
project
.
id
}
/issues/
#{
issue
.
id
}
"
,
non_member
)
...
...
spec/services/system_note_service_spec.rb
View file @
34be1835
...
@@ -164,7 +164,9 @@ describe SystemNoteService, services: true do
...
@@ -164,7 +164,9 @@ describe SystemNoteService, services: true do
let
(
:assignee2
)
{
create
(
:user
)
}
let
(
:assignee2
)
{
create
(
:user
)
}
let
(
:assignee3
)
{
create
(
:user
)
}
let
(
:assignee3
)
{
create
(
:user
)
}
it_behaves_like
'a system note'
it_behaves_like
'a system note'
do
let
(
:action
)
{
'assignee'
}
end
def
build_note
(
old_assignees
,
new_assignees
)
def
build_note
(
old_assignees
,
new_assignees
)
issue
.
assignees
=
new_assignees
issue
.
assignees
=
new_assignees
...
...
spec/services/users/destroy_service_spec.rb
View file @
34be1835
...
@@ -60,7 +60,7 @@ describe Users::DestroyService, services: true do
...
@@ -60,7 +60,7 @@ describe Users::DestroyService, services: true do
it
'migrates the issue so that it is "Unassigned"'
do
it
'migrates the issue so that it is "Unassigned"'
do
migrated_issue
=
Issue
.
find_by_id
(
issue
.
id
)
migrated_issue
=
Issue
.
find_by_id
(
issue
.
id
)
expect
(
migrated_issue
.
assignees
).
to
be_
nil
expect
(
migrated_issue
.
assignees
).
to
be_
empty
end
end
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