mirror of
https://github.com/internetee/registry.git
synced 2025-05-21 19:59:38 +02:00
parent
ffd29f6a67
commit
b9df5aa92d
11 changed files with 411 additions and 281 deletions
68
spec/models/concerns/domain/activatable_spec.rb
Normal file
68
spec/models/concerns/domain/activatable_spec.rb
Normal file
|
@ -0,0 +1,68 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Domain, db: false do
|
||||
describe '#active?' do
|
||||
context 'when :statuses does not contain :inactive' do
|
||||
let(:domain) { described_class.new(statuses: []) }
|
||||
|
||||
it 'returns true' do
|
||||
expect(domain.active?).to be true
|
||||
end
|
||||
end
|
||||
|
||||
context 'when :statuses contains :inactive' do
|
||||
let(:domain) { described_class.new(statuses: [DomainStatus::INACTIVE]) }
|
||||
|
||||
it 'returns false' do
|
||||
expect(domain.active?).to be false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#inactive?' do
|
||||
context 'when :statuses contains :inactive' do
|
||||
let(:domain) { described_class.new(statuses: [DomainStatus::INACTIVE]) }
|
||||
|
||||
it 'returns true' do
|
||||
expect(domain.inactive?).to be true
|
||||
end
|
||||
end
|
||||
|
||||
context 'when :statuses does not contain :inactive' do
|
||||
let(:domain) { described_class.new(statuses: []) }
|
||||
|
||||
it 'returns false' do
|
||||
expect(domain.inactive?).to be false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#activate' do
|
||||
let(:domain) { described_class.new(statuses: [DomainStatus::INACTIVE]) }
|
||||
|
||||
it 'activates domain' do
|
||||
domain.activate
|
||||
expect(domain).to be_active
|
||||
end
|
||||
end
|
||||
|
||||
describe '#deactivate' do
|
||||
context 'when active' do
|
||||
let(:domain) { described_class.new }
|
||||
|
||||
it 'deactivates domain' do
|
||||
domain.deactivate
|
||||
expect(domain).to be_inactive
|
||||
end
|
||||
end
|
||||
|
||||
context 'when inactive' do
|
||||
let(:domain) { described_class.new(statuses: [DomainStatus::INACTIVE]) }
|
||||
|
||||
it 'does not add :inactive status' do
|
||||
domain.deactivate
|
||||
expect(domain.statuses).to eq([DomainStatus::INACTIVE])
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue