DEV: fix and skip upload_controller test

This test of `prevent_anons_from_downloading_files` was testing an image instead of an attachment and it was testing the wrong upload URL. I fixed the test, but with `config.public_file_server.enabled = true` on the test environment, this will always fail, as preventing anonymous file downloads depends on nginx. So, I marked the test as skipped, for now.
This commit is contained in:
Penar Musaraj 2019-04-18 12:58:39 -04:00
parent 7826acc4a7
commit a19d89364f
1 changed files with 5 additions and 4 deletions

View File

@ -198,8 +198,8 @@ describe UploadsController do
let(:sha) { Digest::SHA1.hexdigest("discourse") }
let(:user) { Fabricate(:user) }
def upload_file(file)
fake_logo = Rack::Test::UploadedFile.new(file_from_fixtures(file))
def upload_file(file, folder = "images")
fake_logo = Rack::Test::UploadedFile.new(file_from_fixtures(file, folder))
SiteSetting.authorized_extensions = "*"
sign_in(user)
@ -261,11 +261,12 @@ describe UploadsController do
context "prevent anons from downloading files" do
it "returns 404 when an anonymous user tries to download a file" do
upload = upload_file("logo.png")
skip("this only works when nginx/apache is asset server") if Discourse::Application.config.public_file_server.enabled
upload = upload_file("small.pdf", "pdf")
delete "/session/#{user.username}.json" # upload a file, then sign out
SiteSetting.prevent_anons_from_downloading_files = true
get "/uploads/#{site}/#{upload.sha1}.#{upload.extension}"
get upload.url
expect(response.status).to eq(404)
end
end