refactor spec
This commit is contained in:
parent
16d58d0204
commit
3eadff9111
1 changed files with 25 additions and 42 deletions
|
@ -1,19 +1,13 @@
|
|||
describe Administrateurs::TypesDeChampController, type: :controller do
|
||||
let(:admin) { create(:administrateur) }
|
||||
|
||||
describe '#types_de_champs editor' do
|
||||
let(:procedure) { create(:procedure) }
|
||||
|
||||
before do
|
||||
admin.procedures << procedure
|
||||
sign_in(admin.user)
|
||||
end
|
||||
before { sign_in(procedure.administrateurs.first.user) }
|
||||
|
||||
let(:type_champ) { TypeDeChamp.type_champs.fetch(:text) }
|
||||
describe '#create' do
|
||||
let(:params) { default_params }
|
||||
|
||||
context "create type_de_champ text" do
|
||||
before do
|
||||
post :create, params: {
|
||||
let(:default_params) do
|
||||
{
|
||||
procedure_id: procedure.id,
|
||||
type_de_champ: {
|
||||
type_champ: type_champ,
|
||||
|
@ -21,45 +15,34 @@ describe Administrateurs::TypesDeChampController, type: :controller do
|
|||
private: false,
|
||||
placeholder: "custom placeholder"
|
||||
}
|
||||
}, format: :turbo_stream
|
||||
}
|
||||
end
|
||||
|
||||
it { expect(response).to have_http_status(:ok) }
|
||||
subject { post :create, params: params, format: :turbo_stream }
|
||||
|
||||
context "create type_de_champ text" do
|
||||
let(:type_champ) { TypeDeChamp.type_champs.fetch(:text) }
|
||||
|
||||
it { is_expected.to have_http_status(:ok) }
|
||||
end
|
||||
|
||||
context "validate type_de_champ linked_drop_down_list" do
|
||||
let(:type_champ) { TypeDeChamp.type_champs.fetch(:linked_drop_down_list) }
|
||||
|
||||
before do
|
||||
post :create, params: {
|
||||
procedure_id: procedure.id,
|
||||
type_de_champ: {
|
||||
type_champ: type_champ,
|
||||
libelle: 'Nouveau champ',
|
||||
private: false
|
||||
}
|
||||
}, format: :turbo_stream
|
||||
it do
|
||||
is_expected.to have_http_status(:ok)
|
||||
expect(flash.alert).to eq(nil)
|
||||
end
|
||||
|
||||
it { expect(response).to have_http_status(:ok) }
|
||||
end
|
||||
|
||||
context "create type_de_champ linked_drop_down_list" do
|
||||
let(:type_champ) { TypeDeChamp.type_champs.fetch(:linked_drop_down_list) }
|
||||
let(:params) { default_params.deep_merge(type_de_champ: { drop_down_list_value: '--value--' }) }
|
||||
|
||||
before do
|
||||
post :create, params: {
|
||||
procedure_id: procedure.id,
|
||||
type_de_champ: {
|
||||
type_champ: type_champ,
|
||||
libelle: 'Nouveau champ',
|
||||
drop_down_list_value: '--value--',
|
||||
private: false
|
||||
}
|
||||
}, format: :turbo_stream
|
||||
end
|
||||
|
||||
it { expect(response).to have_http_status(:ok) }
|
||||
it do
|
||||
is_expected.to have_http_status(:ok)
|
||||
expect(flash.alert).to eq(nil)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue