lib: remove the 'migrated' key on filters
In a9a4f6e2a8
, a task to migrate
ProcedurePresentation's filters was added.
This task added a "migrated: true" key to all migrated filters.
Now that this task has run, we can safely remove the extra key.
This commit is contained in:
parent
38c4da2deb
commit
fd74d9a062
2 changed files with 70 additions and 0 deletions
|
@ -0,0 +1,45 @@
|
|||
describe '20201001161931_migrate_filters_to_use_stable_id' do
|
||||
let(:rake_task) { Rake::Task['after_party:remove_migration_status_on_filters'] }
|
||||
|
||||
let(:procedure) { create(:simple_procedure) }
|
||||
let(:instructeur_1) { create(:instructeur) }
|
||||
let(:instructeur_2) { create(:instructeur) }
|
||||
|
||||
let(:assign_to_1) { create(:assign_to, procedure: procedure, instructeur: instructeur_1) }
|
||||
let(:assign_to_2) { create(:assign_to, procedure: procedure, instructeur: instructeur_2) }
|
||||
|
||||
let(:procedure_presentation_with_migration) { create(:procedure_presentation, assign_to: assign_to_1, filters: filters.merge('migrated': true)) }
|
||||
let(:procedure_presentation_without_migration) { create(:procedure_presentation, assign_to: assign_to_2, filters: filters) }
|
||||
|
||||
let(:filters) do
|
||||
{ "suivis" => [{ "table" => "user", "column" => "email", "value" => "test@example.com" }] }
|
||||
end
|
||||
|
||||
before do
|
||||
procedure_presentation_with_migration
|
||||
procedure_presentation_without_migration
|
||||
|
||||
rake_task.invoke
|
||||
|
||||
procedure_presentation_with_migration.reload
|
||||
procedure_presentation_without_migration.reload
|
||||
end
|
||||
|
||||
after { rake_task.reenable }
|
||||
|
||||
context 'when the procedure presentation has a "migrated" key' do
|
||||
it 'removes the "migrated" key' do
|
||||
expect(procedure_presentation_with_migration.filters).not_to have_key('migrated')
|
||||
end
|
||||
|
||||
it 'leaves other keys unchanged' do
|
||||
expect(procedure_presentation_with_migration.filters['suivis']).to be_present
|
||||
end
|
||||
end
|
||||
|
||||
context 'when the procedure presentation doesn’t have a "migrated" key' do
|
||||
it 'leaves keys unchanged' do
|
||||
expect(procedure_presentation_without_migration.filters['suivis']).to be_present
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue