FEATURE: New site setting for additional allowed filetypes for staff (#5364)

* FEATURE: New site setting for additional allowed filetypes for staff

* Problematic variable name

* feedback

* small issues

* fix indentation

* failing tests

* Remove message bus and fix minor issues

* Missed this message bus
This commit is contained in:
OsamaSayegh
2018-02-19 12:44:24 +03:00
committed by Régis Hanol
parent afa2b36842
commit f3815cd785
6 changed files with 95 additions and 24 deletions

View File

@ -148,6 +148,36 @@ describe UploadsController do
expect(id).to be
end
it 'respects `authorized_extensions_for_staff` setting when staff upload file' do
SiteSetting.authorized_extensions = ""
SiteSetting.authorized_extensions_for_staff = "*"
@user.update_columns(moderator: true)
post :create, params: {
file: text_file,
type: "composer",
format: :json
}
expect(response).to be_success
data = JSON.parse(response.body)
expect(data["id"]).to be
end
it 'ignores `authorized_extensions_for_staff` setting when non-staff upload file' do
SiteSetting.authorized_extensions = ""
SiteSetting.authorized_extensions_for_staff = "*"
post :create, params: {
file: text_file,
type: "composer",
format: :json
}
data = JSON.parse(response.body)
expect(data["errors"].first).to eq(I18n.t("upload.unauthorized", authorized_extensions: ''))
end
it 'returns an error when it could not determine the dimensions of an image' do
Jobs.expects(:enqueue).with(:create_avatar_thumbnails, anything).never