Skip to content

Commit

Permalink
all_ems_in_zone is not a scope yet, so we can't chain 'where'
Browse files Browse the repository at this point in the history
Fixes a bug introduced in:
ManageIQ#14675

We'll do our condition checks on arrays for now, until we can properly
use scopes.  The scopes will require us to change callers to expect
scopes, which is why we're fixing this bug for now.
  • Loading branch information
jrafanie committed Apr 18, 2017
1 parent 943dd65 commit bf9868c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/models/mixins/per_ems_worker_mixin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions spec/models/mixins/per_ems_worker_mixin_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit bf9868c

Please sign in to comment.