mirror of
https://github.com/internetee/registry.git
synced 2025-05-16 17:37:17 +02:00
Period validation
This commit is contained in:
parent
6990da7675
commit
1e2dad06f9
6 changed files with 16 additions and 1 deletions
|
@ -25,6 +25,7 @@ module Epp::DomainsHelper
|
|||
name: ph[:name],
|
||||
registrar_id: current_epp_user.registrar.try(:id),
|
||||
registered_at: Time.now,
|
||||
period: ph[:period].to_i,
|
||||
valid_from: Date.today,
|
||||
valid_to: Date.today + ph[:period].to_i.years,
|
||||
auth_info: ph[:authInfo][:pw]
|
||||
|
|
|
@ -10,6 +10,7 @@ class Domain < ActiveRecord::Base
|
|||
|
||||
validates :name, domain_name: true, uniqueness: { message: I18n.t('errors.messages.epp_domain_taken') }
|
||||
validates :name_puny, domain_name: true
|
||||
validates :period, numericality: { only_integer: true, greater_than: 0, less_than: 100 }
|
||||
|
||||
def name=(value)
|
||||
value.strip!
|
||||
|
|
5
db/migrate/20140730104916_add_period_to_domain.rb
Normal file
5
db/migrate/20140730104916_add_period_to_domain.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
class AddPeriodToDomain < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :domains, :period, :integer
|
||||
end
|
||||
end
|
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20140730082532) do
|
||||
ActiveRecord::Schema.define(version: 20140730104916) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
@ -63,6 +63,7 @@ ActiveRecord::Schema.define(version: 20140730082532) do
|
|||
t.datetime "updated_at"
|
||||
t.string "name_dirty"
|
||||
t.string "name_puny"
|
||||
t.integer "period"
|
||||
end
|
||||
|
||||
create_table "epp_sessions", force: true do |t|
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
Fabricator(:domain) do
|
||||
name { "#{Faker::Internet.domain_word}.ee" }
|
||||
period 1
|
||||
end
|
||||
|
|
|
@ -40,4 +40,10 @@ describe Domain do
|
|||
Fabricate(:reserved_domain)
|
||||
expect(Fabricate.build(:domain, name: '1162.ee').valid?).to be false
|
||||
end
|
||||
|
||||
it 'validates period' do
|
||||
expect(Fabricate.build(:domain, period: 0).valid?).to be false
|
||||
expect(Fabricate.build(:domain, period: 120).valid?).to be false
|
||||
expect(Fabricate.build(:domain, period: 99).valid?).to be true
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue