diff options
author | Filipa Lacerda <filipa@gitlab.com> | 2017-11-17 14:47:42 +0000 |
---|---|---|
committer | Filipa Lacerda <filipa@gitlab.com> | 2017-11-17 14:47:48 +0000 |
commit | 2686626dbf0479bd829f9f89114ec53704fc5444 (patch) | |
tree | 618d3434c3a9f3ceda9a2e4eb865712299bb9ed1 /spec/models/commit_collection_spec.rb | |
parent | 9a826fcd31430fcaec95cd31755a5712a9504833 (diff) | |
parent | e68ee8af4d981cb7b83fae76c0a94059add495fb (diff) | |
download | gitlab-ce-36400-trigger-job.tar.gz |
[ci skip] Merge branch 'master' into 36400-trigger-job36400-trigger-job
* master: (21 commits)
Changing OAuth lookup to be case insensitive
Delete orphaned fork networks in a migration
Delete the fork network when removing the last membership
Resolve "Performance issues when loading large number of wiki pages"
Exports a couple of project related code as es6 modules
Fix go-import meta data when enabled_git_access_protocol is a blank string
Add dropdowns documentation
Convert migration to populate latest merge request ID into a background migration
Set 0.69.0 instead of latest for codeclimate image
Fix hashed storage with project transfers to another namespace
De-duplicate background migration matchers defined in spec/support/migrations_helpers.rb
Update database_debugging.md
Update database_debugging.md
Move installation of apps higher
Change to Google Kubernetes Cluster and add internal links
Add Ingress description from official docs
Add info on creating your own k8s cluster from the cluster page
Add info about the installed apps in the Cluster docs
Update HA README.md to clarify GitLab support does not troubleshoot DRBD.
Optimise getting the pipeline status of commits
...
Diffstat (limited to 'spec/models/commit_collection_spec.rb')
-rw-r--r-- | spec/models/commit_collection_spec.rb | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/spec/models/commit_collection_spec.rb b/spec/models/commit_collection_spec.rb new file mode 100644 index 00000000000..066fe7d154e --- /dev/null +++ b/spec/models/commit_collection_spec.rb @@ -0,0 +1,59 @@ +require 'spec_helper' + +describe CommitCollection do + let(:project) { create(:project, :repository) } + let(:commit) { project.commit } + + describe '#each' do + it 'yields every commit' do + collection = described_class.new(project, [commit]) + + expect { |b| collection.each(&b) }.to yield_with_args(commit) + end + end + + describe '#with_pipeline_status' do + it 'sets the pipeline status for every commit so no additional queries are necessary' do + create( + :ci_empty_pipeline, + ref: 'master', + sha: commit.id, + status: 'success', + project: project + ) + + collection = described_class.new(project, [commit]) + collection.with_pipeline_status + + recorder = ActiveRecord::QueryRecorder.new do + expect(commit.status).to eq('success') + end + + expect(recorder.count).to be_zero + end + end + + describe '#respond_to_missing?' do + it 'returns true when the underlying Array responds to the message' do + collection = described_class.new(project, []) + + expect(collection.respond_to?(:last)).to eq(true) + end + + it 'returns false when the underlying Array does not respond to the message' do + collection = described_class.new(project, []) + + expect(collection.respond_to?(:foo)).to eq(false) + end + end + + describe '#method_missing' do + it 'delegates undefined methods to the underlying Array' do + collection = described_class.new(project, [commit]) + + expect(collection.length).to eq(1) + expect(collection.last).to eq(commit) + expect(collection).not_to be_empty + end + end +end |