fixes #3096
This commit is contained in:
@@ -165,7 +165,7 @@ class PostFlag < ActiveRecord::Base
|
|||||||
|
|
||||||
def initialize_creator
|
def initialize_creator
|
||||||
self.creator_id ||= CurrentUser.id
|
self.creator_id ||= CurrentUser.id
|
||||||
self.creator_ip_addr ||= CurrentUser.ip_addr
|
self.creator_ip_addr = CurrentUser.ip_addr if creator_ip_addr == "127.0.0.1" || creator_ip_addr.blank?
|
||||||
end
|
end
|
||||||
|
|
||||||
def resolve!
|
def resolve!
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ class PostFlagTest < ActiveSupport::TestCase
|
|||||||
@alice = FactoryGirl.create(:gold_user)
|
@alice = FactoryGirl.create(:gold_user)
|
||||||
end
|
end
|
||||||
CurrentUser.user = @alice
|
CurrentUser.user = @alice
|
||||||
CurrentUser.ip_addr = "127.0.0.1"
|
CurrentUser.ip_addr = "127.0.0.2"
|
||||||
@post = FactoryGirl.create(:post, :tag_string => "aaa")
|
@post = FactoryGirl.create(:post, :tag_string => "aaa")
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -91,6 +91,7 @@ class PostFlagTest < ActiveSupport::TestCase
|
|||||||
should "initialize its creator" do
|
should "initialize its creator" do
|
||||||
@post_flag = PostFlag.create(:post => @post, :reason => "aaa", :is_resolved => false)
|
@post_flag = PostFlag.create(:post => @post, :reason => "aaa", :is_resolved => false)
|
||||||
assert_equal(@alice.id, @post_flag.creator_id)
|
assert_equal(@alice.id, @post_flag.creator_id)
|
||||||
|
assert_equal(IPAddr.new("127.0.0.2"), @post_flag.creator_ip_addr)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user