Fix error on create bookmark for topic

This commit is contained in:
Martin Brennan 2020-03-13 13:33:57 +10:00
parent af92444948
commit dc02586d99
2 changed files with 2 additions and 1 deletions

View File

@ -551,7 +551,7 @@ class TopicsController < ApplicationController
bookmark_manager = BookmarkManager.new(current_user)
bookmark_manager.create(post_id: first_post.id)
if bookmark_manager.errors
if bookmark_manager.errors.any?
return render_json_error(bookmark_manager, status: 400)
end
else

View File

@ -2376,6 +2376,7 @@ RSpec.describe TopicsController do
post = create_post
post2 = create_post(topic_id: post.topic_id)
put "/t/#{post.topic_id}/bookmark.json"
expect(response.status).to eq(200)
bookmarks_for_topic = Bookmark.where(topic: post.topic, user: user)
expect(bookmarks_for_topic.count).to eq(1)