From c1378b86b667419f489c93b22abcfde73cd6e5a4 Mon Sep 17 00:00:00 2001 From: Joe Rafaniello Date: Fri, 28 Oct 2016 17:29:17 -0400 Subject: [PATCH] Check the dialog_fields labels without regard to order dialog_group.dialog_fields isn't guaranteed to be in order each time we run this test. Instead, we can combine the two tests and just assert we update the two existing rows and create a single new row. Fixes a sporadic test failure: 1) DialogGroup#update_dialog_fields a collection of dialog fields containing two objects with ids and one without an id updates a the dialog fields with an id Failure/Error: expect(dialog_group.dialog_fields.first.label).to eq('updated_field_label') expected: "updated_field_label" got: "new field label" (compared using ==) # ./spec/models/dialog_group_spec.rb:41:in `block (4 levels) in ' This was added in #11833. --- spec/models/dialog_group_spec.rb | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/spec/models/dialog_group_spec.rb b/spec/models/dialog_group_spec.rb index b5adab684d8..4b01f5742e8 100644 --- a/spec/models/dialog_group_spec.rb +++ b/spec/models/dialog_group_spec.rb @@ -33,19 +33,10 @@ { 'name' => 'new field', 'label' => 'new field label' } ] end - - it 'updates a the dialog fields with an id' do + it 'creates or updates the dialog fields' do dialog_group.update_dialog_fields(updated_fields) - dialog_group.reload - expect(dialog_group.dialog_fields.first.label).to eq('updated_field_label') - expect(dialog_group.dialog_fields.last.label).to eq('updated_field_label') - end - - it 'creates a new dialog field from the dialog fields without an id' do - expect do - dialog_group.update_dialog_fields(updated_fields) - end.to change(dialog_group.reload.dialog_fields, :count).by(1) + expect(dialog_group.dialog_fields.collect(&:label)).to match_array(['updated_field_label', 'updated_field_label', 'new field label']) end end