mirror of
https://github.com/internetee/registry.git
synced 2025-05-16 09:27:19 +02:00
parent
579da84c58
commit
59e1e18d32
8 changed files with 29 additions and 2 deletions
|
@ -77,7 +77,8 @@ module Admin
|
|||
:website,
|
||||
:billing_email,
|
||||
:code,
|
||||
:test_registrar)
|
||||
:test_registrar,
|
||||
:accounting_customer_code)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -16,7 +16,9 @@ class Registrar < ActiveRecord::Base
|
|||
|
||||
validates :name, :reg_no, :country_code, :email, :code, presence: true
|
||||
validates :name, :reg_no, :reference_no, :code, uniqueness: true
|
||||
validates :accounting_customer_code, presence: true
|
||||
validate :forbidden_codes
|
||||
|
||||
def forbidden_codes
|
||||
return true unless ['CID'].include? code
|
||||
errors.add(:code, I18n.t(:forbidden_code))
|
||||
|
|
|
@ -43,6 +43,12 @@
|
|||
.col-md-7
|
||||
= f.email_field :billing_email, class: 'form-control'
|
||||
|
||||
.form-group
|
||||
.col-md-4.control-label
|
||||
= f.label :accounting_customer_code
|
||||
.col-md-7
|
||||
= f.text_field :accounting_customer_code, class: 'form-control', required: true
|
||||
|
||||
.row
|
||||
.col-md-8
|
||||
.panel.panel-default
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
class ChangeRegistrarAccountingCustomerCodeToNotNull < ActiveRecord::Migration
|
||||
def change
|
||||
change_column_null :registrars, :accounting_customer_code, false
|
||||
end
|
||||
end
|
|
@ -2473,7 +2473,7 @@ CREATE TABLE registrars (
|
|||
zip character varying,
|
||||
code character varying,
|
||||
website character varying,
|
||||
accounting_customer_code character varying,
|
||||
accounting_customer_code character varying NOT NULL,
|
||||
vat boolean,
|
||||
legacy_id integer,
|
||||
reference_no character varying,
|
||||
|
@ -5055,3 +5055,5 @@ INSERT INTO schema_migrations (version) VALUES ('20171025110933');
|
|||
|
||||
INSERT INTO schema_migrations (version) VALUES ('20171025113808');
|
||||
|
||||
INSERT INTO schema_migrations (version) VALUES ('20171025153841');
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ FactoryGirl.define do
|
|||
zip 'test'
|
||||
email 'test@test.com'
|
||||
country_code 'EE'
|
||||
accounting_customer_code 'test'
|
||||
|
||||
factory :registrar_with_unlimited_balance do
|
||||
after :create do |registrar|
|
||||
|
|
|
@ -13,6 +13,7 @@ class NewRegistrarTest < ActionDispatch::IntegrationTest
|
|||
fill_in 'registrar[reg_no]', with: '1234567'
|
||||
fill_in 'registrar[email]', with: 'test@test.com'
|
||||
fill_in 'registrar[code]', with: 'test'
|
||||
fill_in 'registrar[accounting_customer_code]', with: 'test'
|
||||
click_link_or_button 'Create registrar'
|
||||
|
||||
assert_text 'Registrar has been successfully created'
|
||||
|
|
9
test/models/registrar_test.rb
Normal file
9
test/models/registrar_test.rb
Normal file
|
@ -0,0 +1,9 @@
|
|||
require 'test_helper'
|
||||
|
||||
class RegistrarTest < ActiveSupport::TestCase
|
||||
def test_rejects_absent_accounting_customer_code
|
||||
registrar = Registrar.new(accounting_customer_code: nil)
|
||||
registrar.validate
|
||||
assert registrar.errors.added?(:accounting_customer_code, :blank)
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue