summaryrefslogtreecommitdiff
path: root/spec/helpers
diff options
context:
space:
mode:
authorBob Van Landuyt <bob@gitlab.com>2017-04-26 12:04:22 +0000
committerRémy Coutable <remy@rymai.me>2017-04-26 12:04:22 +0000
commit019b06b9d29162356a89be46f958a8c0cbd022fd (patch)
tree59470748a7ccde2aceec632b9af8c4500ac973fd /spec/helpers
parent93a698f9b25baa1d3a66326f3f9761103c5ffb87 (diff)
downloadgitlab-ce-019b06b9d29162356a89be46f958a8c0cbd022fd.tar.gz
Load a project's CI status in batch from redis
Diffstat (limited to 'spec/helpers')
-rw-r--r--spec/helpers/ci_status_helper_spec.rb15
-rw-r--r--spec/helpers/projects_helper_spec.rb12
2 files changed, 20 insertions, 7 deletions
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) }