diff --git a/app/models/card.rb b/app/models/card.rb index f0923af91..321a4f90e 100644 --- a/app/models/card.rb +++ b/app/models/card.rb @@ -1,5 +1,5 @@ class Card < ApplicationRecord - include Assignable, Colored, DraftCommenting, Engageable, Eventable, Golden, + include Assignable, Colored, Engageable, Eventable, Golden, Messages, Notifiable, Pinnable, Closeable, Scorable, Searchable, Staged, Statuses, Taggable, Watchable diff --git a/app/models/card/draft_commenting.rb b/app/models/card/draft_commenting.rb deleted file mode 100644 index 615d23916..000000000 --- a/app/models/card/draft_commenting.rb +++ /dev/null @@ -1,33 +0,0 @@ -module Card::DraftCommenting - extend ActiveSupport::Concern - - included do - after_save :capture_draft_comment - end - - def draft_comment - find_or_build_initial_comment.body.content - end - - def draft_comment=(body) - if body.present? - @draft_comment = body - else - messages.comments.destroy_all - end - end - - private - def find_or_build_initial_comment - message = messages.comments.first || messages.new(messageable: Comment.new) - message.comment - end - - def capture_draft_comment - if @draft_comment.present? - find_or_build_initial_comment.update! body: @draft_comment, creator: creator - end - - @draft_comment = nil - end -end diff --git a/test/controllers/cards_controller_test.rb b/test/controllers/cards_controller_test.rb index e794e7898..5651ebcb9 100644 --- a/test/controllers/cards_controller_test.rb +++ b/test/controllers/cards_controller_test.rb @@ -36,19 +36,17 @@ class CardsControllerTest < ActionDispatch::IntegrationTest patch collection_card_path(collections(:writebook), cards(:logo)), params: { card: { title: "Logo needs to change", - due_on: 1.week.from_now, image: fixture_file_upload("moon.jpg", "image/jpeg"), - draft_comment: "Something more in-depth", + description: "Something more in-depth", tag_ids: [ tags(:mobile).id ] } } assert_redirected_to collection_card_path(collections(:writebook), cards(:logo)) card = cards(:logo).reload assert_equal "Logo needs to change", card.title - assert_equal 1.week.from_now.to_date, card.due_on assert_equal "moon.jpg", card.image.filename.to_s assert_equal [ tags(:mobile) ], card.tags - assert_equal "Something more in-depth", card.messages.comments.first.comment.body_plain_text.strip + assert_equal "Something more in-depth", card.description_plain_text.strip end test "users can only see cards in collections they have access to" do diff --git a/test/models/card/messages_test.rb b/test/models/card/messages_test.rb index 08ade7f0f..31d730306 100644 --- a/test/models/card/messages_test.rb +++ b/test/models/card/messages_test.rb @@ -6,41 +6,4 @@ class Card::MessagesTest < ActiveSupport::TestCase assert_empty card.messages end - - test "creating a card with an initial draft comment" do - card = collections(:writebook).cards.create! creator: users(:kevin), title: "New", - draft_comment: "This is a comment" - - assert_equal 1, card.messages.count - assert_equal "This is a comment", card.draft_comment.strip - end - - test "updating the draft comment" do - card = collections(:writebook).cards.create! creator: users(:kevin), title: "New", - draft_comment: "This is a comment" - - card.update! draft_comment: "This is an updated comment" - - assert_equal 1, card.messages.count - assert_equal "This is an updated comment", card.draft_comment.strip - end - - test "setting the draft comment to be blank removes it" do - card = collections(:writebook).cards.create! creator: users(:kevin), title: "New", - draft_comment: "This is a comment" - - card.update! draft_comment: " " - - assert card.messages.first.nil? - end - - test "omitting the draft comment does not remove it" do - card = collections(:writebook).cards.create! creator: users(:kevin), title: "New", - draft_comment: "This is a comment" - - card.update! title: "Newer" - - assert_equal 1, card.messages.count - assert_equal "This is a comment", card.draft_comment.strip - end end