Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DEV: Fix new Rubocop offenses #548

Merged
merged 1 commit into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 34 additions & 6 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,35 +1,60 @@
GEM
remote: https://rubygems.org/
specs:
activesupport (7.1.3.2)
base64
bigdecimal
concurrent-ruby (~> 1.0, >= 1.0.2)
connection_pool (>= 2.2.5)
drb
i18n (>= 1.6, < 2)
minitest (>= 5.1)
mutex_m
tzinfo (~> 2.0)
ast (2.4.2)
base64 (0.2.0)
bigdecimal (3.1.6)
concurrent-ruby (1.2.3)
connection_pool (2.4.1)
drb (2.2.0)
ruby2_keywords
i18n (1.14.1)
concurrent-ruby (~> 1.0)
json (2.7.1)
language_server-protocol (3.17.0.3)
minitest (5.22.2)
mutex_m (0.2.0)
parallel (1.24.0)
parser (3.3.0.3)
parser (3.3.0.5)
ast (~> 2.4.1)
racc
prettier_print (1.2.1)
prism (0.24.0)
racc (1.7.3)
rainbow (3.1.1)
regexp_parser (2.9.0)
rexml (3.2.6)
rubocop (1.59.0)
rubocop (1.61.0)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 3.2.2.4)
parser (>= 3.3.0.2)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.30.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.30.0)
parser (>= 3.2.1.0)
rubocop-ast (1.31.0)
parser (>= 3.3.0.4)
prism (>= 0.24.0)
rubocop-capybara (2.20.0)
rubocop (~> 1.41)
rubocop-discourse (3.6.0)
rubocop-discourse (3.7.1)
activesupport (>= 6.1)
rubocop (>= 1.59.0)
rubocop-capybara (>= 2.0.0)
rubocop-factory_bot (>= 2.0.0)
rubocop-rspec (>= 2.25.0)
rubocop-factory_bot (2.25.1)
rubocop (~> 1.41)
Expand All @@ -38,8 +63,11 @@ GEM
rubocop-capybara (~> 2.17)
rubocop-factory_bot (~> 2.22)
ruby-progressbar (1.13.0)
ruby2_keywords (0.0.5)
syntax_tree (6.2.0)
prettier_print (>= 1.2.0)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unicode-display_width (2.5.0)

PLATFORMS
Expand Down
6 changes: 3 additions & 3 deletions lib/discourse_assign/list_controller_extension.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

module DiscourseAssign
module ListControllerExtension
def self.prepended(base)
base.class_eval { ListController.generate_message_route(:private_messages_assigned) }
end
extend ActiveSupport::Concern

prepended { generate_message_route(:private_messages_assigned) }
end
end
6 changes: 3 additions & 3 deletions lib/discourse_assign/post_extension.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

module DiscourseAssign
module PostExtension
def self.prepended(base)
base.class_eval { has_one :assignment, as: :target, dependent: :destroy }
end
extend ActiveSupport::Concern

prepended { has_one :assignment, as: :target, dependent: :destroy }
end
end
6 changes: 3 additions & 3 deletions lib/discourse_assign/topic_extension.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

module DiscourseAssign
module TopicExtension
def self.prepended(base)
base.class_eval { has_one :assignment, as: :target, dependent: :destroy }
end
extend ActiveSupport::Concern

prepended { has_one :assignment, as: :target, dependent: :destroy }
end
end
11 changes: 6 additions & 5 deletions lib/discourse_assign/web_hook_extension.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

module DiscourseAssign
module WebHookExtension
def self.prepended(base)
base.class_eval do
def self.enqueue_assign_hooks(event, payload)
WebHook.enqueue_hooks(:assign, event, payload: payload) if active_web_hooks(event).exists?
end
extend ActiveSupport::Concern

class_methods do
def enqueue_assign_hooks(event, payload)
return unless active_web_hooks(event).exists?
enqueue_hooks(:assign, event, payload: payload)
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/components/topic_query_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
describe TopicQuery do
before { SiteSetting.assign_enabled = true }

fab!(:user) { Fabricate(:user) }
fab!(:user)
fab!(:user2) { Fabricate(:user) }
fab!(:user3) { Fabricate(:user) }
fab!(:user4) { Fabricate(:user) }
Expand Down
2 changes: 1 addition & 1 deletion spec/components/topics_bulk_action_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
require_relative "../support/assign_allowed_group"

describe TopicsBulkAction do
fab!(:post) { Fabricate(:post) }
fab!(:post)
fab!(:post1) { Fabricate(:post) }
fab!(:post2) { Fabricate(:post) }

Expand Down
6 changes: 3 additions & 3 deletions spec/integration/assign_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,10 @@ def assert_publish_topic_state(topic, user: nil, group: nil)
end

context "when already assigned" do
fab!(:post) { Fabricate(:post) }
fab!(:post)
fab!(:post_2) { Fabricate(:post, topic: post.topic) }
let(:topic) { post.topic }
fab!(:user) { Fabricate(:user) }
fab!(:user)

include_context "with group that is allowed to assign"

Expand All @@ -170,7 +170,7 @@ def assert_publish_topic_state(topic, user: nil, group: nil)
describe "move post" do
fab!(:old_topic) { Fabricate(:topic) }
fab!(:post) { Fabricate(:post, topic: old_topic) }
fab!(:user) { Fabricate(:user) }
fab!(:user)
fab!(:assignment) do
Assignment.create!(
target_id: post.id,
Expand Down
4 changes: 2 additions & 2 deletions spec/jobs/regular/unassign_notification_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
describe "#execute" do
fab!(:user1) { Fabricate(:user) }
fab!(:user2) { Fabricate(:user) }
fab!(:topic) { Fabricate(:topic) }
fab!(:topic)
fab!(:post) { Fabricate(:post, topic: topic) }
fab!(:pm_post) { Fabricate(:private_message_post) }
fab!(:pm) { pm_post.topic }
Expand Down Expand Up @@ -61,7 +61,7 @@ def assert_publish_topic_state(topic, user)
describe "Group" do
fab!(:assign_allowed_group) { Group.find_by(name: "staff") }
fab!(:user3) { Fabricate(:user) }
fab!(:group) { Fabricate(:group) }
fab!(:group)
fab!(:assignment) do
Fabricate(:topic_assignment, topic: topic, assigned_to: group, assigned_by_user: user1)
end
Expand Down
6 changes: 3 additions & 3 deletions spec/lib/topic_query_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
require "topic_view"

describe TopicQuery do
fab!(:user) { Fabricate(:user) }
fab!(:admin) { Fabricate(:admin) }
fab!(:user)
fab!(:admin)
fab!(:other_admin) { Fabricate(:admin) }

fab!(:user_pm) { Fabricate(:private_message_topic, user: user) }
fab!(:admin_pm) { Fabricate(:private_message_topic, user: admin) }
fab!(:other_admin_pm) { Fabricate(:private_message_topic, user: other_admin) }

fab!(:group) { Fabricate(:group) }
fab!(:group)

describe "#list_group_topics_assigned" do
before do
Expand Down
4 changes: 2 additions & 2 deletions spec/models/reviewable_spec.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# frozen_string_literal: true

describe Reviewable do
fab!(:user) { Fabricate(:user) }
fab!(:admin) { Fabricate(:admin) }
fab!(:user)
fab!(:admin)
fab!(:post1) { Fabricate(:post) }
fab!(:post2) { Fabricate(:post) }
fab!(:reviewable1) { Fabricate(:reviewable_flagged_post, target: post1) }
Expand Down
6 changes: 3 additions & 3 deletions spec/requests/assign_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
fab!(:non_allowed_group) { Fabricate(:group) }
fab!(:allowed_group) { Fabricate(:group) }

fab!(:admin) { Fabricate(:admin) }
fab!(:admin)
fab!(:allowed_user) { Fabricate(:user, username: "mads", name: "Mads", groups: [allowed_group]) }
fab!(:non_admin_staff) { Fabricate(:user, groups: [staff_group]) }
fab!(:user_in_non_allowed_group) { Fabricate(:user, groups: [non_allowed_group]) }

fab!(:post) { Fabricate(:post) }
fab!(:post)

describe "only allow users from allowed groups to assign" do
it "filters requests where current_user is not member of an allowed group" do
Expand Down Expand Up @@ -339,7 +339,7 @@ def assign_user_to_post
describe "#group_members" do
fab!(:other_allowed_user) { Fabricate(:user, groups: [allowed_group]) }

fab!(:topic) { Fabricate(:topic) }
fab!(:topic)
fab!(:post_in_same_topic) { Fabricate(:post, topic: topic) }

fab!(:assignments) do
Expand Down
2 changes: 1 addition & 1 deletion spec/requests/search_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require "rails_helper"

describe SearchController do
fab!(:admin) { Fabricate(:admin) }
fab!(:admin)
fab!(:group) do
Fabricate(
:group,
Expand Down
2 changes: 1 addition & 1 deletion spec/serializers/flagged_topic_serializer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
require_relative "../support/assign_allowed_group"

describe FlaggedTopicSerializer do
fab!(:user) { Fabricate(:user) }
fab!(:user)
let(:guardian) { Guardian.new(user) }

include_context "with group that is allowed to assign"
Expand Down
4 changes: 2 additions & 2 deletions spec/serializers/group_show_serializer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
require "rails_helper"

RSpec.describe GroupShowSerializer do
fab!(:user) { Fabricate(:user) }
fab!(:user)
fab!(:group) { Fabricate(:group, assignable_level: Group::ALIAS_LEVELS[:everyone]) }
fab!(:group_user) { Fabricate(:group_user, group: group, user: user) }
fab!(:topic) { Fabricate(:topic) }
fab!(:topic)
fab!(:post) { Fabricate(:post, topic: topic) }
fab!(:topic2) { Fabricate(:topic) }
fab!(:post2) { Fabricate(:post, topic: topic2) }
Expand Down
4 changes: 2 additions & 2 deletions spec/serializers/post_serializer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
require_relative "../support/assign_allowed_group"

describe PostSerializer do
fab!(:user) { Fabricate(:user) }
fab!(:topic) { Fabricate(:topic) }
fab!(:user)
fab!(:topic)
fab!(:post) { Fabricate(:post, topic: topic) }
let(:guardian) { Guardian.new(user) }

Expand Down
4 changes: 2 additions & 2 deletions spec/serializers/suggested_topic_serializer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
require "rails_helper"

RSpec.describe SuggestedTopicSerializer do
fab!(:user) { Fabricate(:user) }
fab!(:user)
fab!(:group) { Fabricate(:group, assignable_level: Group::ALIAS_LEVELS[:everyone]) }
fab!(:group_user) { Fabricate(:group_user, group: group, user: user) }
fab!(:topic) { Fabricate(:topic) }
fab!(:topic)
fab!(:post) { Fabricate(:post, topic: topic) }
fab!(:topic2) { Fabricate(:topic) }
fab!(:post2) { Fabricate(:post, topic: topic2) }
Expand Down
2 changes: 1 addition & 1 deletion spec/serializers/topic_list_serializer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
require_relative "../support/assign_allowed_group"

RSpec.describe TopicListSerializer do
fab!(:user) { Fabricate(:user) }
fab!(:user)

let(:private_message_topic) do
topic =
Expand Down
4 changes: 2 additions & 2 deletions spec/serializers/topic_view_serializer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
require_relative "../support/assign_allowed_group"

RSpec.describe TopicViewSerializer do
fab!(:user) { Fabricate(:user) }
fab!(:topic) { Fabricate(:topic) }
fab!(:user)
fab!(:topic)
fab!(:post) { Fabricate(:post, topic: topic) }
let(:guardian) { Guardian.new(user) }

Expand Down
4 changes: 2 additions & 2 deletions spec/serializers/user_bookmark_base_serializer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
add_to_assign_allowed_group(user)
end

fab!(:user) { Fabricate(:user) }
fab!(:topic) { Fabricate(:topic) }
fab!(:user)
fab!(:topic)
fab!(:post) { Fabricate(:post, topic: topic) }
let(:guardian) { Guardian.new(user) }

Expand Down
4 changes: 2 additions & 2 deletions spec/system/assign_topic_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
let(:topic_page) { PageObjects::Pages::Topic.new }
let(:assign_modal) { PageObjects::Modals::Assign.new }
fab!(:staff_user) { Fabricate(:user, groups: [Group[:staff]]) }
fab!(:admin) { Fabricate(:admin) }
fab!(:topic) { Fabricate(:topic) }
fab!(:admin)
fab!(:topic)
fab!(:post) { Fabricate(:post, topic: topic) }

before do
Expand Down
2 changes: 1 addition & 1 deletion spec/system/user_menu_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

RSpec.describe "Assign | User Menu", type: :system, js: true do
fab!(:admin) { Fabricate(:admin) }
fab!(:admin)

let(:user_menu) { PageObjects::Components::UserMenu.new }

Expand Down
Loading