Skip to content

Commit

Permalink
Merge pull request #5255 from hstastna/Approver_user_cannot_deny_request
Browse files Browse the repository at this point in the history
Allow Approver user to deny the request

(cherry picked from commit 7296655)

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1686090
  • Loading branch information
h-kataria authored and simaishi committed Mar 6, 2019
1 parent a4460d9 commit c2b483c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/helpers/application_helper/button/miq_request.rb
Expand Up @@ -14,7 +14,7 @@ def role_allows_feature?

def visible?
return false if @record.resource_type == "AutomationRequest" &&
!%w(miq_request_approval miq_request_deny miq_request_delete).include?(@feature)
!%w(miq_request_approval miq_request_delete).include?(@feature)
true
end

Expand Down
Expand Up @@ -48,7 +48,7 @@ class ApplicationHelper::Toolbar::MiqRequestCenter < ApplicationHelper::Toolbar:
N_('Deny this Request'),
nil,
:klass => ApplicationHelper::Button::MiqRequestApproval,
:options => {:feature => 'miq_request_deny'},
:options => {:feature => 'miq_request_approval'},
:url => "/stamp",
:url_parms => "?typ=d"),
])
Expand Down
Expand Up @@ -14,6 +14,7 @@
let(:request) { "SomeRequest" }
let(:username) { user.name }
let(:state) { "xx" }

%w(MiqProvisionRequest VmReconfigureRequest VmCloudReconfigureRequest
VmMigrateRequest AutomationRequest ServiceTemplateProvisionRequest).each do |cls|
context "id = miq_request_approval" do
Expand All @@ -27,22 +28,28 @@
button.instance_variable_set(:@showtype, "prase")
button.instance_variable_set(:@request_tab, "service")
end

context "resource_type = AutomationRequest" do
let(:request) { "AutomationRequest" }

it "and resource_type = AutomationRequest" do
expect(button.skipped?).to be_falsey
end
end

context "approval_state = approved" do
let(:state) { "approved" }

it "and approval_state = approved" do
expect(button.skipped?).to be_truthy
end
end

it "and showtype = miq_provisions" do
button.instance_variable_set(:@showtype, "miq_provisions")
expect(button.skipped?).to be_truthy
end

it "and approval_state != approved and showtype != miq_provisions" do
expect(button.skipped?).to be_falsey
end
Expand All @@ -53,7 +60,7 @@
view_context,
{},
{'record' => @record, 'showtype' => @showtype},
{:options => {:feature => 'miq_request_deny'}}
{:options => {:feature => 'miq_request_approval'}}
)
end

Expand All @@ -68,28 +75,36 @@
button.instance_variable_set(:@showtype, "prase")
button.instance_variable_set(:@request_tab, "service")
end

context "resource_type = AutomationRequest" do
let(:request) { "AutomationRequest" }

it "and resource_type = AutomationRequest" do
expect(button.skipped?).to be_falsey
end
end

context "approval_state = approved" do
let(:state) { "approved" }

it "and approval_state = approved" do
expect(button.skipped?).to be_truthy
end
end

context "approval_state = denied" do
let(:state) { "denied" }

it "and approval_state = denied" do
expect(button.skipped?).to be_truthy
end
end

it "and showtype = miq_provisions" do
button.instance_variable_set(:@showtype, "miq_provisions")
expect(button.skipped?).to be_truthy
end

it "and approval_state != approved|denied and showtype != miq_provisions" do
expect(button.skipped?).to be_falsey
end
Expand Down

0 comments on commit c2b483c

Please sign in to comment.