diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-15 21:09:26 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-15 21:09:26 +0000 |
commit | 651917dbac09fc4fe9217c08d68420019dff59fb (patch) | |
tree | 6cdda4532d41b7862a33d7f3ab91959c3917d4f0 /spec/helpers/tree_helper_spec.rb | |
parent | da1962d9ac710f95d350d2645c87f5a663123cf2 (diff) | |
download | gitlab-ce-651917dbac09fc4fe9217c08d68420019dff59fb.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/helpers/tree_helper_spec.rb')
-rw-r--r-- | spec/helpers/tree_helper_spec.rb | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/spec/helpers/tree_helper_spec.rb b/spec/helpers/tree_helper_spec.rb index 511cfaaa7a9..307479744ef 100644 --- a/spec/helpers/tree_helper_spec.rb +++ b/spec/helpers/tree_helper_spec.rb @@ -154,4 +154,58 @@ RSpec.describe TreeHelper do expect(helper.commit_in_single_accessible_branch).to include(escaped_branch_name) end end + + describe '#vue_file_list_data' do + before do + allow(helper).to receive(:current_user).and_return(nil) + end + + it 'returns a list of attributes related to the project' do + expect(helper.vue_file_list_data(project, sha)).to include( + can_push_code: nil, + fork_path: nil, + escaped_ref: sha, + ref: sha, + project_path: project.full_path, + project_short_path: project.path, + full_name: project.name_with_namespace + ) + end + + 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 + project.add_guest(user) + fork_project(project, nil, target_project: forked_project) + + allow(helper).to receive(:current_user).and_return(user) + end + + it 'includes fork_path too' do + expect(helper.vue_file_list_data(project, sha)).to include( + fork_path: forked_project.full_path + ) + end + end + + context 'user has write access' do + let_it_be(:user) { create(:user) } + + before do + project.add_developer(user) + + allow(helper).to receive(:current_user).and_return(user) + end + + it 'includes can_push_code: true' do + expect(helper.vue_file_list_data(project, sha)).to include( + can_push_code: "true" + ) + end + end + end end |