mirror of
https://github.com/internetee/registry.git
synced 2025-06-10 14:44:47 +02:00
- `runner 'Invoice.cancel_overdue_invoices'` in `schedule.rb` is changed to `rake 'invoices:cancel_overdue'`. - `invoices.payment_term` database column is removed and its value is hardcoded in UI. - `invoices.paid_at` is removed as unused - `invoices.due_date` column's type is now `date`. - `Invoice#invoice_items` renamed to `Invoice#items` and `Invoice` interface to get a list of items is unified. - Default date format in UI. - Default translations are used. - Tests improved. - Specs converted to tests and removed along with factories. - Database structure improved.
99 lines
2.4 KiB
Ruby
99 lines
2.4 KiB
Ruby
require 'test_helper'
|
|
|
|
class RegistrarTest < ActiveSupport::TestCase
|
|
setup do
|
|
@registrar = registrars(:bestnames)
|
|
end
|
|
|
|
def test_default_fixture_is_valid
|
|
assert @registrar.valid?, proc { @registrar.errors.full_messages }
|
|
end
|
|
|
|
def test_invalid_fixture_is_invalid
|
|
assert registrars(:invalid).invalid?
|
|
end
|
|
|
|
def test_invalid_without_name
|
|
@registrar.name = ''
|
|
assert @registrar.invalid?
|
|
end
|
|
|
|
def test_invalid_without_reg_no
|
|
@registrar.reg_no = ''
|
|
assert @registrar.invalid?
|
|
end
|
|
|
|
def test_invalid_without_email
|
|
@registrar.email = ''
|
|
assert @registrar.invalid?
|
|
end
|
|
|
|
def test_invalid_without_accounting_customer_code
|
|
@registrar.accounting_customer_code = ''
|
|
assert @registrar.invalid?
|
|
end
|
|
|
|
def test_invalid_without_country_code
|
|
@registrar.country_code = ''
|
|
assert @registrar.invalid?
|
|
end
|
|
|
|
def test_invalid_without_language
|
|
@registrar.language = ''
|
|
assert @registrar.invalid?
|
|
end
|
|
|
|
def test_has_default_language
|
|
Setting.default_language = 'en'
|
|
registrar = Registrar.new
|
|
assert_equal 'en', registrar.language
|
|
end
|
|
|
|
def test_overrides_default_language
|
|
Setting.default_language = 'en'
|
|
registrar = Registrar.new(language: 'de')
|
|
assert_equal 'de', registrar.language
|
|
end
|
|
|
|
def test_full_address
|
|
assert_equal 'Main Street, New York, New York, 12345', @registrar.address
|
|
end
|
|
|
|
def test_validates_reference_number_format
|
|
@registrar.reference_no = '1'
|
|
assert @registrar.invalid?
|
|
|
|
@registrar.reference_no = '11'
|
|
assert @registrar.valid?
|
|
|
|
@registrar.reference_no = '1' * 20
|
|
assert @registrar.valid?
|
|
|
|
@registrar.reference_no = '1' * 21
|
|
assert @registrar.invalid?
|
|
|
|
@registrar.reference_no = '1a'
|
|
assert @registrar.invalid?
|
|
end
|
|
|
|
def test_disallows_non_unique_reference_numbers
|
|
registrars(:bestnames).update!(reference_no: '1234')
|
|
|
|
assert_raises ActiveRecord::RecordNotUnique do
|
|
registrars(:goodnames).update!(reference_no: '1234')
|
|
end
|
|
end
|
|
|
|
def test_issues_new_invoice
|
|
travel_to Time.zone.parse('2010-07-05')
|
|
@original_days_to_keep_invoices_active_setting = Setting.days_to_keep_invoices_active
|
|
Setting.days_to_keep_invoices_active = 10
|
|
|
|
invoice = @registrar.issue_prepayment_invoice(100)
|
|
|
|
assert_equal Date.parse('2010-07-05'), invoice.issue_date
|
|
assert_equal Date.parse('2010-07-15'), invoice.due_date
|
|
|
|
Setting.days_to_keep_invoices_active = @original_days_to_keep_invoices_active_setting
|
|
end
|
|
end
|