Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[api] Introduce scope for assigned and unassigned reviews
Use case of this is when e.g. maintenance group assigns a review to a user, the new review should not be displayed in maintenance statistics. Only the original one is of interested for them.
- Loading branch information
Showing
4 changed files
with
64 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
FactoryGirl.define do | ||
factory :history_element_review_assigned, class: 'HistoryElement::ReviewAssigned' do | ||
type { 'HistoryElement::ReviewAssigned' } | ||
end | ||
|
||
factory :history_element_review_accepted, class: 'HistoryElement::ReviewAccepted' do | ||
type { 'HistoryElement::ReviewAccepted' } | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
FactoryGirl.define do | ||
factory :review do | ||
state :new | ||
|
||
factory :user_review do | ||
by_user { create(:user) } | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,41 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.shared_context 'some assigned reviews and some unassigned reviews' do | ||
let!(:user) { create(:user) } | ||
|
||
let!(:review_assigned1) { create(:review, by_user: user.login) } | ||
let!(:review_assigned2) { create(:review, by_user: user.login) } | ||
let!(:review_unassigned1) { create(:review, by_user: user.login) } | ||
let!(:review_unassigned2) { create(:review, by_user: user.login) } | ||
|
||
let!(:history_element1) do | ||
create(:history_element_review_assigned, op_object_id: review_assigned1.id, user_id: user.id) | ||
end | ||
let!(:history_element2) do | ||
create(:history_element_review_assigned, op_object_id: review_assigned2.id, user_id: user.id) | ||
end | ||
let!(:history_element3) do | ||
create(:history_element_review_accepted, op_object_id: review_assigned2.id, user_id: user.id) | ||
end | ||
let!(:history_element4) do | ||
create(:history_element_review_accepted, op_object_id: review_unassigned1.id, user_id: user.id) | ||
end | ||
end | ||
|
||
RSpec.describe Review do | ||
it { should belong_to(:bs_request).touch(true) } | ||
end | ||
|
||
describe '.assigned' do | ||
include_context 'some assigned reviews and some unassigned reviews' | ||
|
||
subject { Review.assigned } | ||
it { is_expected.to match_array([review_assigned1, review_assigned2]) } | ||
end | ||
|
||
describe '.unassigned' do | ||
include_context 'some assigned reviews and some unassigned reviews' | ||
|
||
subject { Review.unassigned } | ||
it { is_expected.to match_array([review_unassigned1, review_unassigned2]) } | ||
end | ||
end |