mirror of
https://github.com/internetee/registry.git
synced 2025-05-16 01:17:18 +02:00
parent
579da84c58
commit
59e1e18d32
8 changed files with 29 additions and 2 deletions
|
@ -77,7 +77,8 @@ module Admin
|
||||||
:website,
|
:website,
|
||||||
:billing_email,
|
:billing_email,
|
||||||
:code,
|
:code,
|
||||||
:test_registrar)
|
:test_registrar,
|
||||||
|
:accounting_customer_code)
|
||||||
end
|
end
|
||||||
end
|
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, :country_code, :email, :code, presence: true
|
||||||
validates :name, :reg_no, :reference_no, :code, uniqueness: true
|
validates :name, :reg_no, :reference_no, :code, uniqueness: true
|
||||||
|
validates :accounting_customer_code, presence: true
|
||||||
validate :forbidden_codes
|
validate :forbidden_codes
|
||||||
|
|
||||||
def forbidden_codes
|
def forbidden_codes
|
||||||
return true unless ['CID'].include? code
|
return true unless ['CID'].include? code
|
||||||
errors.add(:code, I18n.t(:forbidden_code))
|
errors.add(:code, I18n.t(:forbidden_code))
|
||||||
|
|
|
@ -43,6 +43,12 @@
|
||||||
.col-md-7
|
.col-md-7
|
||||||
= f.email_field :billing_email, class: 'form-control'
|
= 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
|
.row
|
||||||
.col-md-8
|
.col-md-8
|
||||||
.panel.panel-default
|
.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,
|
zip character varying,
|
||||||
code character varying,
|
code character varying,
|
||||||
website character varying,
|
website character varying,
|
||||||
accounting_customer_code character varying,
|
accounting_customer_code character varying NOT NULL,
|
||||||
vat boolean,
|
vat boolean,
|
||||||
legacy_id integer,
|
legacy_id integer,
|
||||||
reference_no character varying,
|
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 ('20171025113808');
|
||||||
|
|
||||||
|
INSERT INTO schema_migrations (version) VALUES ('20171025153841');
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ FactoryGirl.define do
|
||||||
zip 'test'
|
zip 'test'
|
||||||
email 'test@test.com'
|
email 'test@test.com'
|
||||||
country_code 'EE'
|
country_code 'EE'
|
||||||
|
accounting_customer_code 'test'
|
||||||
|
|
||||||
factory :registrar_with_unlimited_balance do
|
factory :registrar_with_unlimited_balance do
|
||||||
after :create do |registrar|
|
after :create do |registrar|
|
||||||
|
|
|
@ -13,6 +13,7 @@ class NewRegistrarTest < ActionDispatch::IntegrationTest
|
||||||
fill_in 'registrar[reg_no]', with: '1234567'
|
fill_in 'registrar[reg_no]', with: '1234567'
|
||||||
fill_in 'registrar[email]', with: 'test@test.com'
|
fill_in 'registrar[email]', with: 'test@test.com'
|
||||||
fill_in 'registrar[code]', with: 'test'
|
fill_in 'registrar[code]', with: 'test'
|
||||||
|
fill_in 'registrar[accounting_customer_code]', with: 'test'
|
||||||
click_link_or_button 'Create registrar'
|
click_link_or_button 'Create registrar'
|
||||||
|
|
||||||
assert_text 'Registrar has been successfully created'
|
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