Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-02-20 15:08:51 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-02-20 15:08:51 +0300
commit8c4198cbe631278e87fee04157d23494fbb80cdb (patch)
treed35cf498af480389796fd9e5cb4bcc903aea60f3 /spec
parent1ac794623a8be5dee111716a44dd04ff708f3541 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec')
-rw-r--r--spec/frontend/notes/old_notes_spec.js5
-rw-r--r--spec/lib/gitlab/git/blob_spec.rb18
-rw-r--r--spec/migrations/remove_security_dashboard_feature_flag_spec.rb53
-rw-r--r--spec/migrations/rename_security_dashboard_feature_flag_to_instance_security_dashboard_spec.rb53
4 files changed, 127 insertions, 2 deletions
diff --git a/spec/frontend/notes/old_notes_spec.js b/spec/frontend/notes/old_notes_spec.js
index 5f7a5d57cd8..49b887b21b4 100644
--- a/spec/frontend/notes/old_notes_spec.js
+++ b/spec/frontend/notes/old_notes_spec.js
@@ -28,7 +28,10 @@ window.gl = window.gl || {};
gl.utils = gl.utils || {};
gl.utils.disableButtonIfEmptyField = () => {};
-describe('Old Notes (~/notes.js)', () => {
+// the following test is unreliable and failing in master 2-3 times a day
+// see https://gitlab.com/gitlab-org/gitlab/issues/206906#note_290602581
+// eslint-disable-next-line jest/no-disabled-tests
+describe.skip('Old Notes (~/notes.js)', () => {
beforeEach(() => {
jest.useFakeTimers();
loadFixtures(fixture);
diff --git a/spec/lib/gitlab/git/blob_spec.rb b/spec/lib/gitlab/git/blob_spec.rb
index 3277e02aafa..079f01c2c4e 100644
--- a/spec/lib/gitlab/git/blob_spec.rb
+++ b/spec/lib/gitlab/git/blob_spec.rb
@@ -22,7 +22,23 @@ describe Gitlab::Git::Blob, :seed_helper do
it 'records blob size' do
expect(described_class).to receive(:gitlab_blob_size).and_call_original
- Gitlab::Git::Blob.new(name: 'test', size: 1234)
+ Gitlab::Git::Blob.new(name: 'test', size: 4, data: 'abcd')
+ end
+
+ context 'when untruncated' do
+ it 'attempts to record gitlab_blob_truncated_false' do
+ expect(described_class).to receive(:gitlab_blob_truncated_false).and_call_original
+
+ Gitlab::Git::Blob.new(name: 'test', size: 4, data: 'abcd')
+ end
+ end
+
+ context 'when truncated' do
+ it 'attempts to record gitlab_blob_truncated_true' do
+ expect(described_class).to receive(:gitlab_blob_truncated_true).and_call_original
+
+ Gitlab::Git::Blob.new(name: 'test', size: 40, data: 'abcd')
+ end
end
end
diff --git a/spec/migrations/remove_security_dashboard_feature_flag_spec.rb b/spec/migrations/remove_security_dashboard_feature_flag_spec.rb
new file mode 100644
index 00000000000..7ef43134d24
--- /dev/null
+++ b/spec/migrations/remove_security_dashboard_feature_flag_spec.rb
@@ -0,0 +1,53 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+require Rails.root.join('db', 'post_migrate', '20200214034836_remove_security_dashboard_feature_flag.rb')
+
+describe RemoveSecurityDashboardFeatureFlag, :migration do
+ let(:feature_gates) { table(:feature_gates) }
+
+ subject(:migration) { described_class.new }
+
+ describe '#up' do
+ it 'deletes the security_dashboard feature gate' do
+ security_dashboard_feature = feature_gates.create!(feature_key: :security_dashboard, key: :boolean, value: 'false')
+ actors_security_dashboard_feature = feature_gates.create!(feature_key: :security_dashboard, key: :actors, value: 'Project:1')
+
+ migration.up
+
+ expect { security_dashboard_feature.reload }.to raise_error(ActiveRecord::RecordNotFound)
+ expect(actors_security_dashboard_feature.reload).to be_present
+ end
+ end
+
+ describe '#down' do
+ it 'copies the instance_security_dashboard feature gate to a security_dashboard gate' do
+ feature_gates.create!(feature_key: :instance_security_dashboard, key: :actors, value: 'Project:1')
+ feature_gates.create!(feature_key: :instance_security_dashboard, key: 'boolean', value: 'false')
+
+ migration.down
+
+ security_dashboard_feature = feature_gates.find_by(feature_key: :security_dashboard, key: :boolean)
+ expect(security_dashboard_feature.value).to eq('false')
+ end
+
+ context 'when there is no instance_security_dashboard gate' do
+ it 'does nothing' do
+ migration.down
+
+ security_dashboard_feature = feature_gates.find_by(feature_key: :security_dashboard, key: :boolean)
+ expect(security_dashboard_feature).to be_nil
+ end
+ end
+
+ context 'when there already is a security_dashboard gate' do
+ it 'does nothing' do
+ feature_gates.create!(feature_key: :security_dashboard, key: 'boolean', value: 'false')
+ feature_gates.create!(feature_key: :instance_security_dashboard, key: 'boolean', value: 'false')
+
+ expect { migration.down }.not_to raise_error
+ end
+ end
+ end
+end
diff --git a/spec/migrations/rename_security_dashboard_feature_flag_to_instance_security_dashboard_spec.rb b/spec/migrations/rename_security_dashboard_feature_flag_to_instance_security_dashboard_spec.rb
new file mode 100644
index 00000000000..bc982e8952e
--- /dev/null
+++ b/spec/migrations/rename_security_dashboard_feature_flag_to_instance_security_dashboard_spec.rb
@@ -0,0 +1,53 @@
+# frozen_string_literal: true
+
+require 'spec_helper'
+
+require Rails.root.join('db', 'migrate', '20200212014653_rename_security_dashboard_feature_flag_to_instance_security_dashboard.rb')
+
+describe RenameSecurityDashboardFeatureFlagToInstanceSecurityDashboard, :migration do
+ let(:feature_gates) { table(:feature_gates) }
+
+ subject(:migration) { described_class.new }
+
+ describe '#up' do
+ it 'copies the security_dashboard feature gate to a new instance_security_dashboard gate' do
+ feature_gates.create!(feature_key: :security_dashboard, key: :actors, value: 'Project:1')
+ feature_gates.create!(feature_key: :security_dashboard, key: :boolean, value: 'false')
+
+ migration.up
+
+ instance_security_dashboard_feature = feature_gates.find_by(feature_key: :instance_security_dashboard, key: :boolean)
+ expect(instance_security_dashboard_feature.value).to eq('false')
+ end
+
+ context 'when there is no security_dashboard gate' do
+ it 'does nothing' do
+ migration.up
+
+ instance_security_dashboard_feature = feature_gates.find_by(feature_key: :instance_security_dashboard, key: :boolean)
+ expect(instance_security_dashboard_feature).to be_nil
+ end
+ end
+
+ context 'when there is already an instance_security_dashboard gate' do
+ it 'does nothing' do
+ feature_gates.create!(feature_key: :security_dashboard, key: 'boolean', value: 'false')
+ feature_gates.create!(feature_key: :instance_security_dashboard, key: 'boolean', value: 'false')
+
+ expect { migration.up }.not_to raise_error
+ end
+ end
+ end
+
+ describe '#down' do
+ it 'removes the instance_security_dashboard gate' do
+ actors_instance_security_dashboard_feature = feature_gates.create!(feature_key: :instance_security_dashboard, key: :actors, value: 'Project:1')
+ instance_security_dashboard_feature = feature_gates.create!(feature_key: :instance_security_dashboard, key: :boolean, value: 'false')
+
+ migration.down
+
+ expect { instance_security_dashboard_feature.reload }.to raise_error(ActiveRecord::RecordNotFound)
+ expect(actors_instance_security_dashboard_feature.reload).to be_present
+ end
+ end
+end