mirror of
https://github.com/internetee/registry.git
synced 2025-07-30 06:26:15 +02:00
Fix admin accounts CSV output
This commit is contained in:
parent
7d79e6528d
commit
1fac9d9618
3 changed files with 24 additions and 0 deletions
|
@ -12,4 +12,12 @@ class Account < ApplicationRecord
|
|||
def activities
|
||||
account_activities
|
||||
end
|
||||
|
||||
def as_csv_row
|
||||
[id, balance, currency, registrar]
|
||||
end
|
||||
|
||||
def self.csv_header
|
||||
['Id', 'Balance', 'Currency', 'Registrar'].freeze
|
||||
end
|
||||
end
|
||||
|
|
4
test/fixtures/files/accounts.csv
vendored
Normal file
4
test/fixtures/files/accounts.csv
vendored
Normal file
|
@ -0,0 +1,4 @@
|
|||
Id,Balance,Currency,Registrar
|
||||
112846265,100.0,EUR,Best Names
|
||||
298486374,100.0,EUR,Good Names
|
||||
597560588,0.0,EUR,Not in use
|
|
|
@ -29,4 +29,16 @@ class AdminAccountsSystemTest < ApplicationSystemTestCase
|
|||
assert_text 'Account has been successfully updated'
|
||||
assert_text '234'
|
||||
end
|
||||
|
||||
def test_download_accounts_list_as_csv
|
||||
travel_to Time.zone.parse('2010-07-05 10:30')
|
||||
|
||||
get admin_accounts_path(format: :csv)
|
||||
|
||||
assert_response :ok
|
||||
assert_equal 'text/csv; charset=utf-8', response.headers['Content-Type']
|
||||
assert_equal %(attachment; filename="accounts_#{Time.zone.now.to_formatted_s(:number)}.csv"; filename*=UTF-8''accounts_#{Time.zone.now.to_formatted_s(:number)}.csv),
|
||||
response.headers['Content-Disposition']
|
||||
assert_equal file_fixture('accounts.csv').read, response.body
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue