Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions app/controllers/workshop_ideas_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ def create
authorize! @workshop_idea

if @workshop_idea.save
NotificationServices::CreateNotification.call(
noticeable: @workshop_idea,
kind: :idea_submitted,
recipient_role: :person,
recipient_email: @workshop_idea.created_by.email,
notification_type: 0)
NotificationServices::CreateNotification.call(
noticeable: @workshop_idea,
kind: :idea_submitted_fyi,
Expand Down
17 changes: 17 additions & 0 deletions spec/requests/workshop_ideas_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,23 @@
expect(response).to redirect_to(workshop_idea_path(WorkshopIdea.last))
end

it "sends admin and submitter notifications" do
expect(NotificationServices::CreateNotification).to receive(:call).with(
hash_including(
kind: :idea_submitted,
recipient_role: :person
)
)
expect(NotificationServices::CreateNotification).to receive(:call).with(
hash_including(
kind: :idea_submitted_fyi,
recipient_role: :admin
)
)

post workshop_ideas_path, params: { workshop_idea: valid_attributes }
end

it "handles RecordNotUnique gracefully" do
allow_any_instance_of(WorkshopIdea).to receive(:save).and_raise(
ActiveRecord::RecordNotUnique.new("Duplicate entry")
Expand Down