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

Fix email issue in miq_provision_quota_mixin active_provision by_owner method. #16693

Merged
merged 1 commit into from
Dec 20, 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
5 changes: 2 additions & 3 deletions app/models/mixins/miq_provision_quota_mixin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -252,12 +252,11 @@ def quota_find_prov_request_by_group(options)
end

def quota_find_active_prov_request_by_owner(options)
email = get_option(:owner_email).to_s.strip
quota_find_active_prov_request(options).select { |p| email.casecmp(p.request_owner_email(p)).zero? }
quota_find_active_prov_request(options).select { |p| request_owner_email(self).casecmp(p.request_owner_email(p)).zero? }
end

def request_owner_email(request)
service_request?(request) ? request.requester.email : request.get_option(:owner_email).to_s.strip
service_request?(request) ? request.requester.email : request.get_option(:owner_email)
end

def service_request?(request)
Expand Down
6 changes: 6 additions & 0 deletions spec/models/miq_provision_request_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,12 @@ def queue(requests)
{:count => 4, :memory => 4.gigabytes, :cpu => 8, :storage => 2.gigabytes}
end
it_behaves_like "check_quota"

it "fails without owner_email option" do
load_queue
request.options = {}
expect { request.check_quota(quota_method) }.to raise_error(NoMethodError)
end
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,12 @@ def create_service_bundle(user, items, options = {})
{:count => 3, :memory => 3.gigabytes, :cpu => 8, :storage => 1_610_612_736}
end
it_behaves_like "check_quota"

it "fails without requester.email" do
load_queue
@vmware_user1.update_attributes(:email => nil)
expect { request.check_quota(quota_method) }.to raise_error(NoMethodError)
end
end
end

Expand Down