mack-data_mapper 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README +3 -0
- data/lib/helpers/orm_helpers.rb +47 -0
- data/lib/mack-data_mapper.rb +45 -0
- data/lib/mack-data_mapper_tasks.rb +3 -0
- data/lib/migration_generator/migration_generator.rb +41 -0
- data/lib/migration_generator/templates/db/migrations/%=@migration_name%.rb.template +31 -0
- data/lib/model_generator/manifest.yml +11 -0
- data/lib/model_generator/model_generator.rb +54 -0
- data/lib/model_generator/templates/model.rb.template +11 -0
- data/lib/model_generator/templates/test.rb.template +9 -0
- data/lib/scaffold_generator/manifest.yml +24 -0
- data/lib/scaffold_generator/scaffold_generator.rb +41 -0
- data/lib/scaffold_generator/templates/app/controllers/controller.rb.template +50 -0
- data/lib/scaffold_generator/templates/app/views/edit.html.erb.template +19 -0
- data/lib/scaffold_generator/templates/app/views/index.html.erb.template +41 -0
- data/lib/scaffold_generator/templates/app/views/new.html.erb.template +19 -0
- data/lib/scaffold_generator/templates/app/views/show.html.erb.template +12 -0
- data/lib/scaffold_generator/templates/test.rb.template +9 -0
- data/lib/tasks/db_create_drop_tasks.rake +76 -0
- data/lib/tasks/db_migration_tasks.rake +83 -0
- data/test/database.yml +3 -0
- data/test/fixtures/add_users_migration.rb.fixture +9 -0
- data/test/fixtures/album.rb.fixture +4 -0
- data/test/fixtures/album_unit_test.rb.fixture +9 -0
- data/test/fixtures/album_with_cols.rb.fixture +7 -0
- data/test/fixtures/create_users_migration.rb.fixture +12 -0
- data/test/fixtures/routes.rb.fixture +3 -0
- data/test/fixtures/zoo_no_cols/edit.html.erb.fixture +11 -0
- data/test/fixtures/zoo_no_cols/index.html.erb.fixture +20 -0
- data/test/fixtures/zoo_no_cols/new.html.erb.fixture +11 -0
- data/test/fixtures/zoo_no_cols/show.html.erb.fixture +6 -0
- data/test/fixtures/zoo_with_cols/edit.html.erb.fixture +19 -0
- data/test/fixtures/zoo_with_cols/index.html.erb.fixture +26 -0
- data/test/fixtures/zoo_with_cols/new.html.erb.fixture +19 -0
- data/test/fixtures/zoo_with_cols/show.html.erb.fixture +22 -0
- data/test/fixtures/zoo_with_cols/zoo.rb.fixture +4 -0
- data/test/fixtures/zoo_with_cols/zoos_controller.rb.fixture +50 -0
- data/test/generators/migration_generator_test.rb +71 -0
- data/test/generators/model_generator_test.rb +37 -0
- data/test/generators/scaffold_generator_test.rb +61 -0
- data/test/lib/user.rb +6 -0
- data/test/tasks/db_migration_tasks_test.rb +57 -0
- data/test/test_helper.rb +76 -0
- metadata +117 -0
@@ -0,0 +1,11 @@
|
|
1
|
+
<h1>Edit Zoo</h1>
|
2
|
+
|
3
|
+
<%= error_messages_for :zoo %>
|
4
|
+
|
5
|
+
<% form(zoos_update_url(:id => @zoo.id), :class => "edit_zoo", :id => "edit_zoo", :method => :put) do %>
|
6
|
+
<p>
|
7
|
+
<input id="zoo_submit" name="commit" type="submit" value="Update" />
|
8
|
+
</p>
|
9
|
+
<% end %>
|
10
|
+
|
11
|
+
<%= link_to("Back", zoos_index_url) %>
|
@@ -0,0 +1,20 @@
|
|
1
|
+
<h1>Listing Zoos</h1>
|
2
|
+
|
3
|
+
<table>
|
4
|
+
<tr>
|
5
|
+
<th> </th>
|
6
|
+
</tr>
|
7
|
+
|
8
|
+
<% for zoo in @zoos %>
|
9
|
+
<tr>
|
10
|
+
<td> </td>
|
11
|
+
<td><%= link_to("Show", zoos_show_url(:id => zoo.id)) %></td>
|
12
|
+
<td><%= link_to("Edit", zoos_edit_url(:id => zoo.id)) %></td>
|
13
|
+
<td><%= link_to("Delete", zoos_delete_url(:id => zoo.id), :method => :delete, :confirm => "Are you sure?") %></td>
|
14
|
+
</tr>
|
15
|
+
<% end %>
|
16
|
+
</table>
|
17
|
+
|
18
|
+
<br />
|
19
|
+
|
20
|
+
<%= link_to("New Zoo", zoos_new_url) %>
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<h1>New Zoo</h1>
|
2
|
+
|
3
|
+
<%= error_messages_for :zoo %>
|
4
|
+
|
5
|
+
<% form(zoos_create_url, :class => "new_zoo", :id => "new_zoo") do %>
|
6
|
+
<p>
|
7
|
+
<input id="zoo_submit" name="commit" type="submit" value="Create" />
|
8
|
+
</p>
|
9
|
+
<% end %>
|
10
|
+
|
11
|
+
<%= link_to("Back", zoos_index_url) %>
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<h1>Edit Zoo</h1>
|
2
|
+
|
3
|
+
<%= error_messages_for :zoo %>
|
4
|
+
|
5
|
+
<% form(zoos_update_url(:id => @zoo.id), :class => "edit_zoo", :id => "edit_zoo", :method => :put) do %>
|
6
|
+
<p>
|
7
|
+
<b>Name</b><br />
|
8
|
+
<input type="text" name="zoo[name]" id="zoo_name" size="30" value="<%= @zoo.name %>" />
|
9
|
+
</p>
|
10
|
+
<p>
|
11
|
+
<b>Description</b><br />
|
12
|
+
<textarea name="zoo[description]" id="zoo_description" cols="60" rows="20"><%= @zoo.description %></textarea>
|
13
|
+
</p>
|
14
|
+
<p>
|
15
|
+
<input id="zoo_submit" name="commit" type="submit" value="Update" />
|
16
|
+
</p>
|
17
|
+
<% end %>
|
18
|
+
|
19
|
+
<%= link_to("Back", zoos_index_url) %>
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<h1>Listing Zoos</h1>
|
2
|
+
|
3
|
+
<table>
|
4
|
+
<tr>
|
5
|
+
<th>Name</th>
|
6
|
+
<th>Description</th>
|
7
|
+
<th>CreatedAt</th>
|
8
|
+
<th>UpdatedAt</th>
|
9
|
+
</tr>
|
10
|
+
|
11
|
+
<% for zoo in @zoos %>
|
12
|
+
<tr>
|
13
|
+
<td><%= zoo.name %></td>
|
14
|
+
<td><%= zoo.description %></td>
|
15
|
+
<td><%= zoo.created_at %></td>
|
16
|
+
<td><%= zoo.updated_at %></td>
|
17
|
+
<td><%= link_to("Show", zoos_show_url(:id => zoo.id)) %></td>
|
18
|
+
<td><%= link_to("Edit", zoos_edit_url(:id => zoo.id)) %></td>
|
19
|
+
<td><%= link_to("Delete", zoos_delete_url(:id => zoo.id), :method => :delete, :confirm => "Are you sure?") %></td>
|
20
|
+
</tr>
|
21
|
+
<% end %>
|
22
|
+
</table>
|
23
|
+
|
24
|
+
<br />
|
25
|
+
|
26
|
+
<%= link_to("New Zoo", zoos_new_url) %>
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<h1>New Zoo</h1>
|
2
|
+
|
3
|
+
<%= error_messages_for :zoo %>
|
4
|
+
|
5
|
+
<% form(zoos_create_url, :class => "new_zoo", :id => "new_zoo") do %>
|
6
|
+
<p>
|
7
|
+
<b>Name</b><br />
|
8
|
+
<input type="text" name="zoo[name]" id="zoo_name" size="30" value="<%= @zoo.name %>" />
|
9
|
+
</p>
|
10
|
+
<p>
|
11
|
+
<b>Description</b><br />
|
12
|
+
<textarea name="zoo[description]" id="zoo_description" cols="60" rows="20"><%= @zoo.description %></textarea>
|
13
|
+
</p>
|
14
|
+
<p>
|
15
|
+
<input id="zoo_submit" name="commit" type="submit" value="Create" />
|
16
|
+
</p>
|
17
|
+
<% end %>
|
18
|
+
|
19
|
+
<%= link_to("Back", zoos_index_url) %>
|
@@ -0,0 +1,22 @@
|
|
1
|
+
<p>
|
2
|
+
<h1>Zoo</h1>
|
3
|
+
</p>
|
4
|
+
<p>
|
5
|
+
<b>Name</b><br />
|
6
|
+
<%= @zoo.name %>
|
7
|
+
</p>
|
8
|
+
<p>
|
9
|
+
<b>Description</b><br />
|
10
|
+
<%= @zoo.description %>
|
11
|
+
</p>
|
12
|
+
<p>
|
13
|
+
<b>CreatedAt</b><br />
|
14
|
+
<%= @zoo.created_at %>
|
15
|
+
</p>
|
16
|
+
<p>
|
17
|
+
<b>UpdatedAt</b><br />
|
18
|
+
<%= @zoo.updated_at %>
|
19
|
+
</p>
|
20
|
+
|
21
|
+
<%= link_to("Edit", zoos_edit_url(:id => @zoo.id)) %> |
|
22
|
+
<%= link_to("Back", zoos_index_url) %>
|
@@ -0,0 +1,50 @@
|
|
1
|
+
class ZoosController < Mack::Controller::Base
|
2
|
+
|
3
|
+
# GET /zoos
|
4
|
+
def index
|
5
|
+
@zoos = Zoo.find(:all)
|
6
|
+
end
|
7
|
+
|
8
|
+
# GET /zoos/1
|
9
|
+
def show
|
10
|
+
@zoo = Zoo.find(params(:id))
|
11
|
+
end
|
12
|
+
|
13
|
+
# GET /zoos/new
|
14
|
+
def new
|
15
|
+
@zoo = Zoo.new
|
16
|
+
end
|
17
|
+
|
18
|
+
# GET /zoos/1/edit
|
19
|
+
def edit
|
20
|
+
@zoo = Zoo.find(params(:id))
|
21
|
+
end
|
22
|
+
|
23
|
+
# POST /zoos
|
24
|
+
def create
|
25
|
+
@zoo = Zoo.new(params(:zoo))
|
26
|
+
if @zoo.save
|
27
|
+
redirect_to(zoos_show_url(:id => @zoo.id))
|
28
|
+
else
|
29
|
+
render(:action => "new")
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
# PUT /zoos/1
|
34
|
+
def update
|
35
|
+
@zoo = Zoo.find(params(:id))
|
36
|
+
if @zoo.update_attributes(params(:zoo))
|
37
|
+
redirect_to(zoos_show_url(:id => @zoo.id))
|
38
|
+
else
|
39
|
+
render(:action => "edit")
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
# DELETE /zoos/1
|
44
|
+
def delete
|
45
|
+
@zoo = Zoo.find(params(:id))
|
46
|
+
@zoo.destroy!
|
47
|
+
redirect_to(zoos_index_url)
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper.rb'
|
2
|
+
|
3
|
+
class MigrationGeneratorTest < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def test_next_migration_number
|
6
|
+
mg = MigrationGenerator.new("NAME" => "foo")
|
7
|
+
assert_equal "001", mg.next_migration_number
|
8
|
+
FileUtils.mkdir_p(migrations_directory)
|
9
|
+
assert File.exists?(migrations_directory)
|
10
|
+
File.open(File.join(migrations_directory, "001_foo.rb"), "w") {|f| f.puts ""}
|
11
|
+
assert_equal "002", mg.next_migration_number
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_generate_data_mapper
|
15
|
+
generate_common
|
16
|
+
mig = <<-MIG
|
17
|
+
class FooBar < DataMapper::Migration
|
18
|
+
|
19
|
+
def self.up
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.down
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
MIG
|
27
|
+
assert_equal mig, @file_body
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_generate_data_mapper_with_columns
|
31
|
+
generate_common({"NAME" => "create_users", "cols" => "username:string,email_address:string,created_at:datetime,updated_at:datetime"})
|
32
|
+
mig = <<-MIG
|
33
|
+
class CreateUsers < DataMapper::Migration
|
34
|
+
|
35
|
+
def self.up
|
36
|
+
create_table :users do |t|
|
37
|
+
t.column :username, :string
|
38
|
+
t.column :email_address, :string
|
39
|
+
t.column :created_at, :datetime
|
40
|
+
t.column :updated_at, :datetime
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.down
|
45
|
+
drop_table :users
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
MIG
|
50
|
+
assert_equal mig, @file_body
|
51
|
+
end
|
52
|
+
|
53
|
+
def generate_common(opts = {})
|
54
|
+
5.times do |i|
|
55
|
+
options = {"NAME" => "foo_bar"}.merge(opts)
|
56
|
+
mg = MigrationGenerator.run(options)
|
57
|
+
assert File.exists?(migrations_directory)
|
58
|
+
assert File.exists?(File.join(migrations_directory, "00#{i+1}_#{options["NAME"]}.rb"))
|
59
|
+
File.open(File.join(migrations_directory, "00#{i+1}_#{options["NAME"]}.rb"), "r") do |file|
|
60
|
+
@file_body = file.read
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def test_required_params
|
66
|
+
assert_raise(ArgumentError) { MigrationGenerator.new }
|
67
|
+
mg = MigrationGenerator.new("NAME" => "foo")
|
68
|
+
assert_not_nil mg
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper.rb'
|
2
|
+
|
3
|
+
class ModelGeneratorTest < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def test_generate_data_mapper
|
6
|
+
ModelGenerator.new("name" => "album").generate
|
7
|
+
assert File.exists?(model_loc)
|
8
|
+
assert_equal fixture("album.rb"), File.open(model_loc).read
|
9
|
+
assert File.exists?(migration_loc)
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_generate_data_mapper_with_columns
|
13
|
+
ModelGenerator.new("name" => "albums", "cols" => "title:string,artist_id:integer,description:text").generate
|
14
|
+
assert File.exists?(model_loc)
|
15
|
+
assert_equal fixture("album_with_cols.rb"), File.open(model_loc).read
|
16
|
+
assert File.exists?(migration_loc)
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_unit_test_created
|
20
|
+
ModelGenerator.new("name" => "album").generate
|
21
|
+
assert File.exists?(unit_test_loc)
|
22
|
+
assert_equal fixture("album_unit_test.rb"), File.open(unit_test_loc).read
|
23
|
+
end
|
24
|
+
|
25
|
+
def unit_test_loc
|
26
|
+
File.join(test_directory, "unit", "album_test.rb")
|
27
|
+
end
|
28
|
+
|
29
|
+
def model_loc
|
30
|
+
File.join(models_directory, "album.rb")
|
31
|
+
end
|
32
|
+
|
33
|
+
def migration_loc
|
34
|
+
File.join(migrations_directory, "001_create_albums.rb")
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper.rb'
|
2
|
+
|
3
|
+
class ScaffoldGeneratorTest < Test::Unit::TestCase
|
4
|
+
|
5
|
+
def test_generate_data_mapper
|
6
|
+
sg = ScaffoldGenerator.run("name" => "zoo")
|
7
|
+
File.open(File.join(Mack::Configuration.config_directory, "routes.rb")) do |f|
|
8
|
+
assert_match "r.resource :zoos # Added by rake generate:scaffold name=zoo", f.read
|
9
|
+
end
|
10
|
+
|
11
|
+
assert File.exists?(views_directory)
|
12
|
+
assert_equal fixture("zoo_no_cols", "edit.html.erb"), File.open(File.join(views_directory, "edit.html.erb")).read
|
13
|
+
assert_equal fixture("zoo_no_cols", "index.html.erb"), File.open(File.join(views_directory, "index.html.erb")).read
|
14
|
+
assert_equal fixture("zoo_no_cols", "new.html.erb"), File.open(File.join(views_directory, "new.html.erb")).read
|
15
|
+
assert_equal fixture("zoo_no_cols", "show.html.erb"), File.open(File.join(views_directory, "show.html.erb")).read
|
16
|
+
|
17
|
+
assert File.exists?(model_file)
|
18
|
+
assert File.exists?(controller_file)
|
19
|
+
assert File.exists?(migration_file)
|
20
|
+
assert File.exists?(functional_test_file)
|
21
|
+
assert_equal fixture("zoo_with_cols", "zoos_controller.rb"), File.open(controller_file).read
|
22
|
+
assert_equal fixture("zoo_with_cols", "zoo.rb"), File.open(model_file).read
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_generate_data_mapper_with_columns
|
26
|
+
sg = ScaffoldGenerator.run("name" => "zoo", "cols" => "name:string,description:text,created_at:datetime,updated_at:datetime")
|
27
|
+
File.open(File.join(Mack::Configuration.config_directory, "routes.rb")) do |f|
|
28
|
+
assert_match "r.resource :zoos # Added by rake generate:scaffold name=zoo", f.read
|
29
|
+
end
|
30
|
+
assert File.exists?(views_directory)
|
31
|
+
assert_equal fixture("zoo_with_cols", "edit.html.erb"), File.open(File.join(views_directory, "edit.html.erb")).read
|
32
|
+
assert_equal fixture("zoo_with_cols", "index.html.erb"), File.open(File.join(views_directory, "index.html.erb")).read
|
33
|
+
assert_equal fixture("zoo_with_cols", "new.html.erb"), File.open(File.join(views_directory, "new.html.erb")).read
|
34
|
+
assert_equal fixture("zoo_with_cols", "show.html.erb"), File.open(File.join(views_directory, "show.html.erb")).read
|
35
|
+
|
36
|
+
assert File.exists?(model_file)
|
37
|
+
assert File.exists?(controller_file)
|
38
|
+
assert File.exists?(migration_file)
|
39
|
+
end
|
40
|
+
|
41
|
+
def functional_test_file
|
42
|
+
File.join(test_directory, "functional", "zoos_controller_test.rb")
|
43
|
+
end
|
44
|
+
|
45
|
+
def views_directory
|
46
|
+
File.join(Mack::Configuration.views_directory, "zoos")
|
47
|
+
end
|
48
|
+
|
49
|
+
def model_file
|
50
|
+
File.join(Mack::Configuration.app_directory, "models", "zoo.rb")
|
51
|
+
end
|
52
|
+
|
53
|
+
def controller_file
|
54
|
+
File.join(Mack::Configuration.app_directory, "controllers", "zoos_controller.rb")
|
55
|
+
end
|
56
|
+
|
57
|
+
def migration_file
|
58
|
+
File.join(migrations_directory, "001_create_zoos.rb")
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
data/test/lib/user.rb
ADDED
@@ -0,0 +1,57 @@
|
|
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
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
require "test/unit"
|
2
|
+
require File.join(File.dirname(__FILE__), "..", "..", "test_helpers")
|
3
|
+
|
4
|
+
module Mack
|
5
|
+
module Configuration
|
6
|
+
def self.method_missing(sym, *args)
|
7
|
+
ev = "_mack_#{sym}".downcase
|
8
|
+
return ENV[ev]
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.set(name, value)
|
12
|
+
ENV["_mack_#{name.to_s.downcase}"] = value
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
$genosaurus_output_directory = File.join(File.dirname(__FILE__), "..", "tmp")
|
18
|
+
|
19
|
+
ENV["_mack_config_directory"] = File.dirname(__FILE__)
|
20
|
+
ENV["_mack_root"] = $genosaurus_output_directory
|
21
|
+
ENV["_mack_app_directory"] = File.join($genosaurus_output_directory, "app")
|
22
|
+
ENV["_mack_env"] = "test"
|
23
|
+
ENV["_mack_views_directory"] = File.join(ENV["_mack_app_directory"], "views")
|
24
|
+
|
25
|
+
require File.join(File.dirname(__FILE__), "..", "lib", "mack-data_mapper")
|
26
|
+
require File.join(File.dirname(__FILE__), "..", "..", "mack-orm_common", "lib", "mack-orm_common")
|
27
|
+
|
28
|
+
load File.join(File.dirname(__FILE__), "lib", "user.rb")
|
29
|
+
|
30
|
+
class Test::Unit::TestCase
|
31
|
+
|
32
|
+
# place common methods, assertions, and other type things in this file so
|
33
|
+
# other tests will have access to them.
|
34
|
+
|
35
|
+
def cleanup
|
36
|
+
database.adapter.flush_connections!
|
37
|
+
FileUtils.rm_rf($genosaurus_output_directory)
|
38
|
+
FileUtils.rm_rf(File.join(Mack::Configuration.config_directory, "routes.rb"))
|
39
|
+
end
|
40
|
+
|
41
|
+
def teardown
|
42
|
+
cleanup
|
43
|
+
end
|
44
|
+
|
45
|
+
def setup
|
46
|
+
database.adapter.flush_connections!
|
47
|
+
[$genosaurus_output_directory, migrations_directory, models_directory].each do |d|
|
48
|
+
FileUtils.mkdir_p(d)
|
49
|
+
end
|
50
|
+
FileUtils.cp(fixture_path("routes.rb"), File.join(Mack::Configuration.config_directory, "routes.rb"))
|
51
|
+
end
|
52
|
+
|
53
|
+
def migrations_directory
|
54
|
+
File.join($genosaurus_output_directory, "db", "migrations")
|
55
|
+
end
|
56
|
+
|
57
|
+
def models_directory
|
58
|
+
File.join($genosaurus_output_directory, "app", "models")
|
59
|
+
end
|
60
|
+
|
61
|
+
def test_directory
|
62
|
+
File.join($genosaurus_output_directory, "test")
|
63
|
+
end
|
64
|
+
|
65
|
+
def fixture_path(*name)
|
66
|
+
path = [File.dirname(__FILE__), "fixtures"]
|
67
|
+
path << name
|
68
|
+
path.flatten!
|
69
|
+
File.join(path) + ".fixture"
|
70
|
+
end
|
71
|
+
|
72
|
+
def fixture(*name)
|
73
|
+
File.open(fixture_path(name)).read
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
metadata
ADDED
@@ -0,0 +1,117 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mack-data_mapper
|
3
|
+
version: &id001 !ruby/object:Gem::Version
|
4
|
+
version: 0.5.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- markbates
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-05-06 00:00:00 -04:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: mack-orm_common
|
17
|
+
version_requirement:
|
18
|
+
version_requirements: !ruby/object:Gem::Requirement
|
19
|
+
requirements:
|
20
|
+
- - "="
|
21
|
+
- *id001
|
22
|
+
version:
|
23
|
+
- !ruby/object:Gem::Dependency
|
24
|
+
name: datamapper
|
25
|
+
version_requirement:
|
26
|
+
version_requirements: !ruby/object:Gem::Requirement
|
27
|
+
requirements:
|
28
|
+
- - "="
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: 0.3.2
|
31
|
+
version:
|
32
|
+
description: "mack-data_mapper was developed by: markbates"
|
33
|
+
email:
|
34
|
+
executables: []
|
35
|
+
|
36
|
+
extensions: []
|
37
|
+
|
38
|
+
extra_rdoc_files: []
|
39
|
+
|
40
|
+
files:
|
41
|
+
- lib/helpers/orm_helpers.rb
|
42
|
+
- lib/mack-data_mapper.rb
|
43
|
+
- lib/mack-data_mapper_tasks.rb
|
44
|
+
- lib/migration_generator/migration_generator.rb
|
45
|
+
- lib/migration_generator/templates/db/migrations/%=@migration_name%.rb.template
|
46
|
+
- lib/model_generator/manifest.yml
|
47
|
+
- lib/model_generator/model_generator.rb
|
48
|
+
- lib/model_generator/templates/model.rb.template
|
49
|
+
- lib/model_generator/templates/test.rb.template
|
50
|
+
- lib/scaffold_generator/manifest.yml
|
51
|
+
- lib/scaffold_generator/scaffold_generator.rb
|
52
|
+
- lib/scaffold_generator/templates/app/controllers/controller.rb.template
|
53
|
+
- lib/scaffold_generator/templates/app/views/edit.html.erb.template
|
54
|
+
- lib/scaffold_generator/templates/app/views/index.html.erb.template
|
55
|
+
- lib/scaffold_generator/templates/app/views/new.html.erb.template
|
56
|
+
- lib/scaffold_generator/templates/app/views/show.html.erb.template
|
57
|
+
- lib/scaffold_generator/templates/test.rb.template
|
58
|
+
- lib/tasks/db_create_drop_tasks.rake
|
59
|
+
- lib/tasks/db_migration_tasks.rake
|
60
|
+
- README
|
61
|
+
has_rdoc: true
|
62
|
+
homepage:
|
63
|
+
post_install_message:
|
64
|
+
rdoc_options: []
|
65
|
+
|
66
|
+
require_paths:
|
67
|
+
- lib
|
68
|
+
- lib
|
69
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: "0"
|
74
|
+
version:
|
75
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: "0"
|
80
|
+
version:
|
81
|
+
requirements: []
|
82
|
+
|
83
|
+
rubyforge_project: magrathea
|
84
|
+
rubygems_version: 1.0.1
|
85
|
+
signing_key:
|
86
|
+
specification_version: 2
|
87
|
+
summary: DataMapper ORM support for Mack
|
88
|
+
test_files:
|
89
|
+
- test/database.yml
|
90
|
+
- test/fixtures
|
91
|
+
- test/fixtures/add_users_migration.rb.fixture
|
92
|
+
- test/fixtures/album.rb.fixture
|
93
|
+
- test/fixtures/album_unit_test.rb.fixture
|
94
|
+
- test/fixtures/album_with_cols.rb.fixture
|
95
|
+
- test/fixtures/create_users_migration.rb.fixture
|
96
|
+
- test/fixtures/routes.rb.fixture
|
97
|
+
- test/fixtures/zoo_no_cols
|
98
|
+
- test/fixtures/zoo_no_cols/edit.html.erb.fixture
|
99
|
+
- test/fixtures/zoo_no_cols/index.html.erb.fixture
|
100
|
+
- test/fixtures/zoo_no_cols/new.html.erb.fixture
|
101
|
+
- test/fixtures/zoo_no_cols/show.html.erb.fixture
|
102
|
+
- test/fixtures/zoo_with_cols
|
103
|
+
- test/fixtures/zoo_with_cols/edit.html.erb.fixture
|
104
|
+
- test/fixtures/zoo_with_cols/index.html.erb.fixture
|
105
|
+
- test/fixtures/zoo_with_cols/new.html.erb.fixture
|
106
|
+
- test/fixtures/zoo_with_cols/show.html.erb.fixture
|
107
|
+
- test/fixtures/zoo_with_cols/zoo.rb.fixture
|
108
|
+
- test/fixtures/zoo_with_cols/zoos_controller.rb.fixture
|
109
|
+
- test/generators
|
110
|
+
- test/generators/migration_generator_test.rb
|
111
|
+
- test/generators/model_generator_test.rb
|
112
|
+
- test/generators/scaffold_generator_test.rb
|
113
|
+
- test/lib
|
114
|
+
- test/lib/user.rb
|
115
|
+
- test/tasks
|
116
|
+
- test/tasks/db_migration_tasks_test.rb
|
117
|
+
- test/test_helper.rb
|