Skip to content
Open
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
2 changes: 1 addition & 1 deletion modules/meeting/app/models/meeting_outcome.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class MeetingOutcome < ApplicationRecord
information: 0,
decision: 1,
work_package: 2
}.freeze, suffix: true, default: "information"
}.freeze, suffix: true, default: "information", validate: true

validates :meeting_agenda_item, presence: true
validates :notes, presence: { if: -> { information_kind? } }
Expand Down
2 changes: 2 additions & 0 deletions modules/meeting/config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ en:
position: "Position"
lock_version: "Lock version"
notes: "Notes"
meeting_outcome:
kind: "Kind"
meeting_section:
title: "Title"
position: "Position"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,32 @@
end
end

context "with an invalid kind value" do
# Regression test: an unrecognized enum value used to raise a raw
# ArgumentError (500) instead of a clean validation error, since the
# enum declaration had no validate: true.
let(:body) do
{
kind: "not_a_real_kind",
notes: { raw: "Outcome with invalid kind" },
_links: {
agendaItem: {
href: api_v3_paths.meeting_agenda_item(agenda_item.id)
}
}
}.to_json
end

it "returns 422 rather than raising" do
expect { response }.not_to raise_error
expect(response).to have_http_status(:unprocessable_entity)
end

it "does not create the outcome" do
expect { response }.not_to change(MeetingOutcome, :count)
end
end

context "when creating a work package outcome" do
let(:permissions) { %i[view_meetings manage_outcomes view_work_packages] }
let(:work_package) { create(:work_package, project:) }
Expand Down
Loading