mack-data_mapper 0.5.5 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. data/README +6 -0
  2. data/lib/database.rb +94 -0
  3. data/lib/dm_patches/confirmation_validation.rb +19 -0
  4. data/lib/dm_patches/dm-cli.rb +1 -0
  5. data/lib/dm_patches/migrations.rb +23 -0
  6. data/lib/dm_patches/pooling.rb +229 -0
  7. data/lib/genosaurus_helpers.rb +40 -0
  8. data/lib/helpers/orm_helpers.rb +50 -21
  9. data/lib/mack-data_mapper.rb +43 -16
  10. data/lib/migration_generator/migration_generator.rb +28 -17
  11. data/lib/migration_generator/templates/db/migrations/%=@migration_name%.rb.template +6 -6
  12. data/lib/model_column.rb +42 -0
  13. data/lib/model_generator/manifest.yml +9 -2
  14. data/lib/model_generator/model_generator.rb +25 -20
  15. data/lib/model_generator/templates/model.rb.template +4 -4
  16. data/lib/model_generator/templates/rspec.rb.template +7 -0
  17. data/lib/model_generator/templates/{test.rb.template → test_case.rb.template} +0 -0
  18. data/lib/resource.rb +17 -0
  19. data/lib/runner.rb +17 -0
  20. data/lib/scaffold_generator/manifest.yml +14 -3
  21. data/lib/scaffold_generator/scaffold_generator.rb +4 -4
  22. data/lib/scaffold_generator/templates/app/controllers/controller.rb.template +10 -9
  23. data/lib/scaffold_generator/templates/app/helpers/controllers/helper.rb.template +7 -0
  24. data/lib/scaffold_generator/templates/app/views/edit.html.erb.template +1 -1
  25. data/lib/scaffold_generator/templates/app/views/new.html.erb.template +1 -1
  26. data/lib/scaffold_generator/templates/test/functional/rspec.rb.template +47 -0
  27. data/lib/scaffold_generator/templates/{test.rb.template → test/functional/test_case.rb.template} +0 -0
  28. data/lib/tasks/db_create_drop_tasks.rake +43 -62
  29. data/lib/tasks/db_migration_tasks.rake +25 -62
  30. data/lib/tasks/test_tasks.rake +12 -0
  31. data/lib/test_extensions.rb +90 -0
  32. metadata +28 -52
  33. data/lib/configuration.rb +0 -22
  34. data/lib/persistence.rb +0 -9
  35. data/test/database.yml +0 -3
  36. data/test/fixtures/add_users_migration.rb.fixture +0 -9
  37. data/test/fixtures/album.rb.fixture +0 -4
  38. data/test/fixtures/album_unit_test.rb.fixture +0 -9
  39. data/test/fixtures/album_with_cols.rb.fixture +0 -7
  40. data/test/fixtures/create_users_migration.rb.fixture +0 -12
  41. data/test/fixtures/routes.rb.fixture +0 -3
  42. data/test/fixtures/zoo_no_cols/edit.html.erb.fixture +0 -11
  43. data/test/fixtures/zoo_no_cols/index.html.erb.fixture +0 -20
  44. data/test/fixtures/zoo_no_cols/new.html.erb.fixture +0 -11
  45. data/test/fixtures/zoo_no_cols/show.html.erb.fixture +0 -6
  46. data/test/fixtures/zoo_with_cols/edit.html.erb.fixture +0 -19
  47. data/test/fixtures/zoo_with_cols/index.html.erb.fixture +0 -26
  48. data/test/fixtures/zoo_with_cols/new.html.erb.fixture +0 -19
  49. data/test/fixtures/zoo_with_cols/show.html.erb.fixture +0 -22
  50. data/test/fixtures/zoo_with_cols/zoo.rb.fixture +0 -4
  51. data/test/fixtures/zoo_with_cols/zoos_controller.rb.fixture +0 -50
  52. data/test/generators/migration_generator_test.rb +0 -71
  53. data/test/generators/model_generator_test.rb +0 -37
  54. data/test/generators/scaffold_generator_test.rb +0 -61
  55. data/test/lib/user.rb +0 -6
  56. data/test/tasks/db_migration_tasks_test.rb +0 -57
  57. data/test/test_helper.rb +0 -77
@@ -1,6 +0,0 @@
1
- class User
2
- include DataMapper::Persistence
3
-
4
- property :username, :string
5
- property :email, :string
6
- end
@@ -1,57 +0,0 @@
1
- require File.dirname(__FILE__) + '/../test_helper.rb'
2
-
3
- class DbMigrationTasksTest < Test::Unit::TestCase
4
-
5
- $current_rake_task = File.join(File.dirname(__FILE__), "..", "..", "lib", "tasks", "db_migration_tasks.rake")
6
-
7
- def test_db_rollback
8
- test_db_migrate
9
- si = SchemaInfo.first
10
- assert_equal 2, si.version
11
- assert_equal 1, User.count
12
- rake_task("db:rollback")
13
- si = SchemaInfo.first
14
- assert_equal 1, si.version
15
- assert_equal 0, User.count
16
- end
17
-
18
- def test_db_rollback_two_steps
19
- test_db_migrate
20
- si = SchemaInfo.first
21
- assert_equal 2, si.version
22
- rake_task("db:rollback", "STEP" => "2")
23
- si = SchemaInfo.first
24
- assert_equal 0, si.version
25
- assert !User.table.exists?
26
- end
27
-
28
- def test_db_rollback_unrun_migrations
29
- test_db_migrate
30
- MigrationGenerator.run("name" => "create_comments")
31
- si = SchemaInfo.first
32
- assert_equal 2, si.version
33
- assert_raise(Mack::Errors::UnrunMigrations) { rake_task("db:rollback") }
34
- end
35
-
36
- def test_db_migrate
37
- assert !SchemaInfo.table.exists?
38
- rake_task("db:migrate") do
39
- assert SchemaInfo.table.exists?
40
- si = SchemaInfo.first
41
- assert_equal 0, si.version
42
- end
43
- FileUtils.cp(fixture_path("create_users_migration.rb"), File.join(migrations_directory, "001_create_users.rb"))
44
- assert !User.table.exists?
45
- rake_task("db:migrate")
46
- assert User.table.exists?
47
- si = SchemaInfo.first
48
- assert_equal 1, si.version
49
- FileUtils.cp(fixture_path("add_users_migration.rb"), File.join(migrations_directory, "002_add_users.rb"))
50
- assert_equal 0, User.count
51
- rake_task("db:migrate")
52
- assert_equal 1, User.count
53
- si = SchemaInfo.first
54
- assert_equal 2, si.version
55
- end
56
-
57
- end
@@ -1,77 +0,0 @@
1
- require "test/unit"
2
- require File.join(File.dirname(__FILE__), "..", "..", "test_helpers")
3
- require 'rubygems'
4
- require 'genosaurus'
5
- module Mack
6
- module Configuration
7
- def self.method_missing(sym, *args)
8
- ev = "_mack_#{sym}".downcase
9
- return ENV[ev]
10
- end
11
-
12
- def self.set(name, value)
13
- ENV["_mack_#{name.to_s.downcase}"] = value
14
- end
15
- end
16
- end
17
-
18
- $genosaurus_output_directory = File.join(File.dirname(__FILE__), "..", "tmp")
19
-
20
- ENV["_mack_config_directory"] = File.dirname(__FILE__)
21
- ENV["_mack_root"] = $genosaurus_output_directory
22
- ENV["_mack_app_directory"] = File.join($genosaurus_output_directory, "app")
23
- ENV["_mack_env"] = "test"
24
- ENV["_mack_views_directory"] = File.join(ENV["_mack_app_directory"], "views")
25
-
26
- require File.join(File.dirname(__FILE__), "..", "..", "mack-orm_common", "lib", "mack-orm_common")
27
- require File.join(File.dirname(__FILE__), "..", "lib", "mack-data_mapper")
28
-
29
- load File.join(File.dirname(__FILE__), "lib", "user.rb")
30
-
31
- class Test::Unit::TestCase
32
-
33
- # place common methods, assertions, and other type things in this file so
34
- # other tests will have access to them.
35
-
36
- def cleanup
37
- database.adapter.flush_connections!
38
- FileUtils.rm_rf($genosaurus_output_directory)
39
- FileUtils.rm_rf(File.join(Mack::Configuration.config_directory, "routes.rb"))
40
- end
41
-
42
- def teardown
43
- cleanup
44
- end
45
-
46
- def setup
47
- database.adapter.flush_connections!
48
- [$genosaurus_output_directory, migrations_directory, models_directory].each do |d|
49
- FileUtils.mkdir_p(d)
50
- end
51
- FileUtils.cp(fixture_path("routes.rb"), File.join(Mack::Configuration.config_directory, "routes.rb"))
52
- end
53
-
54
- def migrations_directory
55
- File.join($genosaurus_output_directory, "db", "migrations")
56
- end
57
-
58
- def models_directory
59
- File.join($genosaurus_output_directory, "app", "models")
60
- end
61
-
62
- def test_directory
63
- File.join($genosaurus_output_directory, "test")
64
- end
65
-
66
- def fixture_path(*name)
67
- path = [File.dirname(__FILE__), "fixtures"]
68
- path << name
69
- path.flatten!
70
- File.join(path) + ".fixture"
71
- end
72
-
73
- def fixture(*name)
74
- File.open(fixture_path(name)).read
75
- end
76
-
77
- end