Commit 6472025e authored by Matija Čupić's avatar Matija Čupić

Remove Projects::Clusters::GcpController#list_projects

parent 1e8dbd52
......@@ -2,7 +2,6 @@ class Projects::Clusters::GcpController < Projects::ApplicationController
before_action :authorize_read_cluster!
before_action :authorize_create_cluster!, only: [:new, :create]
before_action :authorize_google_api, except: [:login, :list_projects]
before_action :get_gcp_projects, only: [:new]
def login
begin
......@@ -34,12 +33,6 @@ class Projects::Clusters::GcpController < Projects::ApplicationController
end
end
def list_projects
respond_to do |format|
format.json { render status: :ok, json: { projects: gcp_projects } }
end
end
private
def create_params
......@@ -65,15 +58,6 @@ class Projects::Clusters::GcpController < Projects::ApplicationController
end
end
def get_gcp_projects
redis_token_key = ListGcpProjectsWorker.store_session_token(token_in_session)
ListGcpProjectsWorker.perform_async(redis_token_key)
end
def gcp_projects
ListGcpProjectsWorker.read_projects(token_in_session)
end
def token_in_session
@token_in_session ||=
session[GoogleApi::CloudPlatform::Client.session_key_for_token]
......
......@@ -206,7 +206,6 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
get '/gcp/new', to: 'clusters/gcp#new'
get '/gcp/login', to: 'clusters/gcp#login'
get '/gcp/list_projects', to: 'clusters/gcp#list_projects'
post '/gcp', to: 'clusters/gcp#create'
end
end
......
......@@ -77,8 +77,6 @@ describe Projects::Clusters::GcpController do
end
it 'has new object' do
expect(controller).to receive(:get_gcp_projects)
go
expect(assigns(:cluster)).to be_an_instance_of(Clusters::Cluster)
......@@ -137,8 +135,6 @@ describe Projects::Clusters::GcpController do
context 'when access token is valid' do
before do
stub_google_api_validate_token
allow_any_instance_of(described_class).to receive(:get_gcp_projects)
allow_any_instance_of(described_class).to receive(:gcp_projects).and_return([double])
end
it 'creates a new cluster' do
......@@ -183,28 +179,4 @@ describe Projects::Clusters::GcpController do
post :create, params.merge(namespace_id: project.namespace, project_id: project)
end
end
describe 'GET list_projects' do
describe 'functionality' do
let(:user) { create(:user) }
let(:gcp_projects) { [project_id: 'test-project-1234'] }
before do
project.add_master(user)
sign_in(user)
allow_any_instance_of(described_class).to receive(:gcp_projects).and_return(gcp_projects)
end
it 'renders the response as json' do
go
expect(response.body).to eq({ projects: gcp_projects }.to_json)
end
end
def go
get :list_projects, namespace_id: project.namespace, project_id: project, format: :json
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment