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

Rename into `drop_visibility_level!`

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