Skip to content
Open
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
19 changes: 10 additions & 9 deletions src/api-umbrella/admin-ui/app/mixins/save.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,17 @@ export default Mixin.create({
destroyRecord(options) {
bootbox.confirm(options.prompt, (result) => {
if(result) {
this.model.destroyRecord().then(() => {
success({
title: 'Deleted',
text: (isFunction(options.message)) ? options.message(this.model) : options.message,
textTrusted: true,
const message = (isFunction(options.message)) ? options.message(this.model) : options.message;
this.router.transitionTo(options.transitionToRoute).then(() => {
this.model.destroyRecord().then(() => {
success({
title: 'Deleted',
text: message,
textTrusted: true,
});
}, function(response) {
bootbox.alert('Unexpected error deleting record: ' + response.responseText);
});

this.router.transitionTo(options.transitionToRoute);
}, function(response) {
bootbox.alert('Unexpected error deleting record: ' + response.responseText);
});
}
});
Expand Down
16 changes: 16 additions & 0 deletions test/admin_ui/test_admin_groups.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,20 @@ def test_update
"backend_manage",
].sort, admin_group.permission_ids.sort)
end

def test_delete_shows_success_notification_and_no_error
admin_group = FactoryBot.create(:admin_group, :name => "Delete Me Group")

admin_login
visit "/admin/#/admin_groups/#{admin_group.id}/edit"
assert_field("Group Name", :with => "Delete Me Group")

find("a.remove-action", :text => /Delete Admin Group/).click
click_button("OK")

assert_text("Successfully deleted")
refute_text("Unexpected error deleting record")

assert_nil(AdminGroup.where(:id => admin_group.id).first)
end
end
20 changes: 20 additions & 0 deletions test/admin_ui/test_apis.rb
Original file line number Diff line number Diff line change
Expand Up @@ -432,4 +432,24 @@ def test_nested_select_menu_behavior_inside_modals
assert_select("HTTP Method", :selected => "OPTIONS")
end
end

def test_delete_shows_success_notification_and_no_error
api = FactoryBot.create(:api_backend, :name => "Delete Me API")

admin_login
visit "/admin/#/apis/#{api.id}/edit"
assert_field("Name", :with => "Delete Me API")

# Click the "Delete API" link in the form, then confirm in the bootbox.
find("a.remove-action", :text => /Delete API/).click
click_button("OK")

# The success pnotify must appear...
assert_text("Successfully deleted")
# ...and the misleading error alert must NOT.
refute_text("Unexpected error deleting record")

# And the record must actually be gone.
assert_nil(ApiBackend.where(:id => api.id).first)
end
end
Loading