bootbox_crud 0.1.1.6 → 0.1.1.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (97) hide show
  1. checksums.yaml +4 -4
  2. data/.codeclimate.yml +21 -0
  3. data/.eslintrc +212 -0
  4. data/.gitignore +5 -0
  5. data/.rubocop.yml +1156 -0
  6. data/.travis.yml +11 -0
  7. data/Gemfile +14 -0
  8. data/README.md +4 -2
  9. data/Rakefile +33 -0
  10. data/bootbox_crud.gemspec +2 -0
  11. data/lib/bootbox_crud/action_view/helpers.rb +1 -1
  12. data/lib/bootbox_crud/engine.rb +1 -1
  13. data/lib/bootbox_crud/version.rb +1 -1
  14. data/lib/generators/bootbox_crud/install_generator.rb +5 -5
  15. data/lib/generators/bootbox_crud/templates/config/initializers/simple_form_bootstrap.rb +54 -50
  16. data/lib/generators/rails/haml_modal_crud/haml_modal_crud_generator.rb +2 -2
  17. data/lib/generators/rails/haml_modal_crud/templates/create.js.erb +1 -1
  18. data/lib/generators/rails/haml_modal_crud/templates/destroy.js.erb +1 -1
  19. data/lib/generators/rails/haml_modal_crud/templates/update.js.erb +1 -1
  20. data/lib/generators/rails/modal_crud_route/modal_crud_route_generator.rb +1 -1
  21. data/test/dummy/README.rdoc +28 -0
  22. data/test/dummy/Rakefile +6 -0
  23. data/test/dummy/app/assets/images/.keep +0 -0
  24. data/test/dummy/app/assets/javascripts/application.js +19 -0
  25. data/test/dummy/app/assets/javascripts/models.js +8 -0
  26. data/test/dummy/app/assets/stylesheets/application.css +17 -0
  27. data/test/dummy/app/assets/stylesheets/bootstrap_main.scss +2 -0
  28. data/test/dummy/app/controllers/application_controller.rb +5 -0
  29. data/test/dummy/app/controllers/blocks_controller.rb +92 -0
  30. data/test/dummy/app/controllers/concerns/.keep +0 -0
  31. data/test/dummy/app/helpers/.keep +0 -0
  32. data/test/dummy/app/mailers/.keep +0 -0
  33. data/test/dummy/app/models/.keep +0 -0
  34. data/test/dummy/app/models/block.rb +2 -0
  35. data/test/dummy/app/models/concerns/.keep +0 -0
  36. data/test/dummy/app/views/blocks/_form.html.haml +13 -0
  37. data/test/dummy/app/views/blocks/create.js.erb +2 -0
  38. data/test/dummy/app/views/blocks/destroy.js.erb +1 -0
  39. data/test/dummy/app/views/blocks/edit.html.haml +2 -0
  40. data/test/dummy/app/views/blocks/index.html.haml +38 -0
  41. data/test/dummy/app/views/blocks/new.html.haml +2 -0
  42. data/test/dummy/app/views/blocks/show.html.haml +8 -0
  43. data/test/dummy/app/views/blocks/update.js.erb +1 -0
  44. data/test/dummy/app/views/layouts/application.html.haml +11 -0
  45. data/test/dummy/bin/bundle +3 -0
  46. data/test/dummy/bin/rails +4 -0
  47. data/test/dummy/bin/rake +4 -0
  48. data/test/dummy/bin/setup +29 -0
  49. data/test/dummy/config/application.rb +34 -0
  50. data/test/dummy/config/boot.rb +5 -0
  51. data/test/dummy/config/database.yml +25 -0
  52. data/test/dummy/config/environment.rb +5 -0
  53. data/test/dummy/config/environments/development.rb +41 -0
  54. data/test/dummy/config/environments/production.rb +79 -0
  55. data/test/dummy/config/environments/test.rb +42 -0
  56. data/test/dummy/config/initializers/assets.rb +11 -0
  57. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  58. data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
  59. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  60. data/test/dummy/config/initializers/inflections.rb +16 -0
  61. data/test/dummy/config/initializers/mime_types.rb +4 -0
  62. data/test/dummy/config/initializers/session_store.rb +3 -0
  63. data/test/dummy/config/initializers/simple_form.rb +142 -0
  64. data/test/dummy/config/initializers/simple_form_bootstrap.rb +167 -0
  65. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  66. data/test/dummy/config/locales/en.yml +23 -0
  67. data/test/dummy/config/routes.rb +58 -0
  68. data/test/dummy/config/secrets.yml +22 -0
  69. data/test/dummy/config.ru +4 -0
  70. data/test/dummy/db/migrate/20160328122748_create_blocks.rb +12 -0
  71. data/test/dummy/lib/assets/.keep +0 -0
  72. data/test/dummy/log/.keep +0 -0
  73. data/test/dummy/public/404.html +67 -0
  74. data/test/dummy/public/422.html +67 -0
  75. data/test/dummy/public/500.html +66 -0
  76. data/test/dummy/public/favicon.ico +0 -0
  77. data/test/dummy/spec/javascripts/alert_spec.js.es6 +5 -0
  78. data/test/dummy/spec/javascripts/bb_crud_spec.js.es6 +5 -0
  79. data/test/dummy/spec/javascripts/helpers/.gitkeep +0 -0
  80. data/test/dummy/spec/javascripts/modals_spec.js.es6 +5 -0
  81. data/test/dummy/spec/javascripts/models_spec.js.es6 +5 -0
  82. data/test/dummy/spec/javascripts/support/jasmine.yml +50 -0
  83. data/test/dummy/spec/javascripts/support/jasmine_helper.rb +14 -0
  84. data/test/dummy/test/controllers/blocks_controller_test.rb +49 -0
  85. data/test/dummy/test/fixtures/blocks.yml +19 -0
  86. data/test/dummy/test/models/block_test.rb +11 -0
  87. data/test/generators/generator_test_base.rb +7 -0
  88. data/test/generators/haml_modal_crud_generator_test.rb +15 -0
  89. data/test/generators/install_generator_test.rb +14 -0
  90. data/test/generators/modal_crud_route_generator_test.rb +22 -0
  91. data/test/test_helper.rb +37 -0
  92. data/vendor/assets/javascripts/bootbox_crud_modals.js +33 -20
  93. data/vendor/assets/javascripts/sortable.js +11 -10
  94. data/vendor/assets/stylesheets/{bootbox_crud.css.scss → bootbox_crud.scss} +0 -0
  95. data/vendor/assets/stylesheets/bootbox_crud_main.scss +2 -0
  96. metadata +110 -6
  97. data/vendor/assets/stylesheets/bootbox_crud_main.css.scss +0 -2
@@ -0,0 +1,23 @@
1
+ # Files in the config/locales directory are used for internationalization
2
+ # and are automatically loaded by Rails. If you want to use locales other
3
+ # than English, add the necessary files in this directory.
4
+ #
5
+ # To use the locales, use `I18n.t`:
6
+ #
7
+ # I18n.t 'hello'
8
+ #
9
+ # In views, this is aliased to just `t`:
10
+ #
11
+ # <%= t('hello') %>
12
+ #
13
+ # To use a different locale, set it with `I18n.locale`:
14
+ #
15
+ # I18n.locale = :es
16
+ #
17
+ # This would use the information in config/locales/es.yml.
18
+ #
19
+ # To learn more, please read the Rails Internationalization guide
20
+ # available at http://guides.rubyonrails.org/i18n.html.
21
+
22
+ en:
23
+ hello: "Hello world"
@@ -0,0 +1,58 @@
1
+ Rails.application.routes.draw do
2
+ resources :blocks
3
+ mount JasmineRails::Engine => '/specs' if defined?(JasmineRails)
4
+ # The priority is based upon order of creation: first created -> highest priority.
5
+ # See how all your routes lay out with "rake routes".
6
+
7
+ # You can have the root of your site routed with "root"
8
+ # root 'welcome#index'
9
+
10
+ # Example of regular route:
11
+ # get 'products/:id' => 'catalog#view'
12
+
13
+ # Example of named route that can be invoked with purchase_url(id: product.id)
14
+ # get 'products/:id/purchase' => 'catalog#purchase', as: :purchase
15
+
16
+ # Example resource route (maps HTTP verbs to controller actions automatically):
17
+ # resources :products
18
+
19
+ # Example resource route with options:
20
+ # resources :products do
21
+ # member do
22
+ # get 'short'
23
+ # post 'toggle'
24
+ # end
25
+ #
26
+ # collection do
27
+ # get 'sold'
28
+ # end
29
+ # end
30
+
31
+ # Example resource route with sub-resources:
32
+ # resources :products do
33
+ # resources :comments, :sales
34
+ # resource :seller
35
+ # end
36
+
37
+ # Example resource route with more complex sub-resources:
38
+ # resources :products do
39
+ # resources :comments
40
+ # resources :sales do
41
+ # get 'recent', on: :collection
42
+ # end
43
+ # end
44
+
45
+ # Example resource route with concerns:
46
+ # concern :toggleable do
47
+ # post 'toggle'
48
+ # end
49
+ # resources :posts, concerns: :toggleable
50
+ # resources :photos, concerns: :toggleable
51
+
52
+ # Example resource route within a namespace:
53
+ # namespace :admin do
54
+ # # Directs /admin/products/* to Admin::ProductsController
55
+ # # (app/controllers/admin/products_controller.rb)
56
+ # resources :products
57
+ # end
58
+ end
@@ -0,0 +1,22 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Your secret key is used for verifying the integrity of signed cookies.
4
+ # If you change this key, all old signed cookies will become invalid!
5
+
6
+ # Make sure the secret is at least 30 characters and all random,
7
+ # no regular words or you'll be exposed to dictionary attacks.
8
+ # You can use `rake secret` to generate a secure secret key.
9
+
10
+ # Make sure the secrets in this file are kept private
11
+ # if you're sharing your code publicly.
12
+
13
+ development:
14
+ secret_key_base: 038556a5e29aa61109d2a893b793cfc5bdfcbe26bee7e439f684492bdae7bdba850683534eed4c6c9d276c0147b3e0936d39b9b8d9e25262b8712f674ffd94e9
15
+
16
+ test:
17
+ secret_key_base: 794cbb27258b988826f4fa286a16a2d5069225dd19052350336401c98211d08c34b2b3b364e7f4640b51a1d3442237b6cd7ea2c3f63497864a442d6006783fa8
18
+
19
+ # Do not keep production secrets in the repository,
20
+ # instead read values from the environment.
21
+ production:
22
+ secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
@@ -0,0 +1,4 @@
1
+ # This file is used by Rack-based servers to start the application.
2
+
3
+ require ::File.expand_path('../config/environment', __FILE__)
4
+ run Rails.application
@@ -0,0 +1,12 @@
1
+ class CreateBlocks < ActiveRecord::Migration
2
+ def change
3
+ create_table :blocks do |t|
4
+ t.string :name
5
+ t.integer :width
6
+ t.integer :height
7
+ t.integer :depth
8
+
9
+ t.timestamps null: false
10
+ end
11
+ end
12
+ end
File without changes
File without changes
@@ -0,0 +1,67 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The page you were looking for doesn't exist (404)</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <style>
7
+ body {
8
+ background-color: #EFEFEF;
9
+ color: #2E2F30;
10
+ text-align: center;
11
+ font-family: arial, sans-serif;
12
+ margin: 0;
13
+ }
14
+
15
+ div.dialog {
16
+ width: 95%;
17
+ max-width: 33em;
18
+ margin: 4em auto 0;
19
+ }
20
+
21
+ div.dialog > div {
22
+ border: 1px solid #CCC;
23
+ border-right-color: #999;
24
+ border-left-color: #999;
25
+ border-bottom-color: #BBB;
26
+ border-top: #B00100 solid 4px;
27
+ border-top-left-radius: 9px;
28
+ border-top-right-radius: 9px;
29
+ background-color: white;
30
+ padding: 7px 12% 0;
31
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
+ }
33
+
34
+ h1 {
35
+ font-size: 100%;
36
+ color: #730E15;
37
+ line-height: 1.5em;
38
+ }
39
+
40
+ div.dialog > p {
41
+ margin: 0 0 1em;
42
+ padding: 1em;
43
+ background-color: #F7F7F7;
44
+ border: 1px solid #CCC;
45
+ border-right-color: #999;
46
+ border-left-color: #999;
47
+ border-bottom-color: #999;
48
+ border-bottom-left-radius: 4px;
49
+ border-bottom-right-radius: 4px;
50
+ border-top-color: #DADADA;
51
+ color: #666;
52
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
+ }
54
+ </style>
55
+ </head>
56
+
57
+ <body>
58
+ <!-- This file lives in public/404.html -->
59
+ <div class="dialog">
60
+ <div>
61
+ <h1>The page you were looking for doesn't exist.</h1>
62
+ <p>You may have mistyped the address or the page may have moved.</p>
63
+ </div>
64
+ <p>If you are the application owner check the logs for more information.</p>
65
+ </div>
66
+ </body>
67
+ </html>
@@ -0,0 +1,67 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The change you wanted was rejected (422)</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <style>
7
+ body {
8
+ background-color: #EFEFEF;
9
+ color: #2E2F30;
10
+ text-align: center;
11
+ font-family: arial, sans-serif;
12
+ margin: 0;
13
+ }
14
+
15
+ div.dialog {
16
+ width: 95%;
17
+ max-width: 33em;
18
+ margin: 4em auto 0;
19
+ }
20
+
21
+ div.dialog > div {
22
+ border: 1px solid #CCC;
23
+ border-right-color: #999;
24
+ border-left-color: #999;
25
+ border-bottom-color: #BBB;
26
+ border-top: #B00100 solid 4px;
27
+ border-top-left-radius: 9px;
28
+ border-top-right-radius: 9px;
29
+ background-color: white;
30
+ padding: 7px 12% 0;
31
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
+ }
33
+
34
+ h1 {
35
+ font-size: 100%;
36
+ color: #730E15;
37
+ line-height: 1.5em;
38
+ }
39
+
40
+ div.dialog > p {
41
+ margin: 0 0 1em;
42
+ padding: 1em;
43
+ background-color: #F7F7F7;
44
+ border: 1px solid #CCC;
45
+ border-right-color: #999;
46
+ border-left-color: #999;
47
+ border-bottom-color: #999;
48
+ border-bottom-left-radius: 4px;
49
+ border-bottom-right-radius: 4px;
50
+ border-top-color: #DADADA;
51
+ color: #666;
52
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
+ }
54
+ </style>
55
+ </head>
56
+
57
+ <body>
58
+ <!-- This file lives in public/422.html -->
59
+ <div class="dialog">
60
+ <div>
61
+ <h1>The change you wanted was rejected.</h1>
62
+ <p>Maybe you tried to change something you didn't have access to.</p>
63
+ </div>
64
+ <p>If you are the application owner check the logs for more information.</p>
65
+ </div>
66
+ </body>
67
+ </html>
@@ -0,0 +1,66 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>We're sorry, but something went wrong (500)</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <style>
7
+ body {
8
+ background-color: #EFEFEF;
9
+ color: #2E2F30;
10
+ text-align: center;
11
+ font-family: arial, sans-serif;
12
+ margin: 0;
13
+ }
14
+
15
+ div.dialog {
16
+ width: 95%;
17
+ max-width: 33em;
18
+ margin: 4em auto 0;
19
+ }
20
+
21
+ div.dialog > div {
22
+ border: 1px solid #CCC;
23
+ border-right-color: #999;
24
+ border-left-color: #999;
25
+ border-bottom-color: #BBB;
26
+ border-top: #B00100 solid 4px;
27
+ border-top-left-radius: 9px;
28
+ border-top-right-radius: 9px;
29
+ background-color: white;
30
+ padding: 7px 12% 0;
31
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
+ }
33
+
34
+ h1 {
35
+ font-size: 100%;
36
+ color: #730E15;
37
+ line-height: 1.5em;
38
+ }
39
+
40
+ div.dialog > p {
41
+ margin: 0 0 1em;
42
+ padding: 1em;
43
+ background-color: #F7F7F7;
44
+ border: 1px solid #CCC;
45
+ border-right-color: #999;
46
+ border-left-color: #999;
47
+ border-bottom-color: #999;
48
+ border-bottom-left-radius: 4px;
49
+ border-bottom-right-radius: 4px;
50
+ border-top-color: #DADADA;
51
+ color: #666;
52
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
+ }
54
+ </style>
55
+ </head>
56
+
57
+ <body>
58
+ <!-- This file lives in public/500.html -->
59
+ <div class="dialog">
60
+ <div>
61
+ <h1>We're sorry, but something went wrong.</h1>
62
+ </div>
63
+ <p>If you are the application owner check the logs for more information.</p>
64
+ </div>
65
+ </body>
66
+ </html>
File without changes
@@ -0,0 +1,5 @@
1
+ describe("BBCrud.Alert", () => {
2
+ it("BBCrud.Alert is defined", () => {
3
+ expect(BBCrud.Alert).toBeDefined();
4
+ });
5
+ });
@@ -0,0 +1,5 @@
1
+ describe("BBCrud", () => {
2
+ it("BBCrud is defined", () => {
3
+ expect(BBCrud).toBeDefined();
4
+ });
5
+ });
File without changes
@@ -0,0 +1,5 @@
1
+ describe("BBCrud.Modals", () => {
2
+ it("BBCrud.Modals is defined", () => {
3
+ expect(BBCrud.Modals).toBeDefined();
4
+ });
5
+ });
@@ -0,0 +1,5 @@
1
+ describe("BBCrud.Models", () => {
2
+ it("BBCrud.Models is defined", () => {
3
+ expect(BBCrud.Models).toBeDefined();
4
+ });
5
+ });
@@ -0,0 +1,50 @@
1
+ # path to parent directory of src_files
2
+ # relative path from Rails.root
3
+ # defaults to app/assets/javascripts
4
+ src_dir: "app/assets/javascripts"
5
+
6
+ # path to additional directory of source file that are not part of assets pipeline and need to be included
7
+ # relative path from Rails.root
8
+ # defaults to []
9
+ # include_dir:
10
+ # - ../mobile_app/public/js
11
+
12
+ # path to parent directory of css_files
13
+ # relative path from Rails.root
14
+ # defaults to app/assets/stylesheets
15
+ css_dir: "app/assets/stylesheets"
16
+
17
+ # list of file expressions to include as source files
18
+ # relative path from src_dir
19
+ src_files:
20
+ - "*.{js.es6,js,es6}"
21
+
22
+ # list of file expressions to include as css files
23
+ # relative path from css_dir
24
+ css_files:
25
+
26
+ # path to parent directory of spec_files
27
+ # relative path from Rails.root
28
+ #
29
+ # Alternatively accept an array of directory to include external spec files
30
+ # spec_dir:
31
+ # - spec/javascripts
32
+ # - ../engine/spec/javascripts
33
+ #
34
+ # defaults to spec/javascripts
35
+ spec_dir: spec/javascripts
36
+
37
+ # list of file expressions to include as helpers into spec runner
38
+ # relative path from spec_dir
39
+ helpers:
40
+ - "helpers/**/*.{js.es6,js,es6}"
41
+
42
+ # list of file expressions to include as specs into spec runner
43
+ # relative path from spec_dir
44
+ spec_files:
45
+ - "**/*[Ss]pec.{js.es6,js,es6}"
46
+
47
+ # path to directory of temporary files
48
+ # (spec runner and asset cache)
49
+ # defaults to tmp/jasmine
50
+ tmp_dir: "tmp/jasmine"
@@ -0,0 +1,14 @@
1
+ #Use this file to set/override Jasmine configuration options
2
+ #You can remove it if you don't need it.
3
+ #This file is loaded *after* jasmine.yml is interpreted.
4
+ #
5
+ #Example: using a different boot file.
6
+ #Jasmine.configure do |config|
7
+ # config.boot_dir = '/absolute/path/to/boot_dir'
8
+ # config.boot_files = lambda { ['/absolute/path/to/boot_dir/file.js'] }
9
+ #end
10
+ #
11
+ #Example: prevent PhantomJS auto install, uses PhantomJS already on your path.
12
+ #Jasmine.configure do |config|
13
+ # config.prevent_phantom_js_auto_install = true
14
+ #end
@@ -0,0 +1,49 @@
1
+ require "test_helper"
2
+
3
+ class BlocksControllerTest < ActionController::TestCase
4
+ def block
5
+ @block ||= blocks :one
6
+ end
7
+
8
+ def test_index
9
+ get :index
10
+ assert_response :success
11
+ assert_not_nil assigns(:blocks)
12
+ end
13
+
14
+ def test_new
15
+ get :new
16
+ assert_response :success
17
+ end
18
+
19
+ def test_create
20
+ assert_difference("Block.count") do
21
+ post :create, block: { depth: block.depth, height: block.height, name: block.name, width: block.width }
22
+ end
23
+
24
+ assert_redirected_to block_path(assigns(:block))
25
+ end
26
+
27
+ def test_show
28
+ get :show, id: block
29
+ assert_response :success
30
+ end
31
+
32
+ def test_edit
33
+ get :edit, id: block
34
+ assert_response :success
35
+ end
36
+
37
+ def test_update
38
+ put :update, id: block, block: { depth: block.depth, height: block.height, name: block.name, width: block.width }
39
+ assert_redirected_to block_path(assigns(:block))
40
+ end
41
+
42
+ def test_destroy
43
+ assert_difference("Block.count", -1) do
44
+ delete :destroy, id: block
45
+ end
46
+
47
+ assert_redirected_to blocks_path
48
+ end
49
+ end
@@ -0,0 +1,19 @@
1
+ # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
2
+
3
+ one:
4
+ name: Lego
5
+ width: 1
6
+ height: 1
7
+ depth: 1
8
+
9
+ two:
10
+ name: Big block
11
+ width: 10
12
+ height: 10
13
+ depth: 10
14
+
15
+ three:
16
+ name: Container
17
+ width: 100
18
+ height: 100
19
+ depth: 100
@@ -0,0 +1,11 @@
1
+ require "test_helper"
2
+
3
+ class BlockTest < ActiveSupport::TestCase
4
+ def block
5
+ @block ||= Block.new
6
+ end
7
+
8
+ def test_valid
9
+ assert block.valid?
10
+ end
11
+ end
@@ -0,0 +1,7 @@
1
+ class GeneratorTestBase < Rails::Generators::TestCase
2
+ destination File.expand_path('../../tmp', __FILE__)
3
+
4
+ setup do
5
+ prepare_destination
6
+ end
7
+ end
@@ -0,0 +1,15 @@
1
+ require 'test_helper'
2
+
3
+ require 'generators/rails/haml_modal_crud/haml_modal_crud_generator'
4
+
5
+ class HamlModalCrudGeneratorTest < GeneratorTestBase
6
+ tests Rails::HamlModalCrudGenerator
7
+
8
+ test 'Assert generator creates Block view partials for modals' do
9
+ run_generator %w(Block name width:integer height:integer depth:integer)
10
+ partial_file_content = /model: @block, form_path: 'blocks\/form'/
11
+ assert_file 'app/views/blocks/create.js.erb', partial_file_content
12
+ assert_file 'app/views/blocks/update.js.erb', partial_file_content
13
+ assert_file 'app/views/blocks/destroy.js.erb', partial_file_content
14
+ end
15
+ end
@@ -0,0 +1,14 @@
1
+ require 'test_helper'
2
+
3
+ require 'generators/bootbox_crud/install_generator'
4
+
5
+ class InstallGeneratorTest < GeneratorTestBase
6
+ tests BootboxCrud::InstallGenerator
7
+
8
+ test 'Assert installer copied template files' do
9
+ run_generator
10
+ assert_file 'config/initializers/simple_form.rb'
11
+ assert_file 'config/initializers/simple_form_bootstrap.rb'
12
+ assert_file 'app/assets/javascripts/models.js'
13
+ end
14
+ end
@@ -0,0 +1,22 @@
1
+ require 'test_helper'
2
+ require 'mocha/mini_test'
3
+
4
+ require 'generators/rails/modal_crud_route/modal_crud_route_generator'
5
+
6
+ class ModalCrudRouteGeneratorTest < GeneratorTestBase
7
+ # include Mocha::Integration::MiniTest
8
+ tests Rails::ModalCrudRouteGenerator
9
+
10
+ test 'Assert generator creates Block view partials for modals' do
11
+ stub_application_assets
12
+ run_generator %w(Block name width:integer height:integer depth:integer)
13
+ partial_file_content = /'Block', '\/blocks\/', 'block'/
14
+ assert_file 'app/assets/javascripts/models.js', partial_file_content
15
+ end
16
+
17
+ def stub_application_assets
18
+ assets = mock('assets', :find_asset =>'')
19
+ application = mock('application', :assets => assets)
20
+ Rails.stubs(:application).returns(application)
21
+ end
22
+ end
@@ -0,0 +1,37 @@
1
+ ENV['RAILS_ENV'] = 'test'
2
+
3
+ require 'codeclimate-test-reporter'
4
+ CodeClimate::TestReporter.start
5
+
6
+ require File.expand_path("../../test/dummy/config/environment.rb", __FILE__)
7
+ ActiveRecord::Migrator.migrations_paths = [File.expand_path("../../test/dummy/db/migrate", __FILE__)]
8
+
9
+ #require 'rails'
10
+ require 'rails/test_help'
11
+ require 'rails/generators/base'
12
+ require 'rails/generators/test_case'
13
+ require 'generators/generator_test_base'
14
+ require 'minitest/rails'
15
+
16
+ # Filter out Minitest backtrace while allowing backtrace from other libraries
17
+ # to be shown.
18
+ Minitest.backtrace_filter = Minitest::BacktraceFilter.new
19
+
20
+ # Load support files
21
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
22
+
23
+
24
+ class ActiveSupport::TestCase
25
+ # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
26
+ fixtures :all
27
+ end
28
+
29
+ # Load fixtures from the engine
30
+ if ActiveSupport::TestCase.respond_to?(:fixture_path=)
31
+ ActiveSupport::TestCase.fixture_path = File.expand_path("#{Rails.root}/test/fixtures")
32
+ ActionDispatch::IntegrationTest.fixture_path = ActiveSupport::TestCase.fixture_path
33
+ end
34
+
35
+ if ActiveSupport.respond_to?(:test_order)
36
+ ActiveSupport.test_order = :random
37
+ end