DEV: Update ruby linting (#518)
This commit is contained in:
parent
7fe45c8eb5
commit
6ed4a13fe7
28
Gemfile.lock
28
Gemfile.lock
|
@ -2,43 +2,47 @@ GEM
|
||||||
remote: https://rubygems.org/
|
remote: https://rubygems.org/
|
||||||
specs:
|
specs:
|
||||||
ast (2.4.2)
|
ast (2.4.2)
|
||||||
|
base64 (0.1.1)
|
||||||
json (2.6.3)
|
json (2.6.3)
|
||||||
|
language_server-protocol (3.17.0.3)
|
||||||
parallel (1.23.0)
|
parallel (1.23.0)
|
||||||
parser (3.2.2.3)
|
parser (3.2.2.4)
|
||||||
ast (~> 2.4.1)
|
ast (~> 2.4.1)
|
||||||
racc
|
racc
|
||||||
prettier_print (1.2.1)
|
prettier_print (1.2.1)
|
||||||
racc (1.7.1)
|
racc (1.7.1)
|
||||||
rainbow (3.1.1)
|
rainbow (3.1.1)
|
||||||
regexp_parser (2.8.1)
|
regexp_parser (2.8.2)
|
||||||
rexml (3.2.5)
|
rexml (3.2.6)
|
||||||
rubocop (1.52.1)
|
rubocop (1.57.1)
|
||||||
|
base64 (~> 0.1.1)
|
||||||
json (~> 2.3)
|
json (~> 2.3)
|
||||||
|
language_server-protocol (>= 3.17.0)
|
||||||
parallel (~> 1.10)
|
parallel (~> 1.10)
|
||||||
parser (>= 3.2.2.3)
|
parser (>= 3.2.2.4)
|
||||||
rainbow (>= 2.2.2, < 4.0)
|
rainbow (>= 2.2.2, < 4.0)
|
||||||
regexp_parser (>= 1.8, < 3.0)
|
regexp_parser (>= 1.8, < 3.0)
|
||||||
rexml (>= 3.2.5, < 4.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)
|
ruby-progressbar (~> 1.7)
|
||||||
unicode-display_width (>= 2.4.0, < 3.0)
|
unicode-display_width (>= 2.4.0, < 3.0)
|
||||||
rubocop-ast (1.29.0)
|
rubocop-ast (1.29.0)
|
||||||
parser (>= 3.2.1.0)
|
parser (>= 3.2.1.0)
|
||||||
rubocop-capybara (2.18.0)
|
rubocop-capybara (2.19.0)
|
||||||
rubocop (~> 1.41)
|
rubocop (~> 1.41)
|
||||||
rubocop-discourse (3.2.0)
|
rubocop-discourse (3.4.0)
|
||||||
rubocop (>= 1.1.0)
|
rubocop (>= 1.1.0)
|
||||||
rubocop-rspec (>= 2.0.0)
|
rubocop-rspec (>= 2.0.0)
|
||||||
rubocop-factory_bot (2.23.1)
|
rubocop-factory_bot (2.24.0)
|
||||||
rubocop (~> 1.33)
|
rubocop (~> 1.33)
|
||||||
rubocop-rspec (2.22.0)
|
rubocop-rspec (2.24.1)
|
||||||
rubocop (~> 1.33)
|
rubocop (~> 1.33)
|
||||||
rubocop-capybara (~> 2.17)
|
rubocop-capybara (~> 2.17)
|
||||||
rubocop-factory_bot (~> 2.22)
|
rubocop-factory_bot (~> 2.22)
|
||||||
ruby-progressbar (1.13.0)
|
ruby-progressbar (1.13.0)
|
||||||
syntax_tree (6.1.1)
|
syntax_tree (6.2.0)
|
||||||
prettier_print (>= 1.2.0)
|
prettier_print (>= 1.2.0)
|
||||||
unicode-display_width (2.4.2)
|
unicode-display_width (2.5.0)
|
||||||
|
|
||||||
PLATFORMS
|
PLATFORMS
|
||||||
ruby
|
ruby
|
||||||
|
|
|
@ -9,11 +9,11 @@ class Assignment < ActiveRecord::Base
|
||||||
belongs_to :target, polymorphic: true
|
belongs_to :target, polymorphic: true
|
||||||
|
|
||||||
scope :joins_with_topics,
|
scope :joins_with_topics,
|
||||||
-> {
|
-> do
|
||||||
joins(
|
joins(
|
||||||
"INNER JOIN topics ON topics.id = assignments.target_id AND assignments.target_type = 'Topic' AND topics.deleted_at IS NULL",
|
"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) }
|
scope :active_for_group, ->(group) { where(assigned_to: group, active: true) }
|
||||||
|
|
||||||
|
|
|
@ -530,7 +530,7 @@ class ::Assigner
|
||||||
""
|
""
|
||||||
end
|
end
|
||||||
return "unassigned#{suffix}" if assignment.assigned_to_user?
|
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
|
end
|
||||||
|
|
||||||
def already_assigned?(assign_to, type, note, status)
|
def already_assigned?(assign_to, type, note, status)
|
||||||
|
|
|
@ -5,7 +5,7 @@ module DiscourseAssign
|
||||||
def self.prepended(base)
|
def self.prepended(base)
|
||||||
base.class_eval do
|
base.class_eval do
|
||||||
scope :assignable,
|
scope :assignable,
|
||||||
->(user) {
|
->(user) do
|
||||||
where(
|
where(
|
||||||
"assignable_level in (:levels) OR
|
"assignable_level in (:levels) OR
|
||||||
(
|
(
|
||||||
|
@ -18,7 +18,7 @@ module DiscourseAssign
|
||||||
levels: alias_levels(user),
|
levels: alias_levels(user),
|
||||||
user_id: user&.id,
|
user_id: user&.id,
|
||||||
)
|
)
|
||||||
}
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,10 +4,12 @@ require "rails_helper"
|
||||||
require_relative "../support/assign_allowed_group"
|
require_relative "../support/assign_allowed_group"
|
||||||
|
|
||||||
def assert_reminder_not_created
|
def assert_reminder_not_created
|
||||||
expect { subject.remind(user) }.not_to change { Post.count }
|
expect { reminder.remind(user) }.not_to change { Post.count }
|
||||||
end
|
end
|
||||||
|
|
||||||
RSpec.describe PendingAssignsReminder do
|
RSpec.describe PendingAssignsReminder do
|
||||||
|
subject(:reminder) { described_class.new }
|
||||||
|
|
||||||
before { SiteSetting.assign_enabled = true }
|
before { SiteSetting.assign_enabled = true }
|
||||||
|
|
||||||
let(:user) { Fabricate(:user) }
|
let(:user) { Fabricate(:user) }
|
||||||
|
@ -48,7 +50,7 @@ RSpec.describe PendingAssignsReminder do
|
||||||
|
|
||||||
it "creates a reminder for a particular user and sets the timestamp of the last reminder" do
|
it "creates a reminder for a particular user and sets the timestamp of the last reminder" do
|
||||||
freeze_time
|
freeze_time
|
||||||
subject.remind(user)
|
reminder.remind(user)
|
||||||
|
|
||||||
post = Post.last
|
post = Post.last
|
||||||
|
|
||||||
|
@ -71,8 +73,8 @@ RSpec.describe PendingAssignsReminder do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "deletes previous reminders when creating a new one" do
|
it "deletes previous reminders when creating a new one" do
|
||||||
subject.remind(user)
|
reminder.remind(user)
|
||||||
subject.remind(user)
|
reminder.remind(user)
|
||||||
|
|
||||||
reminders_count =
|
reminders_count =
|
||||||
Topic
|
Topic
|
||||||
|
@ -84,7 +86,7 @@ RSpec.describe PendingAssignsReminder do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "doesn't delete reminders from a different user" do
|
it "doesn't delete reminders from a different user" do
|
||||||
subject.remind(user)
|
reminder.remind(user)
|
||||||
another_user = Fabricate(:user)
|
another_user = Fabricate(:user)
|
||||||
add_to_assign_allowed_group(another_user)
|
add_to_assign_allowed_group(another_user)
|
||||||
3.times do
|
3.times do
|
||||||
|
@ -92,7 +94,7 @@ RSpec.describe PendingAssignsReminder do
|
||||||
Assigner.new(post.topic, user).assign(another_user)
|
Assigner.new(post.topic, user).assign(another_user)
|
||||||
end
|
end
|
||||||
|
|
||||||
subject.remind(another_user)
|
reminder.remind(another_user)
|
||||||
|
|
||||||
reminders_count =
|
reminders_count =
|
||||||
Topic
|
Topic
|
||||||
|
@ -104,9 +106,9 @@ RSpec.describe PendingAssignsReminder do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "doesn't delete reminders if they have replies" do
|
it "doesn't delete reminders if they have replies" do
|
||||||
subject.remind(user)
|
reminder.remind(user)
|
||||||
Fabricate(:post, topic: Topic.last)
|
Fabricate(:post, topic: Topic.last)
|
||||||
subject.remind(user)
|
reminder.remind(user)
|
||||||
|
|
||||||
reminders_count =
|
reminders_count =
|
||||||
Topic
|
Topic
|
||||||
|
@ -123,7 +125,7 @@ RSpec.describe PendingAssignsReminder do
|
||||||
@post5 = Fabricate(:post)
|
@post5 = Fabricate(:post)
|
||||||
Assigner.new(@post5.topic, user).assign(user)
|
Assigner.new(@post5.topic, user).assign(user)
|
||||||
|
|
||||||
subject.remind(user)
|
reminder.remind(user)
|
||||||
|
|
||||||
post = Post.last
|
post = Post.last
|
||||||
topic = post.topic
|
topic = post.topic
|
||||||
|
@ -133,7 +135,7 @@ RSpec.describe PendingAssignsReminder do
|
||||||
@post5.topic.update_status("closed", true, Discourse.system_user)
|
@post5.topic.update_status("closed", true, Discourse.system_user)
|
||||||
expect(@post5.topic.closed).to eq(true)
|
expect(@post5.topic.closed).to eq(true)
|
||||||
|
|
||||||
subject.remind(user)
|
reminder.remind(user)
|
||||||
|
|
||||||
post = Post.last
|
post = Post.last
|
||||||
topic = post.topic
|
topic = post.topic
|
||||||
|
|
Loading…
Reference in New Issue