champ: return the parent dossier even when discarded
Dossier has a `default_scope { kept }`. Because of that, when the parent dossier is discarded, `champ.dossier` will return nil. We should kill the default scope. But meanwhile, ensure that `champ.dossier` returns even a discarded dossier.
This commit is contained in:
parent
76ce622ebf
commit
1cb18e51ac
2 changed files with 12 additions and 1 deletions
|
@ -3,6 +3,17 @@ describe Champ do
|
|||
|
||||
it_should_behave_like "champ_spec"
|
||||
|
||||
describe "associations" do
|
||||
it { is_expected.to belong_to(:dossier) }
|
||||
|
||||
context 'when the parent dossier is discarded' do
|
||||
let(:discarded_dossier) { create(:dossier, :discarded) }
|
||||
subject(:champ) { discarded_dossier.champs.first }
|
||||
|
||||
it { expect(champ.reload.dossier).to eq discarded_dossier }
|
||||
end
|
||||
end
|
||||
|
||||
describe "validations" do
|
||||
let(:row) { 1 }
|
||||
let(:champ) { create(:champ, type_de_champ: create(:type_de_champ), row: row) }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue