fixes #673
This commit is contained in:
@@ -835,7 +835,10 @@ class Post < ActiveRecord::Base
|
|||||||
options ||= {}
|
options ||= {}
|
||||||
options[:except] ||= []
|
options[:except] ||= []
|
||||||
options[:except] += hidden_attributes
|
options[:except] += hidden_attributes
|
||||||
super(options)
|
hash = super(options)
|
||||||
|
hash["uploader_name"] = uploader_name
|
||||||
|
hash["has_large"] = has_large
|
||||||
|
hash
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_xml(options = {}, &block)
|
def to_xml(options = {}, &block)
|
||||||
@@ -847,13 +850,6 @@ class Post < ActiveRecord::Base
|
|||||||
super(options, &block)
|
super(options, &block)
|
||||||
end
|
end
|
||||||
|
|
||||||
def serializable_hash(options = {})
|
|
||||||
hash = super(options)
|
|
||||||
hash["uploader_name"] = uploader_name
|
|
||||||
hash["has_large"] = has_large
|
|
||||||
hash
|
|
||||||
end
|
|
||||||
|
|
||||||
def to_legacy_json
|
def to_legacy_json
|
||||||
return {
|
return {
|
||||||
"has_comments" => last_commented_at.present?,
|
"has_comments" => last_commented_at.present?,
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ class UserFeedback < ActiveRecord::Base
|
|||||||
attr_accessible :body, :user_id, :category, :user_name
|
attr_accessible :body, :user_id, :category, :user_name
|
||||||
validates_presence_of :user, :creator, :body, :category
|
validates_presence_of :user, :creator, :body, :category
|
||||||
validate :creator_is_privileged
|
validate :creator_is_privileged
|
||||||
|
after_create :create_dmail
|
||||||
|
|
||||||
module SearchMethods
|
module SearchMethods
|
||||||
def positive
|
def positive
|
||||||
@@ -66,6 +67,11 @@ class UserFeedback < ActiveRecord::Base
|
|||||||
self.user_id = User.name_to_id(name)
|
self.user_id = User.name_to_id(name)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def create_dmail
|
||||||
|
body = %{#{creator_name} created a "#{category} record":/user_feedbacks?search[user_id]=#{user_id} for your account.}
|
||||||
|
Dmail.create_split(:to_id => user_id, :title => "Your user record has been updated", :body => body)
|
||||||
|
end
|
||||||
|
|
||||||
def creator_is_privileged
|
def creator_is_privileged
|
||||||
if !creator.is_privileged?
|
if !creator.is_privileged?
|
||||||
errors[:creator] << "must be privileged"
|
errors[:creator] << "must be privileged"
|
||||||
|
|||||||
@@ -12,6 +12,17 @@ class UserFeedbackTest < ActiveSupport::TestCase
|
|||||||
CurrentUser.ip_addr = nil
|
CurrentUser.ip_addr = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
should "create a dmail" do
|
||||||
|
user = FactoryGirl.create(:user)
|
||||||
|
privileged = FactoryGirl.create(:privileged_user)
|
||||||
|
member = FactoryGirl.create(:user)
|
||||||
|
|
||||||
|
CurrentUser.user = privileged
|
||||||
|
assert_difference("Dmail.count", 2) do
|
||||||
|
FactoryGirl.create(:user_feedback, :user => user)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
should "should not validate if the creator is not privileged" do
|
should "should not validate if the creator is not privileged" do
|
||||||
user = FactoryGirl.create(:user)
|
user = FactoryGirl.create(:user)
|
||||||
privileged = FactoryGirl.create(:privileged_user)
|
privileged = FactoryGirl.create(:privileged_user)
|
||||||
|
|||||||
Reference in New Issue
Block a user