From c2c99c7c392990320f4cf5e9c38d229a529bfeff Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Thu, 25 Oct 2018 15:36:24 -0400 Subject: [PATCH] FIX: Don't seed flags if ids don't exist This can happen if you use the `replace_flags` plugin API to remove a flag. --- db/fixtures/003_post_action_types.rb | 60 ++++++++++++++++------------ 1 file changed, 35 insertions(+), 25 deletions(-) diff --git a/db/fixtures/003_post_action_types.rb b/db/fixtures/003_post_action_types.rb index f0094764fae..0de70060017 100644 --- a/db/fixtures/003_post_action_types.rb +++ b/db/fixtures/003_post_action_types.rb @@ -13,37 +13,47 @@ PostActionType.seed do |s| s.position = 2 end -PostActionType.seed do |s| - s.id = PostActionType.types[:off_topic] - s.name_key = 'off_topic' - s.is_flag = true - s.position = 3 +if PostActionType.types[:off_topic] + PostActionType.seed do |s| + s.id = PostActionType.types[:off_topic] + s.name_key = 'off_topic' + s.is_flag = true + s.position = 3 + end end -PostActionType.seed do |s| - s.id = PostActionType.types[:inappropriate] - s.name_key = 'inappropriate' - s.is_flag = true - s.position = 4 +if PostActionType.types[:inappropriate] + PostActionType.seed do |s| + s.id = PostActionType.types[:inappropriate] + s.name_key = 'inappropriate' + s.is_flag = true + s.position = 4 + end end -PostActionType.seed do |s| - s.id = PostActionType.types[:spam] - s.name_key = 'spam' - s.is_flag = true - s.position = 6 +if PostActionType.types[:spam] + PostActionType.seed do |s| + s.id = PostActionType.types[:spam] + s.name_key = 'spam' + s.is_flag = true + s.position = 6 + end end -PostActionType.seed do |s| - s.id = PostActionType.types[:notify_user] - s.name_key = 'notify_user' - s.is_flag = true - s.position = 7 +if PostActionType.types[:notify_user] + PostActionType.seed do |s| + s.id = PostActionType.types[:notify_user] + s.name_key = 'notify_user' + s.is_flag = true + s.position = 7 + end end -PostActionType.seed do |s| - s.id = PostActionType.types[:notify_moderators] - s.name_key = 'notify_moderators' - s.is_flag = true - s.position = 8 +if PostActionType.types[:notify_moderators] + PostActionType.seed do |s| + s.id = PostActionType.types[:notify_moderators] + s.name_key = 'notify_moderators' + s.is_flag = true + s.position = 8 + end end