This repository has been archived by the owner on Jan 8, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add tests for new mediated download links
- Loading branch information
Showing
2 changed files
with
34 additions
and
5 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
require 'spec_helper' | ||
|
||
describe("Object Files Download", :type => :request, :integration => true) do | ||
|
||
fixtures :users | ||
fixtures :object_files | ||
|
||
before :each do | ||
@druid = 'druid:oo000oo0001' | ||
@file = Hydrus::ObjectFile.find(2) # this PDF defined in the fixtures belongs to archivist1 | ||
end | ||
|
||
it "should be redirected to the login page when accessing a file URL if not logged in" do | ||
logout | ||
visit @file.url | ||
expect(current_path).to eq(new_user_session_path) | ||
end | ||
|
||
it "should allow the owner of the file to download it" do | ||
login_as('archivist1') # owner of the item can download the file | ||
visit @file.url | ||
expect(page.status_code).to eq(200) | ||
expect(page.response_headers['Content-Type']).to eq("application/pdf") | ||
end | ||
|
||
it "should redirect to home page and provide a not authorized message when accessing a file URL when logged in but do not have view access on the item" do | ||
login_as('archivist99') # no view access on the item, no access | ||
visit @file.url | ||
expect(page.response_headers['Content-Type']).not_to eq("application/pdf") | ||
expect(current_path).to eq(root_path) | ||
expect(find("#flash-notices div.alert")).to have_content("You are not authorized to access this page.") | ||
end | ||
|
||
end |