-
Notifications
You must be signed in to change notification settings - Fork 436
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add specs for BsRequestHistoryElementComponent
- Loading branch information
Showing
1 changed file
with
59 additions
and
24 deletions.
There are no files selected for viewing
83 changes: 59 additions & 24 deletions
83
src/api/spec/components/bs_request_history_element_component_spec.rb
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,40 +1,75 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.describe BsRequestHistoryElementComponent, type: :component do | ||
# rubocop:disable Lint/EmptyBlock | ||
shared_context 'raising an exception warning the user to provide an history element' do | ||
end | ||
# rubocop:enable Lint/EmptyBlock | ||
let(:user) { create(:confirmed_user) } | ||
|
||
# rubocop:disable RSpec/RepeatedExampleGroupBody | ||
context 'when the element provided is not present' do | ||
it_behaves_like 'raising an exception warning the user to provide an history element' | ||
it 'fails when the history element is not passed' do | ||
expect { render_inline(described_class.new) }.to raise_error(ArgumentError, 'missing keyword: :element') | ||
end | ||
|
||
context 'when the element provided is not a history element' do | ||
it_behaves_like 'raising an exception warning the user to provide an history element' | ||
end | ||
context 'with a HistoryElement::RequestAccepted' do | ||
let(:element) { create(:history_element_request_accepted, user: user) } | ||
|
||
it 'describes the element action' do | ||
expect(render_inline(described_class.new(element: element))).to have_text('accepted request') | ||
end | ||
|
||
it 'displays the right icon' do | ||
expect(render_inline(described_class.new(element: element))).to have_css('i.fa-check') | ||
end | ||
|
||
context 'when the element provided is a history element superseded' do | ||
it 'renders the element telling this request was superseded' | ||
it 'renders the element comment' | ||
it 'displays the element comment' do | ||
expect(render_inline(described_class.new(element: element))).to have_text(element.comment) | ||
end | ||
end | ||
|
||
context 'when the element provided is a history element accepted' do | ||
it 'renders the element action' | ||
it 'renders the element comment' | ||
context 'with a HistoryElement::RequestSuperseded' do | ||
let(:element) { create(:history_element_request_superseded, user: user) } | ||
|
||
it 'describes the element action' do | ||
expect(render_inline(described_class.new(element: element))).to have_text('superseded this request with') | ||
end | ||
|
||
it 'displays the right icon' do | ||
expect(render_inline(described_class.new(element: element))).to have_css('i.fa-code-commit') | ||
end | ||
|
||
it 'displays the element comment' do | ||
expect(render_inline(described_class.new(element: element))).to have_text(element.comment) | ||
end | ||
end | ||
|
||
context 'when the element provided is a history element about review added' do | ||
context 'and review is known' do | ||
it 'renders the element action' | ||
it 'renders the element comment' | ||
context 'with a HistoryElement::RequestReviewAdded' do | ||
context 'with review' do | ||
let(:element) { create(:history_element_request_review_added_with_review, user: user) } | ||
|
||
it 'describes the element action' do | ||
expect(render_inline(described_class.new(element: element))).to have_text('as a reviewer') | ||
end | ||
|
||
it 'displays the right icon' do | ||
expect(render_inline(described_class.new(element: element))).to have_css('i.fa-circle') | ||
end | ||
|
||
it 'displays the element comment' do | ||
expect(render_inline(described_class.new(element: element))).to have_text(element.comment) | ||
end | ||
end | ||
|
||
context 'and review is unknown' do | ||
it 'renders the element action' | ||
it 'renders the element comment' | ||
context 'without review' do | ||
let(:element) { create(:history_element_request_review_added_without_review, user: user, description_extension: nil) } | ||
|
||
it 'describes the element action' do | ||
expect(render_inline(described_class.new(element: element))).to have_text('added a reviewer') | ||
end | ||
|
||
it 'displays the right icon' do | ||
expect(render_inline(described_class.new(element: element))).to have_css('i.fa-circle') | ||
end | ||
|
||
it 'displays the element comment' do | ||
expect(render_inline(described_class.new(element: element))).to have_text(element.comment) | ||
end | ||
end | ||
end | ||
# rubocop:enable RSpec/RepeatedExampleGroupBody | ||
end |