Skip to content

Commit

Permalink
Add specs for NotificationActionDescriptionComponent
Browse files Browse the repository at this point in the history
Co-authored-by: Daniel Donisa <daniel.donisa@suse.com>
  • Loading branch information
krauselukas and danidoni committed Sep 22, 2023
1 parent 41103be commit a59cbdf
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -175,4 +175,19 @@
end
end
end

context 'when the notification is for an Event::CreateReport' do
context 'with the recipient being a user' do
let(:notification) do
create(:notification, :create_report, originator: 'user_1', reason: 'Because reasons.')
end

before { render_inline(described_class.new(notification)) }

it 'renders a div containing who created a report and for what' do
expect(rendered_content).to have_selector('div.smart-overflow',
text: "User '#{notification.notifiable.user.login}' created a report for a Comment for the following reason:Because reasons.")
end
end
end
end
14 changes: 14 additions & 0 deletions src/api/spec/factories/notification.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,20 @@
event_type { 'Event::BuildFail' }
notifiable factory: [:package]
end

trait :create_report do
event_type { 'Event::CreateReport' }
notifiable factory: [:report]

transient do
reason { nil }
end

after(:build) do |notification, evaluator|
notification.event_payload['reportable_type'] ||= notification.notifiable.reportable.class.to_s.downcase
notification.event_payload['reason'] ||= evaluator.reason
end
end
end

factory :rss_notification, parent: :notification do
Expand Down

0 comments on commit a59cbdf

Please sign in to comment.