This commit is contained in:
albert
2013-03-01 06:27:48 -08:00
parent 597e566ee4
commit 48953df07b
3 changed files with 21 additions and 8 deletions

View File

@@ -835,7 +835,10 @@ class Post < ActiveRecord::Base
options ||= {}
options[:except] ||= []
options[:except] += hidden_attributes
super(options)
hash = super(options)
hash["uploader_name"] = uploader_name
hash["has_large"] = has_large
hash
end
def to_xml(options = {}, &block)
@@ -847,13 +850,6 @@ class Post < ActiveRecord::Base
super(options, &block)
end
def serializable_hash(options = {})
hash = super(options)
hash["uploader_name"] = uploader_name
hash["has_large"] = has_large
hash
end
def to_legacy_json
return {
"has_comments" => last_commented_at.present?,

View File

@@ -6,6 +6,7 @@ class UserFeedback < ActiveRecord::Base
attr_accessible :body, :user_id, :category, :user_name
validates_presence_of :user, :creator, :body, :category
validate :creator_is_privileged
after_create :create_dmail
module SearchMethods
def positive
@@ -66,6 +67,11 @@ class UserFeedback < ActiveRecord::Base
self.user_id = User.name_to_id(name)
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
if !creator.is_privileged?
errors[:creator] << "must be privileged"

View File

@@ -12,6 +12,17 @@ class UserFeedbackTest < ActiveSupport::TestCase
CurrentUser.ip_addr = nil
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
user = FactoryGirl.create(:user)
privileged = FactoryGirl.create(:privileged_user)