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
e6487168
Commit
e6487168
authored
Feb 01, 2018
by
Matija Čupić
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Read the AutoDevOps instance domain in ProjectAutoDevOps
parent
a3153984
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
49 additions
and
12 deletions
+49
-12
app/models/project.rb
app/models/project.rb
+1
-7
app/models/project_auto_devops.rb
app/models/project_auto_devops.rb
+8
-2
spec/models/project_auto_devops_spec.rb
spec/models/project_auto_devops_spec.rb
+40
-3
No files found.
app/models/project.rb
View file @
e6487168
...
...
@@ -1609,13 +1609,7 @@ class Project < ActiveRecord::Base
def
auto_devops_variables
return
[]
unless
auto_devops_enabled?
auto_devops
&
.
variables
||
if
current_application_settings
.
auto_devops_domain
.
present?
[{
key:
'AUTO_DEVOPS_DOMAIN'
,
value:
current_application_settings
.
auto_devops_domain
,
public:
true
}]
else
[]
end
(
auto_devops
||
ProjectAutoDevops
.
new
)
&
.
variables
end
def
append_or_update_attribute
(
name
,
value
)
...
...
app/models/project_auto_devops.rb
View file @
e6487168
class
ProjectAutoDevops
<
ActiveRecord
::
Base
include
Gitlab
::
CurrentSettings
belongs_to
:project
scope
:enabled
,
->
{
where
(
enabled:
true
)
}
...
...
@@ -6,13 +8,17 @@ class ProjectAutoDevops < ActiveRecord::Base
validates
:domain
,
allow_blank:
true
,
hostname:
{
allow_numeric_hostname:
true
}
def
instance_domain
current_application_settings
.
auto_devops_domain
end
def
has_domain?
domain
.
present?
domain
.
present?
||
instance_domain
.
present?
end
def
variables
variables
=
[]
variables
<<
{
key:
'AUTO_DEVOPS_DOMAIN'
,
value:
domain
,
public:
true
}
if
domain
.
present
?
variables
<<
{
key:
'AUTO_DEVOPS_DOMAIN'
,
value:
domain
||
instance_domain
,
public:
true
}
if
has_domain
?
variables
end
end
spec/models/project_auto_devops_spec.rb
View file @
e6487168
...
...
@@ -18,9 +18,23 @@ describe ProjectAutoDevops do
context
'when domain is empty'
do
let
(
:auto_devops
)
{
build_stubbed
(
:project_auto_devops
,
project:
project
,
domain:
''
)
}
context
'when there is an instance domain specified'
do
before
do
stub_application_setting
(
auto_devops_domain:
'example.com'
)
end
it
{
expect
(
auto_devops
).
to
have_domain
}
end
context
'when there is no instance domain specified'
do
before
do
stub_application_setting
(
auto_devops_domain:
nil
)
end
it
{
expect
(
auto_devops
).
not_to
have_domain
}
end
end
end
describe
'#variables'
do
let
(
:auto_devops
)
{
build_stubbed
(
:project_auto_devops
,
project:
project
,
domain:
domain
)
}
...
...
@@ -29,9 +43,32 @@ describe ProjectAutoDevops do
let
(
:domain
)
{
'example.com'
}
it
'returns AUTO_DEVOPS_DOMAIN'
do
expect
(
auto_devops
.
variables
).
to
include
(
{
key:
'AUTO_DEVOPS_DOMAIN'
,
value:
'example.com'
,
public:
true
})
expect
(
auto_devops
.
variables
).
to
include
(
domain_variable
)
end
end
context
'when domain is not defined'
do
let
(
:domain
)
{
nil
}
context
'when there is an instance domain specified'
do
before
do
stub_application_setting
(
auto_devops_domain:
'example.com'
)
end
it
{
expect
(
auto_devops
.
variables
).
to
include
(
domain_variable
)
}
end
context
'when there is no instance domain specified'
do
before
do
stub_application_setting
(
auto_devops_domain:
nil
)
end
it
{
expect
(
auto_devops
.
variables
).
not_to
include
(
domain_variable
)
}
end
end
def
domain_variable
{
key:
'AUTO_DEVOPS_DOMAIN'
,
value:
'example.com'
,
public:
true
}
end
end
end
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