docbrown/spec/helpers/admin/organizations_helper_spec.rb
Ridhwana 272aea6127
Allow admins to delete an organization (#19699)
* feat: update the layout for organizations

* feat: update the layout for an organization

* feat: organization logos are square

* feat: change the text on the org visit button

* feat: initialize the dropdown menu

* feat: trigger the  modal

* feat: update the text in the model

* feat: tweak wording

* WIP/feat: hook up a route with an action that calls an organization delete worker.

* feat: redirect after showing the notice

* feat: update the authorization required to be super admin

* feat: add the notice to localization

* spec: integration test

* spec: fix

* spec: delete worker

* chore: update the link

* feat: add safe navigation

* feat: make sure that we show an error if the organization has credits

* fix: error message for modal unspent credits

* feat add the spec for the helper

* fix: remove rspec preface

* fix: small fixes to tests and I18n

* fix: updated the number of orgs

* feat: update the message

* feat: update the message

* chore: remove inclusion of helper

* feat: change the name of the parameter

* chore: newline
2023-07-17 12:09:24 +02:00

28 lines
1.1 KiB
Ruby

require "rails_helper"
describe Admin::OrganizationsHelper do
describe "#deletion_modal_error_message" do
let(:organization) { create(:organization) }
let(:super_admin) { create(:user, :super_admin) }
let(:admin) { create(:user, :admin) }
context "when the current user is not a super admin" do
before { allow(helper).to receive(:current_user).and_return(admin) }
it "returns the appropriate error messsage" do
error_message = helper.deletion_modal_error_message(organization)
expect(error_message).to eq("Only Super Admins are allowed to delete organizations.")
end
end
context "when there are credits associated to an organization" do
before { allow(helper).to receive(:current_user).and_return(super_admin) }
it "returns the appropriate error messsage" do
Credit.add_to(organization, 10)
error_message = helper.deletion_modal_error_message(organization)
expect(error_message).to eq("You cannot delete an organization that has associated credits.")
end
end
end
end