Sha256: 29fdf63d5abddd59531c3b0b577902064b093e2383724c65372aea8db7d31959

Contents?: true

Size: 1.58 KB

Versions: 31

Compression:

Stored size: 1.58 KB

Contents

# To run this script, run the following in a mysql instance:
#
#   drop database if exists weblog_development;
#   create database weblog_development;
#   grant all on weblog_development.* to blog@localhost;

require 'minirunit'

config = {
  :username => 'blog',
  :password => ''
}

if RUBY_PLATFORM =~ /java/
  RAILS_CONNECTION_ADAPTERS = ['abstract', 'jdbc']
  config.update({
    :adapter  => 'jdbc',
    :driver   => 'com.mysql.jdbc.Driver',
    :url      => 'jdbc:mysql://localhost:3306/weblog_development',
  })
else
  config.update({
    :adapter  => 'mysql',
    :database => 'weblog_development',
    :host     => 'localhost'
  })
end

require 'active_record'

ActiveRecord::Base.establish_connection(config)

class CreateEntries < ActiveRecord::Migration
  def self.up
    create_table "entries", :force => true do |t|
      t.column :title, :string, :limit => 100
      t.column :updated_on, :datetime
      t.column :content, :text
    end
  end

  def self.down
    drop_table "entries"
  end
end

CreateEntries.up

test_ok ActiveRecord::Base.connection.tables.include?('entries')

class Entry < ActiveRecord::Base
end

Entry.delete_all

test_equal 0, Entry.count

TITLE = "First post!"
CONTENT = "Hello from JRuby on Rails!"
NEW_TITLE = "First post updated title"

post = Entry.new
post.title = TITLE
post.content = CONTENT
post.save

test_equal 1, Entry.count

post = Entry.find(:first)
test_equal TITLE, post.title
test_equal CONTENT, post.content

post.title = NEW_TITLE
post.save

post = Entry.find(:first)
test_equal NEW_TITLE, post.title

post.destroy

test_equal 0, Entry.count

CreateEntries.down

Version data entries

31 entries across 31 versions & 5 rubygems

Version Path
saturnflyer-activerecord-jdbc-adapter-0.9.3 test/minirunit/testMysql.rb
kb-activerecord-jdbc-adapter-0.9.7.1-java test/minirunit/testMysql.rb
activerecord-jdbc-adapter-0.9.7-java test/minirunit/testMysql.rb
activerecord-jdbc-adapter-0.9.6-java test/minirunit/testMysql.rb
activerecord-jdbc-adapter-0.9.5-java test/minirunit/testMysql.rb
activerecord-jdbc-adapter-0.9.4-java test/minirunit/testMysql.rb
activerecord-jdbc-adapter-0.9.3-java test/minirunit/testMysql.rb
jpzwarte-activerecord-jdbc-adapter-0.9.2.6 test/minirunit/testMysql.rb
jpzwarte-activerecord-jdbc-adapter-0.9.2.5 test/minirunit/testMysql.rb
jpzwarte-activerecord-jdbc-adapter-0.9.2.4 test/minirunit/testMysql.rb
jpzwarte-activerecord-jdbc-adapter-0.9.2.3 test/minirunit/testMysql.rb
jpzwarte-activerecord-jdbc-adapter-0.9.2.2 test/minirunit/testMysql.rb
jpzwarte-activerecord-jdbc-adapter-0.9.2.1 test/minirunit/testMysql.rb
activerecord-jdbc-adapter-0.9.0.1 test/minirunit/testMysql.rb
activerecord-jdbc-adapter-0.9.2 test/minirunit/testMysql.rb
ActiveRecord-JDBC-0.2.3 test/minirunit/testMysql.rb
ActiveRecord-JDBC-0.2.2 test/minirunit/testMysql.rb
ActiveRecord-JDBC-0.2.4 test/minirunit/testMysql.rb
ActiveRecord-JDBC-0.4 test/minirunit/testMysql.rb
ActiveRecord-JDBC-0.3 test/minirunit/testMysql.rb