diff options
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 |