Use resourceful routes

https://github.com/rails/rails/pull/23980
This commit is contained in:
Artur Beljajev 2019-10-12 17:06:35 +03:00
parent f8765eca4d
commit 199085f8ac
15 changed files with 152 additions and 113 deletions

View file

@ -0,0 +1,25 @@
require 'test_helper'
class RegistrantAreaDomainsIntegrationTest < ApplicationIntegrationTest
setup do
sign_in users(:registrant)
end
def test_downloads_list_as_csv
get registrant_domains_path(format: :csv)
assert_response :ok
assert_equal "#{Mime[:csv]}; charset=utf-8", response.headers['Content-Type']
assert_equal 'attachment; filename="domains.csv"', response.headers['Content-Disposition']
assert_not_empty response.body
end
def test_downloads_list_as_pdf
get registrant_domains_path(format: :pdf)
assert_response :ok
assert_equal Mime[:pdf], response.headers['Content-Type']
assert_equal 'attachment; filename="domains.pdf"', response.headers['Content-Disposition']
assert_not_empty response.body
end
end

View file

@ -0,0 +1,25 @@
require 'test_helper'
class RegistrarAreaContactsIntegrationTest < ApplicationIntegrationTest
setup do
sign_in users(:api_bestnames)
end
def test_downloads_list_as_csv
get registrar_contacts_path(format: :csv)
assert_response :ok
assert_equal "#{Mime[:csv]}; charset=utf-8", response.headers['Content-Type']
assert_equal 'attachment; filename="contacts.csv"', response.headers['Content-Disposition']
assert_not_empty response.body
end
def test_downloads_list_as_pdf
get registrar_contacts_path(format: :pdf)
assert_response :ok
assert_equal Mime[:pdf], response.headers['Content-Type']
assert_equal 'attachment; filename="contacts.pdf"', response.headers['Content-Disposition']
assert_not_empty response.body
end
end

View file

@ -0,0 +1,20 @@
require 'test_helper'
class RegistrarAreaDomainsIntegrationTest < ApplicationIntegrationTest
setup do
sign_in users(:api_bestnames)
end
def test_downloads_list_as_csv
now = Time.zone.parse('2010-07-05 08:00')
travel_to now
get registrar_domains_path(format: :csv)
assert_response :ok
assert_equal "#{Mime[:csv]}; charset=utf-8", response.headers['Content-Type']
assert_equal %(attachment; filename="Domains_#{l(now, format: :filename)}.csv"),
response.headers['Content-Disposition']
assert_not_empty response.body
end
end