outrigger 3.1.0 → 3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Rakefile +2 -2
- data/lib/outrigger/cops/migration/tagged.rb +3 -6
- data/lib/outrigger/railtie.rb +2 -2
- data/lib/outrigger/version.rb +1 -1
- data/lib/outrigger.rb +6 -6
- data/lib/tasks/outrigger.rake +1 -1
- data/spec/outrigger/migrator_spec.rb +8 -6
- data/spec/outrigger/outrigger_spec.rb +3 -3
- data/spec/outrigger/railtie_spec.rb +2 -2
- data/spec/outrigger/taggable_proxy_spec.rb +1 -1
- data/spec/outrigger/taggable_spec.rb +4 -4
- data/spec/rubocop/cop/migration/tagged_spec.rb +91 -0
- data/spec/spec_helper.rb +12 -11
- metadata +8 -124
- data/spec/outrigger/cops/migration/tagged_spec.rb +0 -91
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1e9ee6034865548d34c7f9927301ffc5543f057f074fb09f3cab47e429f1241e
|
|
4
|
+
data.tar.gz: 9df796e4a6ec0df60c6f4afa2ae13f55f02a7289824ae41db1c02a4b6ee977b9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 326bc1cbd0665a6df25b146141119511be9a4b0257877913a699ff1bd48a00562527b60153c8b5506885c9d4bd0e0edd077abd7a44d6d068c955242b1dda915b
|
|
7
|
+
data.tar.gz: 2bee38a6e7c046708ecacd7a64742ef5f1c498afb3e41e1bdb50485abe5567d5a10093f6ee717c67ed823836fb478bd0b873ff419578d75c6ad8d58ce24c2b69
|
data/Rakefile
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
module RuboCop
|
|
4
4
|
module Cop
|
|
5
5
|
module Migration
|
|
6
|
-
class Tagged <
|
|
6
|
+
class Tagged < Base
|
|
7
7
|
def on_class(node)
|
|
8
8
|
_name, _superclass, body = *node
|
|
9
9
|
return unless body && migration_class?(node)
|
|
@@ -32,17 +32,14 @@ module RuboCop
|
|
|
32
32
|
|
|
33
33
|
if allowed_tags.empty?
|
|
34
34
|
add_offense tag,
|
|
35
|
-
|
|
36
|
-
message: 'No allowed tags have been defined in the RuboCop configuration.'
|
|
35
|
+
message: "No allowed tags have been defined in the RuboCop configuration."
|
|
37
36
|
elsif tag
|
|
38
37
|
return if allowed_tags.include? tag.children.last.to_a.last
|
|
39
38
|
|
|
40
39
|
add_offense tag,
|
|
41
|
-
location: :expression,
|
|
42
40
|
message: "Tags may only be one of #{allowed_tags}."
|
|
43
41
|
else
|
|
44
42
|
add_offense klass,
|
|
45
|
-
location: :expression,
|
|
46
43
|
message: "All migrations require a tag from #{allowed_tags}."
|
|
47
44
|
end
|
|
48
45
|
end
|
|
@@ -54,7 +51,7 @@ module RuboCop
|
|
|
54
51
|
end
|
|
55
52
|
|
|
56
53
|
def allowed_tags
|
|
57
|
-
cop_config[
|
|
54
|
+
cop_config["AllowedTags"].map(&:to_sym)
|
|
58
55
|
end
|
|
59
56
|
end
|
|
60
57
|
end
|
data/lib/outrigger/railtie.rb
CHANGED
|
@@ -5,10 +5,10 @@ module Outrigger
|
|
|
5
5
|
railtie_name :taggable_migrations
|
|
6
6
|
|
|
7
7
|
rake_tasks do
|
|
8
|
-
load
|
|
8
|
+
load "tasks/outrigger.rake"
|
|
9
9
|
end
|
|
10
10
|
|
|
11
|
-
initializer
|
|
11
|
+
initializer "extend_migrations" do
|
|
12
12
|
ActiveSupport.on_load :active_record do
|
|
13
13
|
ActiveRecord::Migration.include(Outrigger::Taggable)
|
|
14
14
|
ActiveRecord::MigrationProxy.include(Outrigger::TaggableProxy)
|
data/lib/outrigger/version.rb
CHANGED
data/lib/outrigger.rb
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require
|
|
3
|
+
require "active_record" unless defined? ActiveRecord
|
|
4
4
|
|
|
5
|
-
require
|
|
6
|
-
require
|
|
7
|
-
require
|
|
5
|
+
require "outrigger/migrator"
|
|
6
|
+
require "outrigger/taggable"
|
|
7
|
+
require "outrigger/taggable_proxy"
|
|
8
8
|
|
|
9
|
-
require
|
|
9
|
+
require "outrigger/railtie" if defined? Rails::Railtie
|
|
10
10
|
|
|
11
11
|
module Outrigger
|
|
12
12
|
class << self
|
|
@@ -18,7 +18,7 @@ module Outrigger
|
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
def migration_context
|
|
21
|
-
if ActiveRecord.version < Gem::Version.new(
|
|
21
|
+
if ActiveRecord.version < Gem::Version.new("7.2")
|
|
22
22
|
ActiveRecord::Base.connection.migration_context
|
|
23
23
|
else
|
|
24
24
|
ActiveRecord::Base.connection_pool.migration_context
|
data/lib/tasks/outrigger.rake
CHANGED
|
@@ -10,14 +10,16 @@ module Outrigger
|
|
|
10
10
|
end
|
|
11
11
|
|
|
12
12
|
let(:migrations) do
|
|
13
|
-
[PostDeployMigration.new(nil, 1),
|
|
13
|
+
[PostDeployMigration.new(nil, 1),
|
|
14
|
+
UntaggedMigration.new(nil, 2),
|
|
15
|
+
PreDeployMigration.new(nil, 3),
|
|
14
16
|
MultiMigration.new(nil, 4)]
|
|
15
17
|
end
|
|
16
18
|
|
|
17
19
|
let(:versions) { [] }
|
|
18
20
|
let(:direction) { :up }
|
|
19
21
|
let(:schema_migration) do
|
|
20
|
-
if ActiveRecord.version < Gem::Version.new(
|
|
22
|
+
if ActiveRecord.version < Gem::Version.new("7.1")
|
|
21
23
|
object_double(ActiveRecord::SchemaMigration, create_table: nil, all_versions: versions)
|
|
22
24
|
else
|
|
23
25
|
instance_double(ActiveRecord::SchemaMigration, create_table: nil, integer_versions: versions)
|
|
@@ -25,7 +27,7 @@ module Outrigger
|
|
|
25
27
|
end
|
|
26
28
|
|
|
27
29
|
let(:migrator) do
|
|
28
|
-
if ActiveRecord.version < Gem::Version.new(
|
|
30
|
+
if ActiveRecord.version < Gem::Version.new("7.1")
|
|
29
31
|
ActiveRecord::Migrator.new(direction, migrations, schema_migration)
|
|
30
32
|
else
|
|
31
33
|
internal_metadata = instance_double(ActiveRecord::InternalMetadata, create_table: nil)
|
|
@@ -37,7 +39,7 @@ module Outrigger
|
|
|
37
39
|
allow(ActiveRecord::InternalMetadata).to receive(:create_table)
|
|
38
40
|
end
|
|
39
41
|
|
|
40
|
-
it
|
|
42
|
+
it "sorts" do
|
|
41
43
|
expect(migrator.runnable.map(&:class)).to eq(
|
|
42
44
|
[
|
|
43
45
|
PreDeployMigration, MultiMigration, UntaggedMigration, PostDeployMigration
|
|
@@ -45,11 +47,11 @@ module Outrigger
|
|
|
45
47
|
)
|
|
46
48
|
end
|
|
47
49
|
|
|
48
|
-
context
|
|
50
|
+
context "when going down" do
|
|
49
51
|
let(:versions) { [1, 2, 3, 4] }
|
|
50
52
|
let(:direction) { :down }
|
|
51
53
|
|
|
52
|
-
it
|
|
54
|
+
it "reverse sorts" do
|
|
53
55
|
expect(migrator.runnable.map(&:class)).to eq(
|
|
54
56
|
[
|
|
55
57
|
PostDeployMigration, UntaggedMigration, MultiMigration, PreDeployMigration
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
describe Outrigger do
|
|
4
|
-
describe
|
|
5
|
-
it
|
|
4
|
+
describe "filter" do
|
|
5
|
+
it "returns a proc that tests migrations" do
|
|
6
6
|
filter = described_class.filter(:predeploy)
|
|
7
7
|
|
|
8
8
|
expect(filter.call(PreDeployMigration)).to be(true)
|
|
9
9
|
end
|
|
10
10
|
|
|
11
|
-
it
|
|
11
|
+
it "accepts multiple tags" do
|
|
12
12
|
filter = described_class.filter(:predeploy, :postdeploy)
|
|
13
13
|
|
|
14
14
|
expect(filter.call(MultiMigration)).to be(true)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
describe Outrigger::Railtie do
|
|
4
|
-
it
|
|
5
|
-
expect(described_class.railtie_name).to eq
|
|
4
|
+
it "provides a railtie_name" do
|
|
5
|
+
expect(described_class.railtie_name).to eq "taggable_migrations"
|
|
6
6
|
end
|
|
7
7
|
end
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
describe Outrigger::Taggable do
|
|
4
|
-
it
|
|
4
|
+
it "PreDeployMigration should be predeploy" do
|
|
5
5
|
expect(PreDeployMigration.tags).to eq([:predeploy])
|
|
6
6
|
end
|
|
7
7
|
|
|
8
|
-
it
|
|
8
|
+
it "UntaggedMigration should be have no tags" do
|
|
9
9
|
expect(UntaggedMigration.tags).to eq([])
|
|
10
10
|
end
|
|
11
11
|
|
|
12
|
-
it
|
|
12
|
+
it "PostDeployMigration should be predeploy" do
|
|
13
13
|
expect(PostDeployMigration.tags).to eq([:postdeploy])
|
|
14
14
|
end
|
|
15
15
|
|
|
16
|
-
it
|
|
16
|
+
it "instance tags should point to class tags" do
|
|
17
17
|
expect(PreDeployMigration.new.tags).to eq([:predeploy])
|
|
18
18
|
end
|
|
19
19
|
end
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "outrigger/cops/migration/tagged"
|
|
4
|
+
|
|
5
|
+
RSpec.describe RuboCop::Cop::Migration::Tagged do
|
|
6
|
+
subject(:cop) { described_class.new(config) }
|
|
7
|
+
|
|
8
|
+
let(:config_hash) do
|
|
9
|
+
{
|
|
10
|
+
"Migration/Tagged" => {
|
|
11
|
+
"AllowedTags" => %w[predeploy deploy],
|
|
12
|
+
"Enabled" => true
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
let(:config) { RuboCop::Config.new(config_hash) }
|
|
18
|
+
|
|
19
|
+
let(:migration_class) do
|
|
20
|
+
<<~RUBY
|
|
21
|
+
class Test < ActiveRecord::Migration[4.2]
|
|
22
|
+
tag :predeploy
|
|
23
|
+
def change
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
RUBY
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
shared_examples_for "valid migrations" do
|
|
30
|
+
it "passes valid versioned migration" do
|
|
31
|
+
offenses = inspect_source(migration_class)
|
|
32
|
+
expect(offenses.empty?).to be(true)
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
context "with valid config" do
|
|
37
|
+
it_behaves_like "valid migrations"
|
|
38
|
+
|
|
39
|
+
context "with missing tags" do
|
|
40
|
+
let(:migration_class) do
|
|
41
|
+
<<~RUBY
|
|
42
|
+
class Test < ActiveRecord::Migration[4.2]
|
|
43
|
+
def change
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
RUBY
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
it "finds missing tag in versioned migration" do
|
|
50
|
+
offenses = inspect_source(migration_class)
|
|
51
|
+
expect(offenses.empty?).to be(false)
|
|
52
|
+
expect(offenses.first.message).to match(/All migrations require a tag from/)
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
context "with invalid tag" do
|
|
57
|
+
let(:migration_class) do
|
|
58
|
+
<<~RUBY
|
|
59
|
+
class Test < ActiveRecord::Migration[4.2]
|
|
60
|
+
tag :foobar
|
|
61
|
+
def change
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
RUBY
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
it "fails on invalid tag in versioned migration" do
|
|
68
|
+
offenses = inspect_source(migration_class)
|
|
69
|
+
expect(offenses.empty?).to be(false)
|
|
70
|
+
expect(offenses.first.message).to match(/Tags may only be one of/)
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
context "with invalid config" do
|
|
76
|
+
let(:config_hash) do
|
|
77
|
+
{
|
|
78
|
+
"Migration/Tagged" => {
|
|
79
|
+
"AllowedTags" => [],
|
|
80
|
+
"Enabled" => true
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
it "fails on missing tags in configuration on versioned migration" do
|
|
86
|
+
offenses = inspect_source(migration_class)
|
|
87
|
+
expect(offenses.empty?).to be(false)
|
|
88
|
+
expect(offenses.first.message).to match(/No allowed tags have been defined/)
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
end
|
data/spec/spec_helper.rb
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require
|
|
3
|
+
require "simplecov"
|
|
4
4
|
SimpleCov.start do
|
|
5
|
-
add_filter
|
|
6
|
-
add_filter
|
|
7
|
-
track_files
|
|
5
|
+
add_filter "lib/outrigger/version.rb"
|
|
6
|
+
add_filter "spec"
|
|
7
|
+
track_files "lib/**/*.rb"
|
|
8
8
|
end
|
|
9
9
|
SimpleCov.minimum_coverage(85)
|
|
10
10
|
|
|
11
|
-
require
|
|
12
|
-
require
|
|
13
|
-
require
|
|
14
|
-
require
|
|
15
|
-
require
|
|
11
|
+
require "bundler/setup"
|
|
12
|
+
require "debug"
|
|
13
|
+
require "rails"
|
|
14
|
+
require "rails/railtie"
|
|
15
|
+
require "rubocop"
|
|
16
|
+
require "rubocop/rspec/support"
|
|
16
17
|
|
|
17
|
-
require
|
|
18
|
+
require "outrigger"
|
|
18
19
|
|
|
19
20
|
ActiveRecord::Migration.include(Outrigger::Taggable)
|
|
20
21
|
ActiveRecord::MigrationProxy.include(Outrigger::TaggableProxy)
|
|
@@ -36,5 +37,5 @@ class MultiMigration < ActiveRecord::Migration[5.0]
|
|
|
36
37
|
end
|
|
37
38
|
|
|
38
39
|
RSpec.configure do |config|
|
|
39
|
-
config.order =
|
|
40
|
+
config.order = "random"
|
|
40
41
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: outrigger
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.
|
|
4
|
+
version: 3.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Drew Bowman
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: activerecord
|
|
@@ -19,7 +18,7 @@ dependencies:
|
|
|
19
18
|
version: '6.0'
|
|
20
19
|
- - "<"
|
|
21
20
|
- !ruby/object:Gem::Version
|
|
22
|
-
version: '8.
|
|
21
|
+
version: '8.2'
|
|
23
22
|
type: :runtime
|
|
24
23
|
prerelease: false
|
|
25
24
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -29,7 +28,7 @@ dependencies:
|
|
|
29
28
|
version: '6.0'
|
|
30
29
|
- - "<"
|
|
31
30
|
- !ruby/object:Gem::Version
|
|
32
|
-
version: '8.
|
|
31
|
+
version: '8.2'
|
|
33
32
|
- !ruby/object:Gem::Dependency
|
|
34
33
|
name: railties
|
|
35
34
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -39,7 +38,7 @@ dependencies:
|
|
|
39
38
|
version: '6.0'
|
|
40
39
|
- - "<"
|
|
41
40
|
- !ruby/object:Gem::Version
|
|
42
|
-
version: '8.
|
|
41
|
+
version: '8.2'
|
|
43
42
|
type: :runtime
|
|
44
43
|
prerelease: false
|
|
45
44
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -49,121 +48,8 @@ dependencies:
|
|
|
49
48
|
version: '6.0'
|
|
50
49
|
- - "<"
|
|
51
50
|
- !ruby/object:Gem::Version
|
|
52
|
-
version: '8.
|
|
53
|
-
- !ruby/object:Gem::Dependency
|
|
54
|
-
name: bundler
|
|
55
|
-
requirement: !ruby/object:Gem::Requirement
|
|
56
|
-
requirements:
|
|
57
|
-
- - "~>"
|
|
58
|
-
- !ruby/object:Gem::Version
|
|
59
|
-
version: '2.2'
|
|
60
|
-
type: :development
|
|
61
|
-
prerelease: false
|
|
62
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
63
|
-
requirements:
|
|
64
|
-
- - "~>"
|
|
65
|
-
- !ruby/object:Gem::Version
|
|
66
|
-
version: '2.2'
|
|
67
|
-
- !ruby/object:Gem::Dependency
|
|
68
|
-
name: byebug
|
|
69
|
-
requirement: !ruby/object:Gem::Requirement
|
|
70
|
-
requirements:
|
|
71
|
-
- - "~>"
|
|
72
|
-
- !ruby/object:Gem::Version
|
|
73
|
-
version: '11.1'
|
|
74
|
-
type: :development
|
|
75
|
-
prerelease: false
|
|
76
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
77
|
-
requirements:
|
|
78
|
-
- - "~>"
|
|
79
|
-
- !ruby/object:Gem::Version
|
|
80
|
-
version: '11.1'
|
|
81
|
-
- !ruby/object:Gem::Dependency
|
|
82
|
-
name: rake
|
|
83
|
-
requirement: !ruby/object:Gem::Requirement
|
|
84
|
-
requirements:
|
|
85
|
-
- - "~>"
|
|
86
|
-
- !ruby/object:Gem::Version
|
|
87
|
-
version: '13.0'
|
|
88
|
-
type: :development
|
|
89
|
-
prerelease: false
|
|
90
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
91
|
-
requirements:
|
|
92
|
-
- - "~>"
|
|
93
|
-
- !ruby/object:Gem::Version
|
|
94
|
-
version: '13.0'
|
|
95
|
-
- !ruby/object:Gem::Dependency
|
|
96
|
-
name: rspec
|
|
97
|
-
requirement: !ruby/object:Gem::Requirement
|
|
98
|
-
requirements:
|
|
99
|
-
- - "~>"
|
|
100
|
-
- !ruby/object:Gem::Version
|
|
101
|
-
version: '3.7'
|
|
102
|
-
type: :development
|
|
103
|
-
prerelease: false
|
|
104
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
105
|
-
requirements:
|
|
106
|
-
- - "~>"
|
|
107
|
-
- !ruby/object:Gem::Version
|
|
108
|
-
version: '3.7'
|
|
109
|
-
- !ruby/object:Gem::Dependency
|
|
110
|
-
name: rubocop
|
|
111
|
-
requirement: !ruby/object:Gem::Requirement
|
|
112
|
-
requirements:
|
|
113
|
-
- - "~>"
|
|
114
|
-
- !ruby/object:Gem::Version
|
|
115
|
-
version: '1.20'
|
|
116
|
-
type: :development
|
|
117
|
-
prerelease: false
|
|
118
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
119
|
-
requirements:
|
|
120
|
-
- - "~>"
|
|
121
|
-
- !ruby/object:Gem::Version
|
|
122
|
-
version: '1.20'
|
|
123
|
-
- !ruby/object:Gem::Dependency
|
|
124
|
-
name: rubocop-rake
|
|
125
|
-
requirement: !ruby/object:Gem::Requirement
|
|
126
|
-
requirements:
|
|
127
|
-
- - "~>"
|
|
128
|
-
- !ruby/object:Gem::Version
|
|
129
|
-
version: '0.6'
|
|
130
|
-
type: :development
|
|
131
|
-
prerelease: false
|
|
132
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
133
|
-
requirements:
|
|
134
|
-
- - "~>"
|
|
135
|
-
- !ruby/object:Gem::Version
|
|
136
|
-
version: '0.6'
|
|
137
|
-
- !ruby/object:Gem::Dependency
|
|
138
|
-
name: rubocop-rspec
|
|
139
|
-
requirement: !ruby/object:Gem::Requirement
|
|
140
|
-
requirements:
|
|
141
|
-
- - "~>"
|
|
142
|
-
- !ruby/object:Gem::Version
|
|
143
|
-
version: '3.6'
|
|
144
|
-
type: :development
|
|
145
|
-
prerelease: false
|
|
146
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
147
|
-
requirements:
|
|
148
|
-
- - "~>"
|
|
149
|
-
- !ruby/object:Gem::Version
|
|
150
|
-
version: '3.6'
|
|
151
|
-
- !ruby/object:Gem::Dependency
|
|
152
|
-
name: simplecov
|
|
153
|
-
requirement: !ruby/object:Gem::Requirement
|
|
154
|
-
requirements:
|
|
155
|
-
- - "~>"
|
|
156
|
-
- !ruby/object:Gem::Version
|
|
157
|
-
version: '0.21'
|
|
158
|
-
type: :development
|
|
159
|
-
prerelease: false
|
|
160
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
161
|
-
requirements:
|
|
162
|
-
- - "~>"
|
|
163
|
-
- !ruby/object:Gem::Version
|
|
164
|
-
version: '0.21'
|
|
51
|
+
version: '8.2'
|
|
165
52
|
description: Migrations
|
|
166
|
-
email:
|
|
167
53
|
executables: []
|
|
168
54
|
extensions: []
|
|
169
55
|
extra_rdoc_files: []
|
|
@@ -177,19 +63,18 @@ files:
|
|
|
177
63
|
- lib/outrigger/taggable_proxy.rb
|
|
178
64
|
- lib/outrigger/version.rb
|
|
179
65
|
- lib/tasks/outrigger.rake
|
|
180
|
-
- spec/outrigger/cops/migration/tagged_spec.rb
|
|
181
66
|
- spec/outrigger/migrator_spec.rb
|
|
182
67
|
- spec/outrigger/outrigger_spec.rb
|
|
183
68
|
- spec/outrigger/railtie_spec.rb
|
|
184
69
|
- spec/outrigger/taggable_proxy_spec.rb
|
|
185
70
|
- spec/outrigger/taggable_spec.rb
|
|
71
|
+
- spec/rubocop/cop/migration/tagged_spec.rb
|
|
186
72
|
- spec/spec_helper.rb
|
|
187
73
|
homepage: https://github.com/instructure/outrigger
|
|
188
74
|
licenses:
|
|
189
75
|
- MIT
|
|
190
76
|
metadata:
|
|
191
77
|
rubygems_mfa_required: 'true'
|
|
192
|
-
post_install_message:
|
|
193
78
|
rdoc_options: []
|
|
194
79
|
require_paths:
|
|
195
80
|
- lib
|
|
@@ -204,8 +89,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
204
89
|
- !ruby/object:Gem::Version
|
|
205
90
|
version: '0'
|
|
206
91
|
requirements: []
|
|
207
|
-
rubygems_version: 3.
|
|
208
|
-
signing_key:
|
|
92
|
+
rubygems_version: 3.6.9
|
|
209
93
|
specification_version: 4
|
|
210
94
|
summary: Tag migrations and run them separately
|
|
211
95
|
test_files: []
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'outrigger/cops/migration/tagged'
|
|
4
|
-
|
|
5
|
-
RSpec.describe RuboCop::Cop::Migration::Tagged do
|
|
6
|
-
let(:config_hash) do
|
|
7
|
-
{
|
|
8
|
-
'Migration/Tagged' => {
|
|
9
|
-
'AllowedTags' => %w[predeploy deploy],
|
|
10
|
-
'Enabled' => true
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
let(:config) { RuboCop::Config.new(config_hash) }
|
|
16
|
-
|
|
17
|
-
let(:migration_class) do
|
|
18
|
-
<<~RUBY
|
|
19
|
-
class Test < ActiveRecord::Migration[4.2]
|
|
20
|
-
tag :predeploy
|
|
21
|
-
def change
|
|
22
|
-
end
|
|
23
|
-
end
|
|
24
|
-
RUBY
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
subject(:cop) { described_class.new(config) } # rubocop:disable RSpec/LeadingSubject
|
|
28
|
-
|
|
29
|
-
shared_examples_for 'valid migrations' do
|
|
30
|
-
it 'passes valid versioned migration' do
|
|
31
|
-
inspect_source(migration_class)
|
|
32
|
-
expect(cop.offenses.empty?).to be(true)
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
context 'with valid config' do
|
|
37
|
-
it_behaves_like 'valid migrations'
|
|
38
|
-
|
|
39
|
-
context 'with missing tags' do
|
|
40
|
-
let(:migration_class) do
|
|
41
|
-
<<~RUBY
|
|
42
|
-
class Test < ActiveRecord::Migration[4.2]
|
|
43
|
-
def change
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
RUBY
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
it 'finds missing tag in versioned migration' do
|
|
50
|
-
inspect_source(migration_class)
|
|
51
|
-
expect(cop.offenses.empty?).to be(false)
|
|
52
|
-
expect(cop.offenses.first.message).to match(/All migrations require a tag from/)
|
|
53
|
-
end
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
context 'with invalid tag' do
|
|
57
|
-
let(:migration_class) do
|
|
58
|
-
<<~RUBY
|
|
59
|
-
class Test < ActiveRecord::Migration[4.2]
|
|
60
|
-
tag :foobar
|
|
61
|
-
def change
|
|
62
|
-
end
|
|
63
|
-
end
|
|
64
|
-
RUBY
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
it 'fails on invalid tag in versioned migration' do
|
|
68
|
-
inspect_source(migration_class)
|
|
69
|
-
expect(cop.offenses.empty?).to be(false)
|
|
70
|
-
expect(cop.offenses.first.message).to match(/Tags may only be one of/)
|
|
71
|
-
end
|
|
72
|
-
end
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
context 'with invalid config' do
|
|
76
|
-
let(:config_hash) do
|
|
77
|
-
{
|
|
78
|
-
'Migration/Tagged' => {
|
|
79
|
-
'AllowedTags' => [],
|
|
80
|
-
'Enabled' => true
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
it 'fails on missing tags in configuration on versioned migration' do
|
|
86
|
-
inspect_source(migration_class)
|
|
87
|
-
expect(cop.offenses.empty?).to be(false)
|
|
88
|
-
expect(cop.offenses.first.message).to match(/No allowed tags have been defined/)
|
|
89
|
-
end
|
|
90
|
-
end
|
|
91
|
-
end
|