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
18a15693
Commit
18a15693
authored
Apr 06, 2018
by
Mayra Cabrera
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handles default expires_at date directly into DeployToken model
parent
8c276580
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
17 additions
and
7 deletions
+17
-7
app/helpers/deploy_tokens_helper.rb
app/helpers/deploy_tokens_helper.rb
+2
-2
app/models/deploy_token.rb
app/models/deploy_token.rb
+3
-1
app/services/deploy_tokens/create_service.rb
app/services/deploy_tokens/create_service.rb
+1
-1
db/migrate/20180319190020_create_deploy_tokens.rb
db/migrate/20180319190020_create_deploy_tokens.rb
+1
-1
db/schema.rb
db/schema.rb
+1
-1
spec/services/deploy_tokens/create_service_spec.rb
spec/services/deploy_tokens/create_service_spec.rb
+9
-1
No files found.
app/helpers/deploy_tokens_helper.rb
View file @
18a15693
...
...
@@ -11,10 +11,10 @@ module DeployTokensHelper
end
def
expires_at_value
(
expires_at
)
expires_at
unless
expires_at
>=
DeployToken
::
F
UTURE_DATE
expires_at
unless
expires_at
>=
DeployToken
::
F
OREVER
end
def
show_expire_at?
(
token
)
token
.
expires?
&&
token
.
expires_at
!=
DeployToken
::
F
UTURE_DATE
token
.
expires?
&&
token
.
expires_at
!=
DeployToken
::
F
OREVER
end
end
app/models/deploy_token.rb
View file @
18a15693
...
...
@@ -4,7 +4,9 @@ class DeployToken < ActiveRecord::Base
add_authentication_token_field
:token
AVAILABLE_SCOPES
=
%i(read_repository read_registry)
.
freeze
FUTURE_DATE
=
Date
.
new
(
3000
-
01
-
01
)
FOREVER
=
DateTime
.
new
(
3000
,
1
,
1
)
default_value_for
:expires_at
,
FOREVER
has_many
:project_deploy_tokens
,
inverse_of: :deploy_token
has_many
:projects
,
through: :project_deploy_tokens
...
...
app/services/deploy_tokens/create_service.rb
View file @
18a15693
...
...
@@ -16,7 +16,7 @@ module DeployTokens
end
def
default_expires_at
DeployToken
::
F
UTURE_DATE
DeployToken
::
F
OREVER
end
end
end
db/migrate/20180319190020_create_deploy_tokens.rb
View file @
18a15693
...
...
@@ -7,7 +7,7 @@ class CreateDeployTokens < ActiveRecord::Migration
t
.
boolean
:read_repository
,
null:
false
,
default:
false
t
.
boolean
:read_registry
,
null:
false
,
default:
false
t
.
datetime_with_timezone
:expires_at
,
null:
false
,
default:
'3000-01-01'
t
.
datetime_with_timezone
:expires_at
,
null:
false
t
.
datetime_with_timezone
:created_at
,
null:
false
t
.
string
:name
,
null:
false
...
...
db/schema.rb
View file @
18a15693
...
...
@@ -687,7 +687,7 @@ ActiveRecord::Schema.define(version: 20180405142733) do
t
.
boolean
"revoked"
,
default:
false
t
.
boolean
"read_repository"
,
default:
false
,
null:
false
t
.
boolean
"read_registry"
,
default:
false
,
null:
false
t
.
datetime_with_timezone
"expires_at"
,
default:
'3000-01-01 00:00:00'
,
null:
false
t
.
datetime_with_timezone
"expires_at"
,
null:
false
t
.
datetime_with_timezone
"created_at"
,
null:
false
t
.
string
"name"
,
null:
false
t
.
string
"token"
,
null:
false
...
...
spec/services/deploy_tokens/create_service_spec.rb
View file @
18a15693
require
'spec_helper'
describe
DeployTokens
::
CreateService
,
:clean_gitlab_redis_shared_state
do
describe
DeployTokens
::
CreateService
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:deploy_token_params
)
{
attributes_for
(
:deploy_token
)
}
...
...
@@ -22,6 +22,14 @@ describe DeployTokens::CreateService, :clean_gitlab_redis_shared_state do
end
end
context
'when expires at date is not passed'
do
let
(
:deploy_token_params
)
{
attributes_for
(
:deploy_token
,
expires_at:
''
)
}
it
'should set FOREVER date'
do
expect
(
subject
.
expires_at
).
to
eq
(
DeployToken
::
FOREVER
)
end
end
context
'when the deploy token is invalid'
do
let
(
:deploy_token_params
)
{
attributes_for
(
:deploy_token
,
read_repository:
false
,
read_registry:
false
)
}
...
...
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