jumpstart 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (107) hide show
  1. data/.gitignore +1 -0
  2. data/Gemfile +2 -1
  3. data/VERSION +1 -1
  4. data/config/jumpstart_setup.yml +1 -0
  5. data/jumpstart.gemspec +15 -89
  6. data/jumpstart_templates/{i0n_rails_3/lib/generators/formtastic_erb/controller/templates/view.html.erb → .gitignore} +0 -0
  7. data/lib/jumpstart.rb +15 -39
  8. data/lib/jumpstart/base.rb +111 -111
  9. data/lib/jumpstart/filetools.rb +11 -7
  10. data/lib/jumpstart/stringtools.rb +41 -0
  11. data/test/helper.rb +12 -6
  12. data/test/jumpstart/test_base.rb +848 -106
  13. data/test/jumpstart/test_filetools.rb +42 -10
  14. data/test/jumpstart/test_stringutils.rb +67 -0
  15. data/test/test_jumpstart_templates/test_base/current_files_and_dirs_test_file.txt +1 -0
  16. data/{jumpstart_templates/i0n_rails_3/lib/generators/formtastic_haml/controller/templates/view.html.haml → test/test_jumpstart_templates/test_fileutils/sort_contained_files_and_dirs_test/file_1.txt} +0 -0
  17. data/{jumpstart_templates/i0n_rails_3/lib/generators/haml/controller/templates/view.html.haml → test/test_jumpstart_templates/test_fileutils/sort_contained_files_and_dirs_test/file_2} +0 -0
  18. data/test/test_jumpstart_templates/test_fileutils/sort_contained_files_and_dirs_test/folder_1/file_3.txt +0 -0
  19. data/test/test_jumpstart_templates/test_fileutils/sort_contained_files_and_dirs_test/folder_1/folder_2/file_4.txt +0 -0
  20. data/test/test_jumpstart_templates/test_fileutils/sort_contained_files_and_dirs_test/folder_1/folder_2/folder_3/file_5.txt +0 -0
  21. data/test/test_jumpstart_templates/test_fileutils/sort_contained_files_and_dirs_test/folder_1/folder_2/folder_4/file_6.txt +0 -0
  22. data/test/test_jumpstart_templates/test_template_1/_20._test_line_file_without_extension +1 -1
  23. data/test/test_jumpstart_templates/test_template_2/jumpstart_config/test_template_2.yml +83 -1
  24. metadata +15 -89
  25. data/.bundle/config +0 -2
  26. data/jumpstart_templates/i0n_rails_3/.gitignore +0 -11
  27. data/jumpstart_templates/i0n_rails_3/_._Gemfile +0 -5
  28. data/jumpstart_templates/i0n_rails_3/app/views/home/index.haml +0 -4
  29. data/jumpstart_templates/i0n_rails_3/app/views/layouts/application.haml +0 -32
  30. data/jumpstart_templates/i0n_rails_3/config/_2._routes.rb +0 -1
  31. data/jumpstart_templates/i0n_rails_3/config/_L._database.yml +0 -1
  32. data/jumpstart_templates/i0n_rails_3/config/deploy.rb +0 -62
  33. data/jumpstart_templates/i0n_rails_3/config/environments/_18._development.rb +0 -5
  34. data/jumpstart_templates/i0n_rails_3/config/environments/_27._test.rb +0 -1
  35. data/jumpstart_templates/i0n_rails_3/config/environments/_41._production.rb +0 -3
  36. data/jumpstart_templates/i0n_rails_3/config/initializers/setup_mail.rb +0 -14
  37. data/jumpstart_templates/i0n_rails_3/jumpstart_config/i0n_rails_3.yml +0 -40
  38. data/jumpstart_templates/i0n_rails_3/jumpstart_config/nginx.local.conf +0 -11
  39. data/jumpstart_templates/i0n_rails_3/jumpstart_config/nginx.remote.conf +0 -37
  40. data/jumpstart_templates/i0n_rails_3/lib/development_mail_interceptor.rb +0 -8
  41. data/jumpstart_templates/i0n_rails_3/lib/generators/authlogic.rb +0 -11
  42. data/jumpstart_templates/i0n_rails_3/lib/generators/authlogic/session/session_generator.rb +0 -18
  43. data/jumpstart_templates/i0n_rails_3/lib/generators/authlogic/session/templates/session.rb +0 -2
  44. data/jumpstart_templates/i0n_rails_3/lib/generators/datamapper.rb +0 -80
  45. data/jumpstart_templates/i0n_rails_3/lib/generators/datamapper/migration/migration_generator.rb +0 -26
  46. data/jumpstart_templates/i0n_rails_3/lib/generators/datamapper/migration/templates/migration.rb +0 -21
  47. data/jumpstart_templates/i0n_rails_3/lib/generators/datamapper/model/model_generator.rb +0 -29
  48. data/jumpstart_templates/i0n_rails_3/lib/generators/datamapper/model/templates/migration.rb +0 -17
  49. data/jumpstart_templates/i0n_rails_3/lib/generators/datamapper/model/templates/model.rb +0 -10
  50. data/jumpstart_templates/i0n_rails_3/lib/generators/datamapper/observer/observer_generator.rb +0 -15
  51. data/jumpstart_templates/i0n_rails_3/lib/generators/datamapper/observer/templates/observer.rb +0 -5
  52. data/jumpstart_templates/i0n_rails_3/lib/generators/factory_girl.rb +0 -11
  53. data/jumpstart_templates/i0n_rails_3/lib/generators/factory_girl/model/model_generator.rb +0 -14
  54. data/jumpstart_templates/i0n_rails_3/lib/generators/factory_girl/model/templates/fixtures.rb +0 -7
  55. data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_erb.rb +0 -9
  56. data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_erb/USAGE +0 -8
  57. data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_erb/controller/controller_generator.rb +0 -24
  58. data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_erb/scaffold/scaffold_generator.rb +0 -27
  59. data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_erb/scaffold/templates/_form.html.erb +0 -12
  60. data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_erb/scaffold/templates/edit.html.erb +0 -6
  61. data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_erb/scaffold/templates/index.html.erb +0 -27
  62. data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_erb/scaffold/templates/layout.html.erb +0 -16
  63. data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_erb/scaffold/templates/new.html.erb +0 -5
  64. data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_erb/scaffold/templates/show.html.erb +0 -10
  65. data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_haml.rb +0 -9
  66. data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_haml/USAGE +0 -8
  67. data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_haml/controller/controller_generator.rb +0 -24
  68. data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_haml/scaffold/scaffold_generator.rb +0 -23
  69. data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_haml/scaffold/templates/_form.haml.erb +0 -9
  70. data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_haml/scaffold/templates/edit.haml.erb +0 -7
  71. data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_haml/scaffold/templates/index.haml.erb +0 -23
  72. data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_haml/scaffold/templates/layout.haml.erb +0 -9
  73. data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_haml/scaffold/templates/new.haml.erb +0 -5
  74. data/jumpstart_templates/i0n_rails_3/lib/generators/formtastic_haml/scaffold/templates/show.haml.erb +0 -9
  75. data/jumpstart_templates/i0n_rails_3/lib/generators/haml.rb +0 -9
  76. data/jumpstart_templates/i0n_rails_3/lib/generators/haml/controller/controller_generator.rb +0 -24
  77. data/jumpstart_templates/i0n_rails_3/lib/generators/haml/scaffold/scaffold_generator.rb +0 -26
  78. data/jumpstart_templates/i0n_rails_3/lib/generators/haml/scaffold/templates/_form.haml.erb +0 -9
  79. data/jumpstart_templates/i0n_rails_3/lib/generators/haml/scaffold/templates/edit.haml.erb +0 -7
  80. data/jumpstart_templates/i0n_rails_3/lib/generators/haml/scaffold/templates/index.haml.erb +0 -23
  81. data/jumpstart_templates/i0n_rails_3/lib/generators/haml/scaffold/templates/layout.haml.erb +0 -9
  82. data/jumpstart_templates/i0n_rails_3/lib/generators/haml/scaffold/templates/new.haml.erb +0 -5
  83. data/jumpstart_templates/i0n_rails_3/lib/generators/haml/scaffold/templates/show.haml.erb +0 -9
  84. data/jumpstart_templates/i0n_rails_3/lib/generators/machinist.rb +0 -11
  85. data/jumpstart_templates/i0n_rails_3/lib/generators/machinist/model/model_generator.rb +0 -19
  86. data/jumpstart_templates/i0n_rails_3/lib/generators/machinist/model/templates/blueprint.rb +0 -5
  87. data/jumpstart_templates/i0n_rails_3/lib/generators/machinist/model/templates/machinist_initializer.rb +0 -19
  88. data/jumpstart_templates/i0n_rails_3/lib/generators/mongomapper.rb +0 -80
  89. data/jumpstart_templates/i0n_rails_3/lib/generators/mongomapper/model/model_generator.rb +0 -29
  90. data/jumpstart_templates/i0n_rails_3/lib/generators/mongomapper/model/templates/model.rb +0 -24
  91. data/jumpstart_templates/i0n_rails_3/lib/generators/mongomapper/observer/observer_generator.rb +0 -15
  92. data/jumpstart_templates/i0n_rails_3/lib/generators/shoulda.rb +0 -11
  93. data/jumpstart_templates/i0n_rails_3/lib/generators/shoulda/controller/controller_generator.rb +0 -16
  94. data/jumpstart_templates/i0n_rails_3/lib/generators/shoulda/controller/templates/controller.rb +0 -84
  95. data/jumpstart_templates/i0n_rails_3/lib/generators/shoulda/model/model_generator.rb +0 -16
  96. data/jumpstart_templates/i0n_rails_3/lib/generators/shoulda/model/templates/model.rb +0 -7
  97. data/jumpstart_templates/i0n_rails_3/lib/tasks/populate.rake +0 -91
  98. data/jumpstart_templates/i0n_rails_3/public/javascripts/init.js +0 -6
  99. data/jumpstart_templates/i0n_rails_3/public/javascripts/jquery-1.4.2.min.js +0 -154
  100. data/jumpstart_templates/i0n_rails_3/public/javascripts/jquery-ui-1.8.custom.min.js +0 -404
  101. data/jumpstart_templates/i0n_rails_3/public/javascripts/rails.js +0 -126
  102. data/jumpstart_templates/i0n_rails_3/public/stylesheets/sass/_setup.sass +0 -86
  103. data/jumpstart_templates/i0n_rails_3/public/stylesheets/sass/global.sass +0 -58
  104. data/jumpstart_templates/i0n_rails_3/public/stylesheets/sass/handheld.sass +0 -7
  105. data/jumpstart_templates/i0n_rails_3/public/stylesheets/sass/ie.sass +0 -40
  106. data/jumpstart_templates/i0n_rails_3/public/stylesheets/sass/print.sass +0 -57
  107. data/jumpstart_templates/i0n_rails_3/public/stylesheets/sass/screen.sass +0 -170
@@ -1,9 +0,0 @@
1
- = form_for @<%= singular_name %> do |f|
2
-
3
- <% for attribute in attributes -%>
4
- .field
5
- = f.label :<%= attribute.name %>
6
- = f.<%= attribute.field_type %> :<%= attribute.name %>
7
- <% end -%>
8
- .actions
9
- = f.submit 'Save'
@@ -1,7 +0,0 @@
1
- %h1 Editing <%= singular_name %>
2
-
3
- = render 'form'
4
-
5
- = link_to 'Show', @<%= singular_name %>
6
- \|
7
- = link_to 'Back', <%= plural_name %>_path
@@ -1,23 +0,0 @@
1
- %h1 Listing <%= plural_name %>
2
-
3
- %table
4
- %tr
5
- <% for attribute in attributes -%>
6
- %th <%= attribute.human_name %>
7
- <% end -%>
8
- %th
9
- %th
10
- %th
11
-
12
- - @<%= plural_name %>.each do |<%= singular_name %>|
13
- %tr
14
- <% for attribute in attributes -%>
15
- %td= <%= singular_name %>.<%= attribute.name %>
16
- <% end -%>
17
- %td= link_to 'Show', <%= singular_name %>
18
- %td= link_to 'Edit', edit_<%= singular_name %>_path(<%= singular_name %>)
19
- %td= link_to 'Destroy', <%= singular_name %>, :confirm => 'Are you sure?', :method => :delete
20
-
21
- %br
22
-
23
- = link_to 'New <%= singular_name %>', new_<%= singular_name %>_path
@@ -1,9 +0,0 @@
1
- !!!
2
- %html
3
- %head
4
- %title= "<%= controller_class_name %>:#{controller.action_name}"
5
- = csrf_meta_tag
6
- = stylesheet_link_tag 'scaffold'
7
- %body
8
- %p.notice= notice
9
- = yield
@@ -1,5 +0,0 @@
1
- %h1 New <%= singular_name %>
2
-
3
- = render 'form'
4
-
5
- = link_to 'Back', <%= plural_name %>_path
@@ -1,9 +0,0 @@
1
- <% for attribute in attributes -%>
2
- %p
3
- %b <%= attribute.human_name %>:
4
- = @<%= singular_name %>.<%= attribute.name %>
5
- <% end -%>
6
-
7
- = link_to 'Edit', edit_<%= singular_name %>_path(@<%= singular_name %>)
8
- \|
9
- = link_to 'Back', <%= plural_name %>_path
@@ -1,11 +0,0 @@
1
- require 'rails/generators/named_base'
2
-
3
- module Machinist
4
- module Generators
5
- class Base < Rails::Generators::NamedBase #:nodoc:
6
- def self.source_root
7
- @_machinist_source_root ||= File.expand_path(File.join(File.dirname(__FILE__), 'machinist', generator_name, 'templates'))
8
- end
9
- end
10
- end
11
- end
@@ -1,19 +0,0 @@
1
- require 'generators/machinist'
2
-
3
- module Machinist
4
- module Generators
5
- class ModelGenerator < Base
6
- argument :attributes, :type => :array, :default => [], :banner => "field:type field:type"
7
- class_option :dir, :type => :string, :default => "test/blueprints", :desc => "The directory where the blueprints should go"
8
-
9
- def create_machinist_initializer
10
- return if File.exists?(File.expand_path("config/initializers/machinist.rb", self.destination_root))
11
- template "machinist_initializer.rb", "config/initializers/machinist.rb"
12
- end
13
-
14
- def create_blueprint_file
15
- template 'blueprint.rb', File.join(options[:dir], "#{table_name}.rb")
16
- end
17
- end
18
- end
19
- end
@@ -1,5 +0,0 @@
1
- <%= class_name %>.blueprint do
2
- <% attributes.each do |attribute| -%>
3
- <%= attribute.name %> <%= attribute.default.inspect %>
4
- <% end -%>
5
- end
@@ -1,19 +0,0 @@
1
- # Add other envs here e.g. cucumber
2
- if Rails.env.test?
3
- require 'machinist'
4
- # require 'machinist/active_record'
5
-
6
- def Machinist.clear!
7
- Sham.clear
8
- # ActiveRecord::Base.clear_blueprints!
9
- end
10
-
11
- def Machinist.load_blueprints
12
- Dir[Rails.root.join(<%= options[:dir].inspect %>, "**", "*.rb")].each do |file|
13
- load file
14
- end
15
- end
16
-
17
- # Put Machinist.load_blueprints in the test_helper.rb
18
-
19
- end
@@ -1,80 +0,0 @@
1
- require 'rails/generators/named_base'
2
- # require 'rails/generators/migration'
3
- require 'rails/generators/active_model'
4
-
5
- module Mongomapper
6
- module Generators
7
- class Base < Rails::Generators::NamedBase #:nodoc:
8
- # include Rails::Generators::Migration
9
-
10
- def self.source_root
11
- @_mongomapper_source_root ||= File.expand_path(File.join(File.dirname(__FILE__),
12
- 'mongomapper', generator_name, 'templates'))
13
- end
14
-
15
- protected
16
-
17
- # # mongomapper does not care if migrations have the same name as long as
18
- # # they have different ids.
19
- # #
20
- # def migration_exists?(dirname, file_name) #:nodoc:
21
- # false
22
- # end
23
- #
24
- # # Implement the required interface for Rails::Generators::Migration.
25
- # #
26
- # def next_migration_number(dirname) #:nodoc:
27
- # if options[:id]
28
- # "%.3d" % options[:id]
29
- # else
30
- # "%.3d" % (current_migration_number(dirname) + 1)
31
- # end
32
- # end
33
- end
34
-
35
- class ActiveModel < Rails::Generators::ActiveModel #:nodoc:
36
- def self.all(klass)
37
- "#{klass}.all"
38
- end
39
-
40
- def self.find(klass, params=nil)
41
- "#{klass}.first(#{params})"
42
- end
43
-
44
- def self.build(klass, params=nil)
45
- if params
46
- "#{klass}.new(#{params})"
47
- else
48
- "#{klass}.new"
49
- end
50
- end
51
-
52
- def save
53
- "#{name}.save"
54
- end
55
-
56
- def update_attributes(params=nil)
57
- "#{name}.update(#{params})"
58
- end
59
-
60
- def errors
61
- "#{name}.errors"
62
- end
63
-
64
- def destroy
65
- "#{name}.destroy"
66
- end
67
- end
68
- end
69
- end
70
-
71
- module Rails
72
- module Generators
73
- class GeneratedAttribute #:nodoc:
74
- def type_class
75
- return 'DateTime' if type.to_s == 'datetime'
76
- return type.to_s.camelcase
77
- end
78
- end
79
- end
80
- end
@@ -1,29 +0,0 @@
1
- require 'generators/mongomapper'
2
-
3
- module Mongomapper
4
- module Generators
5
- class ModelGenerator < Base
6
- argument :attributes, :type => :array, :default => [], :banner => "field:type field:type"
7
- # class_option :_id, :type => :numeric, :desc => "The id to used in the migration"
8
-
9
- check_class_collision
10
-
11
- # class_option :migration, :type => :boolean
12
- class_option :timestamps, :type => :boolean
13
- class_option :parent, :type => :string, :desc => "The parent class for the generated model"
14
-
15
- # def create_migration_file
16
- # if options[:migration] && options[:parent].nil?
17
- # file_name = "create_#{file_path.gsub(/\//, '_').pluralize}"
18
- # migration_template "migration.rb", "db/migrate/#{file_name}.rb"
19
- # end
20
- # end
21
-
22
- def create_model_file
23
- template 'model.rb', File.join('app/models', class_path, "#{file_name}.rb")
24
- end
25
-
26
- hook_for :test_framework
27
- end
28
- end
29
- end
@@ -1,24 +0,0 @@
1
- class <%= class_name %><%= "< #{options[:parent].classify}" if options[:parent] %>
2
- <% unless options[:parent] -%>
3
- include MongoMapper::Document
4
-
5
- timestamps!
6
-
7
- # Validations :::::::::::::::::::::::::::::::::::::::::::::::::::::
8
- # validates_presence_of :attribute
9
-
10
- # Assocations :::::::::::::::::::::::::::::::::::::::::::::::::::::
11
- # belongs_to :model
12
- # many :model
13
- # one :model
14
-
15
- # Callbacks :::::::::::::::::::::::::::::::::::::::::::::::::::::::
16
- # before_create :your_model_method
17
- # after_create :your_model_method
18
- # before_update :your_model_method
19
-
20
- <% end -%>
21
- <% attributes.each do |attribute| -%>
22
- key :<%= attribute.name %>, <%= attribute.type_class %>
23
- <% end -%>
24
- end
@@ -1,15 +0,0 @@
1
- require 'generators/mongomapper'
2
-
3
- module Mongomapper
4
- module Generators
5
- class ObserverGenerator < Base
6
- check_class_collision :suffix => "Observer"
7
-
8
- def create_observer_file
9
- template 'observer.rb', File.join('app/models', class_path, "#{file_name}_observer.rb")
10
- end
11
-
12
- hook_for :test_framework
13
- end
14
- end
15
- end
@@ -1,11 +0,0 @@
1
- require 'rails/generators/named_base'
2
-
3
- module Shoulda
4
- module Generators
5
- class Base < Rails::Generators::NamedBase #:nodoc:
6
- def self.source_root
7
- @_shoulda_source_root ||= File.expand_path(File.join(File.dirname(__FILE__), 'shoulda', generator_name, 'templates'))
8
- end
9
- end
10
- end
11
- end
@@ -1,16 +0,0 @@
1
- require 'generators/shoulda'
2
-
3
- module Shoulda
4
- module Generators
5
- class ControllerGenerator < Base
6
- argument :actions, :type => :array, :default => [], :banner => "action action"
7
- class_option :dir, :type => :string, :default => "test/functional", :desc => "The directory where the controller tests should go"
8
-
9
- check_class_collision :suffix => 'ControllerTest'
10
-
11
- def create_controller_file
12
- template 'controller.rb', File.join(options[:dir], "#{file_name}_controller_test.rb")
13
- end
14
- end
15
- end
16
- end
@@ -1,84 +0,0 @@
1
- require 'test_helper'
2
-
3
- class <%= plural_name %>ControllerTest < ActionController::TestCase
4
- <% if actions.include?('index') %>
5
-
6
- context "index action" do
7
- should "render index template" do
8
- get :index
9
- assert_template 'index'
10
- end
11
- end
12
- <% end %>
13
- <% if actions.include?('show') %>
14
-
15
- context "show action" do
16
- should "render show template" do
17
- get :show, :id => <%= class_name %>.first
18
- assert_template 'show'
19
- end
20
- end
21
- <% end %>
22
- <% if actions.include?('new') %>
23
-
24
- context "new action" do
25
- should "render new template" do
26
- get :new
27
- assert_template 'new'
28
- end
29
- end
30
- <% end %>
31
- <% if actions.include?('create') %>
32
-
33
- context "create action" do
34
- should "render new template when model is invalid" do
35
- <%= class_name %>.any_instance.stubs(:valid?).returns(false)
36
- post :create
37
- assert_template 'new'
38
- end
39
-
40
- should "redirect when model is valid" do
41
- <%= class_name %>.any_instance.stubs(:valid?).returns(true)
42
- post :create
43
- assert_redirected_to
44
- end
45
- end
46
- <% end %>
47
- <% if actions.include?('edit') %>
48
-
49
- context "edit action" do
50
- should "render edit template" do
51
- get :edit, :id => <%= class_name %>.first
52
- assert_template 'edit'
53
- end
54
- end
55
- <% end %>
56
- <% if actions.include?('update') %>
57
-
58
- context "update action" do
59
- should "render edit template when model is invalid" do
60
- <%= class_name %>.any_instance.stubs(:valid?).returns(false)
61
- put :update, :id => <%= class_name %>.first
62
- assert_template 'edit'
63
- end
64
-
65
- should "redirect when model is valid" do
66
- <%= class_name %>.any_instance.stubs(:valid?).returns(true)
67
- put :update, :id => <%= class_name %>.first
68
- assert_redirected_to
69
- end
70
- end
71
- <% end %>
72
- <% if actions.include?('destroy') %>
73
-
74
- context "destroy action" do
75
- should "destroy model and redirect to index action" do
76
- <%= singular_name %> = <%= class_name %>.first
77
- delete :destroy, :id => <%= singular_name %>
78
- assert_redirected_to
79
- assert !<%= class_name %>.exists?(<%= singular_name %>.id)
80
- end
81
- end
82
- <% end %>
83
-
84
- end
@@ -1,16 +0,0 @@
1
- require 'generators/shoulda'
2
-
3
- module Shoulda
4
- module Generators
5
- class ModelGenerator < Base
6
- argument :attributes, :type => :array, :default => [], :banner => "field:type field:type"
7
- class_option :dir, :type => :string, :default => "test/unit", :desc => "The directory where the model tests should go"
8
-
9
- def create_model_test_file
10
- template 'model.rb', File.join(options[:dir], "#{singular_name}_test.rb")
11
- end
12
-
13
- hook_for :fixture_replacement
14
- end
15
- end
16
- end
@@ -1,7 +0,0 @@
1
- require 'test_helper'
2
-
3
- class <%= class_name %>Test < ActiveSupport::TestCase
4
- should "be valid" do
5
- assert <%= class_name %>.new.valid?
6
- end
7
- end
@@ -1,91 +0,0 @@
1
- namespace :db do
2
-
3
- desc "Erase and fill database"
4
- task :populate => :environment do
5
- require 'populator'
6
- require 'faker'
7
- require 'action_controller/test_process'
8
-
9
- # [User, Subscription, Valuation].each(&:delete_all)
10
-
11
- ##################### CREATE USERS #####################
12
-
13
- # User.populate 1 do |admin|
14
- # admin.login = "ian"
15
- # admin.name = "Ian Alexander Wood"
16
- # admin.email = "ianalexanderwood@gmail.com"
17
- # admin.role = "admin"
18
- # admin.crypted_password = "8010530181ee423288e72b2a45d9bf045ed97be6"
19
- # admin.salt = "7823cecd5bcd10b8d86df120d11240e4c35a630b"
20
- # admin.activation_code = nil
21
- # admin.activated_at = Time.now
22
- # end
23
-
24
- # @new_users = []
25
- #
26
- # 200.times do
27
- # user = User.new( :login => (Faker::Internet.user_name + rand(10000).to_s),
28
- # :name => Faker::Name.name,
29
- # :email => (rand(10000).to_s + Faker::Internet.email)
30
- # )
31
- # @new_users.map{|x| x.login}.each do |login|
32
- # if login == user.login
33
- # user.delete
34
- # end
35
- # end
36
- # @new_users.map{|x| x.email}.each do |email|
37
- # if email == user.email
38
- # user.delete
39
- # end
40
- # end
41
- # @new_users << user
42
- # end
43
- #
44
- # @new_users.each do |new_user|
45
- # User.populate 1 do |user|
46
- # user.login = new_user.login
47
- # user.name = new_user.name
48
- # user.email = new_user.email
49
- # user.role = ["analyst","investor"]
50
- # user.crypted_password = "8010530181ee423288e72b2a45d9bf045ed97be6"
51
- # user.salt = "7823cecd5bcd10b8d86df120d11240e4c35a630b"
52
- # user.activation_code = nil
53
- # user.activated_at = Time.now
54
- # end
55
- # end
56
-
57
- ##################### CREATE VALUATIONS #####################
58
-
59
- # @analysts = User.all(:conditions => "role = 'analyst'")
60
- # @investors = User.all(:conditions => "role = 'investor'")
61
- # @admins = User.all(:conditions => "role = 'admin'")
62
- # @users = @analysts + @investors + @admins
63
- # @random_users = (@users.sample((@users.length / 2)) + @admins).uniq
64
- #
65
- # @prices = Price.all
66
- #
67
- # @companies = Company.all
68
- #
69
- # 100.times do
70
- # Valuation.create_valuation( @analysts.map {|user| user.id}.shuffle.last, {:company_id => @companies.map {|company| company.id}.shuffle.last, :file => ActionController::TestUploadedFile.new("#{Rails.root}/test/files/test#{rand(10)}.xls","application/vnd.ms-excel") })
71
- # end
72
- #
73
- # @companies.each do |company|
74
- # @admins.each do |user|
75
- # Valuation.create_valuation( user.id, {:company_id => company.id, :file => ActionController::TestUploadedFile.new("#{Rails.root}/test/files/test#{rand(10)}.xls","application/vnd.ms-excel") })
76
- # end
77
- # end
78
-
79
- ##################### CREATE SUBSCRIPTIONS #####################
80
-
81
- # @valuations = Valuation.all(:conditions => "active=1")
82
- #
83
- # @valuations.each do |valuation|
84
- # @random_users.each do |user|
85
- # Subscription.create(:user_id => user.id, :valuation_id => valuation.id)
86
- # end
87
- # end
88
-
89
- end
90
-
91
- end