fix(champs.pj.clone): stop cloning private piece_justificative_file when user clone his dossier
This commit is contained in:
parent
4629092ab6
commit
4ea601de79
2 changed files with 41 additions and 1 deletions
|
@ -238,7 +238,7 @@ class Champ < ApplicationRecord
|
||||||
kopy.write_attribute(:stable_id, original.stable_id)
|
kopy.write_attribute(:stable_id, original.stable_id)
|
||||||
kopy.write_attribute(:stream, 'main')
|
kopy.write_attribute(:stream, 'main')
|
||||||
end
|
end
|
||||||
ClonePiecesJustificativesService.clone_attachments(original, kopy)
|
ClonePiecesJustificativesService.clone_attachments(original, kopy) if fork || !private?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -569,4 +569,44 @@ describe Champ do
|
||||||
it { expect(ActionView::RecordIdentifier.dom_id(champ.type_de_champ)).to eq("type_de_champ_#{champ.type_de_champ.id}") }
|
it { expect(ActionView::RecordIdentifier.dom_id(champ.type_de_champ)).to eq("type_de_champ_#{champ.type_de_champ.id}") }
|
||||||
it { expect(ActionView::RecordIdentifier.dom_class(champ)).to eq("champ") }
|
it { expect(ActionView::RecordIdentifier.dom_class(champ)).to eq("champ") }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'clone' do
|
||||||
|
subject { champ.clone(fork) }
|
||||||
|
|
||||||
|
context 'when champ public' do
|
||||||
|
let(:champ) { create(:champ_piece_justificative, private: false) }
|
||||||
|
|
||||||
|
context 'when fork' do
|
||||||
|
let(:fork) { true }
|
||||||
|
it do
|
||||||
|
expect(subject.piece_justificative_file).to be_attached
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when not fork' do
|
||||||
|
let(:fork) { false }
|
||||||
|
it do
|
||||||
|
expect(subject.piece_justificative_file).to be_attached
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'champ private' do
|
||||||
|
let(:champ) { create(:champ_piece_justificative, private: true) }
|
||||||
|
|
||||||
|
context 'when fork' do
|
||||||
|
let(:fork) { true }
|
||||||
|
it do
|
||||||
|
expect(subject.piece_justificative_file).to be_attached
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when not fork' do
|
||||||
|
let(:fork) { false }
|
||||||
|
it do
|
||||||
|
expect(subject.piece_justificative_file).not_to be_attached
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue