Commit cff66a0a authored by Matija Čupić's avatar Matija Čupić

Refactor clusters feature spec

parent c12d5a6c
require 'spec_helper' require 'spec_helper'
feature 'Clusters', :js do feature 'EE Clusters' do
include GoogleApi::CloudPlatformHelpers
let(:project) { create(:project) } let(:project) { create(:project) }
let(:user) { create(:user) } let(:user) { create(:user) }
...@@ -11,27 +9,36 @@ feature 'Clusters', :js do ...@@ -11,27 +9,36 @@ feature 'Clusters', :js do
gitlab_sign_in(user) gitlab_sign_in(user)
end end
context 'when user has a cluster and visits cluster index page' do context 'when user has a cluster' do
let!(:cluster) { create(:cluster, :project, :provided_by_gcp) } let!(:cluster) { create(:cluster, :provided_by_gcp, projects: [project]) }
let(:project) { cluster.project }
context 'when license has multiple clusters feature' do
before do before do
visit project_clusters_path(project) allow(License).to receive(:feature_available?).and_call_original
allow(License).to receive(:feature_available?).with(:multiple_clusters).and_return(true)
end end
context 'when license has multiple clusters feature' do context 'when user visits clusters page' do
before do before do
allow_any_instance_of(EE::Project).to receive(:feature_available?).with(:multiple_clusters).and_return(true) visit project_clusters_path(project)
end end
it 'user sees a add cluster button ' do it 'user sees a add cluster button ' do
expect(page).not_to have_selector('.js-add-cluster.disabled')
expect(page).to have_selector('.js-add-cluster') expect(page).to have_selector('.js-add-cluster')
end end
end end
end
context 'when license does not have multiple clusters feature' do context 'when license does not have multiple clusters feature' do
before do before do
allow_any_instance_of(EE::Project).to receive(:feature_available?).with(:multiple_clusters).and_return(false) allow(License).to receive(:feature_available?).and_call_original
allow(License).to receive(:feature_available?).with(:multiple_clusters).and_return(false)
end
context 'when user visits cluster index page' do
before do
visit project_clusters_path(project)
end end
it 'user sees a disabled add cluster button ' do it 'user sees a disabled add cluster button ' do
...@@ -39,4 +46,5 @@ feature 'Clusters', :js do ...@@ -39,4 +46,5 @@ feature 'Clusters', :js do
end end
end end
end end
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