eaco 1.0.0 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 342302faeb4d72f36078ceb1566c2701481e2005
4
- data.tar.gz: b6986e43c743934700e081dfe5a497e5a49a5632
3
+ metadata.gz: 956832fb8b74408d7ced40a87cd50c0e0ec92f41
4
+ data.tar.gz: 5dc7cc945adff2ceb6ced5c780be61f149ad95a8
5
5
  SHA512:
6
- metadata.gz: 7aae3bdd2fe862f8c5185b7cd774d1a0e55d2c7592d687d5b40aef388cc14d468c6eea4fbff0648b3ef8ca73bd2a487d05bf50afa3d252380a1074762be5c8a8
7
- data.tar.gz: 0306f78ebe3b7197dda0afcb44250a56c93e5471af163c6d9d262196c798cb6f0e5e5a42ba52f7bd092cfbc0c50205ef828c7d616b4c4290b3e16d31867d8b9c
6
+ metadata.gz: adf19b59716224cd22e09e703bf1535a2b9443df77b2d6c8e42294785af8bb8a12c5f6c82c6b58e7fcaa9cc79ae5425faf3417c94940a972c0f179572ef50927
7
+ data.tar.gz: 56c7b99cb00d0f4bb36bd646abf1ad000ba6a82a9d3f52747aa1743ee59ebf88aa6fd99a1f3390a4871ebbed53789d451712ef5a619126db53dce7e5a4e079e6
@@ -1,13 +1,41 @@
1
1
  rvm:
2
- - 2.1
3
- - 2.2
4
- - 2.3.1
2
+ - 2.1.10
3
+ - 2.2.7
4
+ - 2.3.4
5
+ - 2.4.1
5
6
 
6
7
  gemfile:
7
8
  - gemfiles/rails_3.2.gemfile
8
9
  - gemfiles/rails_4.0.gemfile
9
10
  - gemfiles/rails_4.1.gemfile
10
11
  - gemfiles/rails_4.2.gemfile
12
+ - gemfiles/rails_5.0.gemfile
13
+ - gemfiles/rails_5.1.gemfile
14
+
15
+ matrix:
16
+ exclude:
17
+ - rvm: 2.1.10
18
+ gemfile: gemfiles/rails_5.0.gemfile
19
+ - rvm: 2.1.10
20
+ gemfile: gemfiles/rails_5.1.gemfile
21
+
22
+ - rvm: 2.3.4
23
+ gemfile: gemfiles/rails_3.2.gemfile
24
+ - rvm: 2.3.4
25
+ gemfile: gemfiles/rails_4.0.gemfile
26
+ - rvm: 2.3.4
27
+ gemfile: gemfiles/rails_4.1.gemfile
28
+ - rvm: 2.3.4
29
+ gemfile: gemfiles/rails_4.2.gemfile
30
+
31
+ - rvm: 2.4.1
32
+ gemfile: gemfiles/rails_3.2.gemfile
33
+ - rvm: 2.4.1
34
+ gemfile: gemfiles/rails_4.0.gemfile
35
+ - rvm: 2.4.1
36
+ gemfile: gemfiles/rails_4.1.gemfile
37
+ - rvm: 2.4.1
38
+ gemfile: gemfiles/rails_4.2.gemfile
11
39
 
12
40
  sudo: false
13
41
 
data/Appraisals CHANGED
@@ -1,4 +1,4 @@
1
- # Test against 3.2 -> 4.2
1
+ # Test against 3.2 -> 5.1
2
2
  #
3
3
  appraise 'rails-3.2' do
4
4
  gem 'rails', '~> 3.2.0'
@@ -20,3 +20,13 @@ appraise 'rails-4.2' do
20
20
  gem 'rails', '~> 4.2.0'
21
21
  gem 'pg'
22
22
  end
23
+
24
+ appraise 'rails-5.0' do
25
+ gem 'rails', '~> 5.0.0'
26
+ gem 'pg'
27
+ end
28
+
29
+ appraise 'rails-5.1' do
30
+ gem 'rails', '~> 5.1.0'
31
+ gem 'pg'
32
+ end
@@ -0,0 +1,17 @@
1
+ # Change Log
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this
6
+ project adheres to [Semantic Versioning](http://semver.org/)
7
+
8
+ ## 1.1.1 - 2017-03-08
9
+
10
+ ### Fixed
11
+ * Fix ActionDispatch::Reloader.to_prepare deprecation
12
+
13
+ ## 1.1.0 - 2016-09-27
14
+
15
+ ### Changed
16
+
17
+ * Add support for Rails 5.
@@ -199,7 +199,11 @@ Feature: Role-based, flexible authorization
199
199
  Scenario: Authorizing a controller
200
200
  When I have an authorized Controller defined as
201
201
  """
202
- before_filter :find_document
202
+ if ActionPack::VERSION::MAJOR == 5
203
+ before_action :find_document
204
+ else
205
+ before_filter :find_document
206
+ end
203
207
 
204
208
  authorize :show, [:document, :read ]
205
209
  authorize :edit, [:document, :write]
@@ -14,9 +14,17 @@ When(/I invoke the Controller "(.+?)" action with query string "(.+?)"$/) do |ac
14
14
 
15
15
  @controller.current_user = @current_user
16
16
 
17
- @controller.request = ActionDispatch::TestRequest.new('QUERY_STRING' => query).tap do |request|
18
- request.params.update('action' => @action_name)
17
+ #:nocov:
18
+ if Rails::VERSION::MAJOR < 5
19
+ @controller.request = ActionDispatch::TestRequest.new('QUERY_STRING' => query).tap do |request|
20
+ request.params.update('action' => @action_name)
21
+ end
22
+ else
23
+ @controller.request = ActionDispatch::TestRequest.create('QUERY_STRING' => query).tap do |request|
24
+ request.action = @action_name
25
+ end
19
26
  end
27
+ #:nocov:
20
28
 
21
29
  @controller.response = ActionDispatch::TestResponse.new
22
30
  end
@@ -1,4 +1,5 @@
1
1
  require 'bundler/setup'
2
+ require 'rails'
2
3
  require 'byebug'
3
4
 
4
5
  require 'eaco/coverage'
@@ -4,6 +4,6 @@ source "https://rubygems.org"
4
4
 
5
5
  gem "rails", "~> 3.2.0"
6
6
  gem "pg"
7
- gem "activerecord-postgres-json", :require => false
7
+ gem "activerecord-postgres-json"
8
8
 
9
- gemspec :path => "../"
9
+ gemspec path: "../"
@@ -5,4 +5,4 @@ source "https://rubygems.org"
5
5
  gem "rails", "~> 4.0.0"
6
6
  gem "pg"
7
7
 
8
- gemspec :path => "../"
8
+ gemspec path: "../"
@@ -5,4 +5,4 @@ source "https://rubygems.org"
5
5
  gem "rails", "~> 4.1.0"
6
6
  gem "pg"
7
7
 
8
- gemspec :path => "../"
8
+ gemspec path: "../"
@@ -5,4 +5,4 @@ source "https://rubygems.org"
5
5
  gem "rails", "~> 4.2.0"
6
6
  gem "pg"
7
7
 
8
- gemspec :path => "../"
8
+ gemspec path: "../"
@@ -0,0 +1,8 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rails", "~> 5.0.0"
6
+ gem "pg"
7
+
8
+ gemspec path: "../"
@@ -0,0 +1,8 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "rails", "~> 5.1.0"
6
+ gem "pg"
7
+
8
+ gemspec path: "../"
@@ -10,8 +10,11 @@ module Eaco
10
10
  autoload :V40, 'eaco/adapters/active_record/compatibility/v40.rb'
11
11
  autoload :V41, 'eaco/adapters/active_record/compatibility/v41.rb'
12
12
  autoload :V42, 'eaco/adapters/active_record/compatibility/v42.rb'
13
+ autoload :V50, 'eaco/adapters/active_record/compatibility/v50.rb'
14
+ autoload :V51, 'eaco/adapters/active_record/compatibility/v51.rb'
13
15
 
14
- autoload :Scoped, 'eaco/adapters/active_record/compatibility/scoped.rb'
16
+ autoload :Scoped, 'eaco/adapters/active_record/compatibility/scoped.rb'
17
+ autoload :Sanitized, 'eaco/adapters/active_record/compatibility/sanitized.rb'
15
18
 
16
19
  ##
17
20
  # Memoizes the given +model+ for later {#check!} calls.
@@ -23,7 +26,7 @@ module Eaco
23
26
  end
24
27
 
25
28
  ##
26
- # Checks whether the target model is compatible.
29
+ # Checks whether ActiveRecord::Base is compatible.
27
30
  # Looks up the {#support_module} and includes it.
28
31
  #
29
32
  # @see #support_module
@@ -32,26 +35,21 @@ module Eaco
32
35
  #
33
36
  def check!
34
37
  layer = support_module
35
- target.instance_eval { include layer }
38
+ ::ActiveRecord::Base.instance_eval { include layer }
36
39
  end
37
40
 
38
41
  private
39
42
 
40
- ##
41
- # @return [ActiveRecord::Base] associated with the model
42
- #
43
- def target
44
- @model.base_class.superclass
45
- end
46
-
47
43
  ##
48
44
  # @return [String] the +ActiveRecord+ major and minor version numbers
49
45
  #
50
46
  # Example: "42" for 4.2
51
47
  #
52
48
  def active_record_version
53
- ver = target.parent.const_get(:VERSION)
54
- [ver.const_get(:MAJOR), ver.const_get(:MINOR)].join
49
+ [
50
+ ::ActiveRecord::VERSION::MAJOR,
51
+ ::ActiveRecord::VERSION::MINOR
52
+ ].join
55
53
  end
56
54
 
57
55
  ##
@@ -0,0 +1,22 @@
1
+ module Eaco
2
+ module Adapters
3
+ module ActiveRecord
4
+ class Compatibility
5
+
6
+ ##
7
+ # Aliases `sanitize` as `connection.quote` for ActiveRecord >= 5.1.
8
+ #
9
+ module Sanitized
10
+
11
+ ##
12
+ # Just returns +ActiveRecord::Base.connection.quote+.
13
+ #
14
+ def sanitize(d)
15
+ self.connection.quote(d)
16
+ end
17
+ end
18
+
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,25 @@
1
+ module Eaco
2
+ module Adapters
3
+ module ActiveRecord
4
+ class Compatibility
5
+
6
+ ##
7
+ # Rails 5.0 support module.
8
+ #
9
+ # JSONB works correctly, but we need +.scoped+ so we revive it through
10
+ # the {Scoped} support module.
11
+ #
12
+ # @see Scoped
13
+ #
14
+ module V50
15
+ extend ActiveSupport::Concern
16
+
17
+ included do
18
+ extend Scoped
19
+ end
20
+ end
21
+
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,30 @@
1
+ module Eaco
2
+ module Adapters
3
+ module ActiveRecord
4
+ class Compatibility
5
+
6
+ ##
7
+ # Rails 5.1 support module.
8
+ #
9
+ # JSONB works correctly, but we need +.scoped+ so we revive it through
10
+ # the {Scoped} support module.
11
+ #
12
+ # @see Scoped
13
+ #
14
+ # Sanitize has dissapeared in favour of quote.
15
+ #
16
+ # @see Sanitized
17
+ #
18
+ module V51
19
+ extend ActiveSupport::Concern
20
+
21
+ included do
22
+ extend Scoped
23
+ extend Sanitized
24
+ end
25
+ end
26
+
27
+ end
28
+ end
29
+ end
30
+ end
@@ -25,7 +25,7 @@ module Eaco
25
25
  def accessible_by(actor)
26
26
  return scoped if actor.is_admin?
27
27
 
28
- designators = actor.designators.map {|d| quote_value(d, nil) }
28
+ designators = actor.designators.map {|d| sanitize(d) }
29
29
 
30
30
  column = "#{connection.quote_table_name(table_name)}.acl"
31
31
 
@@ -54,7 +54,12 @@ module Eaco
54
54
  actions.each {|action| authorization_permissions.update(action => target)}
55
55
 
56
56
  @_eaco_filter_installed ||= begin
57
- before_filter :confront_eaco
57
+ if ActionPack::VERSION::MAJOR == 5
58
+ before_action :confront_eaco
59
+ else
60
+ before_filter :confront_eaco
61
+ end
62
+
58
63
  true
59
64
  end
60
65
  end
@@ -95,11 +95,13 @@ module Eaco
95
95
  #
96
96
  # @raise [Errno::ENOENT] if the configuration file is not found.
97
97
  #
98
+ # :nocov:
99
+ # This isn't ran by Travis as we set EACO_AR_CONFIG, so Coveralls raises
100
+ # a false positive.
98
101
  def default_config_file
99
102
  Pathname.new('features/active_record.yml').realpath
100
103
 
101
104
  rescue Errno::ENOENT => error
102
- # :nocov:
103
105
  raise error.class.new, <<-EOF.squeeze(' ')
104
106
 
105
107
  #{error.message}.
@@ -108,8 +110,8 @@ module Eaco
108
110
  default location, or specify your configuration file location by
109
111
  passing the `EACO_AR_CONFIG' environment variable.
110
112
  EOF
111
- # :nocov:
112
113
  end
114
+ # :nocov:
113
115
 
114
116
  ##
115
117
  # Establish ActiveRecord connection using the given configuration hash
@@ -167,8 +167,8 @@ module Eaco
167
167
  # @return [Class] the ORM base class.
168
168
  #
169
169
  def orm
170
- if target.respond_to?(:base_class)
171
- target.base_class.superclass # Active Record
170
+ if defined?(ActiveRecord::Base) && target.ancestors.include?(ActiveRecord::Base)
171
+ ActiveRecord::Base
172
172
  else
173
173
  target.superclass # Naive
174
174
  end
@@ -18,13 +18,17 @@ module Eaco
18
18
  # @!method parse_rules
19
19
  #
20
20
  initializer 'eaco.parse_rules' do
21
+ # :nocov:
21
22
  Eaco.parse_default_rules_file!
22
23
 
23
24
  unless Rails.configuration.cache_classes
24
- ActionDispatch::Reloader.to_prepare do
25
- Eaco.parse_default_rules_file!
25
+ if defined? ActiveSupport::Reloader
26
+ ActiveSupport::Reloader.to_prepare { Eaco.parse_default_rules_file! }
27
+ else
28
+ ActionDispatch::Reloader.to_prepare { Eaco.parse_default_rules_file! }
26
29
  end
27
30
  end
31
+ # :nocov:
28
32
  end
29
33
 
30
34
  ##
@@ -33,6 +37,7 @@ module Eaco
33
37
  # @!method install_controller_runtime
34
38
  #
35
39
  initializer 'eaco.install_controller_runtime' do
40
+ # :nocov:
36
41
  ActiveSupport.on_load :action_controller do
37
42
 
38
43
  ActionController::Base.instance_eval do
@@ -40,6 +45,7 @@ module Eaco
40
45
  end
41
46
 
42
47
  end
48
+ # :nocov:
43
49
  end
44
50
  end
45
51
 
@@ -40,7 +40,6 @@ module Eaco
40
40
  run_specs
41
41
  run_cucumber
42
42
  report_coverage
43
- generate_documentation
44
43
  end
45
44
 
46
45
  else
@@ -0,0 +1,13 @@
1
+ RSpec::Matchers.define :be_able_to do |*args|
2
+ match do |actor|
3
+ actor.can?(*args)
4
+ end
5
+
6
+ failure_message do |actor|
7
+ "expected to be able to #{args.map(&:inspect).join(" ")}"
8
+ end
9
+
10
+ failure_message_when_negated do |actor|
11
+ "expected not to be able to #{args.map(&:inspect).join(" ")}"
12
+ end
13
+ end
@@ -2,6 +2,6 @@ module Eaco
2
2
 
3
3
  # Current version
4
4
  #
5
- VERSION = '1.0.0'
5
+ VERSION = '1.1.2'
6
6
 
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eaco
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcello Barnaba
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-05 00:00:00.000000000 Z
11
+ date: 2017-07-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -233,6 +233,7 @@ files:
233
233
  - ".travis.yml"
234
234
  - ".yardopts"
235
235
  - Appraisals
236
+ - CHANGELOG.md
236
237
  - Gemfile
237
238
  - Guardfile
238
239
  - LICENSE.txt
@@ -256,17 +257,22 @@ files:
256
257
  - gemfiles/rails_4.0.gemfile
257
258
  - gemfiles/rails_4.1.gemfile
258
259
  - gemfiles/rails_4.2.gemfile
260
+ - gemfiles/rails_5.0.gemfile
261
+ - gemfiles/rails_5.1.gemfile
259
262
  - lib/eaco.rb
260
263
  - lib/eaco/acl.rb
261
264
  - lib/eaco/actor.rb
262
265
  - lib/eaco/adapters.rb
263
266
  - lib/eaco/adapters/active_record.rb
264
267
  - lib/eaco/adapters/active_record/compatibility.rb
268
+ - lib/eaco/adapters/active_record/compatibility/sanitized.rb
265
269
  - lib/eaco/adapters/active_record/compatibility/scoped.rb
266
270
  - lib/eaco/adapters/active_record/compatibility/v32.rb
267
271
  - lib/eaco/adapters/active_record/compatibility/v40.rb
268
272
  - lib/eaco/adapters/active_record/compatibility/v41.rb
269
273
  - lib/eaco/adapters/active_record/compatibility/v42.rb
274
+ - lib/eaco/adapters/active_record/compatibility/v50.rb
275
+ - lib/eaco/adapters/active_record/compatibility/v51.rb
270
276
  - lib/eaco/adapters/active_record/postgres_jsonb.rb
271
277
  - lib/eaco/adapters/couchrest_model.rb
272
278
  - lib/eaco/adapters/couchrest_model/couchdb_lucene.rb
@@ -299,6 +305,7 @@ files:
299
305
  - lib/eaco/rake/default_task.rb
300
306
  - lib/eaco/rake/utils.rb
301
307
  - lib/eaco/resource.rb
308
+ - lib/eaco/rspec.rb
302
309
  - lib/eaco/version.rb
303
310
  - spec/eaco/acl_spec.rb
304
311
  - spec/eaco/actor_spec.rb
@@ -333,7 +340,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
333
340
  version: '0'
334
341
  requirements: []
335
342
  rubyforge_project:
336
- rubygems_version: 2.4.5
343
+ rubygems_version: 2.4.5.1
337
344
  signing_key:
338
345
  specification_version: 4
339
346
  summary: Authorization framework
@@ -364,4 +371,3 @@ test_files:
364
371
  - spec/eaco/resource_spec.rb
365
372
  - spec/eaco_spec.rb
366
373
  - spec/spec_helper.rb
367
- has_rdoc: