BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
3be9820d
Commit
3be9820d
authored
May 23, 2017
by
Z.J. van de Weg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test etag caching router and incorporate review
parent
f0cd6ffd
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
25 additions
and
6 deletions
+25
-6
environments_controller.rb
app/controllers/projects/environments_controller.rb
+1
-1
deployment.rb
app/models/deployment.rb
+5
-0
environments_controller_spec.rb
spec/controllers/projects/environments_controller_spec.rb
+9
-4
router_spec.rb
spec/lib/gitlab/etag_caching/router_spec.rb
+2
-1
deployment_spec.rb
spec/models/deployment_spec.rb
+8
-0
No files found.
app/controllers/projects/environments_controller.rb
View file @
3be9820d
...
@@ -15,7 +15,7 @@ class Projects::EnvironmentsController < Projects::ApplicationController
...
@@ -15,7 +15,7 @@ class Projects::EnvironmentsController < Projects::ApplicationController
respond_to
do
|
format
|
respond_to
do
|
format
|
format
.
html
format
.
html
format
.
json
do
format
.
json
do
Gitlab
::
PollingInterval
.
set_header
(
response
,
interval:
15
_000
)
Gitlab
::
PollingInterval
.
set_header
(
response
,
interval:
3
_000
)
render
json:
{
render
json:
{
environments:
EnvironmentSerializer
environments:
EnvironmentSerializer
...
...
app/models/deployment.rb
View file @
3be9820d
...
@@ -12,6 +12,7 @@ class Deployment < ActiveRecord::Base
...
@@ -12,6 +12,7 @@ class Deployment < ActiveRecord::Base
delegate
:name
,
to: :environment
,
prefix:
true
delegate
:name
,
to: :environment
,
prefix:
true
after_create
:create_ref
after_create
:create_ref
after_create
:invalidate_cache
def
commit
def
commit
project
.
commit
(
sha
)
project
.
commit
(
sha
)
...
@@ -33,6 +34,10 @@ class Deployment < ActiveRecord::Base
...
@@ -33,6 +34,10 @@ class Deployment < ActiveRecord::Base
project
.
repository
.
create_ref
(
ref
,
ref_path
)
project
.
repository
.
create_ref
(
ref
,
ref_path
)
end
end
def
invalidate_cache
environment
.
expire_etag_cache
end
def
manual_actions
def
manual_actions
@manual_actions
||=
deployable
.
try
(
:other_actions
)
@manual_actions
||=
deployable
.
try
(
:other_actions
)
end
end
...
...
spec/controllers/projects/environments_controller_spec.rb
View file @
3be9820d
require
'spec_helper'
require
'spec_helper'
describe
Projects
::
EnvironmentsController
do
describe
Projects
::
EnvironmentsController
do
l
et
(
:user
)
{
create
(
:user
)
}
s
et
(
:user
)
{
create
(
:user
)
}
l
et
(
:project
)
{
create
(
:empty_project
)
}
s
et
(
:project
)
{
create
(
:empty_project
)
}
l
et
(
:environment
)
do
s
et
(
:environment
)
do
create
(
:environment
,
name:
'production'
,
project:
project
)
create
(
:environment
,
name:
'production'
,
project:
project
)
end
end
before
do
before
do
project
.
team
<<
[
user
,
:master
]
project
.
add_master
(
user
)
sign_in
(
user
)
sign_in
(
user
)
end
end
...
@@ -57,6 +57,11 @@ describe Projects::EnvironmentsController do
...
@@ -57,6 +57,11 @@ describe Projects::EnvironmentsController do
expect
(
json_response
[
'available_count'
]).
to
eq
3
expect
(
json_response
[
'available_count'
]).
to
eq
3
expect
(
json_response
[
'stopped_count'
]).
to
eq
1
expect
(
json_response
[
'stopped_count'
]).
to
eq
1
end
end
it
'sets the polling interval header'
do
expect
(
response
).
to
have_http_status
(
:ok
)
expect
(
response
.
headers
[
'Poll-Interval'
]).
to
eq
(
"3000"
)
end
end
end
context
'when requesting stopped environments scope'
do
context
'when requesting stopped environments scope'
do
...
...
spec/lib/gitlab/etag_caching/router_spec.rb
View file @
3be9820d
...
@@ -84,7 +84,8 @@ describe Gitlab::EtagCaching::Router do
...
@@ -84,7 +84,8 @@ describe Gitlab::EtagCaching::Router do
result
=
described_class
.
match
(
env
)
result
=
described_class
.
match
(
env
)
expect
(
result
).
to
be_blank
expect
(
result
).
to
be_present
expect
(
result
.
name
).
to
eq
'environments'
end
end
def
build_env
(
path
)
def
build_env
(
path
)
...
...
spec/models/deployment_spec.rb
View file @
3be9820d
...
@@ -16,6 +16,14 @@ describe Deployment, models: true do
...
@@ -16,6 +16,14 @@ describe Deployment, models: true do
it
{
is_expected
.
to
validate_presence_of
(
:ref
)
}
it
{
is_expected
.
to
validate_presence_of
(
:ref
)
}
it
{
is_expected
.
to
validate_presence_of
(
:sha
)
}
it
{
is_expected
.
to
validate_presence_of
(
:sha
)
}
describe
'after_create callbacks'
do
it
'invalidates the cache for the environment'
do
expect
(
subject
).
to
receive
(
:invalidate_cache
)
subject
.
save!
end
end
describe
'#includes_commit?'
do
describe
'#includes_commit?'
do
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:environment
)
{
create
(
:environment
,
project:
project
)
}
let
(
:environment
)
{
create
(
:environment
,
project:
project
)
}
...
...
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