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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
886fd13f
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
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
61 additions
and
1 deletion
+61
-1
app/controllers/projects/clusters/gcp_controller.rb
app/controllers/projects/clusters/gcp_controller.rb
+10
-1
config/routes/project.rb
config/routes/project.rb
+1
-0
spec/controllers/projects/clusters/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
class
Projects::Clusters::GcpController
<
Projects
::
ApplicationController
before_action
:authorize_read_cluster!
before_action
:authorize_read_cluster!
before_action
:authorize_google_api
,
except:
[
:login
]
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
]
before_action
:authorize_create_cluster!
,
only:
[
:new
,
:create
]
STATUS_POLLING_INTERVAL
=
1
.
minute
.
to_i
STATUS_POLLING_INTERVAL
=
1
.
minute
.
to_i
...
@@ -32,6 +32,15 @@ class Projects::Clusters::GcpController < Projects::ApplicationController
...
@@ -32,6 +32,15 @@ class Projects::Clusters::GcpController < Projects::ApplicationController
end
end
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
def
new
@cluster
=
::
Clusters
::
Cluster
.
new
.
tap
do
|
cluster
|
@cluster
=
::
Clusters
::
Cluster
.
new
.
tap
do
|
cluster
|
cluster
.
build_provider_gcp
cluster
.
build_provider_gcp
...
...
config/routes/project.rb
View file @
886fd13f
...
@@ -192,6 +192,7 @@ constraints(ProjectUrlConstrainer.new) do
...
@@ -192,6 +192,7 @@ constraints(ProjectUrlConstrainer.new) do
get
'/gcp/new'
,
to:
'clusters/gcp#new'
get
'/gcp/new'
,
to:
'clusters/gcp#new'
get
'/gcp/login'
,
to:
'clusters/gcp#login'
get
'/gcp/login'
,
to:
'clusters/gcp#login'
get
'/gcp/check'
,
to:
'clusters/gcp#check'
get
'/gcp/check'
,
to:
'clusters/gcp#check'
post
'/gcp/check'
,
to:
'clusters/gcp#run_check'
post
'/gcp'
,
to:
'clusters/gcp#create'
post
'/gcp'
,
to:
'clusters/gcp#create'
end
end
end
end
...
...
spec/controllers/projects/clusters/gcp_controller_spec.rb
View file @
886fd13f
...
@@ -138,6 +138,56 @@ describe Projects::Clusters::GcpController do
...
@@ -138,6 +138,56 @@ describe Projects::Clusters::GcpController do
end
end
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
'GET new'
do
describe
'functionality'
do
describe
'functionality'
do
let
(
:user
)
{
create
(
:user
)
}
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