Changeset 6991
- Timestamp:
- 06/10/07 23:06:47 (3 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/railties/test/generators/rails_scaffold_generator_test.rb
r6990 r6991 69 69 Dir.mkdir("#{RAILS_ROOT}/public") unless File.exists?("#{RAILS_ROOT}/public") 70 70 Dir.mkdir("#{RAILS_ROOT}/public/stylesheets") unless File.exists?("#{RAILS_ROOT}/public/stylesheets") 71 File.open("#{RAILS_ROOT}/config/routes.rb", 'w') do |f|71 File.open("#{RAILS_ROOT}/config/routes.rb", 'w') do |f| 72 72 f<<"ActionController::Routing::Routes.draw do |map|\n\nend\n" 73 73 end … … 98 98 assert_generated_controller_for :products do |f| 99 99 100 assert_has_method f, :index do |name,m|100 assert_has_method f, :index do |name, m| 101 101 assert_match /@products = Product\.find\(:all\)/, m, "#{name} should query products table" 102 102 end 103 103 104 assert_has_method f, :show,:edit,:update,:destroy do |name,m|104 assert_has_method f, :show, :edit, :update, :destroy do |name, m| 105 105 assert_match /@product = Product\.find\(params\[:id\]\)/, m, "#{name.to_s} should query products table" 106 106 end 107 107 108 assert_has_method f, :new do |name,m|108 assert_has_method f, :new do |name, m| 109 109 assert_match /@product = Product\.new/, m, "#{name.to_s} should instantiate a product" 110 110 end 111 111 112 assert_has_method f, :create do |name,m|112 assert_has_method f, :create do |name, m| 113 113 assert_match /@product = Product\.new\(params\[:product\]\)/, m, "#{name.to_s} should instantiate a product" 114 114 assert_match /format.xml \{ render :xml => @product.errors, :status => :unprocessable_entity \}/, m, "#{name.to_s} should set status to :unprocessable_entity code for xml" … … 123 123 assert_generated_helper_for :products 124 124 assert_generated_stylesheet :scaffold 125 assert_generated_views_for :products, "index.html.erb", "new.html.erb","edit.html.erb","show.html.erb"125 assert_generated_views_for :products, "index.html.erb", "new.html.erb", "edit.html.erb", "show.html.erb" 126 126 assert_generated_migration :create_products 127 127 assert_added_route_for :products … … 133 133 assert_generated_controller_for :products do |f| 134 134 135 assert_has_method f, :index do |name,m|135 assert_has_method f, :index do |name, m| 136 136 assert_match /@products = Product\.find\(:all\)/, m, "#{name} should query products table" 137 137 end 138 138 139 assert_has_method f, :show,:edit,:update,:destroy do |name,m|139 assert_has_method f, :show, :edit, :update, :destroy do |name, m| 140 140 assert_match /@product = Product\.find\(params\[:id\]\)/, m, "#{name.to_s} should query products table" 141 141 end 142 142 143 assert_has_method f, :new do |name,m|143 assert_has_method f, :new do |name, m| 144 144 assert_match /@product = Product\.new/, m, "#{name.to_s} should instantiate a product" 145 145 end 146 146 147 assert_has_method f, :create do |name,m|147 assert_has_method f, :create do |name, m| 148 148 assert_match /@product = Product\.new\(params\[:product\]\)/, m, "#{name.to_s} should instantiate a product" 149 149 assert_match /format.xml \{ render :xml => @product.errors, :status => :unprocessable_entity \}/, m, "#{name.to_s} should set status to :unprocessable_entity code for xml" … … 158 158 assert_generated_helper_for :products 159 159 assert_generated_stylesheet :scaffold 160 assert_generated_views_for :products, "index.html.erb", "new.html.erb","edit.html.erb","show.html.erb"160 assert_generated_views_for :products, "index.html.erb", "new.html.erb", "edit.html.erb", "show.html.erb" 161 161 assert_generated_migration :create_products do |t| 162 162 assert_generated_column t, :name, :string 163 163 assert_generated_column t, :supplier_id, :integer 164 assert_generated_column t, :created_at, :timestamp164 assert_generated_column t, :created_at, :timestamp 165 165 end 166 166