2022-09-08 11:25:39 +02:00
|
|
|
describe EditableChamp::EditableChampComponent, type: :component do
|
|
|
|
let(:component) { described_class.new(form: nil, champ: champ) }
|
|
|
|
|
2022-07-21 17:59:20 +02:00
|
|
|
describe "editable_champ_controller" do
|
|
|
|
let(:dossier) { create(:dossier) }
|
|
|
|
let(:champ) { create(:champ, dossier: dossier) }
|
|
|
|
let(:controllers) { [] }
|
2022-09-08 11:25:39 +02:00
|
|
|
let(:data) { controllers.join(' ') }
|
|
|
|
|
|
|
|
subject { component.send(:stimulus_controller) }
|
2022-07-21 17:59:20 +02:00
|
|
|
|
|
|
|
context 'when an editable champ' do
|
|
|
|
let(:controllers) { ['autosave'] }
|
|
|
|
|
2022-09-08 11:25:39 +02:00
|
|
|
it { expect(subject).to eq(data) }
|
2022-07-21 17:59:20 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'when a repetition champ' do
|
|
|
|
let(:champ) { create(:champ_repetition, dossier: dossier) }
|
|
|
|
|
2022-09-08 11:25:39 +02:00
|
|
|
it { expect(subject).to eq(nil) }
|
2022-07-21 17:59:20 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'when a private champ' do
|
|
|
|
let(:champ) { create(:champ, dossier: dossier, private: true) }
|
|
|
|
|
2023-03-01 18:30:10 +01:00
|
|
|
it { expect(subject).to eq('autosave') }
|
2022-07-21 17:59:20 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'when a dossier is en_construction' do
|
2022-09-08 11:25:39 +02:00
|
|
|
let(:controllers) { ['autosave'] }
|
2022-07-21 17:59:20 +02:00
|
|
|
let(:dossier) { create(:dossier, :en_construction) }
|
|
|
|
|
2022-09-08 11:25:39 +02:00
|
|
|
it { expect(subject).to eq(data) }
|
2022-07-21 17:59:20 +02:00
|
|
|
|
|
|
|
context 'when a public dropdown champ' do
|
2022-09-08 11:25:39 +02:00
|
|
|
let(:controllers) { ['autosave', 'champ-dropdown'] }
|
2022-07-21 17:59:20 +02:00
|
|
|
let(:champ) { create(:champ_drop_down_list, dossier: dossier) }
|
|
|
|
|
2022-09-08 11:25:39 +02:00
|
|
|
it { expect(subject).to eq(data) }
|
2022-07-21 17:59:20 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'when a private dropdown champ' do
|
2023-03-01 18:30:10 +01:00
|
|
|
let(:controllers) { ['autosave', 'champ-dropdown'] }
|
2022-07-21 17:59:20 +02:00
|
|
|
let(:champ) { create(:champ_drop_down_list, dossier: dossier, private: true) }
|
|
|
|
|
2022-09-08 11:25:39 +02:00
|
|
|
it { expect(subject).to eq(data) }
|
2022-07-21 17:59:20 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when a public dropdown champ' do
|
|
|
|
let(:controllers) { ['autosave', 'champ-dropdown'] }
|
|
|
|
let(:champ) { create(:champ_drop_down_list, dossier: dossier) }
|
|
|
|
|
2022-09-08 11:25:39 +02:00
|
|
|
it { expect(subject).to eq(data) }
|
2022-07-21 17:59:20 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
context 'when a private dropdown champ' do
|
2023-03-01 18:30:10 +01:00
|
|
|
let(:controllers) { ['autosave', 'champ-dropdown'] }
|
2022-07-21 17:59:20 +02:00
|
|
|
let(:champ) { create(:champ_drop_down_list, dossier: dossier, private: true) }
|
|
|
|
|
2022-09-08 11:25:39 +02:00
|
|
|
it { expect(subject).to eq(data) }
|
2022-07-21 17:59:20 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|