-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(champs): do not depend on attributes hash key in old code
- Loading branch information
Showing
5 changed files
with
39 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
describe Champs::OptionsController, type: :controller do | ||
let(:user) { create(:user) } | ||
let(:procedure) { create(:procedure, types_de_champ_public: [{ type: :multiple_drop_down_list }]) } | ||
|
||
describe '#remove' do | ||
let(:dossier) { create(:dossier, user:, procedure:) } | ||
let(:champ) { dossier.champs.first } | ||
|
||
before { | ||
sign_in user | ||
champ.update(value: ['toto', 'tata'].to_json) | ||
} | ||
|
||
context 'with stable_id' do | ||
subject { delete :remove, params: { dossier_id: dossier, stable_id: champ.stable_id, option: 'tata' }, format: :turbo_stream } | ||
|
||
it 'remove option' do | ||
expect { subject }.to change { champ.reload.selected_options.size }.from(2).to(1) | ||
end | ||
end | ||
|
||
context 'with champ_id' do | ||
subject { delete :remove, params: { champ_id: champ.id, option: 'tata' }, format: :turbo_stream } | ||
|
||
it 'remove option' do | ||
expect { subject }.to change { champ.reload.selected_options.size }.from(2).to(1) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters