diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-19 21:09:10 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-19 21:09:10 +0300 |
commit | 33795139ea8e72756bee3675b4e16387425e6ab1 (patch) | |
tree | 3ca568fca61482e57810ee30ad5ce4b964a82c4e /spec/rubocop/migration_helpers_spec.rb | |
parent | c7e385e282bcb8505589bce526e692b7bb819ffa (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/rubocop/migration_helpers_spec.rb')
-rw-r--r-- | spec/rubocop/migration_helpers_spec.rb | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/spec/rubocop/migration_helpers_spec.rb b/spec/rubocop/migration_helpers_spec.rb new file mode 100644 index 00000000000..73ced8c58da --- /dev/null +++ b/spec/rubocop/migration_helpers_spec.rb @@ -0,0 +1,56 @@ +# frozen_string_literal: true + +require 'fast_spec_helper' +require 'rubocop' +require 'rspec-parameterized' + +require_relative '../../rubocop/migration_helpers' + +describe RuboCop::MigrationHelpers do + using RSpec::Parameterized::TableSyntax + + subject(:fake_cop) { Class.new { include RuboCop::MigrationHelpers }.new } + + let(:node) { double(:node) } + + before do + allow(node).to receive_message_chain('location.expression.source_buffer.name') + .and_return(name) + end + + describe '#in_migration?' do + where(:name, :expected) do + '/gitlab/db/migrate/20200210184420_create_operations_scopes_table.rb' | true + '/gitlab/db/post_migrate/20200210184420_create_operations_scopes_table.rb' | true + '/gitlab/db/geo/migrate/20200210184420_create_operations_scopes_table.rb' | true + '/gitlab/db/geo/post_migrate/20200210184420_create_operations_scopes_table.rb' | true + '/gitlab/db/elsewhere/20200210184420_create_operations_scopes_table.rb' | false + end + + with_them do + it { expect(fake_cop.in_migration?(node)).to eq(expected) } + end + end + + describe '#in_post_deployment_migration?' do + where(:name, :expected) do + '/gitlab/db/migrate/20200210184420_create_operations_scopes_table.rb' | false + '/gitlab/db/post_migrate/20200210184420_create_operations_scopes_table.rb' | true + '/gitlab/db/geo/migrate/20200210184420_create_operations_scopes_table.rb' | false + '/gitlab/db/geo/post_migrate/20200210184420_create_operations_scopes_table.rb' | true + '/gitlab/db/elsewhere/20200210184420_create_operations_scopes_table.rb' | false + end + + with_them do + it { expect(fake_cop.in_post_deployment_migration?(node)).to eq(expected) } + end + end + + describe "#version" do + let(:name) do + '/path/to/gitlab/db/migrate/20200210184420_create_operations_scopes_table.rb' + end + + it { expect(fake_cop.version(node)).to eq(20200210184420) } + end +end |