Skip to content

Commit

Permalink
Add spec for NotificationNotifiableLinkComponent
Browse files Browse the repository at this point in the history
We only need to test that the link_for_reportables and the
link_for_commentables_on_reportables work as expected. The commentable
uses both so, that's it.
  • Loading branch information
danidoni committed Sep 22, 2023
1 parent a3bbb0b commit 7931785
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,18 @@
expect(rendered_content).to have_link('Comment on Package', href: "/package/show/projet_de_societe/oui?notification_id=#{notification.id}#comments-list")
end
end

context 'for a report notification with the event Event::CreateReport' do
let(:notification) { create(:notification, :create_report) }
let(:project) { notification.notifiable.reportable.commentable.project }
let(:package) { notification.notifiable.reportable.commentable }

before do
render_inline(described_class.new(notification))
end

it 'renders a link to the reported content' do
expect(rendered_content).to have_link('Report for a comment created', href: "/package/show/#{project.name}/#{package.name}?notification_id=#{notification.id}#comments-list")
end
end
end
2 changes: 1 addition & 1 deletion src/api/spec/factories/notification.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
end

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

0 comments on commit 7931785

Please sign in to comment.