Merge pull request #2909 from evazion/fix-dmail-ip-addr
dmails: don't default IP addr to 127.0.0.1 in database (fixes #2908).
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
class RemoveDefaultIpAddrFromDmails < ActiveRecord::Migration
|
||||
def up
|
||||
change_column_default(:dmails, :creator_ip_addr, nil)
|
||||
end
|
||||
|
||||
def down
|
||||
change_column_default(:dmails, :creator_ip_addr, "127.0.0.1")
|
||||
end
|
||||
end
|
||||
@@ -1007,7 +1007,7 @@ CREATE TABLE dmails (
|
||||
is_deleted boolean DEFAULT false NOT NULL,
|
||||
created_at timestamp without time zone,
|
||||
updated_at timestamp without time zone,
|
||||
creator_ip_addr inet DEFAULT '127.0.0.1'::inet NOT NULL
|
||||
creator_ip_addr inet NOT NULL
|
||||
);
|
||||
|
||||
|
||||
@@ -7466,3 +7466,5 @@ INSERT INTO schema_migrations (version) VALUES ('20170117233040');
|
||||
|
||||
INSERT INTO schema_migrations (version) VALUES ('20170218104710');
|
||||
|
||||
INSERT INTO schema_migrations (version) VALUES ('20170302014435');
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ class DmailTest < ActiveSupport::TestCase
|
||||
MEMCACHE.flush_all
|
||||
@user = FactoryGirl.create(:user)
|
||||
CurrentUser.user = @user
|
||||
CurrentUser.ip_addr = "127.0.0.1"
|
||||
CurrentUser.ip_addr = "1.2.3.4"
|
||||
ActionMailer::Base.delivery_method = :test
|
||||
ActionMailer::Base.perform_deliveries = true
|
||||
ActionMailer::Base.deliveries = []
|
||||
@@ -112,6 +112,11 @@ class DmailTest < ActiveSupport::TestCase
|
||||
end
|
||||
end
|
||||
|
||||
should "record the creator's ip addr" do
|
||||
dmail = FactoryGirl.create(:dmail, owner: @user)
|
||||
assert_equal(CurrentUser.ip_addr, dmail.creator_ip_addr.to_s)
|
||||
end
|
||||
|
||||
should "send an email if the user wants it" do
|
||||
user = FactoryGirl.create(:user, :receive_email_notifications => true)
|
||||
assert_difference("ActionMailer::Base.deliveries.size", 1) do
|
||||
|
||||
Reference in New Issue
Block a user