test/n/tc_og.rb in nitro-0.3.0 vs test/n/tc_og.rb in nitro-0.4.1

- old
+ new

@@ -1,29 +1,29 @@ require "test/unit" -require "n/logger"; $log = Logger.new(STDERR) unless $log -require "n/og" +require "nitro/logger"; $log = Logger.new(STDERR) unless $log +require "og" module Test # :nodoc: all # bug: creates a table that fucksup postgres if not # correctly escaped. class User - prop_accessor String, :name + prop_accessor :name, String def initialize(name = nil) @name = name end end class Comment; end class Article - has_many Test::Comment, :comments - prop_accessor String, :title - prop_accessor String, :body - prop_accessor Hash, :options + prop_accessor :title, String + prop_accessor :body, String + prop_accessor :options, Hash + has_many :comments, Test::Comment def initialize(title = nil, body = nil) @title = title @body = body @options = {"hello" => "world"} @@ -41,14 +41,14 @@ puts "-- POST UPDATE CALLED FOR ARTICLE" end end class Comment - belongs_to Test::Article, :article - belongs_to Test::User, :author - prop_accessor String, :body - prop_accessor Time, :create_time + belongs_to :article, Test::Article + belongs_to :author, Test::User + prop_accessor :body, String + prop_accessor :create_time, Time def initialize(body = nil) @create_time = Time.now @body = body end @@ -85,12 +85,12 @@ :password => "navelrulez", :connection_count => 1 } end - N::Og.drop_db!(config) - $og = N::Og.new(config) + Og::Database.drop_db!(config) + $og = Og::Database.new(config) end def teardown $og.shutdown() end @@ -100,21 +100,19 @@ def test_all $DBG = true $og.get_connection() - $og.manage_classes(Article, Comment, User) - article = Article.new("Title", "Here comes the body") $og << article article.title = "Changed" article.save! $og.pupdate("body='Hello'", article) - article.pupdate! "body='Hello'" + article.update_properties "body='Hello'" another = Article[1] assert_equal(1, another.oid) # bug: yaml load problem. assert_equal("world", another.options["hello"]) @@ -131,12 +129,12 @@ # p Article[23] user = User.new("gmosx") user.save! - another = User["gmosx"] + user = User["gmosx"] - assert_equal("gmosx", another.name) + assert_equal("gmosx", user.name) users1 = $og.select("name='gmosx' ORDER BY oid", User) users = $og.select("SELECT * FROM #{User::DBTABLE} WHERE name='gmosx' ORDER BY oid", User)