mirror of
https://github.com/internetee/registry.git
synced 2025-07-20 17:55:55 +02:00
Add tests, fix error handling
This commit is contained in:
parent
e15b1283e5
commit
e92afb59c1
2 changed files with 26 additions and 8 deletions
|
@ -5,14 +5,11 @@ module Admin
|
||||||
def show
|
def show
|
||||||
@ld = LegalDocument.find(params[:id])
|
@ld = LegalDocument.find(params[:id])
|
||||||
filename = @ld.path.split('/').last
|
filename = @ld.path.split('/').last
|
||||||
file = File.open(@ld.path).read
|
file = File.open(@ld.path)&.read
|
||||||
|
send_data file, filename: filename
|
||||||
if file
|
rescue Errno::ENOENT
|
||||||
send_data file, filename: filename
|
flash[:notice] = I18n.t('legal_doc_not_found')
|
||||||
else
|
redirect_to [:admin, @ld.documentable]
|
||||||
flash[:notice] = I18n.t('legal_doc_not_found')
|
|
||||||
redirect_to [:admin, @ld.documentable]
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
21
test/system/admin_area/domains/legal_doc_test.rb
Normal file
21
test/system/admin_area/domains/legal_doc_test.rb
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
require 'application_system_test_case'
|
||||||
|
|
||||||
|
class AdminAreaDomainsLegalDocTest < ApplicationSystemTestCase
|
||||||
|
setup do
|
||||||
|
sign_in users(:admin)
|
||||||
|
@domain = domains(:shop)
|
||||||
|
@document = LegalDocument.create(
|
||||||
|
document_type: 'pdf',
|
||||||
|
documentable_id: @domain.id,
|
||||||
|
documentable_type: 'Domain',
|
||||||
|
path: '\zzz\zzz'
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_absent_doc_downloading_without_errors
|
||||||
|
visit admin_domain_url(@domain)
|
||||||
|
assert_nothing_raised do
|
||||||
|
click_on "#{@document.created_at}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Add table
Add a link
Reference in a new issue