diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-19 11:27:35 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-11-19 11:27:35 +0300 |
commit | 7e9c479f7de77702622631cff2628a9c8dcbc627 (patch) | |
tree | c8f718a08e110ad7e1894510980d2155a6549197 /spec/helpers/tree_helper_spec.rb | |
parent | e852b0ae16db4052c1c567d9efa4facc81146e88 (diff) |
Add latest changes from gitlab-org/gitlab@13-6-stable-eev13.6.0-rc42
Diffstat (limited to 'spec/helpers/tree_helper_spec.rb')
-rw-r--r-- | spec/helpers/tree_helper_spec.rb | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/spec/helpers/tree_helper_spec.rb b/spec/helpers/tree_helper_spec.rb index b5d356b985c..620bf248d7b 100644 --- a/spec/helpers/tree_helper_spec.rb +++ b/spec/helpers/tree_helper_spec.rb @@ -7,6 +7,8 @@ RSpec.describe TreeHelper do let(:repository) { project.repository } let(:sha) { 'c1c67abbaf91f624347bb3ae96eabe3a1b742478' } + let_it_be(:user) { create(:user) } + def create_file(filename) project.repository.create_file( project.creator, @@ -219,7 +221,6 @@ RSpec.describe TreeHelper do context 'user does not have write access but a personal fork exists' do include ProjectForksHelper - let_it_be(:user) { create(:user) } let(:forked_project) { create(:project, :repository, namespace: user.namespace) } before do @@ -277,8 +278,6 @@ RSpec.describe TreeHelper do end context 'user has write access' do - let_it_be(:user) { create(:user) } - before do project.add_developer(user) @@ -314,8 +313,6 @@ RSpec.describe TreeHelper do end context 'gitpod feature is enabled' do - let_it_be(:user) { create(:user) } - before do stub_feature_flags(gitpod: true) allow(Gitlab::CurrentSettings) @@ -358,4 +355,28 @@ RSpec.describe TreeHelper do end end end + + describe '.patch_branch_name' do + before do + allow(helper).to receive(:current_user).and_return(user) + end + + subject { helper.patch_branch_name('master') } + + it 'returns a patch branch name' do + freeze_time do + epoch = Time.now.strftime('%s%L').last(5) + + expect(subject).to eq "#{user.username}-master-patch-#{epoch}" + end + end + + context 'without a current_user' do + let(:user) { nil } + + it 'returns nil' do + expect(subject).to be nil + end + end + end end |