From 9ffec2807666f381d431d1a83ae39305cbc64769 Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Wed, 15 Apr 2015 14:32:10 -0400 Subject: [PATCH] Allow posts in any queue to support topic/post attributes --- app/models/queued_post.rb | 26 +--------------------- spec/fabricators/queued_post_fabricator.rb | 2 +- spec/models/queued_post_spec.rb | 2 +- 3 files changed, 3 insertions(+), 27 deletions(-) diff --git a/app/models/queued_post.rb b/app/models/queued_post.rb index 8dce4ffeefa..9778c4f3e13 100644 --- a/app/models/queued_post.rb +++ b/app/models/queued_post.rb @@ -7,21 +7,6 @@ class QueuedPost < ActiveRecord::Base belongs_to :approved_by, class_name: "User" belongs_to :rejected_by, class_name: "User" - def self.attributes_by_queue - @attributes_by_queue ||= { - base: [:archetype, - :via_email, - :raw_email, - :auto_track, - :custom_fields, - :cooking_options, - :cook_method, - :image_sizes], - new_post: [:reply_to_post_number], - new_topic: [:title, :category, :meta_data, :archetype], - } - end - def self.states @states ||= Enum.new(:new, :approved, :rejected) end @@ -41,10 +26,9 @@ class QueuedPost < ActiveRecord::Base def create_options opts = {raw: raw} - post_attributes.each {|a| opts[a] = post_options[a.to_s] } + opts.merge!(post_options.symbolize_keys) opts[:cooking_options].symbolize_keys! if opts[:cooking_options] - opts[:topic_id] = topic_id if topic_id opts end @@ -60,16 +44,8 @@ class QueuedPost < ActiveRecord::Base created_post end - def self.all_attributes_for(queue) - [QueuedPost.attributes_by_queue[:base], QueuedPost.attributes_by_queue[queue.to_sym]].flatten.compact - end - private - def post_attributes - QueuedPost.all_attributes_for(queue) - end - def change_to!(state, changed_by) state_val = QueuedPost.states[state] diff --git a/spec/fabricators/queued_post_fabricator.rb b/spec/fabricators/queued_post_fabricator.rb index 45cae4006e1..e838ef0ada0 100644 --- a/spec/fabricators/queued_post_fabricator.rb +++ b/spec/fabricators/queued_post_fabricator.rb @@ -1,5 +1,5 @@ Fabricator(:queued_post) do - queue 'new_post' + queue 'test' state QueuedPost.states[:new] user topic diff --git a/spec/models/queued_post_spec.rb b/spec/models/queued_post_spec.rb index 976c3faf169..cd8d169d871 100644 --- a/spec/models/queued_post_spec.rb +++ b/spec/models/queued_post_spec.rb @@ -63,7 +63,7 @@ describe QueuedPost do context "with a valid topic" do let!(:category) { Fabricate(:category) } - let(:qp) { QueuedPost.create(queue: 'new_topic', + let(:qp) { QueuedPost.create(queue: 'eviltrout', state: QueuedPost.states[:new], user_id: user.id, raw: 'This post should be queued up',