debian-mirror-gitlab/spec/models/namespaces/project_namespace_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

36 lines
1.1 KiB
Ruby
Raw Permalink Normal View History

2021-11-11 11:23:49 +05:30
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Namespaces::ProjectNamespace, type: :model do
describe 'relationships' do
it { is_expected.to have_one(:project).with_foreign_key(:project_namespace_id).inverse_of(:project_namespace) }
2022-08-27 11:52:29 +05:30
specify do
project = create(:project)
namespace = project.project_namespace
namespace.reload_project
expect(namespace.project).to eq project
end
2021-11-11 11:23:49 +05:30
end
describe 'validations' do
it { is_expected.not_to validate_presence_of :owner }
end
context 'when deleting project namespace' do
# using delete rather than destroy due to `delete` skipping AR hooks/callbacks
# so it's ensured to work at the DB level. Uses ON DELETE CASCADE on foreign key
let_it_be(:project) { create(:project) }
2021-12-11 22:18:48 +05:30
let_it_be(:project_namespace) { project.project_namespace }
2021-11-11 11:23:49 +05:30
2022-06-21 17:19:12 +05:30
it 'also deletes associated project' do
2021-11-11 11:23:49 +05:30
project_namespace.delete
expect { project_namespace.reload }.to raise_error(ActiveRecord::RecordNotFound)
2022-06-21 17:19:12 +05:30
expect { project.reload }.to raise_error(ActiveRecord::RecordNotFound)
2021-11-11 11:23:49 +05:30
end
end
end