diff options
Diffstat (limited to 'spec/models/organizations/organization_spec.rb')
-rw-r--r-- | spec/models/organizations/organization_spec.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/spec/models/organizations/organization_spec.rb b/spec/models/organizations/organization_spec.rb index 4a75f352b6f..a9cac30e9a1 100644 --- a/spec/models/organizations/organization_spec.rb +++ b/spec/models/organizations/organization_spec.rb @@ -6,6 +6,13 @@ RSpec.describe Organizations::Organization, type: :model, feature_category: :cel let_it_be(:organization) { create(:organization) } let_it_be(:default_organization) { create(:organization, :default) } + describe 'associations' do + it { is_expected.to have_many :namespaces } + it { is_expected.to have_many :groups } + it { is_expected.to have_many(:users).through(:organization_users).inverse_of(:organizations) } + it { is_expected.to have_many(:organization_users).inverse_of(:organization) } + end + describe 'validations' do subject { create(:organization) } @@ -141,4 +148,18 @@ RSpec.describe Organizations::Organization, type: :model, feature_category: :cel expect(organization.to_param).to eq('org_path') end end + + context 'on deleting organizations via SQL' do + it 'does not allow to delete default organization' do + expect { default_organization.delete }.to raise_error( + ActiveRecord::StatementInvalid, /Deletion of the default Organization is not allowed/ + ) + end + + it 'allows to delete any other organization' do + organization.delete + + expect(described_class.where(id: organization)).not_to exist + end + end end |