[openstreetmap/openstreetmap-website] Note subscriptions API (PR #5314)
Tom Hughes
notifications at github.com
Wed Nov 13 18:52:12 UTC 2024
@tomhughes commented on this pull request.
> @@ -0,0 +1,22 @@
+module Api
+ class NoteSubscriptionsController < ApiController
+ before_action :check_api_writable
+ before_action :authorize
+
+ authorize_resource
+
+ def create
+ note_id = params[:note_id].to_i
+ note = Note.find(note_id)
+ note.subscribers << current_user
+ rescue ActiveRecord::RecordNotUnique
+ head :conflict
Is `conflict` right here? This happens if you try and subscribe to a note you're already subscribed to right?
> + end
+
+ def test_destroy
+ user = create(:user)
+ auth_header = bearer_authorization_header user
+ note = create(:note_with_comments)
+ create(:note_subscription, :user => user, :note => note)
+ assert_equal [user], note.subscribers
+
+ assert_difference "NoteSubscription.count", -1 do
+ assert_difference "note.subscribers.count", -1 do
+ delete api_note_subscription_path(note), :headers => auth_header
+ assert_response :success
+ end
+ end
+ end
Maybe assert that `note.subscribers` is empty here? To mirror what the creation test does?
--
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/5314#pullrequestreview-2434149482
You are receiving this because you are subscribed to this thread.
Message ID: <openstreetmap/openstreetmap-website/pull/5314/review/2434149482 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20241113/63927f63/attachment-0001.htm>
More information about the rails-dev
mailing list