Browse Source

Maintenance: Stabilize object attribute test.

Martin Gruner 2 years ago
parent
commit
b07741748f
1 changed files with 8 additions and 11 deletions
  1. 8 11
      spec/system/system/object_manager_spec.rb

+ 8 - 11
spec/system/system/object_manager_spec.rb

@@ -671,7 +671,6 @@ RSpec.describe 'System > Objects', type: :system do
       find('input[name=display]').set attribute_name
     end
 
-    let(:attribute) { ObjectManager::Attribute.find_by(name: attribute_name) }
     let(:data_options) do
       {
         '1' => 'one',
@@ -682,6 +681,10 @@ RSpec.describe 'System > Objects', type: :system do
       }
     end
 
+    def find_attribute
+      ObjectManager::Attribute.find_by(name: attribute_name)
+    end
+
     shared_examples 'having a custom sort option' do
       it 'has a custom option checkbox' do
         in_modal disappears: false do
@@ -716,11 +719,8 @@ RSpec.describe 'System > Objects', type: :system do
 
             # Update Database
             click 'div.js-execute'
-            wait.until do
-              attribute &&
-                attribute['data_option'] &&
-                attribute['data_option']['customsort'] == 'on'
-            end
+            wait.until { find_attribute }
+            expect(find_attribute['data_option']['customsort']).to eq('on')
           end
         end
 
@@ -734,11 +734,8 @@ RSpec.describe 'System > Objects', type: :system do
             # Update Database
             click 'div.js-execute'
 
-            wait.until do
-              attribute &&
-                attribute['data_option'] &&
-                attribute['data_option']['customsort'].nil?
-            end
+            wait.until { find_attribute }
+            expect(find_attribute['data_option']['customsort']).to be_nil
           end
         end
       end