Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix up DiskController and add basic testing
- Loading branch information
Showing
5 changed files
with
76 additions
and
3 deletions.
There are no files selected for viewing
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
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
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
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
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 "test_helper" | ||
require "database/setup" | ||
|
||
require "action_controller" | ||
require "action_controller/test_case" | ||
|
||
require "active_file/disk_controller" | ||
require "active_file/verified_key_with_expiration" | ||
|
||
class ActiveFile::DiskControllerTest < ActionController::TestCase | ||
Routes = ActionDispatch::Routing::RouteSet.new.tap do |routes| | ||
routes.draw do | ||
get "/rails/blobs/:encoded_key" => "active_file/disk#show", as: :rails_disk_blob | ||
end | ||
end | ||
|
||
setup do | ||
@blob = create_blob | ||
@routes = Routes | ||
@controller = ActiveFile::DiskController.new | ||
end | ||
|
||
test "showing blob inline" do | ||
get :show, params: { encoded_key: ActiveFile::VerifiedKeyWithExpiration.encode(@blob.key, expires_in: 5.minutes) } | ||
assert_equal "inline; filename=\"#{@blob.filename}\"", @response.headers["Content-Disposition"] | ||
assert_equal "text/plain", @response.headers["Content-Type"] | ||
end | ||
|
||
test "sending blob as attachment" do | ||
get :show, params: { encoded_key: ActiveFile::VerifiedKeyWithExpiration.encode(@blob.key, expires_in: 5.minutes), disposition: :attachment } | ||
assert_equal "attachment; filename=\"#{@blob.filename}\"", @response.headers["Content-Disposition"] | ||
assert_equal "text/plain", @response.headers["Content-Type"] | ||
end | ||
end |