public
Description: A Ruby web application framework
Homepage: http://www.mackframework.com
Clone URL: git://github.com/markbates/mack.git
Click here to lend your support to: mack and make a donation at www.pledgie.com !
More scaffold_generator tests.
markbates (author)
Wed Apr 09 13:41:50 -0700 2008
commit  08b7a2e9a4b6a642726b4c4653992f55fdf8b8c3
tree    f68c2936978943dc31432e6ef771fda30ce0a5f2
parent  2b79106e03ee25b5daef9f257caeb30c5616b82d
...
 
 
1
2
3
...
1
2
3
4
5
0
@@ -1,3 +1,5 @@
0
+* gem: application_configuration 1.2.2
0
+
0
 ===0.4.2.1
0
 * Fixed bug with gems:list rake task that was looking in the wrong path for the gems.rb file.
0
 
...
3
4
5
6
7
8
9
...
3
4
5
 
6
7
8
0
@@ -3,7 +3,6 @@ class MigrationGenerator < Mack::Generator::Migration::Base
0
   require_param :name
0
   
0
   def generate # :nodoc:
0
-
0
     directory(migrations_directory)
0
     
0
     template_dir = File.join(File.dirname(__FILE__), "templates")
...
1
2
 
3
4
5
 
6
7
8
 
9
10
...
1
 
2
3
4
 
5
6
7
 
8
9
10
0
@@ -1,9 +1,9 @@
0
 class <%= param(:name).camelcase %> < <%= app_config.orm.camelcase %>::Migration
0
-
0
+
0
   def self.up
0
   end
0
-
0
+
0
   def self.down
0
   end
0
-
0
+
0
 end
0
\ No newline at end of file
...
33
34
35
36
37
38
39
40
41
42
43
44
 
 
 
 
 
 
45
46
47
48
49
50
 
51
52
53
54
55
56
...
33
34
35
 
 
 
 
 
 
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
 
54
55
56
0
@@ -33,24 +33,24 @@ class ScaffoldGenerator < Mack::Generator::Base
0
     app_cont_dir = File.join(MACK_APP, "controllers")
0
     directory(app_cont_dir)
0
     
0
- app_model_dir = File.join(MACK_APP, "models")
0
- directory(app_model_dir)
0
-
0
- app_views_dir = File.join(MACK_APP, "views", @name_plural)
0
- directory(app_views_dir)
0
-
0
     temp_dir = File.join(File.dirname(__FILE__), "templates")
0
 
0
     if app_config.orm
0
+ app_model_dir = File.join(MACK_APP, "models")
0
+ directory(app_model_dir)
0
+
0
+ app_views_dir = File.join(MACK_APP, "views", @name_plural)
0
+ directory(app_views_dir)
0
+
0
       template(File.join(temp_dir, "generic", "app", "controllers", "controller.rb.template"), File.join(app_cont_dir, "#{@name_plural}_controller.rb"), :force => param(:force))
0
       template(File.join(temp_dir, "generic", "app", "models", "model.rb.template"), File.join(app_model_dir, "#{@name_singular}.rb"), :force => param(:force))
0
       template(File.join(temp_dir, "generic", "app", "views", "index.html.erb.template"), File.join(app_views_dir, "index.html.erb"), :force => param(:force))
0
       template(File.join(temp_dir, "generic", "app", "views", "edit.html.erb.template"), File.join(app_views_dir, "edit.html.erb"), :force => param(:force))
0
       template(File.join(temp_dir, "generic", "app", "views", "new.html.erb.template"), File.join(app_views_dir, "new.html.erb"), :force => param(:force))
0
       template(File.join(temp_dir, "generic", "app", "views", "show.html.erb.template"), File.join(app_views_dir, "show.html.erb"), :force => param(:force))
0
+ MigrationGenerator.new("NAME" => "create_#{@name_plural}").run
0
     else
0
       template(File.join(temp_dir, "no_orm", "app", "controllers", "controller.rb.template"), File.join(app_cont_dir, "#{@name_plural}_controller.rb"), :force => param(:force))
0
- MigrationGenerator.new("NAME" => "create_#{param(:name)}")
0
     end
0
 
0
   end
...
1
2
 
3
4
5
6
7
 
8
9
10
11
12
 
13
14
15
16
17
 
18
19
20
21
22
 
23
24
25
...
29
30
31
32
 
33
34
35
...
46
47
48
49
 
50
51
...
1
 
2
3
4
5
6
 
7
8
9
10
11
 
12
13
14
15
16
 
17
18
19
20
21
 
22
23
24
25
...
29
30
31
 
32
33
34
35
...
46
47
48
 
49
50
51
0
@@ -1,25 +1,25 @@
0
 class <%= @name_plural_camel %>Controller < Mack::Controller::Base
0
-
0
+
0
   # GET /<%= @name_plural %>
0
   def index
0
     @<%= @name_plural %> = <%= @name_singular_camel %>.find(:all)
0
   end
0
-
0
+
0
   # GET /<%= @name_plural %>/1
0
   def show
0
     @<%= @name_singular %> = <%= @name_singular_camel %>.find(params(:id))
0
   end
0
-
0
+
0
   # GET /<%= @name_plural %>/new
0
   def new
0
     @<%= @name_singular %> = <%= @name_singular_camel %>.new
0
   end
0
-
0
+
0
   # GET /<%= @name_plural %>/1/edit
0
   def edit
0
     @<%= @name_singular %> = <%= @name_singular_camel %>.find(params(:id))
0
   end
0
-
0
+
0
   # POST /<%= @name_plural %>
0
   def create
0
     @<%= @name_singular %> = <%= @name_singular_camel %>.new(params(:<%= @name_singular %>))
0
@@ -29,7 +29,7 @@ class <%= @name_plural_camel %>Controller < Mack::Controller::Base
0
       render(:action => "new")
0
     end
0
   end
0
-
0
+
0
   # PUT /<%= @name_plural %>/1
0
   def update
0
     @<%= @name_singular %> = <%= @name_singular_camel %>.find(params(:id))
0
@@ -46,5 +46,5 @@ class <%= @name_plural_camel %>Controller < Mack::Controller::Base
0
     @<%= @name_singular %>.destroy<%= app_config.orm == "data_mapper" ? "!" : "" %>
0
     redirect_to(<%= @name_plural %>_index_url)
0
   end
0
-
0
+
0
 end
0
\ No newline at end of file
...
1
2
 
3
4
5
6
7
 
8
9
10
11
12
 
13
14
15
16
17
 
18
19
20
21
22
 
23
24
25
26
27
 
28
29
30
31
32
 
33
34
35
36
37
 
38
39
...
1
 
2
3
4
5
6
 
7
8
9
10
11
 
12
13
14
15
16
 
17
18
19
20
21
 
22
23
24
25
26
 
27
28
29
30
31
 
32
33
34
35
36
 
37
38
39
0
@@ -1,38 +1,38 @@
0
 class <%= @name_plural_camel %>Controller < Mack::Controller::Base
0
-
0
+
0
   # GET /<%= @name_plural %>
0
   def index
0
     "<%= @name_plural_camel %>#index"
0
   end
0
-
0
+
0
   # POST /<%= @name_plural %>
0
   def create
0
     "<%= @name_plural_camel %>#create"
0
   end
0
-
0
+
0
   # GET /<%= @name_plural %>/new
0
   def new
0
     "<%= @name_plural_camel %>#new"
0
   end
0
-
0
+
0
   # GET /<%= @name_plural %>/1
0
   def show
0
     "<%= @name_plural_camel %>#show id: #{params(:id)}"
0
   end
0
-
0
+
0
   # GET /<%= @name_plural %>/1/edit
0
   def edit
0
     "<%= @name_plural_camel %>#edit id: #{params(:id)}"
0
   end
0
-
0
+
0
   # PUT /<%= @name_plural %>/1
0
   def update
0
     "<%= @name_plural_camel %>#update id: #{params(:id)}"
0
   end
0
-
0
+
0
   # DELETE /<%= @name_plural %>/1
0
   def delete
0
     "<%= @name_plural_camel %>#delete"
0
   end
0
-
0
+
0
 end
0
\ No newline at end of file
...
10
11
12
13
 
14
15
16
...
10
11
12
 
13
14
15
16
0
@@ -10,7 +10,7 @@ class GemHelper # :nodoc:
0
     self.project = "magrathea"
0
     self.package = "mack"
0
     self.gem_name = "mack"
0
- self.version = "0.4.2.1"
0
+ self.version = "0.4.2.1.105"
0
   end
0
   
0
   def gem_name_with_version
...
48
49
50
51
 
52
53
54
...
48
49
50
 
51
52
53
54
0
@@ -48,7 +48,7 @@ namespace :gem do
0
         
0
         s.add_dependency("rack", "0.3.0")
0
         s.add_dependency("mack_ruby_core_extensions", "0.1.5")
0
- s.add_dependency("application_configuration", "1.2.1")
0
+ s.add_dependency("application_configuration", "1.2.2")
0
         s.add_dependency("cachetastic", "1.4.2")
0
         s.add_dependency("log4r", "1.0.5")
0
         s.add_dependency("thin", "0.7.1")
...
27
28
29
30
 
 
 
 
 
 
 
 
 
 
 
 
31
32
33
...
35
36
37
38
 
 
 
 
 
 
 
 
 
 
 
 
39
40
41
42
43
44
45
46
47
48
 
 
 
 
 
 
 
 
49
50
51
...
27
28
29
 
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
...
46
47
48
 
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
 
 
 
 
 
 
65
66
67
68
69
70
71
72
73
74
75
0
@@ -27,7 +27,18 @@ class MigrationGeneratorTest < Test::Unit::TestCase
0
     temp_app_config("orm" => "active_record") do
0
       assert app_config.orm = "active_record"
0
       generate_common
0
- assert_match "class FooBar < ActiveRecord::Migration", @file_body
0
+ mig = <<-MIG
0
+class FooBar < ActiveRecord::Migration
0
+
0
+ def self.up
0
+ end
0
+
0
+ def self.down
0
+ end
0
+
0
+end
0
+MIG
0
+ assert_equal mig, @file_body
0
     end
0
   end
0
   
0
@@ -35,17 +46,30 @@ class MigrationGeneratorTest < Test::Unit::TestCase
0
     temp_app_config("orm" => "data_mapper") do
0
       assert app_config.orm = "data_mapper"
0
       generate_common
0
- assert_match "class FooBar < DataMapper::Migration", @file_body
0
+ mig = <<-MIG
0
+class FooBar < DataMapper::Migration
0
+
0
+ def self.up
0
+ end
0
+
0
+ def self.down
0
+ end
0
+
0
+end
0
+MIG
0
+ assert_equal mig, @file_body
0
     end
0
   end
0
   
0
   def generate_common
0
- mg = MigrationGenerator.new("NAME" => "foo_bar")
0
- mg.run
0
- assert File.exists?(fake_app_migration_dir)
0
- assert File.exists?(File.join(fake_app_migration_dir, "001_foo_bar.rb"))
0
- File.open(File.join(fake_app_migration_dir, "001_foo_bar.rb"), "r") do |file|
0
- @file_body = file.read
0
+ 5.times do |i|
0
+ mg = MigrationGenerator.new("NAME" => "foo_bar")
0
+ mg.run
0
+ assert File.exists?(fake_app_migration_dir)
0
+ assert File.exists?(File.join(fake_app_migration_dir, "00#{i+1}_foo_bar.rb"))
0
+ File.open(File.join(fake_app_migration_dir, "00#{i+1}_foo_bar.rb"), "r") do |file|
0
+ @file_body = file.read
0
+ end
0
     end
0
   end
0
   

Comments

    No one has commented yet.