From 214f56c114d026a9937d618604d540e8db0571b7 Mon Sep 17 00:00:00 2001 From: James Williams Date: Thu, 18 Jun 2015 09:15:30 -0600 Subject: [PATCH] change external feed entry titles to text closes #CNVS-17774 Change-Id: I558625ca4827c3dd572a40596b14459d2ae3310c Reviewed-on: https://gerrit.instructure.com/56760 Tested-by: Jenkins Reviewed-by: Dan Minkevitch Product-Review: James Williams QA-Review: James Williams --- app/models/external_feed_entry.rb | 15 ++++++++------- ...38_change_external_feed_entry_title_to_text.rb | 11 +++++++++++ 2 files changed, 19 insertions(+), 7 deletions(-) create mode 100644 db/migrate/20150618143738_change_external_feed_entry_title_to_text.rb diff --git a/app/models/external_feed_entry.rb b/app/models/external_feed_entry.rb index 8fc60f87f8d..a6cc2c337b5 100644 --- a/app/models/external_feed_entry.rb +++ b/app/models/external_feed_entry.rb @@ -18,7 +18,7 @@ class ExternalFeedEntry < ActiveRecord::Base include Workflow - + belongs_to :user belongs_to :external_feed belongs_to :asset, :polymorphic => true @@ -26,34 +26,35 @@ class ExternalFeedEntry < ActiveRecord::Base before_save :infer_defaults validates_presence_of :external_feed_id, :workflow_state + validates_length_of :title, :maximum => maximum_text_length, :allow_nil => true, :allow_blank => true validates_length_of :message, :maximum => maximum_text_length, :allow_nil => true, :allow_blank => true sanitize_field :message, CanvasSanitize::SANITIZE attr_accessible :title, :message, :source_name, :source_url, :posted_at, :start_at, :end_at, :user, :url, :uuid, :author_name, :author_url, :author_email, :asset - + def infer_defaults self.uuid ||= Digest::MD5.hexdigest("#{title || rand.to_s}#{posted_at.strftime('%Y-%m-%d') rescue 'no-time'}") end protected :infer_defaults - + def update_feed_attributes(opts) self.update_attributes(opts) @feed_entry_updated = self.changed? end - + def entry_changed? @feed_entry_updated end - + workflow do state :active do event :delete_it, :transitions_to => :deleted event :cancel_it, :transitions_to => :cancelled end - + state :deleted state :cancelled end - + def self.serialization_excludes; [:uuid]; end end diff --git a/db/migrate/20150618143738_change_external_feed_entry_title_to_text.rb b/db/migrate/20150618143738_change_external_feed_entry_title_to_text.rb new file mode 100644 index 00000000000..a24ebe31486 --- /dev/null +++ b/db/migrate/20150618143738_change_external_feed_entry_title_to_text.rb @@ -0,0 +1,11 @@ +class ChangeExternalFeedEntryTitleToText < ActiveRecord::Migration + tag :predeploy + + def self.up + change_column :external_feed_entries, :title, :text + end + + def self.down + change_column :external_feed_entries, :title, :string + end +end