Skip to content

Commit 4902ba6

Browse files
DEV: Bump rubocop-discourse and correct violations (#409)
1 parent 993f7fa commit 4902ba6

22 files changed

+88
-94
lines changed

Gemfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
source "https://rubygems.org"
44

55
group :development do
6-
gem "rubocop-discourse", git: "https://github.com/discourse/rubocop-discourse/", branch: "stree"
6+
gem "rubocop-discourse"
77
gem "syntax_tree"
88
end

Gemfile.lock

+11-17
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,31 @@
1-
GIT
2-
remote: https://github.com/discourse/rubocop-discourse/
3-
revision: 8afca6460a423a11a2e0bf1f7051b18dd9a7231b
4-
branch: stree
5-
specs:
6-
rubocop-discourse (2.5.0)
7-
rubocop (>= 1.1.0)
8-
rubocop-rspec (>= 2.0.0)
9-
101
GEM
112
remote: https://rubygems.org/
123
specs:
134
ast (2.4.2)
14-
json (2.6.2)
5+
json (2.6.3)
156
parallel (1.22.1)
16-
parser (3.1.2.1)
7+
parser (3.1.3.0)
178
ast (~> 2.4.1)
189
prettier_print (0.1.0)
1910
rainbow (3.1.1)
20-
regexp_parser (2.6.0)
11+
regexp_parser (2.6.1)
2112
rexml (3.2.5)
22-
rubocop (1.36.0)
13+
rubocop (1.41.1)
2314
json (~> 2.3)
2415
parallel (~> 1.10)
2516
parser (>= 3.1.2.1)
2617
rainbow (>= 2.2.2, < 4.0)
2718
regexp_parser (>= 1.8, < 3.0)
2819
rexml (>= 3.2.5, < 4.0)
29-
rubocop-ast (>= 1.20.1, < 2.0)
20+
rubocop-ast (>= 1.23.0, < 2.0)
3021
ruby-progressbar (~> 1.7)
3122
unicode-display_width (>= 1.4.0, < 3.0)
32-
rubocop-ast (1.21.0)
23+
rubocop-ast (1.24.0)
3324
parser (>= 3.1.1.0)
34-
rubocop-rspec (2.13.2)
25+
rubocop-discourse (3.0.1)
26+
rubocop (>= 1.1.0)
27+
rubocop-rspec (>= 2.0.0)
28+
rubocop-rspec (2.16.0)
3529
rubocop (~> 1.33)
3630
ruby-progressbar (1.11.0)
3731
syntax_tree (3.2.1)
@@ -42,7 +36,7 @@ PLATFORMS
4236
ruby
4337

4438
DEPENDENCIES
45-
rubocop-discourse!
39+
rubocop-discourse
4640
syntax_tree
4741

4842
BUNDLED WITH

lib/random_assign_utils.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ def self.automation_script!(context, fields, automation)
2323
min_hours = fields.dig("minimum_time_between_assignments", "value").presence
2424
if min_hours &&
2525
TopicCustomField
26-
.where(name: "assigned_to_id", topic_id: topic_id)
27-
.where("created_at < ?", min_hours.to_i.hours.ago)
28-
.exists?
26+
.where(name: "assigned_to_id", topic_id: topic_id)
27+
.where("created_at < ?", min_hours.to_i.hours.ago)
28+
.exists?
2929
log_info(automation, "Topic(#{topic_id}) has already been assigned recently")
3030
return
3131
end

spec/components/search_spec.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
SiteSetting.assign_enabled = true
1313
end
1414

15-
context "Advanced search" do
16-
include_context "A group that is allowed to assign"
15+
describe "Advanced search" do
16+
include_context "with group that is allowed to assign"
1717

1818
let(:post1) { Fabricate(:post) }
1919
let(:post2) { Fabricate(:post) }

spec/components/topic_query_spec.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
fab!(:user3) { Fabricate(:user) }
1212
fab!(:user4) { Fabricate(:user) }
1313

14-
include_context "A group that is allowed to assign"
14+
include_context "with group that is allowed to assign"
1515

1616
before do
1717
add_to_assign_allowed_group(user)
@@ -183,7 +183,7 @@
183183
end
184184
end
185185

186-
context "assigned filter" do
186+
describe "assigned filter" do
187187
it "filters topics assigned to a user" do
188188
assigned_topic = Fabricate(:post).topic
189189
assigned_topic2 = Fabricate(:post).topic

spec/components/topics_bulk_action_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
let(:user) { Fabricate(:user) }
1414
let(:user2) { Fabricate(:user) }
1515

16-
include_context "A group that is allowed to assign"
16+
include_context "with group that is allowed to assign"
1717

1818
before { add_to_assign_allowed_group(user) }
1919

spec/integration/assign_spec.rb

+5-5
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
let(:channel) { "/private-messages/assigned" }
2424
fab!(:group) { Fabricate(:group, assignable_level: Group::ALIAS_LEVELS[:everyone]) }
2525

26-
include_context "A group that is allowed to assign"
26+
include_context "with group that is allowed to assign"
2727

2828
before do
2929
add_to_assign_allowed_group(user)
@@ -102,7 +102,7 @@ def assert_publish_topic_state(topic, user: nil, group: nil)
102102
let(:user1) { Fabricate(:user) }
103103
let(:user2) { Fabricate(:user) }
104104

105-
include_context "A group that is allowed to assign"
105+
include_context "with group that is allowed to assign"
106106

107107
before do
108108
add_to_assign_allowed_group(user1)
@@ -138,13 +138,13 @@ def assert_publish_topic_state(topic, user: nil, group: nil)
138138
end
139139
end
140140

141-
context "already assigned" do
141+
context "when already assigned" do
142142
fab!(:post) { Fabricate(:post) }
143143
fab!(:post_2) { Fabricate(:post, topic: post.topic) }
144144
let(:topic) { post.topic }
145145
fab!(:user) { Fabricate(:user) }
146146

147-
include_context "A group that is allowed to assign"
147+
include_context "with group that is allowed to assign"
148148

149149
it "does not allow to assign topic if post is already assigned" do
150150
add_to_assign_allowed_group(user)
@@ -164,7 +164,7 @@ def assert_publish_topic_state(topic, user: nil, group: nil)
164164
end
165165
end
166166

167-
context "move post" do
167+
describe "move post" do
168168
fab!(:old_topic) { Fabricate(:topic) }
169169
fab!(:post) { Fabricate(:post, topic: old_topic) }
170170
fab!(:user) { Fabricate(:user) }

spec/jobs/regular/assign_notification_spec.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def assert_publish_topic_state(topic, user)
2121

2222
before { assign_allowed_group.add(user1) }
2323

24-
context "User" do
24+
describe "User" do
2525
it "sends notification alert" do
2626
messages =
2727
MessageBus.track_publish("/notification-alert/#{user2.id}") do
@@ -89,7 +89,7 @@ def assert_publish_topic_state(topic, user)
8989
end
9090
end
9191

92-
context "Group" do
92+
describe "Group" do
9393
fab!(:user3) { Fabricate(:user, last_seen_at: 1.day.ago) }
9494
fab!(:user4) { Fabricate(:user, suspended_till: 1.year.from_now) }
9595
fab!(:group) { Fabricate(:group, name: "Developers") }

spec/jobs/regular/unassign_notification_spec.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def assert_publish_topic_state(topic, user)
2121
expect(message.user_ids).to eq([user.id])
2222
end
2323

24-
context "User" do
24+
describe "User" do
2525
it "deletes notifications" do
2626
Jobs::AssignNotification.new.execute(
2727
{
@@ -64,7 +64,7 @@ def assert_publish_topic_state(topic, user)
6464
end
6565
end
6666

67-
context "Group" do
67+
describe "Group" do
6868
fab!(:assign_allowed_group) { Group.find_by(name: "staff") }
6969
fab!(:user3) { Fabricate(:user) }
7070
fab!(:group) { Fabricate(:group) }

spec/lib/assigner_spec.rb

+18-18
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
let(:pm_post) { Fabricate(:private_message_post) }
1313
let(:pm) { pm_post.topic }
1414

15-
context "assigning and unassigning" do
15+
describe "assigning and unassigning" do
1616
let(:post) { Fabricate(:post) }
1717
let(:topic) { post.topic }
1818
let(:secure_category) { Fabricate(:private_category, group: Fabricate(:group)) }
@@ -53,7 +53,7 @@
5353
expect {
5454
described_class.new(topic, admin).assign(moderator_2)
5555
}.to change { moderator.notifications.count }.by(-1)
56-
.and change { moderator_2.notifications.count }.by(1)
56+
.and change { moderator_2.notifications.count }.by(1)
5757
end
5858

5959
it "can assign with note" do
@@ -186,7 +186,7 @@ def assigned_to?(assignee)
186186
assigner.assign(assignee).fetch(:success)
187187
end
188188

189-
context "forbidden reasons" do
189+
describe "forbidden reasons" do
190190
it "doesn't assign if the topic has more than 5 assignments" do
191191
other_post = nil
192192

@@ -487,7 +487,7 @@ def assigned_to?(assignee)
487487
end
488488
end
489489

490-
context "assign_self_regex" do
490+
describe "assign_self_regex" do
491491
fab!(:me) { Fabricate(:admin) }
492492
fab!(:op) { Fabricate(:post) }
493493
fab!(:reply) do
@@ -528,7 +528,7 @@ def assigned_to?(assignee)
528528
end
529529
end
530530

531-
context "assign_other_regex" do
531+
describe "assign_other_regex" do
532532
fab!(:me) { Fabricate(:admin) }
533533
fab!(:other) { Fabricate(:admin) }
534534
fab!(:op) { Fabricate(:post) }
@@ -553,12 +553,12 @@ def assigned_to?(assignee)
553553
end
554554
end
555555

556-
context "unassign_on_close" do
556+
describe "unassign_on_close" do
557557
let(:post) { Fabricate(:post) }
558558
let(:topic) { post.topic }
559559
let(:moderator) { Fabricate(:moderator) }
560560

561-
context "topic" do
561+
context "with topic" do
562562
let(:assigner) { described_class.new(topic, moderator) }
563563

564564
before do
@@ -595,7 +595,7 @@ def assigned_to?(assignee)
595595
end
596596
end
597597

598-
context "post" do
598+
context "with post" do
599599
let(:post_2) { Fabricate(:post, topic: topic) }
600600
let(:assigner) { described_class.new(post_2, moderator) }
601601
let(:post_3) { Fabricate(:post, topic: topic) }
@@ -650,12 +650,12 @@ def assigned_to?(assignee)
650650
end
651651
end
652652

653-
context "reassign_on_open" do
653+
describe "reassign_on_open" do
654654
let(:post) { Fabricate(:post) }
655655
let(:topic) { post.topic }
656656
let(:moderator) { Fabricate(:moderator) }
657657

658-
context "topic" do
658+
describe "topic" do
659659
let(:assigner) { described_class.new(topic, moderator) }
660660

661661
before do
@@ -677,7 +677,7 @@ def assigned_to?(assignee)
677677
end
678678
end
679679

680-
context "post" do
680+
context "with post" do
681681
let(:post_2) { Fabricate(:post, topic: topic) }
682682
let(:assigner) { described_class.new(post_2, moderator) }
683683

@@ -702,7 +702,7 @@ def assigned_to?(assignee)
702702
end
703703
end
704704

705-
context "assign_emailer" do
705+
describe "assign_emailer" do
706706
let(:post) { Fabricate(:post) }
707707
let(:topic) { post.topic }
708708
let(:moderator) { Fabricate(:moderator) }
@@ -719,9 +719,9 @@ def assigned_to?(assignee)
719719
it "doesn't send an email if assignee is a group" do
720720
SiteSetting.assign_mailer = AssignMailer.levels[:always]
721721

722-
expect { described_class.new(topic, moderator).assign(assign_allowed_group) }.to change {
722+
expect { described_class.new(topic, moderator).assign(assign_allowed_group) }.not_to change {
723723
ActionMailer::Base.deliveries.size
724-
}.by(0)
724+
}
725725
end
726726

727727
it "doesn't send an email if the assigner and assignee are not different" do
@@ -735,17 +735,17 @@ def assigned_to?(assignee)
735735
it "doesn't send an email if the assigner and assignee are not different" do
736736
SiteSetting.assign_mailer = AssignMailer.levels[:different_users]
737737

738-
expect { described_class.new(topic, moderator).assign(moderator) }.to change {
738+
expect { described_class.new(topic, moderator).assign(moderator) }.not_to change {
739739
ActionMailer::Base.deliveries.size
740-
}.by(0)
740+
}
741741
end
742742

743743
it "doesn't send an email" do
744744
SiteSetting.assign_mailer = AssignMailer.levels[:never]
745745

746-
expect { described_class.new(topic, moderator).assign(moderator_2) }.to change {
746+
expect { described_class.new(topic, moderator).assign(moderator_2) }.not_to change {
747747
ActionMailer::Base.deliveries.size
748-
}.by(0)
748+
}
749749
end
750750
end
751751
end

spec/lib/pending_assigns_reminder_spec.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
require_relative "../support/assign_allowed_group"
55

66
def assert_reminder_not_created
7-
expect { subject.remind(user) }.to change { Post.count }.by(0)
7+
expect { subject.remind(user) }.not_to change { Post.count }
88
end
99

1010
RSpec.describe PendingAssignsReminder do
@@ -26,7 +26,7 @@ def assert_reminder_not_created
2626
describe "when the user has multiple tasks" do
2727
let(:system) { Discourse.system_user }
2828

29-
include_context "A group that is allowed to assign"
29+
include_context "with group that is allowed to assign"
3030

3131
before do
3232
add_to_assign_allowed_group(user)

0 commit comments

Comments
 (0)