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
94c19fbf
Commit
94c19fbf
authored
Mar 15, 2017
by
Felipe Artur
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add closed_at field to issues
parent
e6f4a4c1
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
46 additions
and
1 deletion
+46
-1
app/models/issue.rb
app/models/issue.rb
+8
-0
changelogs/unreleased/issue_27212.yml
changelogs/unreleased/issue_27212.yml
+4
-0
db/migrate/20170315194013_add_closed_at_to_issues.rb
db/migrate/20170315194013_add_closed_at_to_issues.rb
+7
-0
db/schema.rb
db/schema.rb
+2
-1
spec/lib/gitlab/import_export/safe_model_attributes.yml
spec/lib/gitlab/import_export/safe_model_attributes.yml
+1
-0
spec/models/issue_spec.rb
spec/models/issue_spec.rb
+24
-0
No files found.
app/models/issue.rb
View file @
94c19fbf
...
...
@@ -55,6 +55,14 @@ class Issue < ActiveRecord::Base
state
:opened
state
:reopened
state
:closed
before_transition
any
=>
:closed
do
|
issue
|
issue
.
closed_at
=
Time
.
zone
.
now
end
before_transition
closed:
any
do
|
issue
|
issue
.
closed_at
=
nil
end
end
def
hook_attrs
...
...
changelogs/unreleased/issue_27212.yml
0 → 100644
View file @
94c19fbf
---
title
:
Add closed_at field to issues
merge_request
:
author
:
db/migrate/20170315194013_add_closed_at_to_issues.rb
0 → 100644
View file @
94c19fbf
class
AddClosedAtToIssues
<
ActiveRecord
::
Migration
DOWNTIME
=
false
def
change
add_column
:issues
,
:closed_at
,
:datetime
end
end
db/schema.rb
View file @
94c19fbf
...
...
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord
::
Schema
.
define
(
version:
201703151
74634
)
do
ActiveRecord
::
Schema
.
define
(
version:
201703151
94013
)
do
# These are extensions that must be enabled in order to support this database
enable_extension
"plpgsql"
...
...
@@ -531,6 +531,7 @@ ActiveRecord::Schema.define(version: 20170315174634) do
t
.
text
"description_html"
t
.
integer
"time_estimate"
t
.
integer
"relative_position"
t
.
datetime
"closed_at"
end
add_index
"issues"
,
[
"assignee_id"
],
name:
"index_issues_on_assignee_id"
,
using: :btree
...
...
spec/lib/gitlab/import_export/safe_model_attributes.yml
View file @
94c19fbf
...
...
@@ -15,6 +15,7 @@ Issue:
-
updated_by_id
-
confidential
-
deleted_at
-
closed_at
-
due_date
-
moved_to_id
-
lock_version
...
...
spec/models/issue_spec.rb
View file @
94c19fbf
...
...
@@ -37,6 +37,30 @@ describe Issue, models: true do
end
end
describe
'#closed_at'
do
after
do
Timecop
.
return
end
let!
(
:now
)
{
Timecop
.
freeze
(
Time
.
now
)
}
it
'sets closed_at to Time.now when issue is closed'
do
issue
=
create
(
:issue
,
state:
'opened'
)
issue
.
close
expect
(
issue
.
closed_at
).
to
eq
(
now
)
end
it
'sets closed_at to nil when issue is reopened'
do
issue
=
create
(
:issue
,
state:
'closed'
)
issue
.
reopen
expect
(
issue
.
closed_at
).
to
be_nil
end
end
describe
'#to_reference'
do
let
(
:namespace
)
{
build
(
:namespace
,
path:
'sample-namespace'
)
}
let
(
:project
)
{
build
(
:empty_project
,
name:
'sample-project'
,
namespace:
namespace
)
}
...
...
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