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
Jérome Perrin
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
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
25 additions
and
6 deletions
+25
-6
app/controllers/projects/environments_controller.rb
app/controllers/projects/environments_controller.rb
+1
-1
app/models/deployment.rb
app/models/deployment.rb
+5
-0
spec/controllers/projects/environments_controller_spec.rb
spec/controllers/projects/environments_controller_spec.rb
+9
-4
spec/lib/gitlab/etag_caching/router_spec.rb
spec/lib/gitlab/etag_caching/router_spec.rb
+2
-1
spec/models/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
respond_to
do
|
format
|
format
.
html
format
.
json
do
Gitlab
::
PollingInterval
.
set_header
(
response
,
interval:
15
_000
)
Gitlab
::
PollingInterval
.
set_header
(
response
,
interval:
3
_000
)
render
json:
{
environments:
EnvironmentSerializer
...
...
app/models/deployment.rb
View file @
3be9820d
...
...
@@ -12,6 +12,7 @@ class Deployment < ActiveRecord::Base
delegate
:name
,
to: :environment
,
prefix:
true
after_create
:create_ref
after_create
:invalidate_cache
def
commit
project
.
commit
(
sha
)
...
...
@@ -33,6 +34,10 @@ class Deployment < ActiveRecord::Base
project
.
repository
.
create_ref
(
ref
,
ref_path
)
end
def
invalidate_cache
environment
.
expire_etag_cache
end
def
manual_actions
@manual_actions
||=
deployable
.
try
(
:other_actions
)
end
...
...
spec/controllers/projects/environments_controller_spec.rb
View file @
3be9820d
require
'spec_helper'
describe
Projects
::
EnvironmentsController
do
l
et
(
:user
)
{
create
(
:user
)
}
l
et
(
:project
)
{
create
(
:empty_project
)
}
s
et
(
:user
)
{
create
(
:user
)
}
s
et
(
:project
)
{
create
(
:empty_project
)
}
l
et
(
:environment
)
do
s
et
(
:environment
)
do
create
(
:environment
,
name:
'production'
,
project:
project
)
end
before
do
project
.
team
<<
[
user
,
:master
]
project
.
add_master
(
user
)
sign_in
(
user
)
end
...
...
@@ -57,6 +57,11 @@ describe Projects::EnvironmentsController do
expect
(
json_response
[
'available_count'
]).
to
eq
3
expect
(
json_response
[
'stopped_count'
]).
to
eq
1
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
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
result
=
described_class
.
match
(
env
)
expect
(
result
).
to
be_blank
expect
(
result
).
to
be_present
expect
(
result
.
name
).
to
eq
'environments'
end
def
build_env
(
path
)
...
...
spec/models/deployment_spec.rb
View file @
3be9820d
...
...
@@ -16,6 +16,14 @@ describe Deployment, models: true do
it
{
is_expected
.
to
validate_presence_of
(
:ref
)
}
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
let
(
:project
)
{
create
(
:project
,
:repository
)
}
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