nested_scaffold 0.2.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. checksums.yaml +7 -0
  2. data/.document +5 -0
  3. data/.gitignore +9 -0
  4. data/.travis.yml +10 -0
  5. data/Gemfile +4 -0
  6. data/README.rdoc +4 -13
  7. data/Rakefile +5 -33
  8. data/gemfiles/Gemfile-rails.4.2.x +7 -0
  9. data/gemfiles/Gemfile-rails.4.2.x.lock +114 -0
  10. data/gemfiles/Gemfile-rails.5.0.0.beta3 +7 -0
  11. data/gemfiles/Gemfile-rails.5.0.0.beta3.lock +124 -0
  12. data/lib/generators/active_record/active_record_generator.rb +2 -2
  13. data/lib/generators/haml/templates/edit.html.haml +1 -1
  14. data/lib/generators/nested_scaffold_generator.rb +5 -3
  15. data/lib/generators/scaffold_controller/scaffold_controller_generator.rb +2 -2
  16. data/lib/generators/scaffold_controller/templates/controller.rb +32 -54
  17. data/lib/generators/test_unit/model_generator.rb +9 -0
  18. data/lib/generators/test_unit/templates/functional_test.rb +9 -10
  19. data/nested_scaffold.gemspec +26 -0
  20. metadata +84 -129
  21. data/test/dummy/README.rdoc +0 -3
  22. data/test/dummy/Rakefile +0 -7
  23. data/test/dummy/app/assets/javascripts/application.js +0 -15
  24. data/test/dummy/app/assets/javascripts/boxes.js +0 -2
  25. data/test/dummy/app/assets/stylesheets/application.css +0 -13
  26. data/test/dummy/app/assets/stylesheets/boxes.css +0 -4
  27. data/test/dummy/app/controllers/application_controller.rb +0 -3
  28. data/test/dummy/app/controllers/boxes_controller.rb +0 -83
  29. data/test/dummy/app/helpers/application_helper.rb +0 -2
  30. data/test/dummy/app/helpers/boxes_helper.rb +0 -2
  31. data/test/dummy/app/models/box.rb +0 -2
  32. data/test/dummy/app/views/boxes/_form.html.erb +0 -25
  33. data/test/dummy/app/views/boxes/edit.html.erb +0 -6
  34. data/test/dummy/app/views/boxes/index.html.erb +0 -25
  35. data/test/dummy/app/views/boxes/new.html.erb +0 -5
  36. data/test/dummy/app/views/boxes/show.html.erb +0 -15
  37. data/test/dummy/app/views/layouts/application.html.erb +0 -14
  38. data/test/dummy/config.ru +0 -4
  39. data/test/dummy/config/application.rb +0 -56
  40. data/test/dummy/config/boot.rb +0 -10
  41. data/test/dummy/config/database.yml +0 -25
  42. data/test/dummy/config/environment.rb +0 -5
  43. data/test/dummy/config/environments/development.rb +0 -37
  44. data/test/dummy/config/environments/production.rb +0 -67
  45. data/test/dummy/config/environments/test.rb +0 -37
  46. data/test/dummy/config/initializers/backtrace_silencers.rb +0 -7
  47. data/test/dummy/config/initializers/inflections.rb +0 -15
  48. data/test/dummy/config/initializers/mime_types.rb +0 -5
  49. data/test/dummy/config/initializers/secret_token.rb +0 -7
  50. data/test/dummy/config/initializers/session_store.rb +0 -8
  51. data/test/dummy/config/initializers/wrap_parameters.rb +0 -14
  52. data/test/dummy/config/locales/en.yml +0 -5
  53. data/test/dummy/config/routes.rb +0 -60
  54. data/test/dummy/db/migrate/20120313224522_create_boxes.rb +0 -10
  55. data/test/dummy/db/schema.rb +0 -44
  56. data/test/dummy/db/test.sqlite3 +0 -0
  57. data/test/dummy/log/test.log +0 -18
  58. data/test/dummy/public/404.html +0 -26
  59. data/test/dummy/public/422.html +0 -26
  60. data/test/dummy/public/500.html +0 -25
  61. data/test/dummy/public/favicon.ico +0 -0
  62. data/test/dummy/script/rails +0 -6
  63. data/test/dummy/test/fixtures/boxes.yml +0 -9
  64. data/test/dummy/test/functional/boxes_controller_test.rb +0 -49
  65. data/test/dummy/test/unit/box_test.rb +0 -7
  66. data/test/dummy/test/unit/helpers/boxes_helper_test.rb +0 -4
  67. data/test/nested_scaffold_test.rb +0 -70
  68. data/test/test_helper.rb +0 -18
@@ -1,37 +0,0 @@
1
- Dummy::Application.configure do
2
- # Settings specified here will take precedence over those in config/application.rb
3
-
4
- # The test environment is used exclusively to run your application's
5
- # test suite. You never need to work with it otherwise. Remember that
6
- # your test database is "scratch space" for the test suite and is wiped
7
- # and recreated between test runs. Don't rely on the data there!
8
- config.cache_classes = true
9
-
10
- # Configure static asset server for tests with Cache-Control for performance
11
- config.serve_static_assets = true
12
- config.static_cache_control = "public, max-age=3600"
13
-
14
- # Log error messages when you accidentally call methods on nil
15
- config.whiny_nils = true
16
-
17
- # Show full error reports and disable caching
18
- config.consider_all_requests_local = true
19
- config.action_controller.perform_caching = false
20
-
21
- # Raise exceptions instead of rendering exception templates
22
- config.action_dispatch.show_exceptions = false
23
-
24
- # Disable request forgery protection in test environment
25
- config.action_controller.allow_forgery_protection = false
26
-
27
- # Tell Action Mailer not to deliver emails to the real world.
28
- # The :test delivery method accumulates sent emails in the
29
- # ActionMailer::Base.deliveries array.
30
- config.action_mailer.delivery_method = :test
31
-
32
- # Raise exception on mass assignment protection for Active Record models
33
- config.active_record.mass_assignment_sanitizer = :strict
34
-
35
- # Print deprecation notices to the stderr
36
- config.active_support.deprecation = :stderr
37
- end
@@ -1,7 +0,0 @@
1
- # Be sure to restart your server when you modify this file.
2
-
3
- # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
4
- # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
5
-
6
- # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
7
- # Rails.backtrace_cleaner.remove_silencers!
@@ -1,15 +0,0 @@
1
- # Be sure to restart your server when you modify this file.
2
-
3
- # Add new inflection rules using the following format
4
- # (all these examples are active by default):
5
- # ActiveSupport::Inflector.inflections do |inflect|
6
- # inflect.plural /^(ox)$/i, '\1en'
7
- # inflect.singular /^(ox)en/i, '\1'
8
- # inflect.irregular 'person', 'people'
9
- # inflect.uncountable %w( fish sheep )
10
- # end
11
- #
12
- # These inflection rules are supported but not enabled by default:
13
- # ActiveSupport::Inflector.inflections do |inflect|
14
- # inflect.acronym 'RESTful'
15
- # end
@@ -1,5 +0,0 @@
1
- # Be sure to restart your server when you modify this file.
2
-
3
- # Add new mime types for use in respond_to blocks:
4
- # Mime::Type.register "text/richtext", :rtf
5
- # Mime::Type.register_alias "text/html", :iphone
@@ -1,7 +0,0 @@
1
- # Be sure to restart your server when you modify this file.
2
-
3
- # Your secret key for verifying the integrity of signed cookies.
4
- # If you change this key, all old signed cookies will become invalid!
5
- # Make sure the secret is at least 30 characters and all random,
6
- # no regular words or you'll be exposed to dictionary attacks.
7
- Dummy::Application.config.secret_token = 'c796eadaee8e2bb91ec6e4f8e03f57165a351abc1f229c9201c49fec7729e530a878343954cf43d65c0377c3d5e5810737aba59b678eee8f8f34194df35d1ee6'
@@ -1,8 +0,0 @@
1
- # Be sure to restart your server when you modify this file.
2
-
3
- Dummy::Application.config.session_store :cookie_store, key: '_dummy_session'
4
-
5
- # Use the database for sessions instead of the cookie-based default,
6
- # which shouldn't be used to store highly confidential information
7
- # (create the session table with "rails generate session_migration")
8
- # Dummy::Application.config.session_store :active_record_store
@@ -1,14 +0,0 @@
1
- # Be sure to restart your server when you modify this file.
2
- #
3
- # This file contains settings for ActionController::ParamsWrapper which
4
- # is enabled by default.
5
-
6
- # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
7
- ActiveSupport.on_load(:action_controller) do
8
- wrap_parameters format: [:json]
9
- end
10
-
11
- # Disable root element in JSON by default.
12
- ActiveSupport.on_load(:active_record) do
13
- self.include_root_in_json = false
14
- end
@@ -1,5 +0,0 @@
1
- # Sample localization file for English. Add more files in this directory for other locales.
2
- # See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
3
-
4
- en:
5
- hello: "Hello world"
@@ -1,60 +0,0 @@
1
- Dummy::Application.routes.draw do
2
- resources :boxes
3
-
4
- # The priority is based upon order of creation:
5
- # first created -> highest priority.
6
-
7
- # Sample of regular route:
8
- # match 'products/:id' => 'catalog#view'
9
- # Keep in mind you can assign values other than :controller and :action
10
-
11
- # Sample of named route:
12
- # match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase
13
- # This route can be invoked with purchase_url(:id => product.id)
14
-
15
- # Sample resource route (maps HTTP verbs to controller actions automatically):
16
- # resources :products
17
-
18
- # Sample resource route with options:
19
- # resources :products do
20
- # member do
21
- # get 'short'
22
- # post 'toggle'
23
- # end
24
- #
25
- # collection do
26
- # get 'sold'
27
- # end
28
- # end
29
-
30
- # Sample resource route with sub-resources:
31
- # resources :products do
32
- # resources :comments, :sales
33
- # resource :seller
34
- # end
35
-
36
- # Sample resource route with more complex sub-resources
37
- # resources :products do
38
- # resources :comments
39
- # resources :sales do
40
- # get 'recent', :on => :collection
41
- # end
42
- # end
43
-
44
- # Sample resource route within a namespace:
45
- # namespace :admin do
46
- # # Directs /admin/products/* to Admin::ProductsController
47
- # # (app/controllers/admin/products_controller.rb)
48
- # resources :products
49
- # end
50
-
51
- # You can have the root of your site routed with "root"
52
- # just remember to delete public/index.html.
53
- # root :to => 'welcome#index'
54
-
55
- # See how all your routes lay out with "rake routes"
56
-
57
- # This is a legacy wild controller route that's not recommended for RESTful applications.
58
- # Note: This route will make all actions in every controller accessible via GET requests.
59
- # match ':controller(/:action(/:id))(.:format)'
60
- end
@@ -1,10 +0,0 @@
1
- class CreateBoxes < ActiveRecord::Migration
2
- def change
3
- create_table :boxes do |t|
4
- t.string :name
5
- t.text :notes
6
-
7
- t.timestamps
8
- end
9
- end
10
- end
@@ -1,44 +0,0 @@
1
- # encoding: UTF-8
2
- # This file is auto-generated from the current state of the database. Instead
3
- # of editing this file, please use the migrations feature of Active Record to
4
- # incrementally modify your database, and then regenerate this schema definition.
5
- #
6
- # Note that this schema.rb definition is the authoritative source for your
7
- # database schema. If you need to create the application database on another
8
- # system, you should be using db:schema:load, not running all the migrations
9
- # from scratch. The latter is a flawed and unsustainable approach (the more migrations
10
- # you'll amass, the slower it'll run and the greater likelihood for issues).
11
- #
12
- # It's strongly recommended to check this file into your version control system.
13
-
14
- ActiveRecord::Schema.define(:version => 20120315110556) do
15
-
16
- create_table "boxes", :force => true do |t|
17
- t.string "name"
18
- t.text "notes"
19
- t.datetime "created_at", :null => false
20
- t.datetime "updated_at", :null => false
21
- end
22
-
23
- create_table "items", :force => true do |t|
24
- t.integer "box_id"
25
- t.string "name"
26
- t.integer "quantity"
27
- t.text "notes"
28
- t.datetime "created_at", :null => false
29
- t.datetime "updated_at", :null => false
30
- end
31
-
32
- add_index "items", ["box_id"], :name => "index_items_on_box_id"
33
-
34
- create_table "things", :force => true do |t|
35
- t.integer "box_id"
36
- t.string "name"
37
- t.integer "weight"
38
- t.string "category"
39
- end
40
-
41
- add_index "things", ["box_id"], :name => "index_things_on_box_id"
42
- add_index "things", ["category"], :name => "index_things_on_category"
43
-
44
- end
File without changes
@@ -1,18 +0,0 @@
1
-  (0.1ms) begin transaction
2
-  (0.0ms) rollback transaction
3
-  (0.0ms) begin transaction
4
-  (0.0ms) rollback transaction
5
-  (0.0ms) begin transaction
6
-  (0.0ms) rollback transaction
7
-  (0.0ms) begin transaction
8
-  (0.0ms) rollback transaction
9
-  (0.0ms) begin transaction
10
-  (0.0ms) rollback transaction
11
-  (0.0ms) begin transaction
12
-  (0.0ms) rollback transaction
13
-  (0.0ms) begin transaction
14
-  (0.0ms) rollback transaction
15
-  (0.0ms) begin transaction
16
-  (0.0ms) rollback transaction
17
-  (0.0ms) begin transaction
18
-  (0.0ms) rollback transaction
@@ -1,26 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>The page you were looking for doesn't exist (404)</title>
5
- <style type="text/css">
6
- body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
- div.dialog {
8
- width: 25em;
9
- padding: 0 4em;
10
- margin: 4em auto 0 auto;
11
- border: 1px solid #ccc;
12
- border-right-color: #999;
13
- border-bottom-color: #999;
14
- }
15
- h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
- </style>
17
- </head>
18
-
19
- <body>
20
- <!-- This file lives in public/404.html -->
21
- <div class="dialog">
22
- <h1>The page you were looking for doesn't exist.</h1>
23
- <p>You may have mistyped the address or the page may have moved.</p>
24
- </div>
25
- </body>
26
- </html>
@@ -1,26 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>The change you wanted was rejected (422)</title>
5
- <style type="text/css">
6
- body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
- div.dialog {
8
- width: 25em;
9
- padding: 0 4em;
10
- margin: 4em auto 0 auto;
11
- border: 1px solid #ccc;
12
- border-right-color: #999;
13
- border-bottom-color: #999;
14
- }
15
- h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
- </style>
17
- </head>
18
-
19
- <body>
20
- <!-- This file lives in public/422.html -->
21
- <div class="dialog">
22
- <h1>The change you wanted was rejected.</h1>
23
- <p>Maybe you tried to change something you didn't have access to.</p>
24
- </div>
25
- </body>
26
- </html>
@@ -1,25 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>We're sorry, but something went wrong (500)</title>
5
- <style type="text/css">
6
- body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
- div.dialog {
8
- width: 25em;
9
- padding: 0 4em;
10
- margin: 4em auto 0 auto;
11
- border: 1px solid #ccc;
12
- border-right-color: #999;
13
- border-bottom-color: #999;
14
- }
15
- h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
- </style>
17
- </head>
18
-
19
- <body>
20
- <!-- This file lives in public/500.html -->
21
- <div class="dialog">
22
- <h1>We're sorry, but something went wrong.</h1>
23
- </div>
24
- </body>
25
- </html>
File without changes
@@ -1,6 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3
-
4
- APP_PATH = File.expand_path('../../config/application', __FILE__)
5
- require File.expand_path('../../config/boot', __FILE__)
6
- require 'rails/commands'
@@ -1,9 +0,0 @@
1
- # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
2
-
3
- one:
4
- name: MyString
5
- notes: MyText
6
-
7
- two:
8
- name: MyString
9
- notes: MyText
@@ -1,49 +0,0 @@
1
- require 'test_helper'
2
-
3
- class BoxesControllerTest < ActionController::TestCase
4
- setup do
5
- @box = boxes(:one)
6
- end
7
-
8
- test "should get index" do
9
- get :index
10
- assert_response :success
11
- assert_not_nil assigns(:boxes)
12
- end
13
-
14
- test "should get new" do
15
- get :new
16
- assert_response :success
17
- end
18
-
19
- test "should create box" do
20
- assert_difference('Box.count') do
21
- post :create, box: @box.attributes
22
- end
23
-
24
- assert_redirected_to box_path(assigns(:box))
25
- end
26
-
27
- test "should show box" do
28
- get :show, id: @box
29
- assert_response :success
30
- end
31
-
32
- test "should get edit" do
33
- get :edit, id: @box
34
- assert_response :success
35
- end
36
-
37
- test "should update box" do
38
- put :update, id: @box, box: @box.attributes
39
- assert_redirected_to box_path(assigns(:box))
40
- end
41
-
42
- test "should destroy box" do
43
- assert_difference('Box.count', -1) do
44
- delete :destroy, id: @box
45
- end
46
-
47
- assert_redirected_to boxes_path
48
- end
49
- end
@@ -1,7 +0,0 @@
1
- require 'test_helper'
2
-
3
- class BoxTest < ActiveSupport::TestCase
4
- # test "the truth" do
5
- # assert true
6
- # end
7
- end
@@ -1,4 +0,0 @@
1
- require 'test_helper'
2
-
3
- class BoxesHelperTest < ActionView::TestCase
4
- end
@@ -1,70 +0,0 @@
1
- require 'test_helper'
2
- require 'generators/nested_scaffold_generator'
3
- require 'generators/active_record/active_record_generator'
4
- require 'rails/generators/rails/scaffold/scaffold_generator'
5
- require 'rails/generators/test_unit/controller/controller_generator'
6
-
7
- class NestedScaffoldTest < Rails::Generators::TestCase
8
- tests NestedScaffold::Generators::NestedScaffoldGenerator
9
- destination File.expand_path("../tmp", File.dirname(__FILE__))
10
- setup :prepare_destination
11
- setup :prepare_dummy_files
12
-
13
- Master = "box"
14
- Detail = "sweet"
15
-
16
- test "Assert all files are properly created" do
17
-
18
- res = "#{Master}/#{Detail}"
19
- out = run_generator %w(#{res}/sweet name:string quantity:integer notes:text --orm=active_record --test-framework=test_unit --migration=true --fixture)
20
- puts "\nOutput from generator:\n" + out
21
-
22
- #ls "app/assets/stylesheets"
23
- #ls "db/migrate"
24
-
25
- assert_file "app/controllers/#{Detail}s_controller.rb"
26
- assert_file "test/functional/#{Detail}s_controller_test.rb"
27
- assert_file "app/helpers/#{Detail}s_helper.rb"
28
- assert_file "app/assets/stylesheets/#{Detail}s.css"
29
- assert_file "app/assets/javascripts/#{Detail}s.js"
30
-
31
- assert_file "app/views/#{Detail}s/_form.html.erb"
32
- assert_file "app/views/#{Detail}s/index.html.erb"
33
- assert_file "app/views/#{Detail}s/show.html.erb"
34
- assert_file "app/views/#{Detail}s/new.html.erb"
35
- assert_file "app/views/#{Detail}s/edit.html.erb"
36
-
37
-
38
- assert_file "app/models/#{Detail}.rb"
39
- assert_file "test/fixtures/#{Detail}s.yml"
40
- assert_file "test/unit/#{Detail}_test.rb"
41
- assert_migration "db/migrate/create_#{Detail}s.rb"
42
-
43
-
44
- end
45
-
46
- test "truth" do
47
- assert_kind_of Module, NestedScaffold::Generators::NestedScaffoldGenerator
48
- end
49
-
50
- private
51
- def prepare_dummy_files
52
- FileUtils.cd(File.expand_path("../tmp", File.dirname(__FILE__))) do
53
- FileUtils.mkdir('config')
54
- FileUtils.touch('config/routes.rb')
55
-
56
- FileUtils.mkdir("db")
57
- FileUtils.mkdir("db/migrate")
58
- FileUtils.touch("db/migrate/20120313224522_create_#{Master}.rb")
59
-
60
- end
61
- end
62
-
63
- def ls(path)
64
- d = File.expand_path("../tmp/"+path, File.dirname(__FILE__))
65
- puts "\nOutput from ls (#{d.inspect}):"
66
- Dir.foreach(d) do |f|
67
- puts f.inspect
68
- end
69
- end
70
- end