DEV: Add spec for 56555a0231 (#18245)

This commit is contained in:
Alan Guo Xiang Tan 2022-09-15 11:20:52 +08:00 committed by GitHub
parent 86ecb6c58b
commit 4abc323c8d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 2 deletions

View File

@ -2175,11 +2175,18 @@ RSpec.describe PostsController do
describe "when logged in" do
let(:post) { Fabricate(:post, deleted_at: 2.hours.ago, user: Fabricate(:user), raw_email: 'email_content') }
it "raises an error if the user doesn't have permission to view raw email" do
it 'returns 403 when trying to view raw as user that created the post' do
sign_in(post.user)
get "/posts/#{post.id}/raw-email.json"
expect(response.status).to eq(403)
end
it "returns 403 when trying to view raw email as a normal user" do
sign_in(user)
get "/posts/#{post.id}/raw-email.json"
expect(response).to be_forbidden
expect(response.status).to eq(403)
end
it "can view raw email" do