From 6d3bc3e4d0bc2e03b418d49ab3a34cb34b9aa082 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Mon, 27 Jan 2020 12:54:50 -0500 Subject: [PATCH] FIX: If `fancy_title` was nil the job would fail This is because we were only selecting `fancy_title` from the DB and the method has a fallback. --- lib/pending_assigns_reminder.rb | 2 +- spec/lib/pending_assigns_reminder_spec.rb | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/pending_assigns_reminder.rb b/lib/pending_assigns_reminder.rb index cf2a7e3..370a9d1 100644 --- a/lib/pending_assigns_reminder.rb +++ b/lib/pending_assigns_reminder.rb @@ -35,7 +35,7 @@ class PendingAssignsReminder end def assigned_topics(user, order:) - Topic.joins(:_custom_fields).select(:slug, :id, :fancy_title, 'topic_custom_fields.created_at AS assigned_at') + Topic.joins(:_custom_fields).select(:slug, :id, :title, :fancy_title, 'topic_custom_fields.created_at AS assigned_at') .where('topic_custom_fields.name = ? AND topic_custom_fields.value = ?', TopicAssigner::ASSIGNED_TO_ID, user.id.to_s) .order("topic_custom_fields.created_at #{order}") .limit(3) diff --git a/spec/lib/pending_assigns_reminder_spec.rb b/spec/lib/pending_assigns_reminder_spec.rb index 6956830..0418101 100644 --- a/spec/lib/pending_assigns_reminder_spec.rb +++ b/spec/lib/pending_assigns_reminder_spec.rb @@ -33,6 +33,7 @@ RSpec.describe PendingAssignsReminder do @post1 = Fabricate(:post) @post2 = Fabricate(:post) + @post2.topic.update_column(:fancy_title, nil) @post3 = Fabricate(:post) TopicAssigner.new(@post1.topic, user).assign(user) TopicAssigner.new(@post2.topic, user).assign(user)