diff --git a/app/models/mixins/per_ems_worker_mixin.rb b/app/models/mixins/per_ems_worker_mixin.rb index 93884f72c75..8fb69d3e1ff 100644 --- a/app/models/mixins/per_ems_worker_mixin.rb +++ b/app/models/mixins/per_ems_worker_mixin.rb @@ -18,7 +18,7 @@ def all_ems_in_zone end def all_valid_ems_in_zone - all_ems_in_zone.where(:enabled => true).select(&:authentication_status_ok?) + all_ems_in_zone.select {|e| e.enabled && e.authentication_status_ok?} end def desired_queue_names diff --git a/spec/models/mixins/per_ems_worker_mixin_spec.rb b/spec/models/mixins/per_ems_worker_mixin_spec.rb index 30e239ef545..bcc81c1a9a5 100644 --- a/spec/models/mixins/per_ems_worker_mixin_spec.rb +++ b/spec/models/mixins/per_ems_worker_mixin_spec.rb @@ -15,6 +15,14 @@ expect(@worker_class.queue_name_for_ems(@ems)).to eq(@ems_queue_name) end + it ".all_valid_ems_in_zone" do + expect(@worker_class.all_valid_ems_in_zone).to be_empty + + @ems.update(:enabled => true) + @ems.authentications.first.validation_successful + expect(@worker_class.all_valid_ems_in_zone).to eq([@ems]) + end + it "#worker_options" do expect(@worker_record.worker_options).to eq(:guid => @worker_record.guid, :ems_id => @ems.id) end