Skip to content

Commit

Permalink
Merge pull request #14792 from jrafanie/where_is_my_scope
Browse files Browse the repository at this point in the history
all_ems_in_zone is not a scope yet, so we can't chain 'where'
  • Loading branch information
kbrock authored Apr 18, 2017
2 parents b8b9c81 + bf9868c commit 87f4b38
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 87f4b38

Please sign in to comment.