From 019b06b9d29162356a89be46f958a8c0cbd022fd Mon Sep 17 00:00:00 2001 From: Bob Van Landuyt Date: Wed, 26 Apr 2017 12:04:22 +0000 Subject: Load a project's CI status in batch from redis --- spec/helpers/ci_status_helper_spec.rb | 15 ++++++++------- spec/helpers/projects_helper_spec.rb | 12 ++++++++++++ 2 files changed, 20 insertions(+), 7 deletions(-) (limited to 'spec/helpers') diff --git a/spec/helpers/ci_status_helper_spec.rb b/spec/helpers/ci_status_helper_spec.rb index 3dc13001056..e6bb953e9d8 100644 --- a/spec/helpers/ci_status_helper_spec.rb +++ b/spec/helpers/ci_status_helper_spec.rb @@ -46,14 +46,15 @@ describe CiStatusHelper do end describe "#pipeline_status_cache_key" do - let(:pipeline_status) do - Gitlab::Cache::Ci::ProjectPipelineStatus - .new(build(:project), sha: '123abc', status: 'success') - end - it "builds a cache key for pipeline status" do - expect(helper.pipeline_status_cache_key(pipeline_status)) - .to eq("pipeline-status/123abc-success") + pipeline_status = Gitlab::Cache::Ci::ProjectPipelineStatus.new( + build(:project), + pipeline_info: { + sha: "123abc", + status: "success" + } + ) + expect(helper.pipeline_status_cache_key(pipeline_status)).to eq("pipeline-status/123abc-success") end end end diff --git a/spec/helpers/projects_helper_spec.rb b/spec/helpers/projects_helper_spec.rb index a7fc5d14859..d96d48a1977 100644 --- a/spec/helpers/projects_helper_spec.rb +++ b/spec/helpers/projects_helper_spec.rb @@ -103,6 +103,18 @@ describe ProjectsHelper do end end + describe '#load_pipeline_status' do + it 'loads the pipeline status in batch' do + project = build(:empty_project) + + helper.load_pipeline_status([project]) + # Skip lazy loading of the `pipeline_status` attribute + pipeline_status = project.instance_variable_get('@pipeline_status') + + expect(pipeline_status).to be_a(Gitlab::Cache::Ci::ProjectPipelineStatus) + end + end + describe 'link_to_member' do let(:group) { create(:group) } let(:project) { create(:empty_project, group: group) } -- cgit v1.2.3