FIX: Return additional message types properly

Following a recent refactor, some methods from `FlagSettings` have been
renamed (`custom_types` -> `additional_message_types`). The
`PostActionType` model was using `custom_types` but when the renaming
was done, it was renamed to `with_additional_message` instead of
`additional_message_types`, which under the right circumstances will
raise an error.
This commit is contained in:
Loïc Guitaut
2024-08-06 14:34:37 +02:00
committed by Loïc Guitaut
parent 584106b752
commit 97cd03d41a
2 changed files with 27 additions and 1 deletions

View File

@ -28,4 +28,30 @@ RSpec.describe PostActionType do
end
end
end
describe ".additional_message_types" do
before { described_class.stubs(:overridden_by_plugin_or_skipped_db?).returns(overriden) }
context "when overridden by plugin or skipped DB" do
let(:overriden) { true }
it "returns additional types from flag settings" do
expect(described_class.additional_message_types).to eq(
described_class.flag_settings.additional_message_types,
)
end
end
context "when not overriden by plugin or skipped DB" do
let(:overriden) { false }
it "returns all flags" do
expect(described_class.additional_message_types).to eq(
illegal: 10,
notify_moderators: 7,
notify_user: 6,
)
end
end
end
end