A platform for community discussion. Free, open, simple.
FIX: ensures user notes routes are correctly defined (#34960)
Joffrey JAFFEUXe991d3b2adda
diff --git a/plugins/discourse-user-notes/config/routes.rb b/plugins/discourse-user-notes/config/routes.rbnew file mode 100644index 00000000000..05c1954e218--- /dev/null+++ b/plugins/discourse-user-notes/config/routes.rb@@ -0,0 +1,7 @@+# frozen_string_literal: true++DiscourseUserNotes::Engine.routes.draw do+ get "/" => "user_notes#index"+ post "/" => "user_notes#create"+ delete "/:id" => "user_notes#destroy"+enddiff --git a/plugins/discourse-user-notes/plugin.rb b/plugins/discourse-user-notes/plugin.rbindex dcf1ec5575a..b75f4f6fcf0 100644--- a/plugins/discourse-user-notes/plugin.rb+++ b/plugins/discourse-user-notes/plugin.rb@@ -27,12 +27,6 @@ after_initialize doDiscourse::Application.routes.append { mount ::DiscourseUserNotes::Engine, at: "/user_notes" }- DiscourseUserNotes::Engine.routes.draw do- get "/" => "user_notes#index"- post "/" => "user_notes#create"- delete "/:id" => "user_notes#destroy"- end-allow_staff_user_custom_field(DiscourseUserNotes::COUNT_FIELD)add_to_class(Guardian, :can_delete_user_notes?) dodiff --git a/plugins/discourse-user-notes/spec/system/user_notes_spec.rb b/plugins/discourse-user-notes/spec/system/user_notes_spec.rbnew file mode 100644index 00000000000..074ae612ea5--- /dev/null+++ b/plugins/discourse-user-notes/spec/system/user_notes_spec.rb@@ -0,0 +1,31 @@+# frozen_string_literal: true++RSpec.describe "User Notes", type: :system do+ fab!(:admin)+ fab!(:user)++ before { SiteSetting.user_notes_enabled = true }++ it "allows admin to manage user notes" do+ sign_in(admin)++ visit("/admin/users/#{user.id}/#{user.username}")++ expect(page).to have_css(".show-user-notes-btn")+ click_button(class: "show-user-notes-btn")++ expect(page).to have_css(".user-notes-modal")++ form = PageObjects::Components::FormKit.new(".user-notes-modal .form-kit")+ form.field("content").fill_in("A NOTE")+ form.submit++ expect(page).to have_css(".user-note", text: "A NOTE")++ find(".user-note .btn-danger").click++ PageObjects::Components::Dialog.new.click_danger++ expect(page).to have_no_css(".user-note", text: "A NOTE")+ end+end