Last active
December 21, 2015 02:08
-
-
Save cjcolvar/6232417 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/lib/avalon/batch_ingest.rb b/lib/avalon/batch_ingest.rb | |
index 62d7c6d..9b2cc62 100644 | |
--- a/lib/avalon/batch_ingest.rb | |
+++ b/lib/avalon/batch_ingest.rb | |
@@ -56,16 +56,18 @@ module Avalon | |
base_errors = [] | |
email_address = package.manifest.email || Avalon::Configuration['email']['notification'] | |
current_user = User.where(username: email_address).first || User.where(email: email_address).first | |
- ability = Ability.new current_user | |
- ability.instance_variable_set("@user", current_user) | |
- package.validate do |entry| | |
- media_object = Avalon::Batch.initialize_media_object_from_package( entry ) | |
- if media_object.collection && ! ability.can?(:read, media_object.collection) | |
- base_errors << "You do not have permission to add items to collection: #{media_object.collection.name}." | |
- elsif ! media_object.collection && entry.fields[:collection].present? | |
- base_errors << "There is not a collection in the system with the name: #{entry.fields[:collection].first}." | |
+ if current_user.nil? | |
+ base_errors << "User does not exist in the system: #{email_address}." | |
+ else | |
+ package.validate do |entry| | |
+ media_object = Avalon::Batch.initialize_media_object_from_package( entry ) | |
+ if media_object.collection && ! current_user.can?(:read, media_object.collection) | |
+ base_errors << "You do not have permission to add items to collection: #{media_object.collection.name}." | |
+ elsif ! media_object.collection && entry.fields[:collection].present? | |
+ base_errors << "There is not a collection in the system with the name: #{entry.fields[:collection].first}." | |
+ end | |
+ media_object | |
end | |
- media_object | |
end | |
if package.valid? && base_errors.empty? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rspec ./spec/lib/avalon/batch_ingest_spec.rb:75 # Avalon::Batch invalid manifest should fail if the manifest specified a non-manager user | |
Coverage report generated for RSpec to /home/cjcolvar/Code/avalon/avalon/coverage. 1294 / 2508 LOC (51.59%) covered. | |
[cjcolvar@localhost avalon]$ rspec spec/lib/avalon/batch_ingest_spec.rb | |
/home/cjcolvar/Code/avalon/avalon/spec/lib/avalon/batch_ingest_spec.rb:21: warning: already initialized constant DropboxService | |
*/home/cjcolvar/Code/avalon/avalon/spec/lib/avalon/batch_ingest_spec.rb:21: warning: already initialized constant DropboxService | |
*/home/cjcolvar/Code/avalon/avalon/spec/lib/avalon/batch_ingest_spec.rb:21: warning: already initialized constant DropboxService | |
./home/cjcolvar/Code/avalon/avalon/spec/lib/avalon/batch_ingest_spec.rb:21: warning: already initialized constant DropboxService | |
./home/cjcolvar/Code/avalon/avalon/spec/lib/avalon/batch_ingest_spec.rb:21: warning: already initialized constant DropboxService | |
./home/cjcolvar/Code/avalon/avalon/spec/lib/avalon/batch_ingest_spec.rb:21: warning: already initialized constant DropboxService | |
F | |
Pending: | |
Avalon::Batch should be able to default to public access | |
# [VOV-1348] Wait until implemented | |
# ./spec/lib/avalon/batch_ingest_spec.rb:83 | |
Avalon::Batch should be able to default to specific groups | |
# [VOV-1348] Wait until implemented | |
# ./spec/lib/avalon/batch_ingest_spec.rb:87 | |
Failures: | |
1) Avalon::Batch invalid manifest should fail if the manifest specified a non-manager user | |
Failure/Error: IngestBatchMailer.should_receive(:batch_ingest_validation_error).with(duck_type(:each),duck_type(:each)).and_return(mailer) | |
(<IngestBatchMailer (class)>).batch_ingest_validation_error(#<RSpec::Mocks::ArgumentMatchers::DuckTypeMatcher:0x00000009162a70 @methods_to_respond_to=[:each]>, #<RSpec::Mocks::ArgumentMatchers::DuckTypeMatcher:0x000000091629f8 @methods_to_respond_to=[:each]>) | |
expected: 1 time with arguments: (#<RSpec::Mocks::ArgumentMatchers::DuckTypeMatcher:0x00000009162a70 @methods_to_respond_to=[:each]>, #<RSpec::Mocks::ArgumentMatchers::DuckTypeMatcher:0x000000091629f8 @methods_to_respond_to=[:each]>) | |
received: 2 times with arguments: (#<RSpec::Mocks::ArgumentMatchers::DuckTypeMatcher:0x00000009162a70 @methods_to_respond_to=[:each]>, #<RSpec::Mocks::ArgumentMatchers::DuckTypeMatcher:0x000000091629f8 @methods_to_respond_to=[:each]>) | |
# ./spec/lib/avalon/batch_ingest_spec.rb:77:in `block (3 levels) in <top (required)>' | |
Finished in 53.82 seconds | |
6 examples, 1 failure, 2 pending | |
Failed examples: | |
rspec ./spec/lib/avalon/batch_ingest_spec.rb:75 # Avalon::Batch invalid manifest should fail if the manifest specified a non-manager user | |
Coverage report generated for RSpec to /home/cjcolvar/Code/avalon/avalon/coverage. 1294 / 2508 LOC (51.59%) covered. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment