Skip to content

Commit

Permalink
Merge branch 'master' into master-legacy
Browse files Browse the repository at this point in the history
  • Loading branch information
thatandromeda committed Nov 18, 2019
2 parents dbf5a3f + 6ef1dd8 commit 63aed43
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/controllers/files_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class FilesController < ApplicationController
def show
@upload = FileUpload.where(id: params[:id]).first
if params_match? && viewing_allowed?
render text: File.read(file_path), content_type: @upload.file_content_type
render plain: File.read(file_path), content_type: @upload.file_content_type
else
redirect_to(
root_path,
Expand Down
11 changes: 6 additions & 5 deletions spec/integration/downloading_documents.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
expect_download
end

scenario 'won\'t download a document for a guest user with an expired access token', js: true do
scenario "won't download a document for a guest user with an expired access token", js: true do
token_url = create(
:token_url,
notice: notice,
Expand All @@ -48,15 +48,15 @@
expect_no_download
end

scenario 'won\'t download a document for a logged-in user with no access', js: true do
scenario "won't download a document for a logged-in user with no access", js: true do
sign_in(create(:user, :researcher))

visit notice.file_uploads.first.url

expect_no_download
end

scenario 'won\'t download a document for a guest user', js: true do
scenario "won't download a document for a guest user", js: true do
visit notice.file_uploads.first.url

expect_no_download
Expand All @@ -70,15 +70,15 @@
expect(page).to have_content('Documents notification has been disabled.')
end

scenario 'won\'t disable a document notification for a user with a wrong token', js: true do
scenario "won't disable a document notification for a user with a wrong token", js: true do
visit disable_documents_notification_token_url_path(token_url, token: 'hacky-token')

expect(TokenUrl.last.documents_notification).to eq(true)
expect(page).to have_current_path(root_path)
expect(page).to have_content('Wrong token provided.')
end

scenario 'won\'t disable a document notification for a non-exisiting token url', js: true do
scenario "won't disable a document notification for a non-exisiting token url", js: true do
token_url.destroy

visit disable_documents_notification_token_url_path(token_url, token: 'hohoho')
Expand All @@ -91,6 +91,7 @@

def expect_download
expect(page.response_headers['Content-Type']).to include('application/pdf')
expect(page.status_code).to be 200
end

def expect_no_download
Expand Down

0 comments on commit 63aed43

Please sign in to comment.