Commit 99b5f0ff authored by Reuben Pereira's avatar Reuben Pereira

Use after(:build) instead of before(:create) in project factory

This will run the hook when used with `build(:project)` as well.
parent d4dcf1b3
......@@ -51,7 +51,7 @@ FactoryBot.define do
ci_job_token_scope_enabled { nil }
end
before(:create) do |project, evaluator|
after(:build) do |project, evaluator|
# Builds and MRs can't have higher visibility level than repository access level.
builds_access_level = [evaluator.builds_access_level, evaluator.repository_access_level].min
merge_requests_access_level = [evaluator.merge_requests_access_level, evaluator.repository_access_level].min
......
......@@ -218,5 +218,29 @@ RSpec.describe ProjectFeature do
end
end
end
context 'test build factory' do
let(:project) { build(:project, container_registry_access_level: level) }
subject { project.container_registry_access_level }
context 'private' do
let(:level) { ProjectFeature::PRIVATE }
it { is_expected.to eq(level) }
end
context 'enabled' do
let(:level) { ProjectFeature::ENABLED }
it { is_expected.to eq(level) }
end
context 'disabled' do
let(:level) { ProjectFeature::DISABLED }
it { is_expected.to eq(level) }
end
end
end
end
......@@ -318,7 +318,8 @@ RSpec.describe Project, factory_default: :keep do
end
it 'validates presence of project_feature' do
project = build(:project, project_feature: nil)
project = build(:project)
project.project_feature = nil
expect(project).not_to be_valid
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment