DEV: Introduce syntax_tree for ruby formatting (#408)
This commit is contained in:
parent
4902ba6993
commit
46dd26963c
|
@ -55,3 +55,12 @@ jobs:
|
||||||
- name: Rubocop
|
- name: Rubocop
|
||||||
if: ${{ !cancelled() }}
|
if: ${{ !cancelled() }}
|
||||||
run: bundle exec rubocop .
|
run: bundle exec rubocop .
|
||||||
|
|
||||||
|
- name: Syntax Tree
|
||||||
|
if: ${{ !cancelled() }}
|
||||||
|
run: |
|
||||||
|
if test -f .streerc; then
|
||||||
|
bundle exec stree check Gemfile $(git ls-files '*.rb') $(git ls-files '*.rake')
|
||||||
|
else
|
||||||
|
echo "Stree config not detected for this repository. Skipping."
|
||||||
|
fi
|
||||||
|
|
|
@ -80,7 +80,7 @@ jobs:
|
||||||
|
|
||||||
- name: Get yarn cache directory
|
- name: Get yarn cache directory
|
||||||
id: yarn-cache-dir
|
id: yarn-cache-dir
|
||||||
run: echo "::set-output name=dir::$(yarn cache dir)"
|
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
- name: Yarn cache
|
- name: Yarn cache
|
||||||
uses: actions/cache@v3
|
uses: actions/cache@v3
|
||||||
|
@ -130,7 +130,7 @@ jobs:
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
if [ 0 -lt $(find plugins/${{ github.event.repository.name }}/spec -type f -name "*.rb" 2> /dev/null | wc -l) ]; then
|
if [ 0 -lt $(find plugins/${{ github.event.repository.name }}/spec -type f -name "*.rb" 2> /dev/null | wc -l) ]; then
|
||||||
echo "::set-output name=files_exist::true"
|
echo "files_exist=true" >> $GITHUB_OUTPUT
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Plugin RSpec
|
- name: Plugin RSpec
|
||||||
|
@ -142,7 +142,7 @@ jobs:
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
if [ 0 -lt $(find plugins/${{ github.event.repository.name }}/test/javascripts -type f \( -name "*.js" -or -name "*.es6" \) 2> /dev/null | wc -l) ]; then
|
if [ 0 -lt $(find plugins/${{ github.event.repository.name }}/test/javascripts -type f \( -name "*.js" -or -name "*.es6" \) 2> /dev/null | wc -l) ]; then
|
||||||
echo "::set-output name=files_exist::true"
|
echo "files_exist=true" >> $GITHUB_OUTPUT
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Plugin QUnit
|
- name: Plugin QUnit
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
inherit_gem:
|
inherit_gem:
|
||||||
rubocop-discourse: default.yml
|
rubocop-discourse: stree-compat.yml
|
||||||
|
|
|
@ -6,7 +6,7 @@ GEM
|
||||||
parallel (1.22.1)
|
parallel (1.22.1)
|
||||||
parser (3.1.3.0)
|
parser (3.1.3.0)
|
||||||
ast (~> 2.4.1)
|
ast (~> 2.4.1)
|
||||||
prettier_print (0.1.0)
|
prettier_print (1.1.0)
|
||||||
rainbow (3.1.1)
|
rainbow (3.1.1)
|
||||||
regexp_parser (2.6.1)
|
regexp_parser (2.6.1)
|
||||||
rexml (3.2.5)
|
rexml (3.2.5)
|
||||||
|
@ -28,8 +28,8 @@ GEM
|
||||||
rubocop-rspec (2.16.0)
|
rubocop-rspec (2.16.0)
|
||||||
rubocop (~> 1.33)
|
rubocop (~> 1.33)
|
||||||
ruby-progressbar (1.11.0)
|
ruby-progressbar (1.11.0)
|
||||||
syntax_tree (3.2.1)
|
syntax_tree (5.0.1)
|
||||||
prettier_print
|
prettier_print (>= 1.1.0)
|
||||||
unicode-display_width (2.3.0)
|
unicode-display_width (2.3.0)
|
||||||
|
|
||||||
PLATFORMS
|
PLATFORMS
|
||||||
|
|
|
@ -2,6 +2,6 @@
|
||||||
|
|
||||||
module DiscourseAssign
|
module DiscourseAssign
|
||||||
module DiscourseCalendar
|
module DiscourseCalendar
|
||||||
HOLIDAY_CUSTOM_FIELD ||= 'on_holiday'
|
HOLIDAY_CUSTOM_FIELD ||= "on_holiday"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -23,9 +23,9 @@ class RandomAssignUtils
|
||||||
min_hours = fields.dig("minimum_time_between_assignments", "value").presence
|
min_hours = fields.dig("minimum_time_between_assignments", "value").presence
|
||||||
if min_hours &&
|
if min_hours &&
|
||||||
TopicCustomField
|
TopicCustomField
|
||||||
.where(name: "assigned_to_id", topic_id: topic_id)
|
.where(name: "assigned_to_id", topic_id: topic_id)
|
||||||
.where("created_at < ?", min_hours.to_i.hours.ago)
|
.where("created_at < ?", min_hours.to_i.hours.ago)
|
||||||
.exists?
|
.exists?
|
||||||
log_info(automation, "Topic(#{topic_id}) has already been assigned recently")
|
log_info(automation, "Topic(#{topic_id}) has already been assigned recently")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
|
@ -46,14 +46,13 @@ RSpec.describe Assigner do
|
||||||
it "deletes notification for original assignee when reassigning" do
|
it "deletes notification for original assignee when reassigning" do
|
||||||
Jobs.run_immediately!
|
Jobs.run_immediately!
|
||||||
|
|
||||||
expect {
|
expect { described_class.new(topic, admin).assign(moderator) }.to change {
|
||||||
described_class.new(topic, admin).assign(moderator)
|
moderator.notifications.count
|
||||||
}.to change { moderator.notifications.count }.by(1)
|
}.by(1)
|
||||||
|
|
||||||
expect {
|
expect { described_class.new(topic, admin).assign(moderator_2) }.to change {
|
||||||
described_class.new(topic, admin).assign(moderator_2)
|
moderator.notifications.count
|
||||||
}.to change { moderator.notifications.count }.by(-1)
|
}.by(-1).and change { moderator_2.notifications.count }.by(1)
|
||||||
.and change { moderator_2.notifications.count }.by(1)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it "can assign with note" do
|
it "can assign with note" do
|
||||||
|
|
|
@ -10,7 +10,12 @@ RSpec.describe DiscourseAssign::AssignController do
|
||||||
let(:user) { Fabricate(:admin, name: "Robin Ward", username: "eviltrout") }
|
let(:user) { Fabricate(:admin, name: "Robin Ward", username: "eviltrout") }
|
||||||
fab!(:post) { Fabricate(:post) }
|
fab!(:post) { Fabricate(:post) }
|
||||||
fab!(:user2) do
|
fab!(:user2) do
|
||||||
Fabricate(:active_user, name: "David Taylor", username: "david", groups: [default_allowed_group])
|
Fabricate(
|
||||||
|
:active_user,
|
||||||
|
name: "David Taylor",
|
||||||
|
username: "david",
|
||||||
|
groups: [default_allowed_group],
|
||||||
|
)
|
||||||
end
|
end
|
||||||
let(:non_admin) { Fabricate(:user, groups: [default_allowed_group]) }
|
let(:non_admin) { Fabricate(:user, groups: [default_allowed_group]) }
|
||||||
fab!(:normal_user) { Fabricate(:user) }
|
fab!(:normal_user) { Fabricate(:user) }
|
||||||
|
@ -91,9 +96,7 @@ RSpec.describe DiscourseAssign::AssignController do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#suggestions" do
|
describe "#suggestions" do
|
||||||
before do
|
before { sign_in(user) }
|
||||||
sign_in(user)
|
|
||||||
end
|
|
||||||
|
|
||||||
it "suggests the current user + the last 6 previously assigned users" do
|
it "suggests the current user + the last 6 previously assigned users" do
|
||||||
assignees = 10.times.map { |_| assign_user_to_post.username }
|
assignees = 10.times.map { |_| assign_user_to_post.username }
|
||||||
|
@ -106,7 +109,9 @@ RSpec.describe DiscourseAssign::AssignController do
|
||||||
|
|
||||||
it "doesn't suggest users on holiday" do
|
it "doesn't suggest users on holiday" do
|
||||||
user_on_vacation = assign_user_to_post
|
user_on_vacation = assign_user_to_post
|
||||||
user_on_vacation.upsert_custom_fields(DiscourseAssign::DiscourseCalendar::HOLIDAY_CUSTOM_FIELD => "t")
|
user_on_vacation.upsert_custom_fields(
|
||||||
|
DiscourseAssign::DiscourseCalendar::HOLIDAY_CUSTOM_FIELD => "t",
|
||||||
|
)
|
||||||
|
|
||||||
get "/assign/suggestions.json"
|
get "/assign/suggestions.json"
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue