task: clean header_section options
This commit is contained in:
parent
fcb868c6a8
commit
1169dae310
2 changed files with 118 additions and 0 deletions
|
@ -0,0 +1,95 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require "rails_helper"
|
||||
|
||||
module Maintenance
|
||||
RSpec.describe CleanHeaderSectionOptionsTask do
|
||||
describe '#collection' do
|
||||
subject(:collection) { described_class.collection }
|
||||
|
||||
context 'clean header_section tdc with header_section_level' do
|
||||
let(:tdc) {
|
||||
create(:type_de_champ_header_section,
|
||||
options: {
|
||||
'header_section_level' => '1'
|
||||
})
|
||||
}
|
||||
|
||||
it do
|
||||
expect(collection).not_to include(tdc)
|
||||
end
|
||||
end
|
||||
|
||||
context 'clean header_section tdc with no header_section_level' do
|
||||
let(:tdc) {
|
||||
create(:type_de_champ_header_section,
|
||||
options: {})
|
||||
}
|
||||
|
||||
it do
|
||||
expect(collection).not_to include(tdc)
|
||||
end
|
||||
end
|
||||
|
||||
context 'header_section tdc with bad data options' do
|
||||
let(:tdc) {
|
||||
create(:type_de_champ_header_section,
|
||||
options: {
|
||||
'header_section_level' => '1',
|
||||
'key' => 'value'
|
||||
})
|
||||
}
|
||||
|
||||
it do
|
||||
expect(collection).to include(tdc)
|
||||
end
|
||||
end
|
||||
|
||||
context 'other tdc' do
|
||||
let(:tdc) {
|
||||
create(:type_de_champ_textarea,
|
||||
options: {
|
||||
'character_limit' => '400'
|
||||
})
|
||||
}
|
||||
|
||||
it do
|
||||
expect(collection).not_to include(tdc)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#process" do
|
||||
subject(:process) { described_class.process(tdc) }
|
||||
|
||||
context 'bad data in options' do
|
||||
let(:tdc) {
|
||||
create(:type_de_champ_header_section,
|
||||
options: {
|
||||
'header_section_level' => '1',
|
||||
'key' => 'value'
|
||||
})
|
||||
}
|
||||
|
||||
it do
|
||||
subject
|
||||
expect(tdc.reload.options).to eq({ 'header_section_level' => '1' })
|
||||
end
|
||||
end
|
||||
|
||||
context 'only bad data in options' do
|
||||
let(:tdc) {
|
||||
create(:type_de_champ_header_section,
|
||||
options: {
|
||||
'key' => 'value'
|
||||
})
|
||||
}
|
||||
|
||||
it do
|
||||
subject
|
||||
expect(tdc.reload.options).to eq({})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue