Skip to content

Commit

Permalink
Add tests for StagingProject#missing_reviews
Browse files Browse the repository at this point in the history
  • Loading branch information
bgeuken committed Nov 15, 2018
1 parent 688a353 commit 0d1c3a0
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 3 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 32 additions & 0 deletions src/api/spec/models/staging/staging_project_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,38 @@
status_report.update(uuid: '1234')
end

describe '#missing_reviews' do
let(:other_user) { create(:confirmed_user) }
let(:other_package) { create(:package) }
let(:group) { create(:group) }
let!(:review_1) { create(:review, by_user: other_user, bs_request: submit_request) }
let!(:review_2) { create(:review, by_group: group, bs_request: submit_request) }
let!(:review_3) { create(:review, by_project: other_package.project, bs_request: submit_request) }
let!(:review_4) { create(:review, by_package: other_package, by_project: other_package.project, bs_request: submit_request) }

subject { staging_project.missing_reviews }

it 'contains all open reviews of staged requests' do
# rubocop:disable Style/BracesAroundHashParameters
expect(subject).to contain_exactly(
{ id: review_1.id, request: submit_request.number, state: 'new', package: target_package.name, by: other_user.login },
{ id: review_2.id, request: submit_request.number, state: 'new', package: target_package.name, by: group.title },
{ id: review_3.id, request: submit_request.number, state: 'new', package: target_package.name, by: other_package.project.name },
{ id: review_4.id, request: submit_request.number, state: 'new', package: target_package.name, by: other_package.project.name },
{ id: review_4.id, request: submit_request.number, state: 'new', package: target_package.name, by: other_package.name }
)
# rubocop:enable Style/BracesAroundHashParameters
end

context 'when there is an accepted review' do
before do
review_2.update(state: 'accepted')
end

it { expect(subject.map { |review| review[:id] }).not_to include(review_2.id) }
end
end

describe '#staging_identifier' do
before do
staging_project.update(name: 'openSUSE_41:Staging:myStagingProject')
Expand Down

0 comments on commit 0d1c3a0

Please sign in to comment.