Skip to content

Commit 05fed13

Browse files
authored
Merge pull request #18161 from eduardoj/tests/bs_request_action_description_component
Add missing previews for request action description component
2 parents 8c62e9f + 1635a55 commit 05fed13

File tree

2 files changed

+120
-14
lines changed

2 files changed

+120
-14
lines changed
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
RSpec.describe BsRequestActionDescriptionComponent, type: :component do
2+
context 'add_role' do
3+
before do
4+
create(:add_maintainer_request)
5+
end
6+
7+
it 'renders the "add_role" preview' do
8+
render_preview('add_role')
9+
10+
expect(rendered_content).to have_text('get the role')
11+
end
12+
end
13+
14+
context 'change_devel' do
15+
before do
16+
create(:bs_request_with_change_devel_action)
17+
end
18+
19+
it 'renders the "change_devel" previews' do
20+
%i[change_devel change_devel_text_only].each do |preview_name|
21+
render_preview(preview_name)
22+
23+
expect(rendered_content).to have_text('be devel project/package of')
24+
end
25+
end
26+
end
27+
28+
context 'delete' do
29+
before do
30+
create(:bs_request_action_delete, target_project: create(:project), bs_request: create(:delete_bs_request))
31+
end
32+
33+
it 'renders the "delete" previews' do
34+
%i[delete delete_text_only].each do |preview_name|
35+
render_preview(preview_name)
36+
37+
expect(rendered_content).to have_text('Delete')
38+
end
39+
end
40+
end
41+
42+
context 'maintenance_incident' do
43+
before do
44+
create(:bs_request_with_maintenance_incident_actions)
45+
end
46+
47+
it 'renders the "maintenance_incident" preview' do
48+
render_preview('maintenance_incident_text_only')
49+
50+
expect(rendered_content).to have_text('Submit update from')
51+
end
52+
end
53+
54+
context 'maintenance_release' do
55+
before do
56+
create(:bs_request_with_maintenance_release_actions)
57+
end
58+
59+
it 'renders the "maintenance_release" preview' do
60+
render_preview('maintenance_release_text_only')
61+
62+
expect(rendered_content).to have_text('Maintenance release')
63+
end
64+
end
65+
66+
context 'set_bugowner' do
67+
before do
68+
create(:set_bugowner_request)
69+
end
70+
71+
it 'renders the "set_bugowner" preview' do
72+
render_preview('set_bugowner_text_only')
73+
74+
expect(rendered_content).to have_text('become bugowner')
75+
end
76+
end
77+
78+
context 'submit' do
79+
before do
80+
create(:bs_request_with_submit_action)
81+
end
82+
83+
it 'renders the "submit" previews' do
84+
%i[submit submit_text_only].each do |preview_name|
85+
render_preview(preview_name)
86+
87+
expect(rendered_content).to have_text('Submit')
88+
end
89+
end
90+
end
91+
end
Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,52 @@
11
class BsRequestActionDescriptionComponentPreview < ViewComponent::Preview
2-
# Preview at http://HOST:PORT/rails/view_components/bs_request_action_description_component/submit_preview
3-
def submit_preview
4-
action = BsRequestAction.where(type: :submit).last
2+
# Previews at http://HOST:PORT/rails/view_components/bs_request_action_description_component/
3+
def add_role
4+
action = BsRequestAction.where(type: :add_role).last
55
render(BsRequestActionDescriptionComponent.new(action: action))
66
end
77

8-
def submit_preview_text_only
9-
action = BsRequestAction.where(type: :submit).last
8+
def change_devel
9+
action = BsRequestAction.where(type: :change_devel).last
10+
render(BsRequestActionDescriptionComponent.new(action: action))
11+
end
12+
13+
def change_devel_text_only
14+
action = BsRequestAction.where(type: :change_devel).last
1015
render(BsRequestActionDescriptionComponent.new(action: action, text_only: true))
1116
end
1217

13-
def delete_preview
18+
def delete
1419
action = BsRequestAction.where(type: :delete).last
1520
render(BsRequestActionDescriptionComponent.new(action: action))
1621
end
1722

18-
def delete_preview_text_only
23+
def delete_text_only
1924
action = BsRequestAction.where(type: :delete).last
2025
render(BsRequestActionDescriptionComponent.new(action: action, text_only: true))
2126
end
2227

23-
def add_role_preview
24-
action = BsRequestAction.where(type: :add_role).first
25-
render(BsRequestActionDescriptionComponent.new(action: action))
28+
def maintenance_incident_text_only
29+
action = BsRequestAction.where(type: :maintenance_incident).last
30+
render(BsRequestActionDescriptionComponent.new(action: action, text_only: true))
2631
end
2732

28-
def change_devel_preview
29-
action = BsRequestAction.where(type: :change_devel).first
33+
def maintenance_release_text_only
34+
action = BsRequestAction.where(type: :maintenance_release).last
35+
render(BsRequestActionDescriptionComponent.new(action: action, text_only: true))
36+
end
37+
38+
def set_bugowner_text_only
39+
action = BsRequestAction.where(type: :set_bugowner).last
40+
render(BsRequestActionDescriptionComponent.new(action: action, text_only: true))
41+
end
42+
43+
def submit
44+
action = BsRequestAction.where(type: :submit).last
3045
render(BsRequestActionDescriptionComponent.new(action: action))
3146
end
3247

33-
def change_devel_preview_text_only
34-
action = BsRequestAction.where(type: :change_devel).first
48+
def submit_text_only
49+
action = BsRequestAction.where(type: :submit).last
3550
render(BsRequestActionDescriptionComponent.new(action: action, text_only: true))
3651
end
3752
end

0 commit comments

Comments
 (0)