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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gitlab-ce
Commits
2541e50d
Commit
2541e50d
authored
Jun 15, 2016
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve validations
parent
14a02a6a
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
31 additions
and
34 deletions
+31
-34
app/models/deployment.rb
app/models/deployment.rb
+2
-4
app/models/environment.rb
app/models/environment.rb
+1
-3
db/migrate/20160610204157_add_deployments.rb
db/migrate/20160610204157_add_deployments.rb
+6
-6
db/migrate/20160610204158_add_environments.rb
db/migrate/20160610204158_add_environments.rb
+1
-1
db/schema.rb
db/schema.rb
+20
-20
spec/factories/deployments.rb
spec/factories/deployments.rb
+1
-0
No files found.
app/models/deployment.rb
View file @
2541e50d
class
Deployment
<
ActiveRecord
::
Base
class
Deployment
<
ActiveRecord
::
Base
include
InternalId
include
InternalId
belongs_to
:project
belongs_to
:project
,
required:
true
belongs_to
:environment
belongs_to
:environment
,
required:
true
belongs_to
:user
belongs_to
:user
belongs_to
:deployable
,
polymorphic:
true
belongs_to
:deployable
,
polymorphic:
true
validates
:sha
,
presence:
true
validates
:sha
,
presence:
true
validates
:ref
,
presence:
true
validates
:ref
,
presence:
true
validates
:project
,
associated:
true
validates
:environment
,
associated:
true
delegate
:name
,
to: :environment
,
prefix:
true
delegate
:name
,
to: :environment
,
prefix:
true
...
...
app/models/environment.rb
View file @
2541e50d
class
Environment
<
ActiveRecord
::
Base
class
Environment
<
ActiveRecord
::
Base
belongs_to
:project
belongs_to
:project
,
required:
true
has_many
:deployments
has_many
:deployments
...
@@ -10,8 +10,6 @@ class Environment < ActiveRecord::Base
...
@@ -10,8 +10,6 @@ class Environment < ActiveRecord::Base
format:
{
with:
Gitlab
::
Regex
.
environment_name_regex
,
format:
{
with:
Gitlab
::
Regex
.
environment_name_regex
,
message:
Gitlab
::
Regex
.
environment_name_regex_message
}
message:
Gitlab
::
Regex
.
environment_name_regex_message
}
validates
:project
,
associated:
true
def
last_deployment
def
last_deployment
deployments
.
last
deployments
.
last
end
end
...
...
db/migrate/20160610204157_add_deployments.rb
View file @
2541e50d
...
@@ -6,12 +6,12 @@ class AddDeployments < ActiveRecord::Migration
...
@@ -6,12 +6,12 @@ class AddDeployments < ActiveRecord::Migration
def
change
def
change
create_table
:deployments
,
force:
true
do
|
t
|
create_table
:deployments
,
force:
true
do
|
t
|
t
.
integer
:iid
t
.
integer
:iid
,
null:
false
t
.
integer
:project_id
t
.
integer
:project_id
,
null:
false
t
.
integer
:environment_id
t
.
integer
:environment_id
,
null:
false
t
.
string
:ref
t
.
string
:ref
,
null:
false
t
.
boolean
:tag
t
.
boolean
:tag
,
null:
false
t
.
string
:sha
t
.
string
:sha
,
null:
false
t
.
integer
:user_id
t
.
integer
:user_id
t
.
integer
:deployable_id
t
.
integer
:deployable_id
t
.
string
:deployable_type
t
.
string
:deployable_type
...
...
db/migrate/20160610204158_add_environments.rb
View file @
2541e50d
...
@@ -6,7 +6,7 @@ class AddEnvironments < ActiveRecord::Migration
...
@@ -6,7 +6,7 @@ class AddEnvironments < ActiveRecord::Migration
def
change
def
change
create_table
:environments
,
force:
true
do
|
t
|
create_table
:environments
,
force:
true
do
|
t
|
t
.
integer
:project_id
t
.
integer
:project_id
,
null:
false
t
.
string
:name
,
null:
false
t
.
string
:name
,
null:
false
t
.
datetime
:created_at
t
.
datetime
:created_at
t
.
datetime
:updated_at
t
.
datetime
:updated_at
...
...
db/schema.rb
View file @
2541e50d
...
@@ -384,12 +384,12 @@ ActiveRecord::Schema.define(version: 20160610301627) do
...
@@ -384,12 +384,12 @@ ActiveRecord::Schema.define(version: 20160610301627) do
add_index
"deploy_keys_projects"
,
[
"project_id"
],
name:
"index_deploy_keys_projects_on_project_id"
,
using: :btree
add_index
"deploy_keys_projects"
,
[
"project_id"
],
name:
"index_deploy_keys_projects_on_project_id"
,
using: :btree
create_table
"deployments"
,
force: :cascade
do
|
t
|
create_table
"deployments"
,
force: :cascade
do
|
t
|
t
.
integer
"iid"
t
.
integer
"iid"
,
null:
false
t
.
integer
"project_id"
t
.
integer
"project_id"
,
null:
false
t
.
integer
"environment_id"
t
.
integer
"environment_id"
,
null:
false
t
.
string
"ref"
t
.
string
"ref"
,
null:
false
t
.
boolean
"tag"
t
.
boolean
"tag"
,
null:
false
t
.
string
"sha"
t
.
string
"sha"
,
null:
false
t
.
integer
"user_id"
t
.
integer
"user_id"
t
.
integer
"deployable_id"
t
.
integer
"deployable_id"
t
.
string
"deployable_type"
t
.
string
"deployable_type"
...
@@ -413,7 +413,7 @@ ActiveRecord::Schema.define(version: 20160610301627) do
...
@@ -413,7 +413,7 @@ ActiveRecord::Schema.define(version: 20160610301627) do
add_index
"emails"
,
[
"user_id"
],
name:
"index_emails_on_user_id"
,
using: :btree
add_index
"emails"
,
[
"user_id"
],
name:
"index_emails_on_user_id"
,
using: :btree
create_table
"environments"
,
force: :cascade
do
|
t
|
create_table
"environments"
,
force: :cascade
do
|
t
|
t
.
integer
"project_id"
t
.
integer
"project_id"
,
null:
false
t
.
string
"name"
,
null:
false
t
.
string
"name"
,
null:
false
t
.
datetime
"created_at"
t
.
datetime
"created_at"
t
.
datetime
"updated_at"
t
.
datetime
"updated_at"
...
...
spec/factories/deployments.rb
View file @
2541e50d
...
@@ -2,6 +2,7 @@ FactoryGirl.define do
...
@@ -2,6 +2,7 @@ FactoryGirl.define do
factory
:deployment
,
class:
Deployment
do
factory
:deployment
,
class:
Deployment
do
sha
'97de212e80737a608d939f648d959671fb0a0142'
sha
'97de212e80737a608d939f648d959671fb0a0142'
ref
'master'
ref
'master'
tag
false
environment
factory: :environment
environment
factory: :environment
...
...
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