Commit 9c9dafc6 authored by Aleksei Lipniagov's avatar Aleksei Lipniagov

Rename into `drop_visibility_level!`

parent 5243de82
......@@ -2258,7 +2258,7 @@ class Project < ApplicationRecord
setting
end
def correct_visibility_level
def drop_visibility_level!
if group && group.visibility_level < visibility_level
self.visibility_level = group.visibility_level
end
......
......@@ -143,7 +143,7 @@ module Gitlab
excluded_keys: excluded_keys_for_relation(:project))
@project.assign_attributes(project_params)
@project.correct_visibility_level
@project.drop_visibility_level!
@project.save!
end
end
......
......@@ -5179,7 +5179,7 @@ describe Project do
end
end
describe '#correct_visibility_level' do
describe '#drop_visibility_level!' do
context 'when has a group' do
let(:group) { create(:group, visibility_level: group_visibility_level) }
let(:project) { build(:project, namespace: group, visibility_level: project_visibility_level) }
......@@ -5189,7 +5189,7 @@ describe Project do
let(:project_visibility_level) { Gitlab::VisibilityLevel::INTERNAL }
it 'sets `visibility_level` value from the group' do
expect { project.correct_visibility_level }
expect { project.drop_visibility_level! }
.to change { project.visibility_level }
.to(Gitlab::VisibilityLevel::PRIVATE)
end
......@@ -5200,7 +5200,7 @@ describe Project do
let(:project_visibility_level) { Gitlab::VisibilityLevel::PRIVATE }
it 'does not change the value of the `visibility_level` field' do
expect { project.correct_visibility_level }
expect { project.drop_visibility_level! }
.not_to change { project.visibility_level }
end
end
......@@ -5217,7 +5217,7 @@ describe Project do
let(:project_visibility_level) { Gitlab::VisibilityLevel::INTERNAL }
it 'sets `visibility_level` value to `PRIVATE`' do
expect { project.correct_visibility_level }
expect { project.drop_visibility_level! }
.to change { project.visibility_level }
.to(Gitlab::VisibilityLevel::PRIVATE)
end
......@@ -5227,7 +5227,7 @@ describe Project do
let(:project_visibility_level) { Gitlab::VisibilityLevel::PUBLIC }
it 'does not change the value of the `visibility_level` field' do
expect { project.correct_visibility_level }
expect { project.drop_visibility_level! }
.to not_change { project.visibility_level }
end
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