diff options
Diffstat (limited to 'spec/helpers/groups_helper_spec.rb')
-rw-r--r-- | spec/helpers/groups_helper_spec.rb | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/spec/helpers/groups_helper_spec.rb b/spec/helpers/groups_helper_spec.rb index ac2f028f937..5be247c5b49 100644 --- a/spec/helpers/groups_helper_spec.rb +++ b/spec/helpers/groups_helper_spec.rb @@ -340,4 +340,31 @@ describe GroupsHelper do end end end + + describe '#can_update_default_branch_protection?' do + let(:current_user) { create(:user) } + let(:group) { create(:group) } + + subject { helper.can_update_default_branch_protection?(group) } + + before do + allow(helper).to receive(:current_user) { current_user } + end + + context 'for users who can update default branch protection of the group' do + before do + allow(helper).to receive(:can?).with(current_user, :update_default_branch_protection, group) { true } + end + + it { is_expected.to be_truthy } + end + + context 'for users who cannot update default branch protection of the group' do + before do + allow(helper).to receive(:can?).with(current_user, :update_default_branch_protection, group) { false } + end + + it { is_expected.to be_falsey } + end + end end |