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: Update ruby linting #518

Merged
merged 1 commit into from
Oct 20, 2023
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
28 changes: 16 additions & 12 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,47 @@ GEM
remote: https://rubygems.org/
specs:
ast (2.4.2)
base64 (0.1.1)
json (2.6.3)
language_server-protocol (3.17.0.3)
parallel (1.23.0)
parser (3.2.2.3)
parser (3.2.2.4)
ast (~> 2.4.1)
racc
prettier_print (1.2.1)
racc (1.7.1)
rainbow (3.1.1)
regexp_parser (2.8.1)
rexml (3.2.5)
rubocop (1.52.1)
regexp_parser (2.8.2)
rexml (3.2.6)
rubocop (1.57.1)
base64 (~> 0.1.1)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 3.2.2.3)
parser (>= 3.2.2.4)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.28.0, < 2.0)
rubocop-ast (>= 1.28.1, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.29.0)
parser (>= 3.2.1.0)
rubocop-capybara (2.18.0)
rubocop-capybara (2.19.0)
rubocop (~> 1.41)
rubocop-discourse (3.2.0)
rubocop-discourse (3.4.0)
rubocop (>= 1.1.0)
rubocop-rspec (>= 2.0.0)
rubocop-factory_bot (2.23.1)
rubocop-factory_bot (2.24.0)
rubocop (~> 1.33)
rubocop-rspec (2.22.0)
rubocop-rspec (2.24.1)
rubocop (~> 1.33)
rubocop-capybara (~> 2.17)
rubocop-factory_bot (~> 2.22)
ruby-progressbar (1.13.0)
syntax_tree (6.1.1)
syntax_tree (6.2.0)
prettier_print (>= 1.2.0)
unicode-display_width (2.4.2)
unicode-display_width (2.5.0)

PLATFORMS
ruby
Expand Down
4 changes: 2 additions & 2 deletions app/models/assignment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ class Assignment < ActiveRecord::Base
belongs_to :target, polymorphic: true

scope :joins_with_topics,
-> {
-> do
joins(
"INNER JOIN topics ON topics.id = assignments.target_id AND assignments.target_type = 'Topic' AND topics.deleted_at IS NULL",
)
}
end

scope :active_for_group, ->(group) { where(assigned_to: group, active: true) }

Expand Down
2 changes: 1 addition & 1 deletion lib/assigner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ def moderator_post_unassign_action_code(assignment)
""
end
return "unassigned#{suffix}" if assignment.assigned_to_user?
return "unassigned_group#{suffix}" if assignment.assigned_to_group?
"unassigned_group#{suffix}" if assignment.assigned_to_group?
end

def already_assigned?(assign_to, type, note, status)
Expand Down
4 changes: 2 additions & 2 deletions lib/discourse_assign/group_extension.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module GroupExtension
def self.prepended(base)
base.class_eval do
scope :assignable,
->(user) {
->(user) do
where(
"assignable_level in (:levels) OR
(
Expand All @@ -18,7 +18,7 @@ def self.prepended(base)
levels: alias_levels(user),
user_id: user&.id,
)
}
end
end
end
end
Expand Down
22 changes: 12 additions & 10 deletions spec/lib/pending_assigns_reminder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
require_relative "../support/assign_allowed_group"

def assert_reminder_not_created
expect { subject.remind(user) }.not_to change { Post.count }
expect { reminder.remind(user) }.not_to change { Post.count }
end

RSpec.describe PendingAssignsReminder do
subject(:reminder) { described_class.new }

before { SiteSetting.assign_enabled = true }

let(:user) { Fabricate(:user) }
Expand Down Expand Up @@ -48,7 +50,7 @@ def assert_reminder_not_created

it "creates a reminder for a particular user and sets the timestamp of the last reminder" do
freeze_time
subject.remind(user)
reminder.remind(user)

post = Post.last

Expand All @@ -71,8 +73,8 @@ def assert_reminder_not_created
end

it "deletes previous reminders when creating a new one" do
subject.remind(user)
subject.remind(user)
reminder.remind(user)
reminder.remind(user)

reminders_count =
Topic
Expand All @@ -84,15 +86,15 @@ def assert_reminder_not_created
end

it "doesn't delete reminders from a different user" do
subject.remind(user)
reminder.remind(user)
another_user = Fabricate(:user)
add_to_assign_allowed_group(another_user)
3.times do
post = Fabricate(:post)
Assigner.new(post.topic, user).assign(another_user)
end

subject.remind(another_user)
reminder.remind(another_user)

reminders_count =
Topic
Expand All @@ -104,9 +106,9 @@ def assert_reminder_not_created
end

it "doesn't delete reminders if they have replies" do
subject.remind(user)
reminder.remind(user)
Fabricate(:post, topic: Topic.last)
subject.remind(user)
reminder.remind(user)

reminders_count =
Topic
Expand All @@ -123,7 +125,7 @@ def assert_reminder_not_created
@post5 = Fabricate(:post)
Assigner.new(@post5.topic, user).assign(user)

subject.remind(user)
reminder.remind(user)

post = Post.last
topic = post.topic
Expand All @@ -133,7 +135,7 @@ def assert_reminder_not_created
@post5.topic.update_status("closed", true, Discourse.system_user)
expect(@post5.topic.closed).to eq(true)

subject.remind(user)
reminder.remind(user)

post = Post.last
topic = post.topic
Expand Down