mirror of
https://github.com/discourse/discourse.git
synced 2024-12-09 17:53:40 +08:00
4b1e017722
The mistake was made when flags were moved to the database. The `notify_moderators` (something else) flag should be the last position on the list. This commit contains 3 changes: - update fixtures order; - remove position and enable from fixtures (they can be overridden by admin and we don't want seed to restore them); - migration to fix data if the order was not changed by admin.
74 lines
2.2 KiB
Ruby
74 lines
2.2 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
RSpec.describe Flag, type: :model do
|
|
after(:each) { Flag.reset_flag_settings! }
|
|
|
|
it "has id lower than 1000 for system flags" do
|
|
flag = Fabricate(:flag, id: 1)
|
|
expect(flag.system?).to be true
|
|
flag.destroy!
|
|
end
|
|
|
|
it "has id greater than 1000 for non-system flags" do
|
|
flag = Fabricate(:flag)
|
|
expect(flag.system?).to be false
|
|
expect(flag.id).to be > 1000
|
|
flag.destroy!
|
|
end
|
|
|
|
it "has correct name key" do
|
|
flag = Fabricate(:flag, name: "CuStOm Flag!!!")
|
|
expect(flag.name_key).to eq("custom_flag")
|
|
|
|
flag.update!(name: "It's Illegal")
|
|
expect(flag.name_key).to eq("its_illegal")
|
|
|
|
flag.update!(name: "THIS IS SPaM!+)(*&^%$#@@@!)")
|
|
expect(flag.name_key).to eq("this_is_spam")
|
|
|
|
flag.destroy!
|
|
end
|
|
|
|
it "updates post action types when created, modified or destroyed" do
|
|
expect(PostActionType.flag_types.keys).to eq(
|
|
%i[notify_user off_topic inappropriate spam illegal notify_moderators],
|
|
)
|
|
expect(ReviewableScore.types.keys).to eq(
|
|
%i[notify_user off_topic inappropriate spam illegal notify_moderators needs_approval],
|
|
)
|
|
|
|
flag = Fabricate(:flag, name: "custom")
|
|
expect(PostActionType.flag_types.keys).to eq(
|
|
%i[notify_user off_topic inappropriate spam illegal notify_moderators custom],
|
|
)
|
|
expect(ReviewableScore.types.keys).to eq(
|
|
%i[notify_user off_topic inappropriate spam illegal notify_moderators custom needs_approval],
|
|
)
|
|
|
|
flag.update!(name: "edited_custom")
|
|
expect(PostActionType.flag_types.keys).to eq(
|
|
%i[notify_user off_topic inappropriate spam illegal notify_moderators edited_custom],
|
|
)
|
|
expect(ReviewableScore.types.keys).to eq(
|
|
%i[
|
|
notify_user
|
|
off_topic
|
|
inappropriate
|
|
spam
|
|
illegal
|
|
notify_moderators
|
|
edited_custom
|
|
needs_approval
|
|
],
|
|
)
|
|
|
|
flag.destroy!
|
|
expect(PostActionType.flag_types.keys).to eq(
|
|
%i[notify_user off_topic inappropriate spam illegal notify_moderators],
|
|
)
|
|
expect(ReviewableScore.types.keys).to eq(
|
|
%i[notify_user off_topic inappropriate spam illegal notify_moderators needs_approval],
|
|
)
|
|
end
|
|
end
|