ddr-models 1.2.1 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +75 -1
  3. data/app/models/attachment.rb +6 -1
  4. data/app/models/collection.rb +19 -1
  5. data/app/models/component.rb +6 -1
  6. data/app/models/item.rb +6 -1
  7. data/app/models/solr_document.rb +3 -0
  8. data/app/models/target.rb +8 -1
  9. data/config/initializers/devise.rb~ +245 -0
  10. data/db/migrate/20141104181418_create_users.rb~ +6 -0
  11. data/lib/ddr/auth.rb +6 -1
  12. data/lib/ddr/auth.rb~ +47 -0
  13. data/lib/ddr/auth/ability.rb +5 -0
  14. data/lib/ddr/auth/ability.rb~ +204 -0
  15. data/lib/ddr/auth/group_service.rb~ +53 -0
  16. data/lib/ddr/auth/grouper_service.rb~ +77 -0
  17. data/lib/ddr/auth/remote_group_service.rb~ +35 -0
  18. data/lib/ddr/auth/superuser.rb~ +9 -0
  19. data/lib/ddr/auth/user.rb~ +65 -0
  20. data/lib/ddr/index_fields.rb +2 -2
  21. data/lib/ddr/models.rb +21 -4
  22. data/lib/ddr/models/engine.rb +26 -13
  23. data/lib/ddr/models/version.rb +1 -1
  24. data/lib/ddr/services/id_service.rb +4 -2
  25. data/spec/dummy/db/development.sqlite3 +0 -0
  26. data/spec/dummy/log/development.log +2727 -1701
  27. data/spec/dummy/log/test.log +56845 -35270
  28. data/spec/factories/attachment_factories.rb +0 -4
  29. data/spec/factories/collection_factories.rb +0 -8
  30. data/spec/factories/component_factories.rb +1 -6
  31. data/spec/factories/item_factories.rb +0 -8
  32. data/spec/factories/user_factories.rb~ +7 -0
  33. data/spec/features/grouper_integration_spec.rb~ +21 -0
  34. data/spec/models/ability_spec.rb +11 -24
  35. data/spec/models/ability_spec.rb~ +245 -0
  36. data/spec/models/superuser_spec.rb~ +13 -0
  37. data/spec/models/user_spec.rb~ +56 -0
  38. data/spec/services/group_service_spec.rb~ +71 -0
  39. data/spec/spec_helper.rb +16 -25
  40. metadata +23 -18
  41. data/config/initializers/ddr.rb +0 -8
  42. data/lib/ddr/configurable.rb +0 -34
@@ -0,0 +1,71 @@
1
+ require 'spec_helper'
2
+
3
+ describe DulHydra::Services::GroupService do
4
+ subject { described_class.new }
5
+
6
+ describe "#groups" do
7
+ describe "at minimum" do
8
+ it "should include the 'public' and 'registered' groups" do
9
+ expect(subject.groups).to include("public", "registered")
10
+ end
11
+ end
12
+ describe "using #append_groups hook" do
13
+ before { allow(subject).to receive(:append_groups).and_return(["spam:eggs", "fish:water"]) }
14
+ it "should add the groups to the list" do
15
+ expect(subject.groups).to include("spam:eggs", "fish:water")
16
+ end
17
+ end
18
+ describe "when RoleMapper config file is present and not empty" do
19
+ before do
20
+ allow(described_class).to receive(:include_role_mapper_groups).and_return(true)
21
+ allow(RoleMapper).to receive(:role_names).and_return(["foo", "bar"])
22
+ end
23
+ it "should include the role mapper groups" do
24
+ expect(subject.groups).to include("foo", "bar")
25
+ end
26
+ end
27
+ describe "when RoleMapper config file is missing or empty" do
28
+ before { allow(described_class).to receive(:include_role_mapper_groups).and_return(false) }
29
+ it "should only include the default minimum groups" do
30
+ expect(subject.groups).to match_array(["public", "registered"])
31
+ end
32
+ end
33
+ end
34
+
35
+ describe "#user_groups(user)" do
36
+ describe "when user is not persisted" do
37
+ let(:user) { FactoryGirl.build(:user) }
38
+ it "should return only 'public' group" do
39
+ expect(subject.user_groups(user)).to eq(["public"])
40
+ end
41
+ end
42
+ describe "when the user is persisted" do
43
+ let(:user) { FactoryGirl.create(:user) }
44
+ it "should include the 'public' and 'registered' groups" do
45
+ expect(subject.user_groups(user)).to include("public", "registered")
46
+ end
47
+ describe "using #append_user_groups(user) hook" do
48
+ before { allow(subject).to receive(:append_user_groups).with(user).and_return(["spam:eggs", "fish:water"]) }
49
+ it "should add the groups to the list" do
50
+ expect(subject.user_groups(user)).to include("spam:eggs", "fish:water")
51
+ end
52
+ end
53
+ describe "when the RoleMapper config file is present and not empty" do
54
+ before do
55
+ allow(described_class).to receive(:include_role_mapper_groups).and_return(true)
56
+ allow(RoleMapper).to receive(:roles).with(user).and_return(["foo", "bar"])
57
+ end
58
+ it "should add the user's roles to the list" do
59
+ expect(subject.user_groups(user)).to include("foo", "bar")
60
+ end
61
+ end
62
+ describe "when RoleMapper config file is missing or empty" do
63
+ before { allow(described_class).to receive(:include_role_mapper_groups).and_return(false) }
64
+ it "should only include the default minimum groups" do
65
+ expect(subject.groups).to match_array(["public", "registered"])
66
+ end
67
+ end
68
+ end
69
+ end
70
+ end
71
+
@@ -7,33 +7,19 @@ require "rails"
7
7
  require "rspec/rails"
8
8
  require "factory_girl_rails"
9
9
  require "database_cleaner"
10
+ require "tempfile"
10
11
 
11
12
  Dir[File.join(File.dirname(__FILE__), "support", "*.rb")].each { |f| require f }
12
13
 
13
14
  DatabaseCleaner.strategy = :truncation
14
15
 
15
16
  require "ddr-antivirus"
16
- Ddr::Antivirus.scanner_adapter = :null
17
-
18
- require "logger"
19
- Ddr::Antivirus.logger = Logger.new(File::NULL)
20
-
21
- # This file was generated by the `rspec --init` command. Conventionally, all
22
- # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
23
- # The generated `.rspec` file contains `--require spec_helper` which will cause this
24
- # file to always be loaded, without a need to explicitly require it in any files.
25
- #
26
- # Given that it is always loaded, you are encouraged to keep this file as
27
- # light-weight as possible. Requiring heavyweight dependencies from this file
28
- # will add to the boot time of your test suite on EVERY test run, even for an
29
- # individual file that may not need all of that loaded. Instead, consider making
30
- # a separate helper file that requires the additional dependencies and performs
31
- # the additional setup, and require it from the spec files that actually need it.
32
- #
33
- # The `.rspec` file also contains a few flags that are not defaults but that
34
- # users commonly want.
35
- #
36
- # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
17
+ Ddr::Antivirus.configure do |config|
18
+ config.scanner_adapter = :null
19
+ require "logger"
20
+ config.logger = Logger.new(File::NULL)
21
+ end
22
+
37
23
  RSpec.configure do |config|
38
24
 
39
25
  config.include ActionDispatch::TestProcess
@@ -79,7 +65,7 @@ RSpec.configure do |config|
79
65
 
80
66
  # This setting enables warnings. It's recommended, but in some cases may
81
67
  # be too noisy due to issues in dependencies.
82
- #config.warnings = true
68
+ config.warnings = false
83
69
 
84
70
  # Many RSpec users commonly either run the entire suite or an individual
85
71
  # file, and it's useful to allow more verbose output when running an
@@ -94,7 +80,7 @@ RSpec.configure do |config|
94
80
  # Print the 10 slowest examples and example groups at the
95
81
  # end of the spec run, to help surface which specs are running
96
82
  # particularly slow.
97
- #config.profile_examples = 10
83
+ # config.profile_examples = 10
98
84
 
99
85
  # Run specs in random order to surface order dependencies. If you find an
100
86
  # order dependency and want to debug it, you can fix the order by providing
@@ -111,11 +97,16 @@ RSpec.configure do |config|
111
97
  config.before(:suite) do
112
98
  DatabaseCleaner.clean
113
99
  ActiveFedora::Base.destroy_all
114
- Ddr::Models.external_file_store = Dir.mktmpdir
100
+ Ddr::Models.configure do |config|
101
+ config.external_file_store = Dir.mktmpdir
102
+ config.external_file_subpath_pattern = "--"
103
+ config.minter_statefile = Tempfile.new("minter_statefile").path
104
+ end
115
105
  end
116
106
 
117
107
  config.after(:suite) do
118
- FileUtils.remove_entry_secure Ddr::Models.external_file_store
108
+ FileUtils.remove_entry_secure(Ddr::Models.external_file_store)
109
+ FileUtils.remove_entry_secure(Ddr::Models.minter_statefile)
119
110
  end
120
111
 
121
112
  config.after(:each) do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ddr-models
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jim Coble
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-11-10 00:00:00.000000000 Z
12
+ date: 2014-11-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -81,20 +81,6 @@ dependencies:
81
81
  - - ">="
82
82
  - !ruby/object:Gem::Version
83
83
  version: '0'
84
- - !ruby/object:Gem::Dependency
85
- name: clamav
86
- requirement: !ruby/object:Gem::Requirement
87
- requirements:
88
- - - ">="
89
- - !ruby/object:Gem::Version
90
- version: '0'
91
- type: :runtime
92
- prerelease: false
93
- version_requirements: !ruby/object:Gem::Requirement
94
- requirements:
95
- - - ">="
96
- - !ruby/object:Gem::Version
97
- version: '0'
98
84
  - !ruby/object:Gem::Dependency
99
85
  name: noid
100
86
  requirement: !ruby/object:Gem::Requirement
@@ -267,26 +253,33 @@ files:
267
253
  - app/models/target.rb
268
254
  - config/initializers/active_fedora_base.rb
269
255
  - config/initializers/active_fedora_datastream.rb
270
- - config/initializers/ddr.rb
271
256
  - config/initializers/devise.rb
257
+ - config/initializers/devise.rb~
272
258
  - config/initializers/subscriptions.rb
273
259
  - config/routes.rb
274
260
  - db/migrate/20141021233359_create_events.rb
275
261
  - db/migrate/20141021234156_create_minted_ids.rb
276
262
  - db/migrate/20141103192146_create_workflow_state.rb
277
263
  - db/migrate/20141104181418_create_users.rb
264
+ - db/migrate/20141104181418_create_users.rb~
278
265
  - db/migrate/20141107124012_add_columns_to_user.rb
279
266
  - lib/ddr-models.rb
280
267
  - lib/ddr/actions.rb
281
268
  - lib/ddr/actions/fixity_check.rb
282
269
  - lib/ddr/auth.rb
270
+ - lib/ddr/auth.rb~
283
271
  - lib/ddr/auth/ability.rb
272
+ - lib/ddr/auth/ability.rb~
284
273
  - lib/ddr/auth/group_service.rb
274
+ - lib/ddr/auth/group_service.rb~
285
275
  - lib/ddr/auth/grouper_service.rb
276
+ - lib/ddr/auth/grouper_service.rb~
286
277
  - lib/ddr/auth/remote_group_service.rb
278
+ - lib/ddr/auth/remote_group_service.rb~
287
279
  - lib/ddr/auth/superuser.rb
280
+ - lib/ddr/auth/superuser.rb~
288
281
  - lib/ddr/auth/user.rb
289
- - lib/ddr/configurable.rb
282
+ - lib/ddr/auth/user.rb~
290
283
  - lib/ddr/datastreams.rb
291
284
  - lib/ddr/datastreams/content_metadata_datastream.rb
292
285
  - lib/ddr/datastreams/datastream_behavior.rb
@@ -389,6 +382,8 @@ files:
389
382
  - spec/factories/target_factories.rb
390
383
  - spec/factories/test_model_factories.rb
391
384
  - spec/factories/user_factories.rb
385
+ - spec/factories/user_factories.rb~
386
+ - spec/features/grouper_integration_spec.rb~
392
387
  - spec/fixtures/contentMetadata.xml
393
388
  - spec/fixtures/image1.tiff
394
389
  - spec/fixtures/image2.tiff
@@ -398,6 +393,7 @@ files:
398
393
  - spec/fixtures/sample.pdf
399
394
  - spec/fixtures/target.png
400
395
  - spec/models/ability_spec.rb
396
+ - spec/models/ability_spec.rb~
401
397
  - spec/models/active_fedora_base_spec.rb
402
398
  - spec/models/active_fedora_datastream_spec.rb
403
399
  - spec/models/attachment_spec.rb
@@ -412,9 +408,12 @@ files:
412
408
  - spec/models/permanent_identification_spec.rb
413
409
  - spec/models/role_assignments_datastream_spec.rb
414
410
  - spec/models/superuser_spec.rb
411
+ - spec/models/superuser_spec.rb~
415
412
  - spec/models/target_spec.rb
416
413
  - spec/models/user_spec.rb
414
+ - spec/models/user_spec.rb~
417
415
  - spec/services/group_service_spec.rb
416
+ - spec/services/group_service_spec.rb~
418
417
  - spec/services/id_service_spec.rb
419
418
  - spec/spec_helper.rb
420
419
  - spec/support/shared_examples_for_access_controllables.rb
@@ -501,6 +500,8 @@ test_files:
501
500
  - spec/factories/target_factories.rb
502
501
  - spec/factories/test_model_factories.rb
503
502
  - spec/factories/user_factories.rb
503
+ - spec/factories/user_factories.rb~
504
+ - spec/features/grouper_integration_spec.rb~
504
505
  - spec/fixtures/contentMetadata.xml
505
506
  - spec/fixtures/image1.tiff
506
507
  - spec/fixtures/image2.tiff
@@ -510,6 +511,7 @@ test_files:
510
511
  - spec/fixtures/sample.pdf
511
512
  - spec/fixtures/target.png
512
513
  - spec/models/ability_spec.rb
514
+ - spec/models/ability_spec.rb~
513
515
  - spec/models/active_fedora_base_spec.rb
514
516
  - spec/models/active_fedora_datastream_spec.rb
515
517
  - spec/models/attachment_spec.rb
@@ -524,9 +526,12 @@ test_files:
524
526
  - spec/models/permanent_identification_spec.rb
525
527
  - spec/models/role_assignments_datastream_spec.rb
526
528
  - spec/models/superuser_spec.rb
529
+ - spec/models/superuser_spec.rb~
527
530
  - spec/models/target_spec.rb
528
531
  - spec/models/user_spec.rb
532
+ - spec/models/user_spec.rb~
529
533
  - spec/services/group_service_spec.rb
534
+ - spec/services/group_service_spec.rb~
530
535
  - spec/services/id_service_spec.rb
531
536
  - spec/spec_helper.rb
532
537
  - spec/support/shared_examples_for_access_controllables.rb
@@ -1,8 +0,0 @@
1
- Ddr::Models.configure do |config|
2
-
3
- config.external_file_store = ENV['EXTERNAL_FILE_STORE']
4
- config.external_file_subpath_pattern = ENV['EXTERNAL_FILE_SUBPATH_PATTERN'] || "--"
5
- config.noid_template = "2.reeddeeddk"
6
- config.minter_statefile = Rails.env.test? ? "/tmp/minter-state" : ENV['MINTER_STATEFILE']
7
-
8
- end
@@ -1,34 +0,0 @@
1
- module Ddr
2
- module Configurable
3
- extend ActiveSupport::Concern
4
-
5
- included do
6
- # Base directory of external file store
7
- mattr_accessor :external_file_store
8
-
9
- # Regexp for building external file subpath from hex digest
10
- mattr_accessor :external_file_subpath_regexp
11
-
12
- # Pattern (template) for constructing noids
13
- mattr_accessor :noid_template
14
-
15
- # Noid minter state file location
16
- mattr_accessor :minter_statefile
17
- end
18
-
19
- module ClassMethods
20
- def configure
21
- yield self
22
- end
23
-
24
- def external_file_subpath_pattern= (pattern)
25
- unless /^-{1,2}(\/-{1,2}){0,3}$/ =~ pattern
26
- raise "Invalid external file subpath pattern: #{pattern}"
27
- end
28
- re = pattern.split("/").map { |x| "(\\h{#{x.length}})" }.join("")
29
- self.external_file_subpath_regexp = Regexp.new("^#{re}")
30
- end
31
- end
32
-
33
- end
34
- end