blacklight-access_controls 0.2.0 → 0.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e429877da325ab5e409d1d62676ef8d5e1fc0495
4
- data.tar.gz: c77b7f0cf4e24cdaa8acfe763e92aacd16b36f64
3
+ metadata.gz: 7e7447f8da715903fc974515f34db237e8ba5653
4
+ data.tar.gz: 6afe65e64d3fc0ee3bb9b8c79279a6167dd5d74c
5
5
  SHA512:
6
- metadata.gz: 054afd2481955b5278a523a11d57723b0d1c8b6fe27d18e5956abae262b2d93ed77e9775b0ad582f70d73269d4e9c69a3c790a5aa5b0e7884e59db2a918c9523
7
- data.tar.gz: d679058bc3c0aa1a782f992433678e229f10d892e81257dfe9329601dcfefaeb0db3af6e579706781a9393ae30f48725c7b9b6f5b1e21035269182b974a200f2
6
+ metadata.gz: b4c4174a084bda61d07de209e9b2486a84bed7cd9b714a557f85ffc47bc371fc1aa85241db4155a532622e13a38418ec563f5d4b113707427578b051af9221e0
7
+ data.tar.gz: e5ab41654830f20e8355a51f07b2f6c2ae05dc7aa917bc7e71d31c4ca560490e61fe0cfe00aed1430f0688c1b2778438d454d4a394ad7d0f21c5f6be9e7a00b1
@@ -0,0 +1,22 @@
1
+ language: ruby
2
+ sudo: false
3
+ cache:
4
+ directories:
5
+ - /tmp/solr-5.3.0
6
+
7
+ notifications:
8
+ email: false
9
+
10
+ rvm:
11
+ - 2.3.0
12
+
13
+ env:
14
+ - "RAILS_VERSION=4.2.5"
15
+
16
+ notifications:
17
+ irc: "irc.freenode.org#blacklight"
18
+ email:
19
+ - blacklight-commits@googlegroups.com
20
+
21
+ global_env:
22
+ - NOKOGIRI_USE_SYSTEM_LIBRARIES=true
data/Rakefile CHANGED
@@ -1,4 +1,11 @@
1
1
  #!/usr/bin/env rake
2
+ begin
3
+ require 'bundler/setup'
4
+ rescue LoadError
5
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
+ end
7
+
8
+ Bundler::GemHelper.install_tasks
2
9
 
3
10
  require 'solr_wrapper'
4
11
 
@@ -19,14 +26,13 @@ require 'engine_cart/rake_task'
19
26
  require 'rspec/core/rake_task'
20
27
  RSpec::Core::RakeTask.new(:spec)
21
28
 
22
- task :default => 'solr:spec'
29
+ task default: 'ci'
23
30
 
24
31
  def solr_config_dir
25
32
  File.join(File.expand_path(File.dirname(__FILE__)), "solr_conf", "conf")
26
33
  end
27
34
 
28
35
  namespace :solr do
29
-
30
36
  desc 'Configure solr cores'
31
37
  task :config do
32
38
  SolrWrapper.wrap do |solr|
@@ -43,5 +49,7 @@ namespace :solr do
43
49
  end
44
50
  end
45
51
  end
46
-
47
52
  end
53
+
54
+ desc "Run CI build"
55
+ task ci: ['engine_cart:generate', 'solr:spec']
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.3.0
@@ -18,7 +18,7 @@ Gem::Specification.new do |gem|
18
18
  gem.required_ruby_version = '>= 1.9.3'
19
19
 
20
20
  gem.add_dependency 'cancancan', '~> 1.8'
21
- gem.add_dependency "blacklight", '~> 5.16'
21
+ gem.add_dependency "blacklight", '~> 6.0'
22
22
 
23
23
  gem.add_development_dependency "rake", '~> 10.1'
24
24
  gem.add_development_dependency 'rspec', '~> 3.1'
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'rails'
2
3
  require 'cancan'
3
4
  require 'blacklight'
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Blacklight
2
3
  module AccessControls
3
4
  extend ActiveSupport::Autoload
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'cancan'
2
3
 
3
4
  module Blacklight
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # This is behavior for the catalog controller.
2
3
 
3
4
  module Blacklight
@@ -7,9 +8,9 @@ module Blacklight
7
8
 
8
9
  # Override blacklight to produce a search_builder that has
9
10
  # the current ability in context
10
- def search_builder processor_chain = search_params_logic
11
- super(true).tap { |builder| builder.current_ability = current_ability }
12
- end
11
+ def search_builder
12
+ super.tap { |builder| builder.current_ability = current_ability }
13
+ end
13
14
 
14
15
  # Controller "before" filter for enforcing access controls
15
16
  # on show actions.
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Blacklight
2
3
  module AccessControls
3
4
  class Config
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Blacklight
2
3
  module AccessControls
3
4
  module Enforcement
@@ -23,6 +24,14 @@ module Blacklight
23
24
  @current_ability || raise("current_ability has not been set on #{self}")
24
25
  end
25
26
 
27
+ def except(*)
28
+ super.tap { |new_builder| new_builder.current_ability = current_ability }
29
+ end
30
+
31
+ def append(*)
32
+ super.tap { |new_builder| new_builder.current_ability = current_ability }
33
+ end
34
+
26
35
  protected
27
36
 
28
37
  def gated_discovery_filters(permission_types = discovery_permissions, ability = current_ability)
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  class Blacklight::AccessControls::PermissionsCache
2
3
 
3
4
  def initialize
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Blacklight::AccessControls
2
3
  module PermissionsQuery
3
4
  extend ActiveSupport::Concern
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # Injects behaviors into User model so that it will work with
2
3
  # Blacklight Access Controls. By default, this module assumes
3
4
  # you are using the User model created by Blacklight, which uses
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  class Ability
2
3
  include CanCan::Ability
3
4
  include Blacklight::AccessControls::Ability
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Blacklight
2
3
  class AccessControlsGenerator < Rails::Generators::Base
3
4
 
@@ -56,5 +57,10 @@ module Blacklight
56
57
  copy_file 'ability.rb', 'app/models/ability.rb'
57
58
  end
58
59
 
60
+ def add_configuration
61
+ say_status('status', 'ADDING BLACKLIGHT ACCESS CONTROLS CONFIGURATION', :yellow)
62
+ copy_file 'blacklight_access_controls.rb', 'config/initializers/blacklight_access_controls.rb'
63
+ end
64
+
59
65
  end
60
66
  end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+ Blacklight::AccessControls.configure do |config|
3
+ # This specifies the solr field names of permissions-related fields.
4
+ # The default fields used are shown below, if you index your permissions to other fields update the configuration below.
5
+ # If you change these, you must also update the permissions request handler in your solrconfig.xml to return those values
6
+ #
7
+ # config.discover_group_field = Solrizer.solr_name("discover_access_group", :symbol)
8
+ # config.discover_user_field = Solrizer.solr_name("discover_access_person", :symbol)
9
+ # config.read_group_field = Solrizer.solr_name("read_access_group", :symbol)
10
+ # config.read_user_field = Solrizer.solr_name("read_access_person", :symbol)
11
+ # config.download_group_field = Solrizer.solr_name("download_access_group", :symbol)
12
+ # config.download_user_field = Solrizer.solr_name("dowload_access_person", :symbol)
13
+ #
14
+ # specify the user model
15
+ # config.user_model = 'User'
16
+ end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  FactoryGirl.define do
2
3
  factory :user do
3
4
  sequence(:email) { |n| "user_#{n}@example.com" }
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  ENV['RAILS_ENV'] ||= 'test'
2
3
 
3
4
  require 'engine_cart'
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module SolrSupport
2
3
 
3
4
  def create_solr_doc(hash)
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'rails/generators'
2
3
 
3
4
  class TestAppGenerator < Rails::Generators::Base
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
  require 'cancan/matchers'
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe Blacklight::AccessControls::Catalog do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe Blacklight::AccessControls::Config do
@@ -1,9 +1,10 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe Blacklight::AccessControls::Enforcement do
4
5
  let(:controller) { CatalogController.new }
5
6
  let(:search_builder) { SearchBuilder.new(method_chain, context) }
6
- let(:method_chain) { CatalogController.search_params_logic }
7
+ let(:method_chain) { SearchBuilder.default_processor_chain }
7
8
  let(:context) { controller }
8
9
 
9
10
  let(:user) { User.new }
@@ -63,6 +64,28 @@ describe Blacklight::AccessControls::Enforcement do
63
64
  end
64
65
  end
65
66
 
67
+ describe "#except" do
68
+ let(:user) { build(:user) }
69
+ let(:ability) { Ability.new(user) }
70
+ before { search_builder.current_ability = ability }
71
+ subject { search_builder.except('foo') }
72
+
73
+ it "keeps the current_ability set" do
74
+ expect(subject.current_ability).to eq ability
75
+ end
76
+ end
77
+
78
+ describe "#append" do
79
+ let(:user) { build(:user) }
80
+ let(:ability) { Ability.new(user) }
81
+ before { search_builder.current_ability = ability }
82
+ subject { search_builder.append('foo') }
83
+
84
+ it "keeps the current_ability set" do
85
+ expect(subject.current_ability).to eq ability
86
+ end
87
+ end
88
+
66
89
  describe "apply_gated_discovery" do
67
90
  let(:user) { create(:user) }
68
91
  let(:groups) { ["archivist","researcher"] }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blacklight-access_controls
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Beer
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2015-12-04 00:00:00.000000000 Z
14
+ date: 2016-01-21 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: cancancan
@@ -33,14 +33,14 @@ dependencies:
33
33
  requirements:
34
34
  - - "~>"
35
35
  - !ruby/object:Gem::Version
36
- version: '5.16'
36
+ version: '6.0'
37
37
  type: :runtime
38
38
  prerelease: false
39
39
  version_requirements: !ruby/object:Gem::Requirement
40
40
  requirements:
41
41
  - - "~>"
42
42
  - !ruby/object:Gem::Version
43
- version: '5.16'
43
+ version: '6.0'
44
44
  - !ruby/object:Gem::Dependency
45
45
  name: rake
46
46
  requirement: !ruby/object:Gem::Requirement
@@ -133,6 +133,7 @@ extensions: []
133
133
  extra_rdoc_files: []
134
134
  files:
135
135
  - ".gitignore"
136
+ - ".travis.yml"
136
137
  - Gemfile
137
138
  - README.textile
138
139
  - Rakefile
@@ -149,6 +150,7 @@ files:
149
150
  - lib/blacklight/access_controls/user.rb
150
151
  - lib/generators/blacklight/ability.rb
151
152
  - lib/generators/blacklight/access_controls_generator.rb
153
+ - lib/generators/blacklight/blacklight_access_controls.rb
152
154
  - solr_conf/conf/abc123
153
155
  - solr_conf/conf/admin-extra.html
154
156
  - solr_conf/conf/admin-extra.menu-bottom.html