diff --git a/.github/workflows/plugin-linting.yml b/.github/workflows/plugin-linting.yml index c807794..6d2bb97 100644 --- a/.github/workflows/plugin-linting.yml +++ b/.github/workflows/plugin-linting.yml @@ -55,3 +55,12 @@ jobs: - name: Rubocop if: ${{ !cancelled() }} 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 diff --git a/.github/workflows/plugin-tests.yml b/.github/workflows/plugin-tests.yml index 9d390bc..f30a5be 100644 --- a/.github/workflows/plugin-tests.yml +++ b/.github/workflows/plugin-tests.yml @@ -80,7 +80,7 @@ jobs: - name: Get yarn cache directory id: yarn-cache-dir - run: echo "::set-output name=dir::$(yarn cache dir)" + run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT - name: Yarn cache uses: actions/cache@v3 @@ -130,7 +130,7 @@ jobs: shell: bash run: | 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 - name: Plugin RSpec @@ -142,7 +142,7 @@ jobs: shell: bash 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 - echo "::set-output name=files_exist::true" + echo "files_exist=true" >> $GITHUB_OUTPUT fi - name: Plugin QUnit diff --git a/.rubocop.yml b/.rubocop.yml index d46296c..fb14dfa 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,2 +1,2 @@ inherit_gem: - rubocop-discourse: default.yml + rubocop-discourse: stree-compat.yml diff --git a/.streerc b/.streerc new file mode 100644 index 0000000..0bc4379 --- /dev/null +++ b/.streerc @@ -0,0 +1,2 @@ +--print-width=100 +--plugins=plugin/trailing_comma diff --git a/Gemfile.lock b/Gemfile.lock index 9ccd6c3..8c5185d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -6,7 +6,7 @@ GEM parallel (1.22.1) parser (3.1.3.0) ast (~> 2.4.1) - prettier_print (0.1.0) + prettier_print (1.1.0) rainbow (3.1.1) regexp_parser (2.6.1) rexml (3.2.5) @@ -28,8 +28,8 @@ GEM rubocop-rspec (2.16.0) rubocop (~> 1.33) ruby-progressbar (1.11.0) - syntax_tree (3.2.1) - prettier_print + syntax_tree (5.0.1) + prettier_print (>= 1.1.0) unicode-display_width (2.3.0) PLATFORMS diff --git a/lib/discourse_calendar.rb b/lib/discourse_calendar.rb index 3e7f36f..837ce11 100644 --- a/lib/discourse_calendar.rb +++ b/lib/discourse_calendar.rb @@ -2,6 +2,6 @@ module DiscourseAssign module DiscourseCalendar - HOLIDAY_CUSTOM_FIELD ||= 'on_holiday' + HOLIDAY_CUSTOM_FIELD ||= "on_holiday" end end diff --git a/lib/random_assign_utils.rb b/lib/random_assign_utils.rb index 4531239..fc0edaa 100644 --- a/lib/random_assign_utils.rb +++ b/lib/random_assign_utils.rb @@ -23,9 +23,9 @@ class RandomAssignUtils min_hours = fields.dig("minimum_time_between_assignments", "value").presence if min_hours && TopicCustomField - .where(name: "assigned_to_id", topic_id: topic_id) - .where("created_at < ?", min_hours.to_i.hours.ago) - .exists? + .where(name: "assigned_to_id", topic_id: topic_id) + .where("created_at < ?", min_hours.to_i.hours.ago) + .exists? log_info(automation, "Topic(#{topic_id}) has already been assigned recently") return end diff --git a/spec/lib/assigner_spec.rb b/spec/lib/assigner_spec.rb index 6360e3e..4f9b9bb 100644 --- a/spec/lib/assigner_spec.rb +++ b/spec/lib/assigner_spec.rb @@ -46,14 +46,13 @@ RSpec.describe Assigner do it "deletes notification for original assignee when reassigning" do Jobs.run_immediately! - expect { - described_class.new(topic, admin).assign(moderator) - }.to change { moderator.notifications.count }.by(1) + expect { described_class.new(topic, admin).assign(moderator) }.to change { + moderator.notifications.count + }.by(1) - expect { - described_class.new(topic, admin).assign(moderator_2) - }.to change { moderator.notifications.count }.by(-1) - .and change { moderator_2.notifications.count }.by(1) + expect { described_class.new(topic, admin).assign(moderator_2) }.to change { + moderator.notifications.count + }.by(-1).and change { moderator_2.notifications.count }.by(1) end it "can assign with note" do diff --git a/spec/requests/assign_controller_spec.rb b/spec/requests/assign_controller_spec.rb index 90b9422..c9611b7 100644 --- a/spec/requests/assign_controller_spec.rb +++ b/spec/requests/assign_controller_spec.rb @@ -10,7 +10,12 @@ RSpec.describe DiscourseAssign::AssignController do let(:user) { Fabricate(:admin, name: "Robin Ward", username: "eviltrout") } fab!(:post) { Fabricate(:post) } 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 let(:non_admin) { Fabricate(:user, groups: [default_allowed_group]) } fab!(:normal_user) { Fabricate(:user) } @@ -91,9 +96,7 @@ RSpec.describe DiscourseAssign::AssignController do end describe "#suggestions" do - before do - sign_in(user) - end + before { sign_in(user) } it "suggests the current user + the last 6 previously assigned users" do 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 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"