Kouhei Sutou
null+****@clear*****
Tue Dec 23 11:23:00 JST 2014
Kouhei Sutou 2014-12-23 11:23:00 +0900 (Tue, 23 Dec 2014) New Revision: 8e6ef582ee228dc81d11612198174908d68a6452 https://github.com/ranguba/activegroonga/commit/8e6ef582ee228dc81d11612198174908d68a6452 Message: Update updated_at on create Because ActiveRecords does. http://qiita.com/niku/items/508705c0dbc5357b126c Reported by niku. Thanks!!! Modified files: lib/active_groonga/persistence.rb test/test-base.rb Modified: lib/active_groonga/persistence.rb (+4 -2) =================================================================== --- lib/active_groonga/persistence.rb 2014-09-23 01:07:39 +0900 (c60912d) +++ lib/active_groonga/persistence.rb 2014-12-23 11:23:00 +0900 (378f270) @@ -1,4 +1,4 @@ -# Copyright (C) 2009-2010 Kouhei Sutou <kou �� clear-code.com> +# Copyright (C) 2009-2014 Kouhei Sutou <kou �� clear-code.com> # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -104,7 +104,9 @@ module ActiveGroonga else record = table.add(attributes) end - record["created_at"] = Time.now if record.have_column?("created_at") + current_time = Time.now + record["created_at"] = current_time if record.have_column?("created_at") + record["updated_at"] = current_time if record.have_column?("updated_at") reload_attributes(record) @id = record.id @key = record.key if record.support_key? Modified: test/test-base.rb (+2 -2) =================================================================== --- test/test-base.rb 2014-09-23 01:07:39 +0900 (0230c2e) +++ test/test-base.rb 2014-12-23 11:23:00 +0900 (e76f91c) @@ -1,4 +1,4 @@ -# Copyright (C) 2009-2010 Kouhei Sutou <kou �� clear-code.com> +# Copyright (C) 2009-2014 Kouhei Sutou <kou �� clear-code.com> # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -200,7 +200,7 @@ class TestBase < Test::Unit::TestCase google = Bookmark.create("uri" => "http://google.com/", "comment" => "a search engine") assert_not_equal(Time.at(0), google.created_at) - assert_equal(Time.at(0), google.updated_at) + assert_not_equal(Time.at(0), google.updated_at) end def test_reload -------------- next part -------------- HTML����������������������������... Descargar