Spec: mutualize subject

This commit is contained in:
simon lehericey 2018-09-26 15:15:46 +02:00
parent 7b27f00a23
commit d14944fba3

View file

@ -5,24 +5,22 @@ describe API::V1::ProceduresController, type: :controller do
it { expect(described_class).to be < APIController } it { expect(described_class).to be < APIController }
describe 'GET show' do describe 'GET show' do
subject { get :show, params: { id: procedure_id, token: token } }
context 'when procedure does not exist' do context 'when procedure does not exist' do
subject { get :show, params: { id: 999_999_999, token: token } } let(:procedure_id) { 999_999_999 }
it { expect(subject.status).to eq(404) } it { expect(subject.status).to eq(404) }
end end
context 'when procedure does not belong to administrateur' do context 'when procedure does not belong to administrateur' do
let(:procedure) { create(:procedure, administrateur: create(:administrateur)) } let(:procedure_id) { create(:procedure, administrateur: create(:administrateur)).id }
subject { get :show, params: { id: procedure, token: token } }
it { expect(subject.status).to eq(404) } it { expect(subject.status).to eq(404) }
end end
context 'when procedure exist' do context 'when procedure exist' do
let(:procedure) { create(:procedure, :with_two_type_de_piece_justificative, :with_type_de_champ, administrateur: admin) } let(:procedure_id) { create(:procedure, :with_two_type_de_piece_justificative, :with_type_de_champ, administrateur: admin).id }
subject { get :show, params: { id: procedure, token: token } }
it 'return REST code 200', :show_in_doc do it 'return REST code 200', :show_in_doc do
expect(subject.status).to eq(200) expect(subject.status).to eq(200)