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
886fd13f
Unverified
Commit
886fd13f
authored
Dec 16, 2017
by
Matija Čupić
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Worker rerun action to GcpController
parent
63859419
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
61 additions
and
1 deletion
+61
-1
gcp_controller.rb
app/controllers/projects/clusters/gcp_controller.rb
+10
-1
project.rb
config/routes/project.rb
+1
-0
gcp_controller_spec.rb
spec/controllers/projects/clusters/gcp_controller_spec.rb
+50
-0
No files found.
app/controllers/projects/clusters/gcp_controller.rb
View file @
886fd13f
class
Projects
::
Clusters
::
GcpController
<
Projects
::
ApplicationController
before_action
:authorize_read_cluster!
before_action
:authorize_google_api
,
except:
[
:login
]
before_action
:authorize_google_project_billing
,
except:
[
:login
,
:check
]
before_action
:authorize_google_project_billing
,
except:
[
:login
,
:check
,
:run_check
]
before_action
:authorize_create_cluster!
,
only:
[
:new
,
:create
]
STATUS_POLLING_INTERVAL
=
1
.
minute
.
to_i
...
...
@@ -32,6 +32,15 @@ class Projects::Clusters::GcpController < Projects::ApplicationController
end
end
def
run_check
respond_to
do
|
format
|
format
.
json
do
CheckGcpProjectBillingWorker
.
perform_async
(
token_in_session
)
head
:no_content
end
end
end
def
new
@cluster
=
::
Clusters
::
Cluster
.
new
.
tap
do
|
cluster
|
cluster
.
build_provider_gcp
...
...
config/routes/project.rb
View file @
886fd13f
...
...
@@ -192,6 +192,7 @@ constraints(ProjectUrlConstrainer.new) do
get
'/gcp/new'
,
to:
'clusters/gcp#new'
get
'/gcp/login'
,
to:
'clusters/gcp#login'
get
'/gcp/check'
,
to:
'clusters/gcp#check'
post
'/gcp/check'
,
to:
'clusters/gcp#run_check'
post
'/gcp'
,
to:
'clusters/gcp#create'
end
end
...
...
spec/controllers/projects/clusters/gcp_controller_spec.rb
View file @
886fd13f
...
...
@@ -138,6 +138,56 @@ describe Projects::Clusters::GcpController do
end
end
describe
'POST check'
do
let
(
:user
)
{
create
(
:user
)
}
before
do
project
.
add_master
(
user
)
sign_in
(
user
)
end
describe
'functionality'
do
context
'when access token is valid'
do
before
do
stub_google_api_validate_token
end
it
'calls check worker asynchronously'
do
expect
(
CheckGcpProjectBillingWorker
).
to
receive
(
:perform_async
)
expect
(
go
).
to
have_http_status
(
:no_content
)
end
end
context
'when access token is expired'
do
before
do
stub_google_api_expired_token
end
it
{
expect
(
go
).
to
redirect_to
(
gcp_login_project_clusters_path
(
project
))
}
end
context
'when access token is not stored in session'
do
it
{
expect
(
go
).
to
redirect_to
(
gcp_login_project_clusters_path
(
project
))
}
end
end
describe
'security'
do
it
{
expect
{
go
}.
to
be_allowed_for
(
:admin
)
}
it
{
expect
{
go
}.
to
be_allowed_for
(
:owner
).
of
(
project
)
}
it
{
expect
{
go
}.
to
be_allowed_for
(
:master
).
of
(
project
)
}
it
{
expect
{
go
}.
to
be_denied_for
(
:developer
).
of
(
project
)
}
it
{
expect
{
go
}.
to
be_denied_for
(
:reporter
).
of
(
project
)
}
it
{
expect
{
go
}.
to
be_denied_for
(
:guest
).
of
(
project
)
}
it
{
expect
{
go
}.
to
be_denied_for
(
:user
)
}
it
{
expect
{
go
}.
to
be_denied_for
(
:external
)
}
end
def
go
post
:run_check
,
namespace_id:
project
.
namespace
,
project_id:
project
,
format: :json
end
end
describe
'GET new'
do
describe
'functionality'
do
let
(
:user
)
{
create
(
:user
)
}
...
...
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