From 192f16ba795d91cb59f246f0e4fa80c929a63098 Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 20 Aug 2015 10:38:22 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9memo=E7=B1=BB=20=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E6=96=B0=E7=9A=84=E7=94=A8=E6=88=B7=E7=95=99=E8=A8=80?= =?UTF-8?q?=E8=A1=A8=E7=BB=93=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 2 +- app/models/journals_for_message.rb | 3 ++- app/models/user_feedback_message.rb | 10 ++++++++++ spec/factories/user_feedback_messages.rb | 9 +++++++++ spec/models/user_feedback_message_spec.rb | 5 +++++ 5 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 app/models/user_feedback_message.rb create mode 100644 spec/factories/user_feedback_messages.rb create mode 100644 spec/models/user_feedback_message_spec.rb diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 5badac36e..74c3afaa7 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -147,7 +147,7 @@ class UsersController < ApplicationController @user_forge_messages = ForgeMessage.where("forge_message_type =? and user_id =?", "Forum", @user).order("created_at desc") @user_forge_messages_count = @user_forge_messages.count when 'forum' - @user_memo_messages = Memo.where("memo_type =? and user_id =?", "Memo", @user).order("created_at desc") + @user_memo_messages = MemoMessage.where("memo_type =? and user_id =?", "Memo", @user).order("created_at desc") @user_memo_messages_count = @user_memo_messages.count else render_404 diff --git a/app/models/journals_for_message.rb b/app/models/journals_for_message.rb index 818bdaa74..305e7742f 100644 --- a/app/models/journals_for_message.rb +++ b/app/models/journals_for_message.rb @@ -209,7 +209,8 @@ class JournalsForMessage < ActiveRecord::Base end else # 留言回复 # 添加留言回复人 - if self.user_id != self.parent.user_id # 如果回帖人不是用户自己 + # reply_to = User.find(self.reply_id) + if self.user_id != self.parent.user_id && self.user_id != self.reply_id # 如果回帖人不是用户自己 receivers << User.find(self.reply_id) end if self.user_id != self.parent.jour_id diff --git a/app/models/user_feedback_message.rb b/app/models/user_feedback_message.rb new file mode 100644 index 000000000..98b53e973 --- /dev/null +++ b/app/models/user_feedback_message.rb @@ -0,0 +1,10 @@ +class UserFeedbackMessage < ActiveRecord::Base + attr_accessible :journals_for_message_id, :journals_for_message_type, :user_id, :viewed + + belongs_to :journals_for_message + belongs_to :user + + validates :user_id,presence: true + validates :journals_for_message_id,presence: true + validates :journals_for_message_type, presence: true +end diff --git a/spec/factories/user_feedback_messages.rb b/spec/factories/user_feedback_messages.rb new file mode 100644 index 000000000..26a768dad --- /dev/null +++ b/spec/factories/user_feedback_messages.rb @@ -0,0 +1,9 @@ +FactoryGirl.define do + factory :user_feedback_message do + user_id 1 +journals_for_message_id 1 +journals_for_message_type "MyString" +viewed 1 + end + +end diff --git a/spec/models/user_feedback_message_spec.rb b/spec/models/user_feedback_message_spec.rb new file mode 100644 index 000000000..4ea61c36a --- /dev/null +++ b/spec/models/user_feedback_message_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe UserFeedbackMessage, :type => :model do + pending "add some examples to (or delete) #{__FILE__}" +end