mirror of
https://github.com/czhu12/canine.git
synced 2025-12-19 09:49:58 -06:00
52 lines
1.4 KiB
Ruby
52 lines
1.4 KiB
Ruby
# == Schema Information
|
|
#
|
|
# Table name: domains
|
|
#
|
|
# id :bigint not null, primary key
|
|
# domain_name :string not null
|
|
# status :integer default("checking_dns")
|
|
# status_reason :string
|
|
# created_at :datetime not null
|
|
# updated_at :datetime not null
|
|
# service_id :bigint not null
|
|
#
|
|
# Indexes
|
|
#
|
|
# index_domains_on_service_id (service_id)
|
|
#
|
|
require 'rails_helper'
|
|
|
|
RSpec.describe Domain, type: :model do
|
|
let(:domain) { build(:domain) }
|
|
|
|
describe '#downcase_domain_name' do
|
|
it 'downcases the domain name before saving' do
|
|
domain.domain_name = "EXAMPLE.COM"
|
|
domain.save
|
|
expect(domain.domain_name).to eq("example.com")
|
|
end
|
|
end
|
|
|
|
describe '#strip_protocol' do
|
|
it 'removes the protocol from the domain name' do
|
|
domain.domain_name = "http://example.com"
|
|
domain.send(:strip_protocol)
|
|
expect(domain.domain_name).to eq("example.com")
|
|
end
|
|
end
|
|
|
|
describe '#domain_name_has_tld' do
|
|
it 'adds an error if the domain name does not have a TLD' do
|
|
domain.domain_name = "example"
|
|
domain.valid?
|
|
expect(domain.errors[:domain_name]).to include("is not valid")
|
|
end
|
|
|
|
it 'does not add an error if the domain name has a TLD' do
|
|
domain.domain_name = "example.com"
|
|
domain.valid?
|
|
expect(domain.errors[:domain_name]).to be_empty
|
|
end
|
|
end
|
|
end
|