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
Hide 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"
...
@@ -777,37 +777,37 @@ ActiveRecord::Schema.define(version: 20160610301627) do
...
@@ -777,37 +777,37 @@ ActiveRecord::Schema.define(version: 20160610301627) do
t
.
datetime
"created_at"
t
.
datetime
"created_at"
t
.
datetime
"updated_at"
t
.
datetime
"updated_at"
t
.
integer
"creator_id"
t
.
integer
"creator_id"
t
.
boolean
"issues_enabled"
,
default:
true
,
null:
false
t
.
boolean
"issues_enabled"
,
default:
true
,
null:
false
t
.
boolean
"merge_requests_enabled"
,
default:
true
,
null:
false
t
.
boolean
"merge_requests_enabled"
,
default:
true
,
null:
false
t
.
boolean
"wiki_enabled"
,
default:
true
,
null:
false
t
.
boolean
"wiki_enabled"
,
default:
true
,
null:
false
t
.
integer
"namespace_id"
t
.
integer
"namespace_id"
t
.
boolean
"snippets_enabled"
,
default:
true
,
null:
false
t
.
boolean
"snippets_enabled"
,
default:
true
,
null:
false
t
.
datetime
"last_activity_at"
t
.
datetime
"last_activity_at"
t
.
string
"import_url"
t
.
string
"import_url"
t
.
integer
"visibility_level"
,
default:
0
,
null:
false
t
.
integer
"visibility_level"
,
default:
0
,
null:
false
t
.
boolean
"archived"
,
default:
false
,
null:
false
t
.
boolean
"archived"
,
default:
false
,
null:
false
t
.
string
"avatar"
t
.
string
"avatar"
t
.
string
"import_status"
t
.
string
"import_status"
t
.
float
"repository_size"
,
default:
0.0
t
.
float
"repository_size"
,
default:
0.0
t
.
integer
"star_count"
,
default:
0
,
null:
false
t
.
integer
"star_count"
,
default:
0
,
null:
false
t
.
string
"import_type"
t
.
string
"import_type"
t
.
string
"import_source"
t
.
string
"import_source"
t
.
integer
"commit_count"
,
default:
0
t
.
integer
"commit_count"
,
default:
0
t
.
text
"import_error"
t
.
text
"import_error"
t
.
integer
"ci_id"
t
.
integer
"ci_id"
t
.
boolean
"builds_enabled"
,
default:
true
,
null:
false
t
.
boolean
"builds_enabled"
,
default:
true
,
null:
false
t
.
boolean
"shared_runners_enabled"
,
default:
true
,
null:
false
t
.
boolean
"shared_runners_enabled"
,
default:
true
,
null:
false
t
.
string
"runners_token"
t
.
string
"runners_token"
t
.
string
"build_coverage_regex"
t
.
string
"build_coverage_regex"
t
.
boolean
"build_allow_git_fetch"
,
default:
true
,
null:
false
t
.
boolean
"build_allow_git_fetch"
,
default:
true
,
null:
false
t
.
integer
"build_timeout"
,
default:
3600
,
null:
false
t
.
integer
"build_timeout"
,
default:
3600
,
null:
false
t
.
boolean
"pending_delete"
,
default:
false
t
.
boolean
"pending_delete"
,
default:
false
t
.
boolean
"public_builds"
,
default:
true
,
null:
false
t
.
boolean
"public_builds"
,
default:
true
,
null:
false
t
.
integer
"pushes_since_gc"
,
default:
0
t
.
integer
"pushes_since_gc"
,
default:
0
t
.
boolean
"last_repository_check_failed"
t
.
boolean
"last_repository_check_failed"
t
.
datetime
"last_repository_check_at"
t
.
datetime
"last_repository_check_at"
t
.
boolean
"container_registry_enabled"
t
.
boolean
"container_registry_enabled"
t
.
boolean
"only_allow_merge_if_build_succeeds"
,
default:
false
,
null:
false
t
.
boolean
"only_allow_merge_if_build_succeeds"
,
default:
false
,
null:
false
t
.
boolean
"has_external_issue_tracker"
t
.
boolean
"has_external_issue_tracker"
end
end
...
...
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