Skip to content

Commit 401ceab

Browse files
committed
MAGETWO-97122: User Role minor changes
1 parent 5d053d6 commit 401ceab

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

app/code/Magento/User/Controller/Adminhtml/User/Role/Delete.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,14 @@ public function execute()
3636

3737
return $resultRedirect->setPath('adminhtml/*/editrole', ['rid' => $rid]);
3838
}
39+
$role = $this->_initRole();
40+
if (!$role->getId()) {
41+
$this->messageManager->addError(__('We can\'t find a role to delete.'));
42+
43+
return $resultRedirect->setPath("*/*/");
44+
}
3945

4046
try {
41-
$role = $this->_initRole();
42-
if (!$role->getId()) {
43-
throw new \Exception();
44-
}
4547
$role->delete();
4648
$this->messageManager->addSuccess(__('You deleted the role.'));
4749
} catch (\Exception $e) {

app/code/Magento/User/Test/Unit/Controller/Adminhtml/User/Role/DeleteTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ public function testExecuteWithoutRole()
289289

290290
$this->messageManagerMock->expects($this->once())
291291
->method('addError')
292-
->with(__('An error occurred while deleting this role.'))
292+
->with(__('We can\'t find a role to delete.'))
293293
->willReturnSelf();
294294

295295
$this->resultRedirectMock->expects($this->once())

0 commit comments

Comments
 (0)