Commit 600d5f4f authored by Shinya Maeda's avatar Shinya Maeda

Fix tests. Remove NOT NULL constraint from cluster.user.

parent 6ebe6792
......@@ -58,6 +58,9 @@ module Clusters
def update_kubernetes_integration!
raise 'Kubernetes service already configured' unless manages_kubernetes_service?
# This is neccesary, otheriwse enabled? returns true even though cluster updated with enabled: false
cluster.reload
ensure_kubernetes_service&.update!(
active: enabled?,
api_url: api_url,
......
......@@ -3,7 +3,7 @@ class CreateNewClustersArchitectures < ActiveRecord::Migration
def change
create_table :clusters do |t|
t.references :user, null: false, index: true, foreign_key: { on_delete: :nullify }
t.references :user, index: true, foreign_key: { on_delete: :nullify }
t.integer :provider_type
t.integer :platform_type
......
......@@ -507,7 +507,7 @@ ActiveRecord::Schema.define(version: 20171026082505) do
add_index "cluster_providers_gcp", ["cluster_id"], name: "index_cluster_providers_gcp_on_cluster_id", unique: true, using: :btree
create_table "clusters", force: :cascade do |t|
t.integer "user_id", null: false
t.integer "user_id"
t.integer "provider_type"
t.integer "platform_type"
t.datetime_with_timezone "created_at", null: false
......
......@@ -6,7 +6,7 @@ describe Projects::ClustersController, '(JavaScript fixtures)', type: :controlle
let(:admin) { create(:admin) }
let(:namespace) { create(:namespace, name: 'frontend-fixtures' )}
let(:project) { create(:project, :repository, namespace: namespace) }
let(:cluster) { project.create_cluster!(gcp_cluster_name: "gke-test-creation-1", gcp_project_id: 'gitlab-internal-153318', gcp_cluster_zone: 'us-central1-a', gcp_cluster_size: '1', project_namespace: 'aaa', gcp_machine_type: 'n1-standard-1')}
let(:cluster) { create(:cluster, :provided_by_gcp, projects: [project]) }
render_views
......
......@@ -147,10 +147,16 @@ deploy_keys:
- user
- deploy_keys_projects
- projects
cluster:
- project
clusters:
- projects
- user
- service
cluster_projects:
- projects
- clusters
provider_gcp:
- cluster
platform_kubernetes:
- cluster
services:
- project
- service_hook
......
......@@ -117,7 +117,6 @@ describe Clusters::Platforms::Kubernetes, :use_clean_rails_memory_store_caching
let(:kubernetes_service) { project.kubernetes_service }
it 'updates KubernetesService' do
# TODO: This doesn't work as intended because `enabled?` in Clusters::Platforms::Kubernetes is still true without `reload`
cluster.update(enabled: enabled)
expect(kubernetes_service.active).to eq(enabled)
......@@ -135,7 +134,7 @@ describe Clusters::Platforms::Kubernetes, :use_clean_rails_memory_store_caching
end
it 'raises an error' do
expect{ cluster.save! }.to raise_error('Kubernetes service already configured')
expect { cluster.save! }.to raise_error('Kubernetes service already configured')
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