Admin can delete enterprise roles

This commit is contained in:
Rohan Mitchell
2014-08-15 16:05:09 +10:00
parent 95a0bf39f7
commit 9ddfb1584b
2 changed files with 20 additions and 0 deletions

View File

@@ -16,5 +16,11 @@ module Admin
render status: 400, json: {errors: @enterprise_role.errors.full_messages.join(', ')}
end
end
def destroy
@enterprise_role = EnterpriseRole.find params[:id]
@enterprise_role.destroy
render nothing: true
end
end
end

View File

@@ -62,6 +62,20 @@ feature %q{
page.should have_content "That role is already present."
end.to change(EnterpriseRole, :count).by(0)
end
scenario "deleting a relationship" do
u = create(:user, email: 'u@example.com')
e = create(:enterprise, name: 'One')
er = create(:enterprise_role, user: u, enterprise: e)
visit admin_enterprise_roles_path
page.should have_relationship u, e
first("a.delete-enterprise-role").click
page.should_not have_relationship u, e
EnterpriseRole.where(id: er.id).should be_empty
end
end