Commit 46d1c976 authored by Robert May's avatar Robert May

Fix pipeline status for commit caching

Fixes a bug with the commit cache key used for partial
caching, where the key was changing on every page load.

Changelog: fixed
parent 819b3d12
......@@ -161,7 +161,7 @@ module CommitsHelper
ref,
{
merge_request: merge_request,
pipeline_status: hashed_pipeline_status(commit, ref),
pipeline_status: commit.status_for(ref),
xhr: request.xhr?,
controller: controller.controller_path,
path: @path # referred to in #link_to_browse_code
......@@ -242,14 +242,4 @@ module CommitsHelper
project_commit_path(project, commit)
end
end
private
def hashed_pipeline_status(commit, ref)
status = commit.status_for(ref)
return if status.nil?
Digest::SHA1.hexdigest(status.to_s)
end
end
......@@ -11,6 +11,8 @@ module Gitlab
attr_reader :subject, :user
delegate :cache_key, to: :subject
def initialize(subject, user)
@subject = subject
@user = user
......
......@@ -294,7 +294,8 @@ RSpec.describe CommitsHelper do
subject { helper.commit_partial_cache_key(commit, ref: ref, merge_request: merge_request, request: request) }
let(:commit) { create(:commit).present(current_user: user) }
let(:commit_status) { create(:commit_status) }
let(:commit_status) { Gitlab::Ci::Status::Running.new(pipeline, user) }
let(:pipeline) { create(:ci_pipeline, :running) }
let(:user) { create(:user) }
let(:ref) { "master" }
let(:merge_request) { nil }
......@@ -315,7 +316,7 @@ RSpec.describe CommitsHelper do
is_expected.to include(
{
merge_request: merge_request,
pipeline_status: Digest::SHA1.hexdigest(commit_status.to_s),
pipeline_status: commit_status,
xhr: true,
controller: "commits",
path: current_path
......
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