careacademy-acl9 3.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (138) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +24 -0
  3. data/.ruby-version +1 -0
  4. data/.travis.yml +26 -0
  5. data/Appraisals +23 -0
  6. data/CHANGELOG.md +122 -0
  7. data/CONTRIBUTING.md +62 -0
  8. data/Gemfile +7 -0
  9. data/Gemfile.lock +167 -0
  10. data/LICENSE +9 -0
  11. data/MIT-LICENSE +20 -0
  12. data/README.md +326 -0
  13. data/Rakefile +20 -0
  14. data/TODO +42 -0
  15. data/acl9.gemspec +27 -0
  16. data/bin/appraisal +16 -0
  17. data/bin/bundler +16 -0
  18. data/bin/cc-tddium-post-worker +16 -0
  19. data/bin/erubis +16 -0
  20. data/bin/rackup +16 -0
  21. data/bin/rails +16 -0
  22. data/bin/rake +16 -0
  23. data/bin/sprockets +16 -0
  24. data/bin/tapout +16 -0
  25. data/bin/thor +16 -0
  26. data/bin/tilt +16 -0
  27. data/bin/yard +16 -0
  28. data/bin/yardoc +16 -0
  29. data/bin/yri +16 -0
  30. data/gemfiles/.bundle/config +2 -0
  31. data/gemfiles/rails_5.0.gemfile +10 -0
  32. data/gemfiles/rails_5.1.gemfile +10 -0
  33. data/gemfiles/rails_5.2.gemfile +9 -0
  34. data/gemfiles/rails_6.0.gemfile +9 -0
  35. data/gemfiles/rails_6.1.gemfile +9 -0
  36. data/gemfiles/rails_7.0.gemfile +9 -0
  37. data/lib/acl9/controller_extensions/dsl_base.rb +212 -0
  38. data/lib/acl9/controller_extensions/generators.rb +166 -0
  39. data/lib/acl9/controller_extensions.rb +85 -0
  40. data/lib/acl9/helpers.rb +49 -0
  41. data/lib/acl9/model_extensions/for_object.rb +74 -0
  42. data/lib/acl9/model_extensions/for_subject.rb +232 -0
  43. data/lib/acl9/model_extensions.rb +136 -0
  44. data/lib/acl9/prepositions.rb +18 -0
  45. data/lib/acl9/version.rb +3 -0
  46. data/lib/acl9.rb +78 -0
  47. data/lib/generators/acl9/setup/USAGE +35 -0
  48. data/lib/generators/acl9/setup/setup_generator.rb +122 -0
  49. data/lib/generators/acl9/setup/templates/create_role_tables.rb +31 -0
  50. data/lib/generators/acl9/setup/templates/role.rb +3 -0
  51. data/test/config_test.rb +55 -0
  52. data/test/controller_extensions/actions_test.rb +199 -0
  53. data/test/controller_extensions/anon_test.rb +39 -0
  54. data/test/controller_extensions/base.rb +96 -0
  55. data/test/controller_extensions/basics_test.rb +44 -0
  56. data/test/controller_extensions/conditions_test.rb +48 -0
  57. data/test/controller_extensions/method_test.rb +70 -0
  58. data/test/controller_extensions/multi_match_test.rb +142 -0
  59. data/test/controller_extensions/multiple_role_arguments_test.rb +136 -0
  60. data/test/controller_extensions/prepositions_test.rb +108 -0
  61. data/test/controller_extensions/pseudo_role_test.rb +26 -0
  62. data/test/controller_extensions/role_test.rb +75 -0
  63. data/test/controllers/acl_action_override_test.rb +24 -0
  64. data/test/controllers/acl_arguments_test.rb +5 -0
  65. data/test/controllers/acl_block_test.rb +5 -0
  66. data/test/controllers/acl_boolean_method_test.rb +5 -0
  67. data/test/controllers/acl_helper_method_test.rb +29 -0
  68. data/test/controllers/acl_ivars_test.rb +15 -0
  69. data/test/controllers/acl_method2_test.rb +6 -0
  70. data/test/controllers/acl_method_test.rb +6 -0
  71. data/test/controllers/acl_object_hash_test.rb +18 -0
  72. data/test/controllers/acl_query_method_named_test.rb +9 -0
  73. data/test/controllers/acl_query_method_test.rb +9 -0
  74. data/test/controllers/acl_query_method_with_lambda_test.rb +9 -0
  75. data/test/controllers/acl_query_mixin.rb +54 -0
  76. data/test/controllers/acl_subject_method_test.rb +15 -0
  77. data/test/controllers/arguments_checking_test.rb +43 -0
  78. data/test/dummy/app/assets/config/manifest.js +0 -0
  79. data/test/dummy/app/controllers/acl_action_override.rb +15 -0
  80. data/test/dummy/app/controllers/acl_arguments.rb +10 -0
  81. data/test/dummy/app/controllers/acl_block.rb +6 -0
  82. data/test/dummy/app/controllers/acl_boolean_method.rb +23 -0
  83. data/test/dummy/app/controllers/acl_helper_method.rb +11 -0
  84. data/test/dummy/app/controllers/acl_ivars.rb +17 -0
  85. data/test/dummy/app/controllers/acl_method.rb +6 -0
  86. data/test/dummy/app/controllers/acl_method2.rb +6 -0
  87. data/test/dummy/app/controllers/acl_objects_hash.rb +10 -0
  88. data/test/dummy/app/controllers/acl_query_method.rb +9 -0
  89. data/test/dummy/app/controllers/acl_query_method_named.rb +15 -0
  90. data/test/dummy/app/controllers/acl_query_method_with_lambda.rb +9 -0
  91. data/test/dummy/app/controllers/acl_subject_method.rb +16 -0
  92. data/test/dummy/app/controllers/application_controller.rb +13 -0
  93. data/test/dummy/app/controllers/empty_controller.rb +5 -0
  94. data/test/dummy/app/helpers/application_helper.rb +2 -0
  95. data/test/dummy/app/helpers/some_helper.rb +8 -0
  96. data/test/dummy/app/models/.keep +0 -0
  97. data/test/dummy/app/models/access.rb +3 -0
  98. data/test/dummy/app/models/account.rb +3 -0
  99. data/test/dummy/app/models/bar.rb +3 -0
  100. data/test/dummy/app/models/concerns/.keep +0 -0
  101. data/test/dummy/app/models/foo.rb +3 -0
  102. data/test/dummy/app/models/foo_bar.rb +3 -0
  103. data/test/dummy/app/models/other/foo.rb +5 -0
  104. data/test/dummy/app/models/other/role.rb +5 -0
  105. data/test/dummy/app/models/other/user.rb +5 -0
  106. data/test/dummy/app/models/role.rb +3 -0
  107. data/test/dummy/app/models/string_object_role.rb +3 -0
  108. data/test/dummy/app/models/string_user.rb +3 -0
  109. data/test/dummy/app/models/user.rb +3 -0
  110. data/test/dummy/app/models/uuid.rb +4 -0
  111. data/test/dummy/config/application.rb +23 -0
  112. data/test/dummy/config/boot.rb +4 -0
  113. data/test/dummy/config/database.yml +25 -0
  114. data/test/dummy/config/environment.rb +5 -0
  115. data/test/dummy/config/environments/development.rb +37 -0
  116. data/test/dummy/config/environments/test.rb +40 -0
  117. data/test/dummy/config/initializers/assets.rb +8 -0
  118. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  119. data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
  120. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  121. data/test/dummy/config/initializers/inflections.rb +16 -0
  122. data/test/dummy/config/initializers/mime_types.rb +4 -0
  123. data/test/dummy/config/initializers/secrets.rb +1 -0
  124. data/test/dummy/config/initializers/session_store.rb +3 -0
  125. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  126. data/test/dummy/config/locales/en.yml +23 -0
  127. data/test/dummy/config/routes.rb +14 -0
  128. data/test/dummy/config.ru +4 -0
  129. data/test/dummy/db/migrate/20141117132218_create_tables.rb +149 -0
  130. data/test/helpers/helper_test.rb +89 -0
  131. data/test/models/roles_test.rb +369 -0
  132. data/test/models/roles_with_custom_association_names_test.rb +28 -0
  133. data/test/models/roles_with_custom_class_names_test.rb +28 -0
  134. data/test/models/system_roles_test.rb +22 -0
  135. data/test/models/users_roles_and_subjects_with_namespaced_class_names_test.rb +30 -0
  136. data/test/test_helper.rb +94 -0
  137. data/test/version_test.rb +7 -0
  138. metadata +321 -0
@@ -0,0 +1,11 @@
1
+ class ACLHelperMethod < ApplicationController
2
+ access_control :helper => :foo? do
3
+ allow :owner, :of => :foo
4
+ end
5
+
6
+ def allow
7
+ @foo = Foo.first
8
+
9
+ render inline: "<div><%= foo? ? 'OK' : 'AccessDenied' %></div>"
10
+ end
11
+ end
@@ -0,0 +1,17 @@
1
+ class ACLIvars < EmptyController
2
+
3
+ before_action :set_ivars
4
+
5
+ access_control do
6
+ action :destroy do
7
+ allow :owner, of: :foo
8
+ allow :bartender, at: Foo
9
+ end
10
+ end
11
+
12
+ private
13
+
14
+ def set_ivars
15
+ @foo = Bar
16
+ end
17
+ end
@@ -0,0 +1,6 @@
1
+ class ACLMethod < EmptyController
2
+ access_control :as_method => :acl do
3
+ allow all, :to => [:index, :show]
4
+ allow :admin, :except => [:index, :show]
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ class ACLMethod2 < EmptyController
2
+ access_control :acl do
3
+ allow all, :to => [:index, :show]
4
+ allow :admin, :except => [:index, :show]
5
+ end
6
+ end
@@ -0,0 +1,10 @@
1
+ class ACLObjectsHash < ApplicationController
2
+ access_control :allowed?, :filter => false do
3
+ allow :owner, :of => :foo
4
+ end
5
+
6
+ def allow
7
+ @foo = nil
8
+ head allowed?( :foo => Foo.find_by_id(params[:user_id]) ) ? :ok : :unauthorized
9
+ end
10
+ end
@@ -0,0 +1,9 @@
1
+ class ACLQueryMethod < ApplicationController
2
+ attr_accessor :current_user
3
+
4
+ access_control :acl, :query_method => true do
5
+ allow :editor, :to => [:edit, :update, :destroy]
6
+ allow :viewer, :to => [:index, :show]
7
+ allow :owner, :of => :foo, :to => :fooize
8
+ end
9
+ end
@@ -0,0 +1,15 @@
1
+ class ACLQueryMethodNamed < ApplicationController
2
+ attr_accessor :current_user
3
+
4
+ access_control :acl, :query_method => 'allow_ay' do
5
+ allow :editor, :to => [:edit, :update, :destroy]
6
+ allow :viewer, :to => [:index, :show]
7
+ allow :owner, :of => :foo, :to => :fooize
8
+ end
9
+
10
+ def acl?(*args)
11
+ @foo = Foo.first
12
+
13
+ allow_ay(*args)
14
+ end
15
+ end
@@ -0,0 +1,9 @@
1
+ class ACLQueryMethodWithLambda < ApplicationController
2
+ attr_accessor :current_user
3
+
4
+ access_control :query_method => :acl? do
5
+ allow :editor, :to => [:edit, :update, :destroy]
6
+ allow :viewer, :to => [:index, :show]
7
+ allow :owner, :of => :foo, :to => :fooize
8
+ end
9
+ end
@@ -0,0 +1,16 @@
1
+ class ACLSubjectMethod < ApplicationController
2
+ access_control :subject_method => :the_only_user do
3
+ allow :the_only_one
4
+ end
5
+
6
+ def index
7
+ head :ok
8
+ end
9
+
10
+ private
11
+
12
+ alias_method :the_only_user, :current_user
13
+ def current_user
14
+ raise "ACK!"
15
+ end
16
+ end
@@ -0,0 +1,13 @@
1
+ class ApplicationController < ActionController::Base
2
+ before_action :before_action
3
+
4
+ attr_accessor :current_user
5
+
6
+ def current_user
7
+ @current_user ||= User.find params[:user_id] if params[:user_id]
8
+ end
9
+
10
+ def before_action
11
+ @foo = Foo.first
12
+ end
13
+ end
@@ -0,0 +1,5 @@
1
+ class EmptyController < ApplicationController
2
+ %i[index show new edit create update destroy].each do |action|
3
+ define_method(action) { render plain: 'OK' }
4
+ end
5
+ end
@@ -0,0 +1,2 @@
1
+ module ApplicationHelper
2
+ end
@@ -0,0 +1,8 @@
1
+ module SomeHelper
2
+ include Acl9Helpers
3
+
4
+ access_control :the_question do
5
+ allow :hamlet, :to => :be
6
+ allow :hamlet, :except => :be
7
+ end
8
+ end
File without changes
@@ -0,0 +1,3 @@
1
+ class Access < ActiveRecord::Base
2
+ acts_as_authorization_role :subject_class_name => "Account"
3
+ end
@@ -0,0 +1,3 @@
1
+ class Account < ActiveRecord::Base
2
+ acts_as_authorization_subject association_name: :roles, role_class_name: 'Access'
3
+ end
@@ -0,0 +1,3 @@
1
+ class Bar < ActiveRecord::Base
2
+ acts_as_authorization_object
3
+ end
File without changes
@@ -0,0 +1,3 @@
1
+ class Foo < ActiveRecord::Base
2
+ acts_as_authorization_object
3
+ end
@@ -0,0 +1,3 @@
1
+ class FooBar < ActiveRecord::Base
2
+ acts_as_authorization_object :role_class_name => 'Access', :subject_class_name => 'Account'
3
+ end
@@ -0,0 +1,5 @@
1
+ module Other
2
+ class Foo < ActiveRecord::Base
3
+ acts_as_authorization_object :role_class_name => 'Other::Role', :subject_class_name => "Other::User"
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ module Other
2
+ class Role < ActiveRecord::Base
3
+ acts_as_authorization_role :join_table_name => "other_roles_users", :subject_class_name => "Other::User"
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ module Other
2
+ class User < ActiveRecord::Base
3
+ acts_as_authorization_subject :association_name => :roles, :join_table_name => "other_roles_users", :role_class_name => "Other::Role"
4
+ end
5
+ end
@@ -0,0 +1,3 @@
1
+ class Role < ActiveRecord::Base
2
+ acts_as_authorization_role
3
+ end
@@ -0,0 +1,3 @@
1
+ class StringObjectRole < ActiveRecord::Base
2
+ acts_as_authorization_role subject_class_name: "StringUser"
3
+ end
@@ -0,0 +1,3 @@
1
+ class StringUser < ActiveRecord::Base
2
+ acts_as_authorization_subject role_class_name: "StringObjectRole"
3
+ end
@@ -0,0 +1,3 @@
1
+ class User < ActiveRecord::Base
2
+ acts_as_authorization_subject
3
+ end
@@ -0,0 +1,4 @@
1
+ class Uuid < ActiveRecord::Base
2
+ self.primary_key = "uuid"
3
+ acts_as_authorization_object role_class_name: "StringObjectRole", subject_class_name: "StringUser"
4
+ end
@@ -0,0 +1,23 @@
1
+ require File.expand_path('../boot', __FILE__)
2
+
3
+ require 'rails/all'
4
+
5
+ # Require the gems listed in Gemfile, including any gems
6
+ # you've limited to :test, :development, or :production.
7
+ Bundler.require
8
+
9
+ module Dummy
10
+ class Application < Rails::Application
11
+ # Settings in config/environments/* take precedence over those specified here.
12
+ # Application configuration should go into files in config/initializers
13
+ # -- all .rb files in that directory are automatically loaded.
14
+
15
+ # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
16
+ # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
17
+ # config.time_zone = 'Central Time (US & Canada)'
18
+
19
+ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
20
+ # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
21
+ # config.i18n.default_locale = :de
22
+ end
23
+ end
@@ -0,0 +1,4 @@
1
+ # Set up gems listed in the Gemfile.
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
3
+
4
+ require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
@@ -0,0 +1,25 @@
1
+ # SQLite version 3.x
2
+ # gem install sqlite3
3
+ #
4
+ # Ensure the SQLite 3 gem is defined in your Gemfile
5
+ # gem 'sqlite3'
6
+ #
7
+ default: &default
8
+ adapter: sqlite3
9
+ pool: 5
10
+ timeout: 5000
11
+
12
+ development:
13
+ <<: *default
14
+ database: ':memory:'
15
+
16
+ # Warning: The database defined as "test" will be erased and
17
+ # re-generated from your development database when you run "rake".
18
+ # Do not set this db to the same as development or production.
19
+ test:
20
+ <<: *default
21
+ database: ':memory:'
22
+
23
+ production:
24
+ <<: *default
25
+ database: ':memory:'
@@ -0,0 +1,5 @@
1
+ # Load the Rails application.
2
+ require File.expand_path('../application', __FILE__)
3
+
4
+ # Initialize the Rails application.
5
+ Dummy::Application.initialize!
@@ -0,0 +1,37 @@
1
+ Dummy::Application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb.
3
+
4
+ # In the development environment your application's code is reloaded on
5
+ # every request. This slows down response time but is perfect for development
6
+ # since you don't have to restart the web server when you make code changes.
7
+ config.cache_classes = false
8
+
9
+ # Do not eager load code on boot.
10
+ config.eager_load = false
11
+
12
+ # Show full error reports and disable caching.
13
+ config.consider_all_requests_local = true
14
+ config.action_controller.perform_caching = false
15
+
16
+ # Don't care if the mailer can't send.
17
+ config.action_mailer.raise_delivery_errors = false
18
+
19
+ # Print deprecation notices to the Rails logger.
20
+ config.active_support.deprecation = :log
21
+
22
+ # Raise an error on page load if there are pending migrations.
23
+ config.active_record.migration_error = :page_load
24
+
25
+ # Debug mode disables concatenation and preprocessing of assets.
26
+ # This option may cause significant delays in view rendering with a large
27
+ # number of complex assets.
28
+ config.assets.debug = true
29
+
30
+ # Adds additional error checking when serving assets at runtime.
31
+ # Checks for improperly declared sprockets dependencies.
32
+ # Raises helpful error messages.
33
+ config.assets.raise_runtime_errors = true
34
+
35
+ # Raises error for missing translations
36
+ # config.action_view.raise_on_missing_translations = true
37
+ end
@@ -0,0 +1,40 @@
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
+ # Do not eager load code on boot. This avoids loading your whole application
11
+ # just for the purpose of running a single test. If you are using a tool that
12
+ # preloads Rails for running tests, you may have to set it to true.
13
+ config.eager_load = false
14
+
15
+ # Configure static asset server for tests with Cache-Control for performance.
16
+ config.public_file_server.enabled = true
17
+ config.public_file_server.headers = { 'Cache-Control' => 'public, max-age=3600' }
18
+
19
+ # Show full error reports and disable caching.
20
+ config.consider_all_requests_local = true
21
+ config.action_controller.perform_caching = false
22
+
23
+ # Raise exceptions instead of rendering exception templates.
24
+ config.action_dispatch.show_exceptions = false
25
+
26
+ # Disable request forgery protection in test environment.
27
+ config.action_controller.allow_forgery_protection = false
28
+
29
+ # Tell Action Mailer not to deliver emails to the real world.
30
+ # The :test delivery method accumulates sent emails in the
31
+ # ActionMailer::Base.deliveries array.
32
+ config.action_mailer.delivery_method = :test
33
+
34
+ # Print deprecation notices to the stderr.
35
+ config.active_support.deprecation = :stderr
36
+
37
+ # Raises error for missing translations
38
+ # config.action_view.raise_on_missing_translations = true
39
+ config.log_level = :unknown
40
+ end
@@ -0,0 +1,8 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Version of your assets, change this if you want to expire all your assets.
4
+ Dummy::Application.config.assets.version = '1.0'
5
+
6
+ # Precompile additional assets.
7
+ # application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
8
+ # Rails.application.config.assets.precompile += %w( search.js )
@@ -0,0 +1,7 @@
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!
@@ -0,0 +1,3 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ Dummy::Application.config.action_dispatch.cookies_serializer = :json
@@ -0,0 +1,4 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Configure sensitive parameters which will be filtered from the log file.
4
+ Dummy::Application.config.filter_parameters += [:password]
@@ -0,0 +1,16 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Add new inflection rules using the following format. Inflections
4
+ # are locale specific, and you may define rules for as many different
5
+ # locales as you wish. All of these examples are active by default:
6
+ # ActiveSupport::Inflector.inflections(:en) do |inflect|
7
+ # inflect.plural /^(ox)$/i, '\1en'
8
+ # inflect.singular /^(ox)en/i, '\1'
9
+ # inflect.irregular 'person', 'people'
10
+ # inflect.uncountable %w( fish sheep )
11
+ # end
12
+
13
+ # These inflection rules are supported but not enabled by default:
14
+ # ActiveSupport::Inflector.inflections(:en) do |inflect|
15
+ # inflect.acronym 'RESTful'
16
+ # end
@@ -0,0 +1,4 @@
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
@@ -0,0 +1 @@
1
+ Dummy::Application.config.secret_key_base = 'b29f2acba41e296f52ae4e3d11de570df29f69fe1ca9cad18634fec6fc2569d0b32ce5f66a822758a80bf6c9c828b038e0366f098397df636479b4ec437c9a46'
@@ -0,0 +1,3 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ Dummy::Application.config.session_store :cookie_store, key: '_dummy_session'
@@ -0,0 +1,14 @@
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] if respond_to?(:wrap_parameters)
9
+ end
10
+
11
+ # To enable root element in JSON for ActiveRecord objects.
12
+ # ActiveSupport.on_load(:active_record) do
13
+ # self.include_root_in_json = true
14
+ # end
@@ -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,14 @@
1
+ Dummy::Application.routes.draw do
2
+ resources :acl_action_override do
3
+ collection do
4
+ get :check_allow_with_foo
5
+ get :check_allow
6
+ end
7
+ end
8
+
9
+ resources :acl_boolean_method, :acl_block, :acl_ivars, :acl_method, :acl_method2, :acl_subject_method, :acl_arguments
10
+
11
+ get :acl_helper_method, to: "acl_helper_method#allow"
12
+ get :acl_objects_hash, to: "acl_objects_hash#allow"
13
+
14
+ end
@@ -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 Dummy::Application
@@ -0,0 +1,149 @@
1
+ class CreateTables < ActiveRecord::Migration[ActiveRecord::Migration.current_version]
2
+ def self.r5?
3
+ Rails.gem_version >= Gem::Version.new(5)
4
+ end
5
+ def r5?
6
+ self.class.r5?
7
+ end
8
+
9
+ def change
10
+ create_table :roles do |t|
11
+ t.string :name, :limit => 40
12
+ t.boolean :system
13
+ if r5?
14
+ t.references :authorizable, polymorphic: true
15
+ else
16
+ t.string :authorizable_type, :limit => 40
17
+ t.integer :authorizable_id
18
+ end
19
+ t.timestamps null: false
20
+ end
21
+
22
+ unless r5?
23
+ add_index :roles, [:authorizable_type, :authorizable_id]
24
+ end
25
+
26
+ create_table :roles_users, id: false do |t|
27
+ t.references :user
28
+ t.references :role
29
+ end
30
+
31
+ unless r5?
32
+ add_index :roles_users, :user_id
33
+ add_index :roles_users, :role_id
34
+ end
35
+
36
+ create_table :users do |t|
37
+ t.string :name
38
+ t.timestamps null: false
39
+ end
40
+
41
+ create_table :foos do |t|
42
+ t.string :name
43
+ t.timestamps null: false
44
+ end
45
+
46
+ create_table :bars do |t|
47
+ t.string :name
48
+ t.timestamps null: false
49
+ end
50
+
51
+ create_table :uuids, id: false do |t|
52
+ t.string :uuid, primary_key: true
53
+ t.string :name
54
+ t.timestamps null: false
55
+ end
56
+
57
+ create_table :string_object_roles do |t|
58
+ t.string :name
59
+ t.boolean :system
60
+ t.string :authorizable_type
61
+ t.string :authorizable_id
62
+ t.timestamps null: false
63
+ end
64
+
65
+ create_table :string_object_roles_string_users, id: false do |t|
66
+ t.references :string_user, index: { name: "susor" }
67
+ t.references :string_object_role, index: { name: "sorsu" }
68
+ end
69
+
70
+ create_table :string_users do |t|
71
+ t.string :name
72
+ t.timestamps null: false
73
+ end
74
+
75
+
76
+ create_table :accounts do |t|
77
+ t.string :name
78
+ t.timestamps null: false
79
+ end
80
+
81
+ create_table :accesses do |t|
82
+ t.string :name
83
+ t.boolean :system
84
+ if r5?
85
+ t.references :authorizable, polymorphic: true
86
+ else
87
+ t.string :authorizable_type, :limit => 40
88
+ t.integer :authorizable_id
89
+ end
90
+ t.timestamps null: false
91
+ end
92
+
93
+ unless r5?
94
+ add_index :accesses, [:authorizable_type, :authorizable_id]
95
+ end
96
+
97
+ create_table :accesses_accounts, id: false do |t|
98
+ t.references :account
99
+ t.references :access
100
+ end
101
+
102
+ unless r5?
103
+ add_index :accesses_accounts, :access_id
104
+ add_index :accesses_accounts, :account_id
105
+ end
106
+
107
+ create_table :foo_bars do |t|
108
+ t.string :name
109
+ t.timestamps null: false
110
+ end
111
+
112
+
113
+ create_table :other_roles do |t|
114
+ t.string :name, :limit => 40
115
+ t.boolean :system
116
+ if r5?
117
+ t.references :authorizable, polymorphic: true
118
+ else
119
+ t.string :authorizable_type, :limit => 40
120
+ t.integer :authorizable_id
121
+ end
122
+ t.timestamps null: false
123
+ end
124
+
125
+ unless r5?
126
+ add_index :other_roles, [:authorizable_type, :authorizable_id]
127
+ end
128
+
129
+ create_table :other_roles_users, id: false do |t|
130
+ t.references :user
131
+ t.references :role
132
+ end
133
+
134
+ unless r5?
135
+ add_index :other_roles_users, :user_id
136
+ add_index :other_roles_users, :role_id
137
+ end
138
+
139
+ create_table :other_users do |t|
140
+ t.string :name
141
+ t.timestamps null: false
142
+ end
143
+
144
+ create_table :other_foos do |t|
145
+ t.string :name
146
+ t.timestamps null: false
147
+ end
148
+ end
149
+ end