Extract EE specific files/lines for spec/models/concerns

We have the following files containing EE specific code. We should move them to ee/

spec/models/concerns/issuable_spec.rb
diff --git a/spec/models/concerns/issuable_spec.rb b/home/yorickpeterse/Projects/gitlab/gdk-ee/gitlab/spec/models/concerns/issuable_spec.rb
index 41159348e04..e8bd3e681a0 100644
--- a/spec/models/concerns/issuable_spec.rb
+++ b/home/yorickpeterse/Projects/gitlab/gdk-ee/gitlab/spec/models/concerns/issuable_spec.rb
@@ -452,6 +452,23 @@ describe Issuable do
     end
   end
 
+  describe '.labels_hash' do
+    let(:feature_label) { create(:label, title: 'Feature') }
+    let(:second_label) { create(:label, title: 'Second Label') }
+    let!(:issues) { create_list(:labeled_issue, 3, labels: [feature_label, second_label]) }
+    let(:issue_id) { issues.first.id }
+
+    it 'maps issue ids to labels titles' do
+      expect(Issue.labels_hash[issue_id]).to include('Feature')
+    end
+
+    it 'works on relations filtered by multiple labels' do
+      relation = Issue.with_label(['Feature', 'Second Label'])
+
+      expect(relation.labels_hash[issue_id]).to include('Feature', 'Second Label')
+    end
+  end
+
   describe '#user_notes_count' do
     let(:project) { create(:project) }
     let(:issue1) { create(:issue, project: project) }
spec/models/concerns/prometheus_adapter_spec.rb
diff --git a/spec/models/concerns/prometheus_adapter_spec.rb b/home/yorickpeterse/Projects/gitlab/gdk-ee/gitlab/spec/models/concerns/prometheus_adapter_spec.rb
index f4b9c57e71a..2413f9e5db8 100644
--- a/spec/models/concerns/prometheus_adapter_spec.rb
+++ b/home/yorickpeterse/Projects/gitlab/gdk-ee/gitlab/spec/models/concerns/prometheus_adapter_spec.rb
@@ -4,14 +4,15 @@ describe PrometheusAdapter, :use_clean_rails_memory_store_caching do
   include PrometheusHelpers
   include ReactiveCachingHelpers
 
-  class TestClass
-    include PrometheusAdapter
-  end
-
   let(:project) { create(:prometheus_project) }
   let(:service) { project.prometheus_service }
 
-  let(:described_class) { TestClass }
+  let(:described_class) do
+    Class.new do
+      include PrometheusAdapter
+    end
+  end
+
   let(:environment_query) { Gitlab::Prometheus::Queries::EnvironmentQuery }
 
   describe '#query' do
@@ -74,6 +75,29 @@ describe PrometheusAdapter, :use_clean_rails_memory_store_caching do
         end
       end
     end
+
+    describe 'validate_query' do
+      let(:environment) { build_stubbed(:environment, slug: 'env-slug') }
+      let(:validation_query) { Gitlab::Prometheus::Queries::ValidateQuery.name }
+      let(:query) { 'avg(response)' }
+      let(:validation_respone) { { data: { valid: true } } }
+
+      around do |example|
+        Timecop.freeze { example.run }
+      end
+
+      context 'with valid data' do
+        subject { service.query(:validate, query) }
+
+        before do
+          stub_reactive_cache(service, validation_respone, validation_query, query)
+        end
+
+        it 'returns query data' do
+          is_expected.to eq(query: { valid: true })
+        end
+      end
+    end
   end
 
   describe '#calculate_reactive_cache' do
spec/models/concerns/sha_attribute_spec.rb
diff --git a/spec/models/concerns/sha_attribute_spec.rb b/home/yorickpeterse/Projects/gitlab/gdk-ee/gitlab/spec/models/concerns/sha_attribute_spec.rb
index 0d3beb6a6e3..b6732c4740f 100644
--- a/spec/models/concerns/sha_attribute_spec.rb
+++ b/home/yorickpeterse/Projects/gitlab/gdk-ee/gitlab/spec/models/concerns/sha_attribute_spec.rb
@@ -70,6 +70,19 @@ describe ShaAttribute do
           expect { model.sha_attribute(:name) }.to raise_error(ActiveRecord::NoDatabaseError)
         end
       end
+
+      # EE-specific start
+      context 'when Geo database is not configured' do
+        it 'allows the attribute to be added' do
+          allow(model).to receive(:table_exists?).and_raise(Geo::TrackingBase::SecondaryNotConfigured.new)
+
+          expect(model).not_to receive(:columns)
+          expect(model).to receive(:attribute)
+
+          model.sha_attribute(:name)
+        end
+      end
+      # EE specific end
     end
 
     context 'when in production' do
Edited Feb 26, 2019 by Yorick Peterse
Assignee Loading
Time tracking Loading