Commit 83511120 authored by Gary Holtz's avatar Gary Holtz Committed by Andrew Fontaine

Using an existing function for commit list check

parent 5f4c1308
......@@ -428,10 +428,6 @@ module ProjectsHelper
project.merge_requests_enabled? && can?(user, :read_merge_request, project)
end
def able_to_see_last_commit?(show_last_commit_as_description, project, user)
show_last_commit_as_description && can?(user, :read_commit_status, project)
end
def fork_button_disabled_tooltip(project)
return unless current_user
......
......@@ -5,7 +5,7 @@
- pipeline_status = true unless local_assigns[:pipeline_status] == false
- skip_namespace = false unless local_assigns[:skip_namespace] == true
- user = local_assigns[:user]
- show_last_commit_as_description = false unless local_assigns[:show_last_commit_as_description] == true
- show_last_commit_as_description = false unless local_assigns[:show_last_commit_as_description] == true && can_show_last_commit_in_list?(project)
- remote = false unless local_assigns[:remote] == true
- skip_pagination = false unless local_assigns[:skip_pagination] == true
- compact_mode = false unless local_assigns[:compact_mode] == true
......@@ -37,7 +37,7 @@
- css_class = (i >= projects_limit) || project.pending_delete? ? 'hide' : nil
= render "shared/projects/project", project: project, skip_namespace: skip_namespace,
avatar: avatar, stars: stars, css_class: css_class, use_creator_avatar: use_creator_avatar,
forks: project.forking_enabled?, show_last_commit_as_description: able_to_see_last_commit?(show_last_commit_as_description, project, user),
forks: project.forking_enabled?, show_last_commit_as_description: show_last_commit_as_description,
user: user, merge_requests: able_to_see_merge_requests?(project, user), issues: able_to_see_issues?(project, user),
pipeline_status: pipeline_status, compact_mode: compact_mode
= paginate_collection(projects, remote: remote) unless skip_pagination
......
......@@ -1046,27 +1046,6 @@ RSpec.describe ProjectsHelper do
end
end
end
describe "#able_to_see_last_commit?" do
subject { helper.able_to_see_last_commit?(show_last_commit_as_description, project, user) }
where(:can_read_last_commit, :show_last_commit_as_description, :expected) do
false | false | false
true | false | false
false | true | false
true | true | true
end
with_them do
before do
allow(helper).to receive(:can?).with(user, :read_commit_status, project).and_return(can_read_last_commit)
end
it 'returns the correct response' do
expect(subject).to eq(expected)
end
end
end
end
describe '#fork_button_disabled_tooltip' do
......
......@@ -22,7 +22,7 @@ RSpec.describe 'shared/projects/_list' do
end
it "will not show elements a user shouldn't be able to see" do
allow(view).to receive(:able_to_see_last_commit?).and_return(false)
allow(view).to receive(:can_show_last_commit_in_list?).and_return(false)
allow(view).to receive(:able_to_see_merge_requests?).and_return(false)
allow(view).to receive(:able_to_see_issues?).and_return(false)
......
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