abilities 0.1.2 → 4.0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/MIT-LICENSE +1 -1
- data/README.md +31 -44
- data/Rakefile +1 -14
- data/lib/abilities.rb +9 -18
- data/lib/abilities/definitions.rb +38 -29
- data/lib/abilities/extensions/action_controller/base.rb +28 -0
- data/lib/abilities/proxy.rb +6 -7
- data/lib/abilities/railtie.rb +4 -3
- data/lib/abilities/version.rb +1 -1
- data/lib/generators/abilities/install/install_generator.rb +15 -0
- data/lib/generators/abilities/{templates/abilities.rb → install/templates/configuration.rb} +0 -0
- data/test/dummy/Rakefile +0 -1
- data/test/dummy/app/assets/javascripts/application.js +2 -2
- data/test/dummy/app/assets/stylesheets/application.css +1 -1
- data/test/dummy/app/controllers/products_controller.rb +10 -0
- data/test/dummy/app/models/product.rb +2 -0
- data/test/dummy/app/models/user.rb +0 -1
- data/test/dummy/app/views/layouts/application.html.erb +9 -11
- data/test/dummy/app/views/products/show.html.erb +6 -0
- data/test/dummy/bin/bundle +1 -0
- data/test/dummy/bin/rails +2 -1
- data/test/dummy/bin/rake +1 -0
- data/test/dummy/bin/setup +30 -0
- data/test/dummy/config.ru +1 -1
- data/test/dummy/config/abilities.rb +6 -7
- data/test/dummy/config/application.rb +3 -0
- data/test/dummy/config/database.yml +4 -22
- data/test/dummy/config/database.yml.travis +3 -0
- data/test/dummy/config/environments/development.rb +6 -2
- data/test/dummy/config/environments/production.rb +16 -24
- data/test/dummy/config/environments/test.rb +7 -12
- data/test/dummy/config/initializers/assets.rb +11 -0
- data/test/dummy/config/initializers/mime_types.rb +1 -1
- data/test/dummy/config/routes.rb +1 -54
- data/test/dummy/config/secrets.yml +3 -3
- data/test/dummy/db/migrate/20140629203344_create_users.rb +1 -3
- data/test/dummy/db/migrate/20140629203412_create_products.rb +7 -0
- data/test/dummy/db/schema.rb +9 -9
- data/test/dummy/log/development.log +78 -0
- data/test/dummy/log/test.log +1465 -246
- data/test/dummy/public/404.html +57 -63
- data/test/dummy/public/422.html +57 -63
- data/test/dummy/public/500.html +56 -62
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/2b/2bzOr5XdBQAg_ZBDeXY157jGXLRL6qjEoFZBTPyLFwM.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/48/48oV_bpl6OaHjWm9j-I1uNUp5m7SbkTgYjW6NaNnTfU.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/5L/5Lly_CA8DZvPhQV2jDQx-Y6P_y3Ygra9t5jfSlGhHDA.cache +2 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/OI/OI6uxGcnsKavdWTtwDAasU3wPx8QXhzBgV0X2n1KjMQ.cache +2 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/SG/SGNGr7AZfBE1q7ev2-YM1G-o0XAZ0pKqbsS3NvHtRcA.cache +1 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/fG/fG_uaNK13wisQiji91xNsGecGxX9QhMCF2eSX_aR0G0.cache +1 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/gb/gbunrAFVOHPwl2npUgKv_C3f_qiJnZDd9zG5-h3jrpo.cache +1 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/hZ/hZi1k6tpxxCGYxRe7zY74ItcOI8gZrREOpGuA8JSpGg.cache +2 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/j0/j06P5zp022n2VUoAPi5fqCp_UbS7OaCD8XtVtEbHy58.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/mv/mvqN6PphkrOOC8zbUEhpC_9E_4ybdO25MRy_gG6dq3Y.cache +1 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/nm/nmcUZlKAIwyJ_35Nm9P8pukLeRX5aApP6NFj5MpNPgc.cache +1 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/pE/pEhaat2KBd5SrT7szC_8R1_6hK17FTpvoRFkmCRSD3M.cache +2 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/sB/sB6xWxBmgzVC0Co9__ANYrE58lr4WPwiwFa9mswooWM.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/va/vaNrIny9hchHD9eIJxAicyYLC7qeV4PTh4Nh40_Y6Vg.cache +1 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/x6/x6W7JXRDHOmqATQMRSTLu17o8EcA-ietA1qm_PMPjbo.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/xd/xdBKQyhEAlDIstGvXw945PWJoEWi23rKuY7elOcWqHc.cache +1 -0
- data/test/generator_test.rb +4 -4
- data/test/policy_test.rb +62 -0
- data/test/test_helper.rb +5 -16
- data/test/view_test.rb +6 -17
- metadata +63 -32
- data/lib/abilities/action_controller/base.rb +0 -20
- data/lib/abilities/action_view/base.rb +0 -14
- data/lib/abilities/concern.rb +0 -12
- data/lib/abilities/configuration.rb +0 -13
- data/lib/generators/abilities/install_generator.rb +0 -13
- data/test/changes_test.rb +0 -12
- data/test/checking_test.rb +0 -64
- data/test/controller_test.rb +0 -38
- data/test/dummy/README.rdoc +0 -28
- data/test/dummy/app/models/post.rb +0 -3
- data/test/dummy/config/initializers/abilities.rb +0 -7
- data/test/dummy/config/initializers/secret_token.rb +0 -1
- data/test/dummy/db/migrate/20140629203412_create_posts.rb +0 -10
@@ -1,14 +1,12 @@
|
|
1
1
|
<!DOCTYPE html>
|
2
2
|
<html>
|
3
|
-
<head>
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
</head>
|
9
|
-
<body>
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
</body>
|
3
|
+
<head>
|
4
|
+
<title>Dummy</title>
|
5
|
+
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
|
6
|
+
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
|
7
|
+
<%= csrf_meta_tags %>
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
<%= yield %>
|
11
|
+
</body>
|
14
12
|
</html>
|
data/test/dummy/bin/bundle
CHANGED
data/test/dummy/bin/rails
CHANGED
data/test/dummy/bin/rake
CHANGED
@@ -0,0 +1,30 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'pathname'
|
4
|
+
|
5
|
+
# path to your application root.
|
6
|
+
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
|
7
|
+
|
8
|
+
Dir.chdir APP_ROOT do
|
9
|
+
# This script is a starting point to setup your application.
|
10
|
+
# Add necessary setup steps to this file:
|
11
|
+
|
12
|
+
puts '== Installing dependencies =='
|
13
|
+
system 'gem install bundler --conservative'
|
14
|
+
system 'bundle check || bundle install'
|
15
|
+
|
16
|
+
# puts "\n== Copying sample files =="
|
17
|
+
# unless File.exist?('config/database.yml')
|
18
|
+
# system 'cp config/database.yml.sample config/database.yml'
|
19
|
+
# end
|
20
|
+
|
21
|
+
puts "\n== Preparing database =="
|
22
|
+
system 'bin/rake db:setup'
|
23
|
+
|
24
|
+
puts "\n== Removing old logs and tempfiles =="
|
25
|
+
system 'rm -f log/*'
|
26
|
+
system 'rm -rf tmp/cache'
|
27
|
+
|
28
|
+
puts "\n== Restarting application server =="
|
29
|
+
system 'touch tmp/restart.txt'
|
30
|
+
end
|
data/test/dummy/config.ru
CHANGED
@@ -1,10 +1,9 @@
|
|
1
1
|
Abilities.define do
|
2
|
-
can :
|
3
|
-
|
4
|
-
|
5
|
-
can :edit, Post do |subject|
|
6
|
-
subject.user == self
|
2
|
+
can :touch, :any
|
3
|
+
can :manage, User do |user|
|
4
|
+
user == self
|
7
5
|
end
|
8
|
-
can :
|
9
|
-
can
|
6
|
+
can :create, [Product, User]
|
7
|
+
can %i(view list), Product
|
8
|
+
cannot :detroy, Product unless admin?
|
10
9
|
end
|
@@ -18,5 +18,8 @@ module Dummy
|
|
18
18
|
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
19
19
|
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
20
20
|
# config.i18n.default_locale = :de
|
21
|
+
|
22
|
+
# Do not swallow errors in after_commit/after_rollback callbacks.
|
23
|
+
config.active_record.raise_in_transactional_callbacks = true
|
21
24
|
end
|
22
25
|
end
|
@@ -1,25 +1,7 @@
|
|
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
1
|
development:
|
13
|
-
|
14
|
-
database:
|
2
|
+
adapter: postgresql
|
3
|
+
database: abilities_development
|
15
4
|
|
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
5
|
test:
|
20
|
-
|
21
|
-
database:
|
22
|
-
|
23
|
-
production:
|
24
|
-
<<: *default
|
25
|
-
database: db/production.sqlite3
|
6
|
+
adapter: postgresql
|
7
|
+
database: abilities_test
|
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
Rails.application.configure do
|
2
2
|
# Settings specified here will take precedence over those in config/application.rb.
|
3
3
|
|
4
4
|
# In the development environment your application's code is reloaded on
|
@@ -10,7 +10,7 @@ Dummy::Application.configure do
|
|
10
10
|
config.eager_load = false
|
11
11
|
|
12
12
|
# Show full error reports and disable caching.
|
13
|
-
config.consider_all_requests_local
|
13
|
+
config.consider_all_requests_local = true
|
14
14
|
config.action_controller.perform_caching = false
|
15
15
|
|
16
16
|
# Don't care if the mailer can't send.
|
@@ -27,6 +27,10 @@ Dummy::Application.configure do
|
|
27
27
|
# number of complex assets.
|
28
28
|
config.assets.debug = true
|
29
29
|
|
30
|
+
# Asset digests allow you to set far-future HTTP expiration dates on all assets,
|
31
|
+
# yet still be able to expire them through the digest params.
|
32
|
+
config.assets.digest = true
|
33
|
+
|
30
34
|
# Adds additional error checking when serving assets at runtime.
|
31
35
|
# Checks for improperly declared sprockets dependencies.
|
32
36
|
# Raises helpful error messages.
|
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
Rails.application.configure do
|
2
2
|
# Settings specified here will take precedence over those in config/application.rb.
|
3
3
|
|
4
4
|
# Code is not reloaded between requests.
|
@@ -11,20 +11,18 @@ Dummy::Application.configure do
|
|
11
11
|
config.eager_load = true
|
12
12
|
|
13
13
|
# Full error reports are disabled and caching is turned on.
|
14
|
-
config.consider_all_requests_local
|
14
|
+
config.consider_all_requests_local = false
|
15
15
|
config.action_controller.perform_caching = true
|
16
16
|
|
17
17
|
# Enable Rack::Cache to put a simple HTTP cache in front of your application
|
18
18
|
# Add `rack-cache` to your Gemfile before enabling this.
|
19
|
-
# For large-scale production use, consider using a caching reverse proxy like
|
19
|
+
# For large-scale production use, consider using a caching reverse proxy like
|
20
|
+
# NGINX, varnish or squid.
|
20
21
|
# config.action_dispatch.rack_cache = true
|
21
22
|
|
22
|
-
# Disable
|
23
|
-
|
24
|
-
|
25
|
-
else
|
26
|
-
config.serve_static_assets = false
|
27
|
-
end
|
23
|
+
# Disable serving static files from the `/public` folder by default since
|
24
|
+
# Apache or NGINX already handles this.
|
25
|
+
config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present?
|
28
26
|
|
29
27
|
# Compress JavaScripts and CSS.
|
30
28
|
config.assets.js_compressor = :uglifier
|
@@ -33,21 +31,22 @@ Dummy::Application.configure do
|
|
33
31
|
# Do not fallback to assets pipeline if a precompiled asset is missed.
|
34
32
|
config.assets.compile = false
|
35
33
|
|
36
|
-
#
|
34
|
+
# Asset digests allow you to set far-future HTTP expiration dates on all assets,
|
35
|
+
# yet still be able to expire them through the digest params.
|
37
36
|
config.assets.digest = true
|
38
37
|
|
39
|
-
#
|
40
|
-
config.assets.version = '1.0'
|
38
|
+
# `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
|
41
39
|
|
42
40
|
# Specifies the header that your server uses for sending files.
|
43
|
-
# config.action_dispatch.x_sendfile_header =
|
44
|
-
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for
|
41
|
+
# config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
|
42
|
+
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
|
45
43
|
|
46
44
|
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
|
47
45
|
# config.force_ssl = true
|
48
46
|
|
49
|
-
#
|
50
|
-
|
47
|
+
# Use the lowest log level to ensure availability of diagnostic information
|
48
|
+
# when problems arise.
|
49
|
+
config.log_level = :debug
|
51
50
|
|
52
51
|
# Prepend all log lines with the following tags.
|
53
52
|
# config.log_tags = [ :subdomain, :uuid ]
|
@@ -59,11 +58,7 @@ Dummy::Application.configure do
|
|
59
58
|
# config.cache_store = :mem_cache_store
|
60
59
|
|
61
60
|
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
|
62
|
-
# config.action_controller.asset_host =
|
63
|
-
|
64
|
-
# Precompile additional assets.
|
65
|
-
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
|
66
|
-
# config.assets.precompile += %w( search.js )
|
61
|
+
# config.action_controller.asset_host = 'http://assets.example.com'
|
67
62
|
|
68
63
|
# Ignore bad email addresses and do not raise email delivery errors.
|
69
64
|
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
|
@@ -76,9 +71,6 @@ Dummy::Application.configure do
|
|
76
71
|
# Send deprecation notices to registered listeners.
|
77
72
|
config.active_support.deprecation = :notify
|
78
73
|
|
79
|
-
# Disable automatic flushing of the log to improve performance.
|
80
|
-
# config.autoflush_log = false
|
81
|
-
|
82
74
|
# Use default logging formatter so that PID and timestamp are not suppressed.
|
83
75
|
config.log_formatter = ::Logger::Formatter.new
|
84
76
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
Rails.application.configure do
|
2
2
|
# Settings specified here will take precedence over those in config/application.rb.
|
3
3
|
|
4
4
|
# The test environment is used exclusively to run your application's
|
@@ -12,16 +12,12 @@ Dummy::Application.configure do
|
|
12
12
|
# preloads Rails for running tests, you may have to set it to true.
|
13
13
|
config.eager_load = false
|
14
14
|
|
15
|
-
# Configure static
|
16
|
-
|
17
|
-
config.serve_static_files = false
|
18
|
-
else
|
19
|
-
config.serve_static_assets = false
|
20
|
-
end
|
15
|
+
# Configure static file server for tests with Cache-Control for performance.
|
16
|
+
config.serve_static_files = true
|
21
17
|
config.static_cache_control = 'public, max-age=3600'
|
22
18
|
|
23
19
|
# Show full error reports and disable caching.
|
24
|
-
config.consider_all_requests_local
|
20
|
+
config.consider_all_requests_local = true
|
25
21
|
config.action_controller.perform_caching = false
|
26
22
|
|
27
23
|
# Raise exceptions instead of rendering exception templates.
|
@@ -35,13 +31,12 @@ Dummy::Application.configure do
|
|
35
31
|
# ActionMailer::Base.deliveries array.
|
36
32
|
config.action_mailer.delivery_method = :test
|
37
33
|
|
34
|
+
# Randomize the order test cases are executed.
|
35
|
+
config.active_support.test_order = :random
|
36
|
+
|
38
37
|
# Print deprecation notices to the stderr.
|
39
38
|
config.active_support.deprecation = :stderr
|
40
39
|
|
41
40
|
# Raises error for missing translations
|
42
41
|
# config.action_view.raise_on_missing_translations = true
|
43
|
-
|
44
|
-
if Rails::VERSION::MAJOR == 4 && Rails::VERSION::MINOR >= 2
|
45
|
-
config.active_support.test_order = :random
|
46
|
-
end
|
47
42
|
end
|
@@ -0,0 +1,11 @@
|
|
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
|
+
Rails.application.config.assets.version = '1.0'
|
5
|
+
|
6
|
+
# Add additional assets to the asset load path
|
7
|
+
# Rails.application.config.assets.paths << Emoji.images_path
|
8
|
+
|
9
|
+
# Precompile additional assets.
|
10
|
+
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
|
11
|
+
# Rails.application.config.assets.precompile += %w( search.js )
|
data/test/dummy/config/routes.rb
CHANGED
@@ -1,56 +1,3 @@
|
|
1
1
|
Rails.application.routes.draw do
|
2
|
-
|
3
|
-
# See how all your routes lay out with "rake routes".
|
4
|
-
|
5
|
-
# You can have the root of your site routed with "root"
|
6
|
-
# root 'welcome#index'
|
7
|
-
|
8
|
-
# Example of regular route:
|
9
|
-
# get 'products/:id' => 'catalog#view'
|
10
|
-
|
11
|
-
# Example of named route that can be invoked with purchase_url(id: product.id)
|
12
|
-
# get 'products/:id/purchase' => 'catalog#purchase', as: :purchase
|
13
|
-
|
14
|
-
# Example resource route (maps HTTP verbs to controller actions automatically):
|
15
|
-
# resources :products
|
16
|
-
|
17
|
-
# Example resource route with options:
|
18
|
-
# resources :products do
|
19
|
-
# member do
|
20
|
-
# get 'short'
|
21
|
-
# post 'toggle'
|
22
|
-
# end
|
23
|
-
#
|
24
|
-
# collection do
|
25
|
-
# get 'sold'
|
26
|
-
# end
|
27
|
-
# end
|
28
|
-
|
29
|
-
# Example resource route with sub-resources:
|
30
|
-
# resources :products do
|
31
|
-
# resources :comments, :sales
|
32
|
-
# resource :seller
|
33
|
-
# end
|
34
|
-
|
35
|
-
# Example resource route with more complex sub-resources:
|
36
|
-
# resources :products do
|
37
|
-
# resources :comments
|
38
|
-
# resources :sales do
|
39
|
-
# get 'recent', on: :collection
|
40
|
-
# end
|
41
|
-
# end
|
42
|
-
|
43
|
-
# Example resource route with concerns:
|
44
|
-
# concern :toggleable do
|
45
|
-
# post 'toggle'
|
46
|
-
# end
|
47
|
-
# resources :posts, concerns: :toggleable
|
48
|
-
# resources :photos, concerns: :toggleable
|
49
|
-
|
50
|
-
# Example resource route within a namespace:
|
51
|
-
# namespace :admin do
|
52
|
-
# # Directs /admin/products/* to Admin::ProductsController
|
53
|
-
# # (app/controllers/admin/products_controller.rb)
|
54
|
-
# resources :products
|
55
|
-
# end
|
2
|
+
get 'product' => 'products#show'
|
56
3
|
end
|
@@ -11,12 +11,12 @@
|
|
11
11
|
# if you're sharing your code publicly.
|
12
12
|
|
13
13
|
development:
|
14
|
-
secret_key_base:
|
14
|
+
secret_key_base: 2c1c8d4cbaa726b21aa6483b7d556125f4897508e2b94f8b3ddaec675168382c9b3b6eb5a9359d2fade03f539c16ac1ef905891c2410f2fd00b83b76c1666feb
|
15
15
|
|
16
16
|
test:
|
17
|
-
secret_key_base:
|
17
|
+
secret_key_base: 9dd531171128e7c3d11dd2c5c18c84ba43d29b677043002634a6f4d58bf2687a283b7b6dc6af741d63c3824f11fa1f858010d7c2509a932023f2ece0d3bfe6cf
|
18
18
|
|
19
19
|
# Do not keep production secrets in the repository,
|
20
20
|
# instead read values from the environment.
|
21
21
|
production:
|
22
|
-
secret_key_base: <%= ENV[
|
22
|
+
secret_key_base: <%= ENV['SECRET_KEY_BASE'] %>
|
data/test/dummy/db/schema.rb
CHANGED
@@ -13,19 +13,19 @@
|
|
13
13
|
|
14
14
|
ActiveRecord::Schema.define(version: 20140629203412) do
|
15
15
|
|
16
|
-
|
17
|
-
|
16
|
+
# These are extensions that must be enabled in order to support this database
|
17
|
+
enable_extension "plpgsql"
|
18
|
+
|
19
|
+
create_table "products", force: :cascade do |t|
|
18
20
|
t.integer "user_id"
|
19
|
-
t.datetime "created_at"
|
20
|
-
t.datetime "updated_at"
|
21
|
+
t.datetime "created_at", null: false
|
22
|
+
t.datetime "updated_at", null: false
|
21
23
|
end
|
22
24
|
|
23
|
-
create_table "users", force:
|
24
|
-
t.string "name"
|
25
|
-
t.string "email"
|
25
|
+
create_table "users", force: :cascade do |t|
|
26
26
|
t.boolean "admin"
|
27
|
-
t.datetime "created_at"
|
28
|
-
t.datetime "updated_at"
|
27
|
+
t.datetime "created_at", null: false
|
28
|
+
t.datetime "updated_at", null: false
|
29
29
|
end
|
30
30
|
|
31
31
|
end
|