diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-18 00:08:09 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-18 00:08:09 +0000 |
commit | 2a65a97e12a0754b9f0d91ee996a6e61e00c80c8 (patch) | |
tree | f439c93cc95a324ba7422b0b650431a628be9b07 /spec/models/commit_status_spec.rb | |
parent | 2d96e61ceb1a3f26283dfba43f85d99488752296 (diff) | |
download | gitlab-ce-2a65a97e12a0754b9f0d91ee996a6e61e00c80c8.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/models/commit_status_spec.rb')
-rw-r--r-- | spec/models/commit_status_spec.rb | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/spec/models/commit_status_spec.rb b/spec/models/commit_status_spec.rb index 1e1b679a32c..31aebac54e1 100644 --- a/spec/models/commit_status_spec.rb +++ b/spec/models/commit_status_spec.rb @@ -312,6 +312,72 @@ describe CommitStatus do end end + describe '.for_ref' do + subject { described_class.for_ref('bb').order(:id) } + + let(:statuses) do + [create_status(ref: 'aa'), + create_status(ref: 'bb'), + create_status(ref: 'cc')] + end + + it 'returns statuses with the specified ref' do + is_expected.to eq(statuses.values_at(1)) + end + end + + describe '.by_name' do + subject { described_class.by_name('bb').order(:id) } + + let(:statuses) do + [create_status(name: 'aa'), + create_status(name: 'bb'), + create_status(name: 'cc')] + end + + it 'returns statuses with the specified name' do + is_expected.to eq(statuses.values_at(1)) + end + end + + describe '.for_project_paths' do + subject do + described_class + .for_project_paths(paths) + .order(:id) + end + + context 'with a single path' do + let(:other_project) { create(:project, :repository) } + let(:paths) { other_project.full_path } + + let(:other_pipeline) do + create(:ci_pipeline, project: other_project, sha: other_project.commit.id) + end + + let(:statuses) do + [create_status(pipeline: pipeline), + create_status(pipeline: other_pipeline)] + end + + it 'returns statuses for other_project' do + is_expected.to eq(statuses.values_at(1)) + end + end + + context 'with array of paths' do + let(:paths) { [project.full_path] } + + let(:statuses) do + [create_status(pipeline: pipeline)] + end + + it 'returns statuses for project' do + is_expected.to eq(statuses.values_at(0)) + end + end + end + describe '.status' do context 'when there are multiple statuses present' do before do |