rubocop-discourse 3.8.0 → 3.8.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +1 -1
- data/lib/rubocop/cop/discourse/no_add_reference_active_record_migrations.rb +2 -2
- data/lib/rubocop/cop/discourse/no_chdir.rb +1 -1
- data/lib/rubocop/cop/discourse/no_direct_multisite_manipulation.rb +1 -1
- data/lib/rubocop/cop/discourse/no_json_parse_response.rb +3 -6
- data/lib/rubocop/cop/discourse/no_mixing_multisite_and_standard_specs.rb +1 -1
- data/lib/rubocop/cop/discourse/no_mocking_jobs.rb +1 -1
- data/lib/rubocop/cop/discourse/no_nokogiri_html_fragment.rb +1 -1
- data/lib/rubocop/cop/discourse/no_reset_column_information_in_migrations.rb +1 -1
- data/lib/rubocop/cop/discourse/no_time_new_without_args.rb +2 -4
- data/lib/rubocop/cop/discourse/no_uri_escape_encode.rb +2 -2
- data/lib/rubocop/cop/discourse/only_top_level_multisite_specs.rb +1 -1
- data/lib/rubocop/cop/discourse/time_eq_matcher.rb +2 -4
- data/rubocop-discourse.gemspec +3 -2
- data/rubocop-rspec.yml +9 -1
- data/spec/lib/rubocop/cop/no_add_reference_active_record_migrations_spec.rb +11 -12
- data/spec/lib/rubocop/cop/no_mixing_multisite_and_standard_specs_spec.rb +8 -8
- data/spec/lib/rubocop/cop/no_mocking_jobs_enqueue_spec.rb +6 -6
- data/spec/lib/rubocop/cop/no_reset_column_information_migrations_spec.rb +5 -6
- data/spec/lib/rubocop/cop/only_top_level_multisite_specs_spec.rb +12 -12
- data/spec/lib/rubocop/cop/time_eq_matcher_spec.rb +4 -4
- metadata +18 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d99caa8cf2d3885ef79b260a4b7747d7060a4fc57bf4b72d10627b7c076f1460
|
4
|
+
data.tar.gz: 92bb54e600d4875a6ba0f21a003438292e2f6c15874f8e170677e9721d1cb3ba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2a589b65b0f8ef2948e9efbf061e9a022d5434f98f25644ff19c6c7ef6c37581c569f988af30894a80a16f0e4bf7c8611156ed6e1b480ad8a78f7ede2a160a4f
|
7
|
+
data.tar.gz: bd12917c2c595b37fda32e695ecdc3f513072b9d55c018b6e31c07b62654c9dca299f8eadd2019ea8df43674c9a29643137f477dd633002649aee31aa3a80474
|
data/.github/workflows/ci.yml
CHANGED
@@ -44,7 +44,7 @@ module RuboCop
|
|
44
44
|
# index_posts_on_image_upload_id ON posts USING btree (image_upload_id)
|
45
45
|
# SQL
|
46
46
|
# end
|
47
|
-
class NoAddReferenceOrAliasesActiveRecordMigration <
|
47
|
+
class NoAddReferenceOrAliasesActiveRecordMigration < Base
|
48
48
|
MSG = <<~MSG
|
49
49
|
AR methods add_reference, add_belongs_to, t.references, and t.belongs_to are
|
50
50
|
high-risk for large tables and have too many background magic operations.
|
@@ -74,7 +74,7 @@ module RuboCop
|
|
74
74
|
using_add_reference?(node),
|
75
75
|
using_add_belongs_to?(node),
|
76
76
|
using_t_references?(node),
|
77
|
-
using_t_belongs_to?(node)
|
77
|
+
using_t_belongs_to?(node),
|
78
78
|
].none?
|
79
79
|
return
|
80
80
|
end
|
@@ -16,7 +16,7 @@ module RuboCop
|
|
16
16
|
# it "works", type: :multisite do
|
17
17
|
# do_something
|
18
18
|
# end
|
19
|
-
class NoDirectMultisiteManipulation <
|
19
|
+
class NoDirectMultisiteManipulation < Base
|
20
20
|
MSG =
|
21
21
|
"Use `type: :multisite` example setting instead of modifying `Rails.configuration.multisite`."
|
22
22
|
|
@@ -11,9 +11,8 @@ module RuboCop
|
|
11
11
|
#
|
12
12
|
# # good
|
13
13
|
# expect(response.parsed_body).to eq({})
|
14
|
-
class NoJsonParseResponse <
|
15
|
-
MSG =
|
16
|
-
"Use `response.parsed_body` instead of `JSON.parse(response.body)` in specs."
|
14
|
+
class NoJsonParseResponse < Base
|
15
|
+
MSG = "Use `response.parsed_body` instead of `JSON.parse(response.body)` in specs."
|
17
16
|
|
18
17
|
def_node_matcher :json_parse_body?, <<-MATCHER
|
19
18
|
(send
|
@@ -29,9 +28,7 @@ module RuboCop
|
|
29
28
|
end
|
30
29
|
|
31
30
|
def autocorrect(node)
|
32
|
-
lambda
|
33
|
-
corrector.replace(node.loc.expression, "response.parsed_body")
|
34
|
-
end
|
31
|
+
lambda { |corrector| corrector.replace(node.loc.expression, "response.parsed_body") }
|
35
32
|
end
|
36
33
|
end
|
37
34
|
end
|
@@ -23,7 +23,7 @@ module RuboCop
|
|
23
23
|
# # x_multisite_spec.rb
|
24
24
|
# describe "x", type: :multisite do
|
25
25
|
# end
|
26
|
-
class NoMixingMultisiteAndStandardSpecs <
|
26
|
+
class NoMixingMultisiteAndStandardSpecs < Base
|
27
27
|
MSG =
|
28
28
|
"Do not mix multisite and standard specs. Consider moving multisite describes to a separate file."
|
29
29
|
|
@@ -12,7 +12,7 @@ module RuboCop
|
|
12
12
|
#
|
13
13
|
# # good
|
14
14
|
# Nokogiri::HTML5.fragment("<p>test</p>")
|
15
|
-
class NoNokogiriHtmlFragment <
|
15
|
+
class NoNokogiriHtmlFragment < Base
|
16
16
|
MSG = "Nokogiri::HTML.fragment is deprecated and should not be used."
|
17
17
|
|
18
18
|
def_node_matcher :using_nokogiri_html_fragment?, <<-MATCHER
|
@@ -7,7 +7,7 @@ module RuboCop
|
|
7
7
|
# migrations. The method is not thread safe and we run migrations
|
8
8
|
# concurrently for multisites. Also, we don't encourage the use of
|
9
9
|
# ActiveRecord methods in migrations and prefer to write SQL directly.
|
10
|
-
class NoResetColumnInformationInMigrations <
|
10
|
+
class NoResetColumnInformationInMigrations < Base
|
11
11
|
MSG =
|
12
12
|
"ActiveRecord::ModelSchema.reset_column_information is not thread-safe " \
|
13
13
|
"and we run migrations concurrently on multisite clusters. Using this " \
|
@@ -11,7 +11,7 @@ module RuboCop
|
|
11
11
|
#
|
12
12
|
# # good
|
13
13
|
# now = Time.zone.now
|
14
|
-
class NoTimeNewWithoutArgs <
|
14
|
+
class NoTimeNewWithoutArgs < Base
|
15
15
|
MSG = "Use `Time.zone.now` instead of `Time.new` without arguments."
|
16
16
|
|
17
17
|
def_node_matcher :time_new_without_args?, <<-MATCHER
|
@@ -25,9 +25,7 @@ module RuboCop
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def autocorrect(node)
|
28
|
-
lambda
|
29
|
-
corrector.replace(node.loc.expression, "Time.zone.now")
|
30
|
-
end
|
28
|
+
lambda { |corrector| corrector.replace(node.loc.expression, "Time.zone.now") }
|
31
29
|
end
|
32
30
|
end
|
33
31
|
end
|
@@ -15,7 +15,7 @@ module RuboCop
|
|
15
15
|
# # good
|
16
16
|
# UrlHelper.encode("https://a%20a.com?a='a%22")
|
17
17
|
# Addressable::URI.encode("https://a%20a.com?a='a%22")
|
18
|
-
class NoURIEscapeEncode <
|
18
|
+
class NoURIEscapeEncode < Base
|
19
19
|
MSG =
|
20
20
|
"URI.escape, URI.encode, URI.unescape, URI.decode are deprecated and should not be used."
|
21
21
|
|
@@ -40,7 +40,7 @@ module RuboCop
|
|
40
40
|
using_uri_escape?(node),
|
41
41
|
using_uri_encode?(node),
|
42
42
|
using_uri_unescape?(node),
|
43
|
-
using_uri_decode?(node)
|
43
|
+
using_uri_decode?(node),
|
44
44
|
].none?
|
45
45
|
return
|
46
46
|
end
|
@@ -11,7 +11,7 @@ module RuboCop
|
|
11
11
|
#
|
12
12
|
# # good
|
13
13
|
# expect(user.created_at).to eq_time(Time.zone.now)
|
14
|
-
class TimeEqMatcher <
|
14
|
+
class TimeEqMatcher < Base
|
15
15
|
MSG = "Use eq_time when testing timestamps"
|
16
16
|
|
17
17
|
def_node_matcher :using_eq_matcher_with_timestamp?, <<-MATCHER
|
@@ -29,9 +29,7 @@ module RuboCop
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def autocorrect(node)
|
32
|
-
lambda
|
33
|
-
corrector.replace(node.children.last.loc.selector, "eq_time")
|
34
|
-
end
|
32
|
+
lambda { |corrector| corrector.replace(node.children.last.loc.selector, "eq_time") }
|
35
33
|
end
|
36
34
|
|
37
35
|
private
|
data/rubocop-discourse.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = "rubocop-discourse"
|
5
|
-
s.version = "3.8.
|
5
|
+
s.version = "3.8.2"
|
6
6
|
s.summary = "Custom rubocop cops used by Discourse"
|
7
7
|
s.authors = ["Discourse Team"]
|
8
8
|
s.license = "MIT"
|
@@ -13,10 +13,11 @@ Gem::Specification.new do |s|
|
|
13
13
|
|
14
14
|
s.add_runtime_dependency "activesupport", ">= 6.1"
|
15
15
|
s.add_runtime_dependency "rubocop", ">= 1.59.0"
|
16
|
-
s.add_runtime_dependency "rubocop-rspec", ">=
|
16
|
+
s.add_runtime_dependency "rubocop-rspec", ">= 3.0.1"
|
17
17
|
s.add_runtime_dependency "rubocop-factory_bot", ">= 2.0.0"
|
18
18
|
s.add_runtime_dependency "rubocop-capybara", ">= 2.0.0"
|
19
19
|
s.add_runtime_dependency "rubocop-rails", ">= 2.25.0"
|
20
|
+
s.add_runtime_dependency "rubocop-rspec_rails", ">= 2.30.0"
|
20
21
|
|
21
22
|
s.add_development_dependency "rake", "~> 13.1.0"
|
22
23
|
s.add_development_dependency "rspec", "~> 3.12.0"
|
data/rubocop-rspec.yml
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require:
|
2
2
|
- rubocop-rspec
|
3
|
+
- rubocop-rspec_rails
|
3
4
|
|
4
5
|
RSpec/AnyInstance:
|
5
6
|
Enabled: false # To be decided
|
@@ -223,8 +224,15 @@ RSpec/VoidExpect:
|
|
223
224
|
RSpec/Yield:
|
224
225
|
Enabled: true
|
225
226
|
|
226
|
-
RSpec/
|
227
|
+
RSpec/Dialect:
|
227
228
|
Enabled: true
|
229
|
+
PreferredMethods:
|
230
|
+
background: :before
|
231
|
+
scenario: :it
|
232
|
+
xscenario: :xit
|
233
|
+
given: :let
|
234
|
+
given!: :let!
|
235
|
+
feature: :describe
|
228
236
|
|
229
237
|
RSpecRails/HttpStatus:
|
230
238
|
Enabled: true
|
@@ -2,28 +2,27 @@
|
|
2
2
|
|
3
3
|
require "spec_helper"
|
4
4
|
|
5
|
-
describe RuboCop::Cop::Discourse::NoAddReferenceOrAliasesActiveRecordMigration,
|
6
|
-
:config do
|
5
|
+
describe RuboCop::Cop::Discourse::NoAddReferenceOrAliasesActiveRecordMigration, :config do
|
7
6
|
subject(:cop) { described_class.new(config) }
|
8
7
|
|
9
8
|
let(:config) { RuboCop::Config.new }
|
10
9
|
|
11
10
|
it "raises an offense if add_reference is used, with or without arguments" do
|
12
|
-
inspect_source(<<~RUBY)
|
11
|
+
offenses = inspect_source(<<~RUBY)
|
13
12
|
add_reference :posts, :users, foreign_key: true, null: false
|
14
13
|
RUBY
|
15
|
-
expect(
|
14
|
+
expect(offenses.first.message).to match(described_class::MSG)
|
16
15
|
end
|
17
16
|
|
18
17
|
it "raises an offense if add_belongs_to is used, with or without arguments" do
|
19
|
-
inspect_source(<<~RUBY)
|
18
|
+
offenses = inspect_source(<<~RUBY)
|
20
19
|
add_belongs_to :posts, :users, foreign_key: true, null: false
|
21
20
|
RUBY
|
22
|
-
expect(
|
21
|
+
expect(offenses.first.message).to match(described_class::MSG)
|
23
22
|
end
|
24
23
|
|
25
24
|
it "raises an offense if t.references, or any variable.references is used, with or without arguments" do
|
26
|
-
inspect_source(<<~RUBY)
|
25
|
+
offenses = inspect_source(<<~RUBY)
|
27
26
|
create_table do |t|
|
28
27
|
t.references :topic, null: false
|
29
28
|
end
|
@@ -31,12 +30,12 @@ describe RuboCop::Cop::Discourse::NoAddReferenceOrAliasesActiveRecordMigration,
|
|
31
30
|
mytable.references :topic, null: false
|
32
31
|
end
|
33
32
|
RUBY
|
34
|
-
expect(
|
35
|
-
expect(
|
33
|
+
expect(offenses.count).to eq(2)
|
34
|
+
expect(offenses.first.message).to match(described_class::MSG)
|
36
35
|
end
|
37
36
|
|
38
37
|
it "raises an offense if t.belongs_to, or any variable.belongs_to is used, with or without arguments" do
|
39
|
-
inspect_source(<<~RUBY)
|
38
|
+
offenses = inspect_source(<<~RUBY)
|
40
39
|
create_table do |t|
|
41
40
|
t.belongs_to :topic, null: false
|
42
41
|
end
|
@@ -44,7 +43,7 @@ describe RuboCop::Cop::Discourse::NoAddReferenceOrAliasesActiveRecordMigration,
|
|
44
43
|
mytable.belongs_to :topic, null: false
|
45
44
|
end
|
46
45
|
RUBY
|
47
|
-
expect(
|
48
|
-
expect(
|
46
|
+
expect(offenses.count).to eq(2)
|
47
|
+
expect(offenses.first.message).to match(described_class::MSG)
|
49
48
|
end
|
50
49
|
end
|
@@ -8,7 +8,7 @@ describe RuboCop::Cop::Discourse::NoMixingMultisiteAndStandardSpecs, :config do
|
|
8
8
|
let(:config) { RuboCop::Config.new }
|
9
9
|
|
10
10
|
it "raises an offense if there are multisite and standard top-level describes" do
|
11
|
-
inspect_source(<<~RUBY)
|
11
|
+
offenses = inspect_source(<<~RUBY)
|
12
12
|
RSpec.describe "test" do
|
13
13
|
end
|
14
14
|
|
@@ -16,11 +16,11 @@ describe RuboCop::Cop::Discourse::NoMixingMultisiteAndStandardSpecs, :config do
|
|
16
16
|
end
|
17
17
|
RUBY
|
18
18
|
|
19
|
-
expect(
|
19
|
+
expect(offenses.first.message).to match(described_class::MSG)
|
20
20
|
end
|
21
21
|
|
22
22
|
it "raises an offense if there are multiple multisite and standard top-level describes" do
|
23
|
-
inspect_source(<<~RUBY)
|
23
|
+
offenses = inspect_source(<<~RUBY)
|
24
24
|
describe "test", type: :multisite do
|
25
25
|
end
|
26
26
|
|
@@ -31,11 +31,11 @@ describe RuboCop::Cop::Discourse::NoMixingMultisiteAndStandardSpecs, :config do
|
|
31
31
|
end
|
32
32
|
RUBY
|
33
33
|
|
34
|
-
expect(
|
34
|
+
expect(offenses.first.message).to match(described_class::MSG)
|
35
35
|
end
|
36
36
|
|
37
37
|
it "does not raise an offense if there are only multisite describes" do
|
38
|
-
inspect_source(<<~RUBY)
|
38
|
+
offenses = inspect_source(<<~RUBY)
|
39
39
|
require "foo"
|
40
40
|
|
41
41
|
describe "test", type: :multisite do
|
@@ -49,11 +49,11 @@ describe RuboCop::Cop::Discourse::NoMixingMultisiteAndStandardSpecs, :config do
|
|
49
49
|
end
|
50
50
|
RUBY
|
51
51
|
|
52
|
-
expect(
|
52
|
+
expect(offenses).to eq([])
|
53
53
|
end
|
54
54
|
|
55
55
|
it "does not raise an offense if there are only standard describes" do
|
56
|
-
inspect_source(<<~RUBY)
|
56
|
+
offenses = inspect_source(<<~RUBY)
|
57
57
|
require "rails_helper"
|
58
58
|
|
59
59
|
describe "test" do
|
@@ -65,6 +65,6 @@ describe RuboCop::Cop::Discourse::NoMixingMultisiteAndStandardSpecs, :config do
|
|
65
65
|
end
|
66
66
|
RUBY
|
67
67
|
|
68
|
-
expect(
|
68
|
+
expect(offenses).to eq([])
|
69
69
|
end
|
70
70
|
end
|
@@ -8,26 +8,26 @@ describe RuboCop::Cop::Discourse::NoMockingJobs, :config do
|
|
8
8
|
let(:config) { RuboCop::Config.new }
|
9
9
|
|
10
10
|
it "raises an offense if Jobs is mocked with :enqueue" do
|
11
|
-
inspect_source(<<~RUBY)
|
11
|
+
offenses = inspect_source(<<~RUBY)
|
12
12
|
Jobs.expects(:enqueue)
|
13
13
|
RUBY
|
14
14
|
|
15
|
-
expect(
|
15
|
+
expect(offenses.first.message).to end_with(described_class::MSG)
|
16
16
|
end
|
17
17
|
|
18
18
|
it "raises an offense if Jobs is mocked with :enqueue_in" do
|
19
|
-
inspect_source(<<~RUBY)
|
19
|
+
offenses = inspect_source(<<~RUBY)
|
20
20
|
Jobs.expects(:enqueue_in)
|
21
21
|
RUBY
|
22
22
|
|
23
|
-
expect(
|
23
|
+
expect(offenses.first.message).to end_with(described_class::MSG)
|
24
24
|
end
|
25
25
|
|
26
26
|
it "does not raise an offense if Jobs is not mocked with :enqueue or :enqueue_in" do
|
27
|
-
inspect_source(<<~RUBY)
|
27
|
+
offenses = inspect_source(<<~RUBY)
|
28
28
|
Jobs.enqueue(:some_job)
|
29
29
|
RUBY
|
30
30
|
|
31
|
-
expect(
|
31
|
+
expect(offenses).to eq([])
|
32
32
|
end
|
33
33
|
end
|
@@ -2,8 +2,7 @@
|
|
2
2
|
|
3
3
|
require "spec_helper"
|
4
4
|
|
5
|
-
describe RuboCop::Cop::Discourse::NoResetColumnInformationInMigrations,
|
6
|
-
:config do
|
5
|
+
describe RuboCop::Cop::Discourse::NoResetColumnInformationInMigrations, :config do
|
7
6
|
subject(:cop) { described_class.new(config) }
|
8
7
|
|
9
8
|
let(:config) { RuboCop::Config.new }
|
@@ -11,7 +10,7 @@ describe RuboCop::Cop::Discourse::NoResetColumnInformationInMigrations,
|
|
11
10
|
before { config["Discourse/NoResetColumnInformationInMigrations"]["Enabled"] = true }
|
12
11
|
|
13
12
|
it "raises an offense if reset_column_information is used" do
|
14
|
-
inspect_source(<<~RUBY)
|
13
|
+
offenses = inspect_source(<<~RUBY)
|
15
14
|
class SomeMigration < ActiveRecord::Migration[6.0]
|
16
15
|
def up
|
17
16
|
Post.reset_column_information
|
@@ -19,11 +18,11 @@ describe RuboCop::Cop::Discourse::NoResetColumnInformationInMigrations,
|
|
19
18
|
end
|
20
19
|
RUBY
|
21
20
|
|
22
|
-
expect(
|
21
|
+
expect(offenses.first.message).to match(described_class::MSG)
|
23
22
|
end
|
24
23
|
|
25
24
|
it "raise an offense if reset_column_information is used without AR model" do
|
26
|
-
inspect_source(<<~RUBY)
|
25
|
+
offenses = inspect_source(<<~RUBY)
|
27
26
|
class SomeMigration < ActiveRecord::Migration[6.0]
|
28
27
|
def up
|
29
28
|
"post".classify.constantize.reset_column_information
|
@@ -31,6 +30,6 @@ describe RuboCop::Cop::Discourse::NoResetColumnInformationInMigrations,
|
|
31
30
|
end
|
32
31
|
RUBY
|
33
32
|
|
34
|
-
expect(
|
33
|
+
expect(offenses.first.message).to match(described_class::MSG)
|
35
34
|
end
|
36
35
|
end
|
@@ -8,29 +8,29 @@ describe RuboCop::Cop::Discourse::OnlyTopLevelMultisiteSpecs, :config do
|
|
8
8
|
let(:config) { RuboCop::Config.new }
|
9
9
|
|
10
10
|
it "raises an offense if multisite config option is used in a sub-describe" do
|
11
|
-
inspect_source(<<~RUBY)
|
11
|
+
offenses = inspect_source(<<~RUBY)
|
12
12
|
describe "test" do
|
13
13
|
describe "sub-test", type: :multisite do
|
14
14
|
end
|
15
15
|
end
|
16
16
|
RUBY
|
17
17
|
|
18
|
-
expect(
|
18
|
+
expect(offenses.first.message).to match(described_class::MSG)
|
19
19
|
end
|
20
20
|
|
21
21
|
it "raises an offense if multisite config option is used in a sub-describe (RSpec const version)" do
|
22
|
-
inspect_source(<<~RUBY)
|
22
|
+
offenses = inspect_source(<<~RUBY)
|
23
23
|
RSpec.describe "test" do
|
24
24
|
RSpec.describe "sub-test", type: :multisite do
|
25
25
|
end
|
26
26
|
end
|
27
27
|
RUBY
|
28
28
|
|
29
|
-
expect(
|
29
|
+
expect(offenses.first.message).to match(described_class::MSG)
|
30
30
|
end
|
31
31
|
|
32
32
|
it "raises an offense if multisite config option is used in an example" do
|
33
|
-
inspect_source(<<~RUBY)
|
33
|
+
offenses = inspect_source(<<~RUBY)
|
34
34
|
describe "test" do
|
35
35
|
it "acts as an example" do
|
36
36
|
end
|
@@ -40,33 +40,33 @@ describe RuboCop::Cop::Discourse::OnlyTopLevelMultisiteSpecs, :config do
|
|
40
40
|
end
|
41
41
|
RUBY
|
42
42
|
|
43
|
-
expect(
|
43
|
+
expect(offenses.first.message).to match(described_class::MSG)
|
44
44
|
end
|
45
45
|
|
46
46
|
it "raises an offense if multisite config option is used in a context" do
|
47
|
-
inspect_source(<<~RUBY)
|
47
|
+
offenses = inspect_source(<<~RUBY)
|
48
48
|
describe "test" do
|
49
49
|
context "special circumstances", type: :multisite do
|
50
50
|
end
|
51
51
|
end
|
52
52
|
RUBY
|
53
53
|
|
54
|
-
expect(
|
54
|
+
expect(offenses.first.message).to match(described_class::MSG)
|
55
55
|
end
|
56
56
|
|
57
57
|
it "does not raise an offense if multisite config option is used on top-level describe" do
|
58
|
-
inspect_source(<<~RUBY)
|
58
|
+
offenses = inspect_source(<<~RUBY)
|
59
59
|
describe "test", type: :multisite do
|
60
60
|
describe "sub-test" do
|
61
61
|
end
|
62
62
|
end
|
63
63
|
RUBY
|
64
64
|
|
65
|
-
expect(
|
65
|
+
expect(offenses).to eq([])
|
66
66
|
end
|
67
67
|
|
68
68
|
it "does not raise an offense if multisite config option is used on top-level describe (RSpec const version)" do
|
69
|
-
inspect_source(<<~RUBY)
|
69
|
+
offenses = inspect_source(<<~RUBY)
|
70
70
|
require "rails_helper"
|
71
71
|
|
72
72
|
RSpec.describe "test", type: :multisite do
|
@@ -75,6 +75,6 @@ describe RuboCop::Cop::Discourse::OnlyTopLevelMultisiteSpecs, :config do
|
|
75
75
|
end
|
76
76
|
RUBY
|
77
77
|
|
78
|
-
expect(
|
78
|
+
expect(offenses).to eq([])
|
79
79
|
end
|
80
80
|
end
|
@@ -8,18 +8,18 @@ describe RuboCop::Cop::Discourse::TimeEqMatcher, :config do
|
|
8
8
|
let(:config) { RuboCop::Config.new }
|
9
9
|
|
10
10
|
it "raises an offense if a timestamp is compared using `eq`" do
|
11
|
-
inspect_source(<<~RUBY)
|
11
|
+
offenses = inspect_source(<<~RUBY)
|
12
12
|
expect(user.created_at).to eq(Time.zone.now)
|
13
13
|
RUBY
|
14
14
|
|
15
|
-
expect(
|
15
|
+
expect(offenses.first.message).to match(described_class::MSG)
|
16
16
|
end
|
17
17
|
|
18
18
|
it "passes if a timestamp is compared using `eq_time`" do
|
19
|
-
inspect_source(<<~RUBY)
|
19
|
+
offenses = inspect_source(<<~RUBY)
|
20
20
|
expect(user.created_at).to eq_time(Time.zone.now)
|
21
21
|
RUBY
|
22
22
|
|
23
|
-
expect(
|
23
|
+
expect(offenses).to be_empty
|
24
24
|
end
|
25
25
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubocop-discourse
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.8.
|
4
|
+
version: 3.8.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Discourse Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-10-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 3.0.1
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: 3.0.1
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rubocop-factory_bot
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -94,6 +94,20 @@ dependencies:
|
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: 2.25.0
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rubocop-rspec_rails
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 2.30.0
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 2.30.0
|
97
111
|
- !ruby/object:Gem::Dependency
|
98
112
|
name: rake
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|