Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

all_ems_in_zone is not a scope yet, so we can't chain 'where' #14792

Merged
merged 1 commit into from
Apr 18, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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