Commit 8c4198cb authored by GitLab Bot's avatar GitLab Bot

Add latest changes from gitlab-org/gitlab@master

parent 1ac79462
...@@ -3,6 +3,7 @@ image: "registry.gitlab.com/gitlab-org/gitlab-build-images:ruby-2.6.5-golang-1.1 ...@@ -3,6 +3,7 @@ image: "registry.gitlab.com/gitlab-org/gitlab-build-images:ruby-2.6.5-golang-1.1
stages: stages:
- sync - sync
- prepare - prepare
- fixtures
- test - test
- post-test - post-test
- review-prepare - review-prepare
......
...@@ -43,3 +43,6 @@ Dangerfile @gl-quality/eng-prod ...@@ -43,3 +43,6 @@ Dangerfile @gl-quality/eng-prod
/danger/ @gl-quality/eng-prod /danger/ @gl-quality/eng-prod
/lib/gitlab/danger/ @gl-quality/eng-prod /lib/gitlab/danger/ @gl-quality/eng-prod
/scripts/ @gl-quality/eng-prod /scripts/ @gl-quality/eng-prod
# Delivery owner files
/.gitlab/ci/releases.gitlab-ci.yml @gitlab-org/delivery
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
- .use-pg9 - .use-pg9
stage: test stage: test
needs: ["setup-test-env"] needs: ["setup-test-env"]
dependencies: ["setup-test-env"]
variables: variables:
FIXTURE_PATH: "db/fixtures/development" FIXTURE_PATH: "db/fixtures/development"
SEED_CYCLE_ANALYTICS: "true" SEED_CYCLE_ANALYTICS: "true"
......
...@@ -46,7 +46,9 @@ docs lint: ...@@ -46,7 +46,9 @@ docs lint:
- .docs:rules:docs-lint - .docs:rules:docs-lint
image: "registry.gitlab.com/gitlab-org/gitlab-docs:docs-lint" image: "registry.gitlab.com/gitlab-org/gitlab-docs:docs-lint"
stage: test stage: test
dependencies: [] needs:
- job: "retrieve-tests-metadata"
artifacts: false
script: script:
- scripts/lint-doc.sh - scripts/lint-doc.sh
# Lint Markdown # Lint Markdown
......
...@@ -120,15 +120,54 @@ compile-assets pull-cache as-if-foss: ...@@ -120,15 +120,54 @@ compile-assets pull-cache as-if-foss:
policy: pull policy: pull
key: "assets-compile:v9:foss" key: "assets-compile:v9:foss"
.frontend-job-base: .frontend-fixtures-base:
extends: extends:
- .default-tags - .default-tags
- .default-retry - .default-retry
- .default-cache - .default-cache
- .default-before_script - .default-before_script
- .use-pg9 - .use-pg9
stage: fixtures
needs:
- job: "setup-test-env"
artifacts: true
- job: "compile-assets pull-cache"
artifacts: true
script:
- date
- scripts/gitaly-test-spawn
- date
- bundle exec rake frontend:fixtures
artifacts:
name: frontend-fixtures
expire_in: 31d
when: always
paths:
- node_modules
- public/assets
- tmp/tests/frontend/
frontend-fixtures:
extends:
- .frontend-fixtures-base
- .frontend:rules:default-frontend-jobs
frontend-fixtures-as-if-foss:
extends:
- .frontend-fixtures-base
- .frontend:rules:default-frontend-jobs-as-if-foss
- .as-if-foss
.frontend-job-base:
extends:
- .default-tags
- .default-retry
- .default-cache
- .default-before_script
variables:
USE_BUNDLE_INSTALL: "false"
SETUP_DB: "false"
stage: test stage: test
needs: ["setup-test-env", "compile-assets pull-cache"]
.karma-base: .karma-base:
extends: .frontend-job-base extends: .frontend-job-base
...@@ -138,14 +177,13 @@ compile-assets pull-cache as-if-foss: ...@@ -138,14 +177,13 @@ compile-assets pull-cache as-if-foss:
script: script:
- export BABEL_ENV=coverage CHROME_LOG_FILE=chrome_debug.log - export BABEL_ENV=coverage CHROME_LOG_FILE=chrome_debug.log
- date - date
- scripts/gitaly-test-spawn - yarn karma
- date
- bundle exec rake karma
karma: karma:
extends: extends:
- .karma-base - .karma-base
- .frontend:rules:default-frontend-jobs - .frontend:rules:default-frontend-jobs
needs: ["frontend-fixtures"]
coverage: '/^Statements *: (\d+\.\d+%)/' coverage: '/^Statements *: (\d+\.\d+%)/'
artifacts: artifacts:
name: coverage-javascript name: coverage-javascript
...@@ -163,13 +201,11 @@ karma-as-if-foss: ...@@ -163,13 +201,11 @@ karma-as-if-foss:
- .karma-base - .karma-base
- .frontend:rules:default-frontend-jobs-as-if-foss - .frontend:rules:default-frontend-jobs-as-if-foss
- .as-if-foss - .as-if-foss
needs: ["frontend-fixtures-as-if-foss"]
.jest-base: .jest-base:
extends: .frontend-job-base extends: .frontend-job-base
script: script:
- scripts/gitaly-test-spawn
- date
- bundle exec rake frontend:fixtures
- date - date
- yarn jest --ci --coverage - yarn jest --ci --coverage
cache: cache:
...@@ -182,6 +218,7 @@ jest: ...@@ -182,6 +218,7 @@ jest:
extends: extends:
- .jest-base - .jest-base
- .frontend:rules:default-frontend-jobs - .frontend:rules:default-frontend-jobs
needs: ["frontend-fixtures"]
artifacts: artifacts:
name: coverage-frontend name: coverage-frontend
expire_in: 31d expire_in: 31d
...@@ -198,6 +235,7 @@ jest-as-if-foss: ...@@ -198,6 +235,7 @@ jest-as-if-foss:
- .jest-base - .jest-base
- .frontend:rules:default-frontend-jobs-as-if-foss - .frontend:rules:default-frontend-jobs-as-if-foss
- .as-if-foss - .as-if-foss
needs: ["frontend-fixtures-as-if-foss"]
cache: cache:
policy: pull policy: pull
......
...@@ -3,7 +3,9 @@ ...@@ -3,7 +3,9 @@
- .default-tags - .default-tags
- .default-retry - .default-retry
stage: test stage: test
dependencies: [] needs:
- job: "retrieve-tests-metadata"
artifacts: false
cache: cache:
key: "qa-framework-jobs:v1" key: "qa-framework-jobs:v1"
paths: paths:
......
...@@ -12,6 +12,9 @@ code_quality: ...@@ -12,6 +12,9 @@ code_quality:
- .default-retry - .default-retry
- .reports:rules:code_quality - .reports:rules:code_quality
stage: test stage: test
needs:
- job: "retrieve-tests-metadata"
artifacts: false
image: docker:stable image: docker:stable
allow_failure: true allow_failure: true
services: services:
...@@ -39,7 +42,6 @@ code_quality: ...@@ -39,7 +42,6 @@ code_quality:
paths: paths:
- gl-code-quality-report.json # GitLab-specific - gl-code-quality-report.json # GitLab-specific
expire_in: 1 week # GitLab-specific expire_in: 1 week # GitLab-specific
dependencies: []
# We need to duplicate this job's definition because it seems it's impossible to # We need to duplicate this job's definition because it seems it's impossible to
# override an included `only.refs`. # override an included `only.refs`.
...@@ -52,7 +54,9 @@ sast: ...@@ -52,7 +54,9 @@ sast:
- .reports:rules:sast - .reports:rules:sast
stage: test stage: test
allow_failure: true allow_failure: true
dependencies: [] # GitLab-specific needs:
- job: "retrieve-tests-metadata"
artifacts: false
artifacts: artifacts:
paths: paths:
- gl-sast-report.json # GitLab-specific - gl-sast-report.json # GitLab-specific
...@@ -90,6 +94,9 @@ dependency_scanning: ...@@ -90,6 +94,9 @@ dependency_scanning:
- .default-retry - .default-retry
- .reports:rules:dependency_scanning - .reports:rules:dependency_scanning
stage: test stage: test
needs:
- job: "retrieve-tests-metadata"
artifacts: false
image: docker:stable image: docker:stable
variables: variables:
DOCKER_DRIVER: overlay2 DOCKER_DRIVER: overlay2
...@@ -148,7 +155,6 @@ dependency_scanning: ...@@ -148,7 +155,6 @@ dependency_scanning:
reports: reports:
dependency_scanning: gl-dependency-scanning-report.json dependency_scanning: gl-dependency-scanning-report.json
expire_in: 1 week # GitLab-specific expire_in: 1 week # GitLab-specific
dependencies: []
# We need to duplicate this job's definition because it seems it's impossible to # We need to duplicate this job's definition because it seems it's impossible to
# override an included `only.refs`. # override an included `only.refs`.
......
...@@ -248,7 +248,9 @@ danger-review: ...@@ -248,7 +248,9 @@ danger-review:
- .review:rules:danger - .review:rules:danger
image: registry.gitlab.com/gitlab-org/gitlab-build-images:danger image: registry.gitlab.com/gitlab-org/gitlab-build-images:danger
stage: test stage: test
dependencies: [] needs:
- job: "retrieve-tests-metadata"
artifacts: false
script: script:
- git version - git version
- node --version - node --version
......
...@@ -371,11 +371,11 @@ ...@@ -371,11 +371,11 @@
################## ##################
.releases:rules:canonical-dot-com-gitlab-stable-branch-only: .releases:rules:canonical-dot-com-gitlab-stable-branch-only:
rules: rules:
- if: '$CI_SERVER_HOST == "gitlab.com" && $CI_PROJECT_NAME == "gitlab-org/gitlab" && $CI_COMMIT_REF_NAME =~ /^[\d-]+-stable-ee$/' - if: '$CI_SERVER_HOST == "gitlab.com" && $CI_PROJECT_PATH == "gitlab-org/gitlab" && $CI_COMMIT_REF_NAME =~ /^[\d-]+-stable-ee$/'
.releases:rules:canonical-dot-com-security-gitlab-stable-branch-only: .releases:rules:canonical-dot-com-security-gitlab-stable-branch-only:
rules: rules:
- if: '$CI_SERVER_HOST == "gitlab.com" && $CI_PROJECT_NAME == "gitlab-org/security/gitlab" && $CI_COMMIT_REF_NAME =~ /^[\d-]+-stable-ee$/' - if: '$CI_SERVER_HOST == "gitlab.com" && $CI_PROJECT_PATH == "gitlab-org/security/gitlab" && $CI_COMMIT_REF_NAME =~ /^[\d-]+-stable-ee$/'
################# #################
# Reports rules # # Reports rules #
......
...@@ -355,7 +355,7 @@ group :development, :test do ...@@ -355,7 +355,7 @@ group :development, :test do
gem 'database_cleaner', '~> 1.7.0' gem 'database_cleaner', '~> 1.7.0'
gem 'factory_bot_rails', '~> 5.1.0' gem 'factory_bot_rails', '~> 5.1.0'
gem 'rspec-rails', '~> 4.0.0.beta3' gem 'rspec-rails', '~> 4.0.0.beta4'
# Prevent occasions where minitest is not bundled in packaged versions of ruby (see #3826) # Prevent occasions where minitest is not bundled in packaged versions of ruby (see #3826)
gem 'minitest', '~> 5.11.0' gem 'minitest', '~> 5.11.0'
......
...@@ -894,36 +894,36 @@ GEM ...@@ -894,36 +894,36 @@ GEM
chunky_png chunky_png
rqrcode-rails3 (0.1.7) rqrcode-rails3 (0.1.7)
rqrcode (>= 0.4.2) rqrcode (>= 0.4.2)
rspec (3.8.0) rspec (3.9.0)
rspec-core (~> 3.8.0) rspec-core (~> 3.9.0)
rspec-expectations (~> 3.8.0) rspec-expectations (~> 3.9.0)
rspec-mocks (~> 3.8.0) rspec-mocks (~> 3.9.0)
rspec-core (3.8.2) rspec-core (3.9.1)
rspec-support (~> 3.8.0) rspec-support (~> 3.9.1)
rspec-expectations (3.8.4) rspec-expectations (3.9.0)
diff-lcs (>= 1.2.0, < 2.0) diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.8.0) rspec-support (~> 3.9.0)
rspec-mocks (3.8.1) rspec-mocks (3.9.1)
diff-lcs (>= 1.2.0, < 2.0) diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.8.0) rspec-support (~> 3.9.0)
rspec-parameterized (0.4.2) rspec-parameterized (0.4.2)
binding_ninja (>= 0.2.3) binding_ninja (>= 0.2.3)
parser parser
proc_to_ast proc_to_ast
rspec (>= 2.13, < 4) rspec (>= 2.13, < 4)
unparser unparser
rspec-rails (4.0.0.beta3) rspec-rails (4.0.0.beta4)
actionpack (>= 4.2) actionpack (>= 4.2)
activesupport (>= 4.2) activesupport (>= 4.2)
railties (>= 4.2) railties (>= 4.2)
rspec-core (~> 3.8) rspec-core (~> 3.9)
rspec-expectations (~> 3.8) rspec-expectations (~> 3.9)
rspec-mocks (~> 3.8) rspec-mocks (~> 3.9)
rspec-support (~> 3.8) rspec-support (~> 3.9)
rspec-retry (0.6.1) rspec-retry (0.6.1)
rspec-core (> 3.3) rspec-core (> 3.3)
rspec-set (0.1.3) rspec-set (0.1.3)
rspec-support (3.8.2) rspec-support (3.9.2)
rspec_junit_formatter (0.4.1) rspec_junit_formatter (0.4.1)
rspec-core (>= 2, < 4, != 2.12.0) rspec-core (>= 2, < 4, != 2.12.0)
rspec_profiling (0.0.5) rspec_profiling (0.0.5)
...@@ -1350,7 +1350,7 @@ DEPENDENCIES ...@@ -1350,7 +1350,7 @@ DEPENDENCIES
rouge (~> 3.16.0) rouge (~> 3.16.0)
rqrcode-rails3 (~> 0.1.7) rqrcode-rails3 (~> 0.1.7)
rspec-parameterized rspec-parameterized
rspec-rails (~> 4.0.0.beta3) rspec-rails (~> 4.0.0.beta4)
rspec-retry (~> 0.6.1) rspec-retry (~> 0.6.1)
rspec-set (~> 0.1.3) rspec-set (~> 0.1.3)
rspec_junit_formatter rspec_junit_formatter
......
# frozen_string_literal: true
class RenameSecurityDashboardFeatureFlagToInstanceSecurityDashboard < ActiveRecord::Migration[6.0]
DOWNTIME = false
class FeatureGate < ApplicationRecord
self.table_name = 'feature_gates'
end
def up
security_dashboard_feature = FeatureGate.find_by(feature_key: :security_dashboard, key: :boolean)
if security_dashboard_feature.present?
FeatureGate.safe_find_or_create_by!(
feature_key: :instance_security_dashboard,
key: :boolean,
value: security_dashboard_feature.value
)
end
end
def down
FeatureGate.find_by(feature_key: :instance_security_dashboard, key: :boolean)&.delete
end
end
# frozen_string_literal: true
class RemoveSecurityDashboardFeatureFlag < ActiveRecord::Migration[6.0]
DOWNTIME = false
class FeatureGate < ApplicationRecord
self.table_name = 'feature_gates'
end
def up
FeatureGate.find_by(feature_key: :security_dashboard, key: :boolean)&.delete
end
def down
instance_security_dashboard_feature = FeatureGate.find_by(feature_key: :instance_security_dashboard, key: :boolean)
if instance_security_dashboard_feature.present?
FeatureGate.safe_find_or_create_by!(
feature_key: :security_dashboard,
key: instance_security_dashboard_feature.key,
value: instance_security_dashboard_feature.value
)
end
end
end
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2020_02_13_220211) do ActiveRecord::Schema.define(version: 2020_02_14_034836) do
# These are extensions that must be enabled in order to support this database # These are extensions that must be enabled in order to support this database
enable_extension "pg_trgm" enable_extension "pg_trgm"
......
...@@ -136,17 +136,23 @@ graph RL; ...@@ -136,17 +136,23 @@ graph RL;
E[review-build-cng]; E[review-build-cng];
F[build-qa-image]; F[build-qa-image];
G[review-deploy]; G[review-deploy];
I["karma, jest, webpack-dev-server, static-analysis"]; I["karma, jest"];
I2["karma-as-if-foss, jest-as-if-foss<br/>(EE default refs only)"]; I2["karma-as-if-foss, jest-as-if-foss<br/>(EE default refs only)"];
J["compile-assets pull-push-cache<br/>(master only)"]; J["compile-assets pull-push-cache<br/>(master only)"];
J2["compile-assets pull-push-cache as-if-foss<br/>(EE master only)"]; J2["compile-assets pull-push-cache as-if-foss<br/>(EE master only)"];
K[compile-assets pull-cache]; K[compile-assets pull-cache];
K2["compile-assets pull-cache as-if-foss<br/>(EE default refs only)"]; K2["compile-assets pull-cache as-if-foss<br/>(EE default refs only)"];
U[frontend-fixtures];
U2["frontend-fixtures-as-if-foss<br/>(EE default refs only)"];
V["webpack-dev-server, static-analysis"];
M[coverage]; M[coverage];
N["pages (master only)"]; N["pages (master only)"];
Q[package-and-qa]; Q[package-and-qa];
S["RSpec<br/>(e.g. rspec unit pg9)"] S["RSpec<br/>(e.g. rspec unit pg9)"]
T[retrieve-tests-metadata]; T[retrieve-tests-metadata];
QA["qa:internal, qa:selectors"];
QA2["qa:internal-as-if-foss, qa:selectors-as-if-foss<br/>(EE default refs only)"];
X["docs lint, code_quality, sast, dependency_scanning, danger-review"];
subgraph "`prepare` stage" subgraph "`prepare` stage"
A A
...@@ -160,17 +166,26 @@ subgraph "`prepare` stage" ...@@ -160,17 +166,26 @@ subgraph "`prepare` stage"
T T
end end
subgraph "`fixture` stage"
U -.-> |needs and depends on| A;
U -.-> |needs and depends on| K;
U2 -.-> |needs and depends on| A;
U2 -.-> |needs and depends on| K2;
end
subgraph "`test` stage" subgraph "`test` stage"
D -.-> |needs| A; D -.-> |needs| A;
I -.-> |needs and depends on| A; I -.-> |needs and depends on| U;
I -.-> |needs and depends on| K; I2 -.-> |needs and depends on| U2;
I2 -.-> |needs and depends on| A;
I2 -.-> |needs and depends on| K;
L -.-> |needs and depends on| A; L -.-> |needs and depends on| A;
S -.-> |needs and depends on| A; S -.-> |needs and depends on| A;
S -.-> |needs and depends on| K; S -.-> |needs and depends on| K;
S -.-> |needs and depends on| T; S -.-> |needs and depends on| T;
L["db:*, gitlab:setup, graphql-docs-verify, downtime_check"] -.-> |needs| A; L["db:*, gitlab:setup, graphql-docs-verify, downtime_check"] -.-> |needs| A;
V -.-> |needs and depends on| K;
X -.-> |needs| T;
QA -.-> |needs| T;
QA2 -.-> |needs| T;
end end
subgraph "`post-test` stage" subgraph "`post-test` stage"
......
...@@ -124,11 +124,12 @@ module Gitlab ...@@ -124,11 +124,12 @@ module Gitlab
self.__send__("#{key}=", options[key.to_sym]) # rubocop:disable GitlabSecurity/PublicSend self.__send__("#{key}=", options[key.to_sym]) # rubocop:disable GitlabSecurity/PublicSend
end end
record_metric_blob_size
# Retain the actual size before it is encoded # Retain the actual size before it is encoded
@loaded_size = @data.bytesize if @data @loaded_size = @data.bytesize if @data
@loaded_all_data = @loaded_size == size @loaded_all_data = @loaded_size == size
record_metric_blob_size
record_metric_truncated(truncated?)
end end
def binary_in_repo? def binary_in_repo?
...@@ -210,6 +211,14 @@ module Gitlab ...@@ -210,6 +211,14 @@ module Gitlab
self.class.gitlab_blob_size.observe({}, size) self.class.gitlab_blob_size.observe({}, size)
end end
def record_metric_truncated(bool)
if bool
self.class.gitlab_blob_truncated_true.increment
else
self.class.gitlab_blob_truncated_false.increment
end
end
def has_lfs_version_key? def has_lfs_version_key?
!empty? && text_in_repo? && data.start_with?("version https://git-lfs.github.com/spec") !empty? && text_in_repo? && data.start_with?("version https://git-lfs.github.com/spec")
end end
......
...@@ -28,7 +28,10 @@ window.gl = window.gl || {}; ...@@ -28,7 +28,10 @@ window.gl = window.gl || {};
gl.utils = gl.utils || {}; gl.utils = gl.utils || {};
gl.utils.disableButtonIfEmptyField = () => {}; 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(() => { beforeEach(() => {
jest.useFakeTimers(); jest.useFakeTimers();
loadFixtures(fixture); loadFixtures(fixture);
......
...@@ -22,7 +22,23 @@ describe Gitlab::Git::Blob, :seed_helper do ...@@ -22,7 +22,23 @@ describe Gitlab::Git::Blob, :seed_helper do
it 'records blob size' do it 'records blob size' do
expect(described_class).to receive(:gitlab_blob_size).and_call_original 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
end end
......
# 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
# 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
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