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:
parent
ac30a798f0
commit
c500dbdaaf
|
@ -110,7 +110,7 @@ class PostActionType < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def additional_message_types
|
def additional_message_types
|
||||||
return flag_settings.with_additional_message if overridden_by_plugin_or_skipped_db?
|
return flag_settings.additional_message_types if overridden_by_plugin_or_skipped_db?
|
||||||
flag_enum(all_flags.select(&:require_message))
|
flag_enum(all_flags.select(&:require_message))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -28,4 +28,30 @@ RSpec.describe PostActionType do
|
||||||
end
|
end
|
||||||
end
|
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
|
end
|
||||||
|
|
Loading…
Reference in New Issue