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
Léo-Paul Géneau
gitlab-ce
Commits
9b0e8a09
Commit
9b0e8a09
authored
Feb 27, 2018
by
haseeb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added forign key and specs
parent
f211e47e
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
15 additions
and
1 deletion
+15
-1
app/models/user.rb
app/models/user.rb
+1
-0
db/migrate/20180209165249_add_closed_by_to_issues.rb
db/migrate/20180209165249_add_closed_by_to_issues.rb
+8
-1
db/schema.rb
db/schema.rb
+2
-0
spec/services/issues/close_service_spec.rb
spec/services/issues/close_service_spec.rb
+4
-0
No files found.
app/models/user.rb
View file @
9b0e8a09
...
@@ -135,6 +135,7 @@ class User < ActiveRecord::Base
...
@@ -135,6 +135,7 @@ class User < ActiveRecord::Base
has_many
:issue_assignees
has_many
:issue_assignees
has_many
:assigned_issues
,
class_name:
"Issue"
,
through: :issue_assignees
,
source: :issue
has_many
:assigned_issues
,
class_name:
"Issue"
,
through: :issue_assignees
,
source: :issue
has_many
:assigned_merge_requests
,
dependent: :nullify
,
foreign_key: :assignee_id
,
class_name:
"MergeRequest"
# rubocop:disable Cop/ActiveRecordDependent
has_many
:assigned_merge_requests
,
dependent: :nullify
,
foreign_key: :assignee_id
,
class_name:
"MergeRequest"
# rubocop:disable Cop/ActiveRecordDependent
has_many
:closed_issues
,
class_name:
'Issue'
,
dependent: :nullify
,
foreign_key: :closed_by_id
has_many
:custom_attributes
,
class_name:
'UserCustomAttribute'
has_many
:custom_attributes
,
class_name:
'UserCustomAttribute'
has_many
:callouts
,
class_name:
'UserCallout'
has_many
:callouts
,
class_name:
'UserCallout'
...
...
db/migrate/20180209165249_add_closed_by_to_issues.rb
View file @
9b0e8a09
...
@@ -4,10 +4,17 @@
...
@@ -4,10 +4,17 @@
class
AddClosedByToIssues
<
ActiveRecord
::
Migration
class
AddClosedByToIssues
<
ActiveRecord
::
Migration
include
Gitlab
::
Database
::
MigrationHelpers
include
Gitlab
::
Database
::
MigrationHelpers
disable_ddl_transaction!
# Set this constant to true if this migration requires downtime.
# Set this constant to true if this migration requires downtime.
DOWNTIME
=
false
DOWNTIME
=
false
def
change
def
up
add_column
:issues
,
:closed_by_id
,
:integer
add_column
:issues
,
:closed_by_id
,
:integer
add_concurrent_foreign_key
:issues
,
:users
,
column: :closed_by_id
,
on_delete: :nullify
end
def
down
remove_foreign_key
:issues
,
column: :closed_by_id
remove_column
:issues
,
:closed_by_id
end
end
end
end
db/schema.rb
View file @
9b0e8a09
...
@@ -876,6 +876,7 @@ ActiveRecord::Schema.define(version: 20180216121030) do
...
@@ -876,6 +876,7 @@ ActiveRecord::Schema.define(version: 20180216121030) do
t
.
integer
"last_edited_by_id"
t
.
integer
"last_edited_by_id"
t
.
boolean
"discussion_locked"
t
.
boolean
"discussion_locked"
t
.
datetime_with_timezone
"closed_at"
t
.
datetime_with_timezone
"closed_at"
t
.
integer
"closed_by_id"
end
end
add_index
"issues"
,
[
"author_id"
],
name:
"index_issues_on_author_id"
,
using: :btree
add_index
"issues"
,
[
"author_id"
],
name:
"index_issues_on_author_id"
,
using: :btree
...
@@ -2013,6 +2014,7 @@ ActiveRecord::Schema.define(version: 20180216121030) do
...
@@ -2013,6 +2014,7 @@ ActiveRecord::Schema.define(version: 20180216121030) do
add_foreign_key
"issues"
,
"milestones"
,
name:
"fk_96b1dd429c"
,
on_delete: :nullify
add_foreign_key
"issues"
,
"milestones"
,
name:
"fk_96b1dd429c"
,
on_delete: :nullify
add_foreign_key
"issues"
,
"projects"
,
name:
"fk_899c8f3231"
,
on_delete: :cascade
add_foreign_key
"issues"
,
"projects"
,
name:
"fk_899c8f3231"
,
on_delete: :cascade
add_foreign_key
"issues"
,
"users"
,
column:
"author_id"
,
name:
"fk_05f1e72feb"
,
on_delete: :nullify
add_foreign_key
"issues"
,
"users"
,
column:
"author_id"
,
name:
"fk_05f1e72feb"
,
on_delete: :nullify
add_foreign_key
"issues"
,
"users"
,
column:
"closed_by_id"
,
name:
"fk_c63cbf6c25"
,
on_delete: :nullify
add_foreign_key
"issues"
,
"users"
,
column:
"updated_by_id"
,
name:
"fk_ffed080f01"
,
on_delete: :nullify
add_foreign_key
"issues"
,
"users"
,
column:
"updated_by_id"
,
name:
"fk_ffed080f01"
,
on_delete: :nullify
add_foreign_key
"label_priorities"
,
"labels"
,
on_delete: :cascade
add_foreign_key
"label_priorities"
,
"labels"
,
on_delete: :cascade
add_foreign_key
"label_priorities"
,
"projects"
,
on_delete: :cascade
add_foreign_key
"label_priorities"
,
"projects"
,
on_delete: :cascade
...
...
spec/services/issues/close_service_spec.rb
View file @
9b0e8a09
...
@@ -67,6 +67,10 @@ describe Issues::CloseService do
...
@@ -67,6 +67,10 @@ describe Issues::CloseService do
expect
(
issue
).
to
be_closed
expect
(
issue
).
to
be_closed
end
end
it
'records closed user'
do
expect
(
issue
.
closed_by_id
).
to
be
(
user
.
id
)
end
it
'sends email to user2 about assign of new issue'
do
it
'sends email to user2 about assign of new issue'
do
email
=
ActionMailer
::
Base
.
deliveries
.
last
email
=
ActionMailer
::
Base
.
deliveries
.
last
expect
(
email
.
to
.
first
).
to
eq
(
user2
.
email
)
expect
(
email
.
to
.
first
).
to
eq
(
user2
.
email
)
...
...
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