Add procedure revisions spec

This commit is contained in:
Paul Chavard 2020-07-08 19:11:03 +02:00 committed by Paul Chavard
parent 0338080430
commit 58535c6a35
2 changed files with 54 additions and 0 deletions

View file

@ -130,4 +130,30 @@ describe ProcedureRevision do
expect(procedure.types_de_champ.size).to eq(2)
end
end
describe '#create_new_revision' do
let(:new_revision) { procedure.create_new_revision }
before { new_revision.save }
it 'should be part of procedure' do
expect(new_revision.procedure).to eq(revision.procedure)
expect(procedure.revisions.count).to eq(2)
expect(procedure.revisions).to eq([revision, new_revision])
end
it 'should have types_de_champ' do
expect(new_revision.types_de_champ.count).to eq(2)
expect(new_revision.types_de_champ_private.count).to eq(1)
expect(new_revision.types_de_champ).to eq(revision.types_de_champ)
expect(new_revision.types_de_champ_private).to eq(revision.types_de_champ_private)
expect(new_revision.revision_types_de_champ.count).to eq(2)
expect(new_revision.revision_types_de_champ_private.count).to eq(1)
expect(new_revision.revision_types_de_champ.count).to eq(revision.revision_types_de_champ.count)
expect(new_revision.revision_types_de_champ_private.count).to eq(revision.revision_types_de_champ_private.count)
expect(new_revision.revision_types_de_champ).not_to eq(revision.revision_types_de_champ)
expect(new_revision.revision_types_de_champ_private).not_to eq(revision.revision_types_de_champ_private)
end
end
end

View file

@ -572,6 +572,13 @@ describe Procedure do
expect(Procedure.find_by(path: "example-path")).to eq(procedure)
expect(Procedure.find_by(path: "example-path").administrateurs).to eq(procedure.administrateurs)
end
it 'creates a new draft revision' do
expect(procedure.published_revision).not_to be_nil
expect(procedure.draft_revision).not_to be_nil
expect(procedure.revisions.count).to eq(2)
expect(procedure.revisions).to eq([procedure.published_revision, procedure.draft_revision])
end
end
context 'when publishing over a previous canonical procedure' do
@ -622,6 +629,13 @@ describe Procedure do
it 'unpublishes the canonical procedure' do
expect(canonical_procedure.unpublished_at).to eq(now)
end
it 'creates a new draft revision' do
expect(procedure.published_revision).not_to be_nil
expect(procedure.draft_revision).not_to be_nil
expect(procedure.revisions.count).to eq(2)
expect(procedure.revisions).to eq([procedure.published_revision, procedure.draft_revision])
end
end
context 'when publishing over a previous procedure with canonical procedure' do
@ -668,6 +682,13 @@ describe Procedure do
expect(procedure.published_at).not_to be_nil
expect(procedure.unpublished_at).to eq(now)
}
it 'sets published revision' do
expect(procedure.published_revision).not_to be_nil
expect(procedure.draft_revision).not_to be_nil
expect(procedure.revisions.count).to eq(2)
expect(procedure.revisions.last).to eq(procedure.draft_revision)
end
end
describe "#brouillon?" do
@ -742,6 +763,13 @@ describe Procedure do
it { expect(procedure.close?).to be_truthy }
it { expect(procedure.closed_at).to eq(now) }
it 'sets published revision' do
expect(procedure.published_revision).not_to be_nil
expect(procedure.draft_revision).not_to be_nil
expect(procedure.revisions.count).to eq(2)
expect(procedure.revisions.last).to eq(procedure.draft_revision)
end
end
describe 'path_customized?' do