forum posts: raise privilege error when viewing restricted topics.
Raise a privilege error when trying to view a restricted topic instead of handling it in the controller. This way error handling is standardized.
This commit is contained in:
@@ -103,6 +103,15 @@ class ForumPostsControllerTest < ActionDispatch::IntegrationTest
|
||||
end
|
||||
end
|
||||
|
||||
context "show action" do
|
||||
should "raise an error if the user doesn't have permission to view the topic" do
|
||||
as(@user) { @forum_post.topic.update(min_level: User::Levels::ADMIN) }
|
||||
get_auth forum_post_path(@forum_post), @user
|
||||
|
||||
assert_response 403
|
||||
end
|
||||
end
|
||||
|
||||
context "edit action" do
|
||||
should "render if the editor is the creator of the topic" do
|
||||
get_auth edit_forum_post_path(@forum_post), @user
|
||||
|
||||
Reference in New Issue
Block a user