Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🔥 Ne réécrie pas la méthode update d'une question qcm #1764

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 0 additions & 22 deletions app/admin/questions_qcm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,28 +48,6 @@
end

controller do
def update
if @question.update(question_params)
redirect_to admin_question_qcm_path
else
render :edit, status: :unprocessable_entity
end
end

private

def question_params
params.require(:question_qcm).permit(
:categorie, :libelle, :nom_technique, :description,
:metacompetence, :type_qcm, :illustration, :supprimer_illustration,
:supprimer_audio_intitule,
:supprimer_audio_modalite_reponse,
:supprimer_audio_consigne,
choix_attributes: %i[id intitule audio type_choix _destroy nom_technique],
transcriptions_attributes: %i[id categorie ecrit audio _destroy]
)
end
Comment on lines -51 to -71
Copy link
Contributor Author

@marouria marouria Nov 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

J'ai l'impression que ça ne sert à rien et c'est difficile à maintenir car il faut ne pas oublier de mettre à jour la liste des params. Dans ce cas précis ça ne mettait donc pas à jour le champs :demarrage_audio_modalite_reponse

On ne le fait pas pour les autres types de questions.


def set_question
@question = Question.includes(transcriptions: :audio_attachment).find(params[:id])
end
Expand Down
14 changes: 14 additions & 0 deletions spec/features/admin/question_qcm_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,20 @@
end
end

context "quand l'admin coche lire la consigne en premier" do
before do
visit edit_admin_question_qcm_path(question)
check 'question_qcm_demarrage_audio_modalite_reponse'
end

it 'met à jour la question' do
expect(question.demarrage_audio_modalite_reponse).to be false
click_on 'Enregistrer'
question.reload
expect(question.demarrage_audio_modalite_reponse).to be true
end
end

context "quand l'admin coche supprimer l'audio de l'intitulé" do
before do
Question.first.transcriptions.find_by(categorie: :intitule)
Expand Down