Skip to content
This repository has been archived by the owner on Jun 27, 2020. It is now read-only.

Commit

Permalink
Upgrade ddr-models to 1.13; closes #1325.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jim Coble committed Apr 22, 2015
1 parent ab88c4e commit c9657c9
Show file tree
Hide file tree
Showing 16 changed files with 46 additions and 42 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ language: ruby
before_install:
- sudo apt-get update -qq
- sudo apt-get install -qq libclamav6 libclamav-dev clamav clamav-data
- sudo apt-get install -qq libvips-dev
rvm:
- 2.1
before_script:
Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ source 'http://rubygems.org'
gem 'rails', '~> 4.1.6'
gem 'hydra-head', '~> 7.2.0'
gem 'ddr-alerts', '~> 1.0.0'
gem 'ddr-models', '~> 1.12.3'
gem 'ddr-models', '~> 1.13.2'
gem 'devise'
gem 'deprecation'

Expand Down
25 changes: 9 additions & 16 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -86,18 +86,18 @@ GEM
rails (~> 4.1.6)
ddr-antivirus (1.3.2)
activesupport (~> 4.0)
ddr-models (1.12.3)
ddr-models (1.13.2)
active-fedora (~> 7.0)
ddr-antivirus (~> 1.3.1)
devise (~> 3.4)
ezid-client (~> 1.0)
grouper-rest-client
hydra-core (~> 7.2)
hydra-derivatives
hydra-validations
hydra-validations (~> 0.5)
net-ldap (~> 0.11)
omniauth-shibboleth (~> 1.2.0)
rails (~> 4.1.6)
rdf-vocab (~> 0.4)
rdf-vocab (= 0.7.0)
resque (~> 1.25)
deprecation (0.1.0)
activesupport
Expand All @@ -118,7 +118,7 @@ GEM
nokogiri (>= 1.4.3)
erubis (2.7.0)
execjs (2.2.2)
ezid-client (1.0.1)
ezid-client (1.1.0)
factory_girl (4.5.0)
activesupport (>= 3.0.0)
factory_girl_rails (4.5.0)
Expand All @@ -131,7 +131,7 @@ GEM
rest-client (>= 1.6.1)
haml (4.0.6)
tilt
hashie (3.4.0)
hashie (3.4.1)
hike (1.2.3)
hooks (0.3.6)
uber (~> 0.0.4)
Expand All @@ -149,18 +149,11 @@ GEM
hydra-access-controls (= 7.2.2)
jettywrapper (>= 1.4.1)
rails (>= 3.2.3, < 5)
hydra-derivatives (0.1.1)
active-fedora
activesupport (>= 3.2.13, < 5.0)
hydra-file_characterization
mini_magick
hydra-file_characterization (0.3.1)
activesupport (>= 3.0.0)
hydra-head (7.2.2)
hydra-access-controls (= 7.2.2)
hydra-core (= 7.2.2)
rails (>= 3.2.6)
hydra-validations (0.4.0)
hydra-validations (0.5.0)
activemodel (~> 4.0)
i18n (0.7.0)
jettywrapper (1.8.3)
Expand Down Expand Up @@ -204,7 +197,6 @@ GEM
mail (2.6.3)
mime-types (>= 1.16, < 3)
mime-types (1.25.1)
mini_magick (4.2.0)
mini_portile (0.6.2)
minitest (5.5.1)
mono_logger (1.1.0)
Expand All @@ -213,6 +205,7 @@ GEM
nest (1.1.2)
redis
net-http-persistent (2.9.4)
net-ldap (0.11)
netrc (0.10.2)
nokogiri (1.6.6.2)
mini_portile (~> 0.6.0)
Expand Down Expand Up @@ -425,7 +418,7 @@ DEPENDENCIES
coveralls
database_cleaner
ddr-alerts (~> 1.0.0)
ddr-models (~> 1.12.3)
ddr-models (~> 1.13.2)
deprecation
devise
equivalent-xml
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def find_models_with_gated_discovery(model, opts={})
end

def group_service
@group_service ||= Ddr::Auth::RemoteGroupService.new(request.env)
@group_service ||= Ddr::Auth::Groups.build(current_user, request.env)
end

def all_permissions
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ def group_options(groups)

def all_group_options
# TODO: List public first, then registered, then rest in alpha order (?)
@all_group_options ||= group_options(group_service.groups)
@all_group_options ||= group_options(Ddr::Auth::Groups.all)
end

def selected_group_options(permission)
Expand Down
8 changes: 4 additions & 4 deletions spec/controllers/collections_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def new_collection
end

def update_policy
patch :default_permissions, id: object, permissions: {"discover" => ["group:public", "user:Sally", "user:Mitch"], "read" => ["group:registered", "user:Gil", "user:Ben"], "edit" => ["group:editors", "group:managers", "user:Rocky", "user:Gwen", "user:Teresa"]}, license: {"title" => "No Access", "description" => "No one can get to it", "url" => "http://www.example.com"}
patch :default_permissions, id: object, permissions: {"discover" => ["group:public", "user:Sally@example.com", "user:Mitch@example.com"], "read" => ["group:registered", "user:Gil@example.com", "user:Ben@example.com"], "edit" => ["group:editors", "group:managers", "user:Rocky@example.com", "user:Gwen@example.com", "user:Teresa@example.com"]}, license: {"title" => "No Access", "description" => "No one can get to it", "url" => "http://www.example.com"}
end

describe CollectionsController, type: :controller, collections: true do
Expand Down Expand Up @@ -149,9 +149,9 @@ def update_policy
expect(object.default_discover_groups).to eq(["public"])
expect(object.default_read_groups).to eq(["registered"])
expect(object.default_edit_groups).to eq(["editors", "managers"])
expect(object.default_discover_users).to eq(["Sally", "Mitch"])
expect(object.default_read_users).to eq(["Gil", "Ben"])
expect(object.default_edit_users).to eq(["Rocky", "Gwen", "Teresa"])
expect(object.default_discover_users).to eq(["Sally@example.com", "Mitch@example.com"])
expect(object.default_read_users).to eq(["Gil@example.com", "Ben@example.com"])
expect(object.default_edit_users).to eq(["Rocky@example.com", "Gwen@example.com", "Teresa@example.com"])
expect(object.default_license_title).to eq("No Access")
expect(object.default_license_description).to eq("No one can get to it")
expect(object.default_license_url).to eq("http://www.example.com")
Expand Down
4 changes: 2 additions & 2 deletions spec/controllers/components_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ def create_component opts={}
create_component
expect(assigns(:current_object).parent).to eq(item)
end
it "should have a thumbnail (if it's an image)" do
it "should update derivatives" do
expect_any_instance_of(Ddr::Managers::DerivativesManager).to receive(:update_derivatives)
create_component
expect(assigns(:current_object)).to have_thumbnail
end
it "should create an event" do
expect{ create_component }.to change{ Ddr::Events::CreationEvent.count }.by(1)
Expand Down
4 changes: 2 additions & 2 deletions spec/factories/user_factories.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FactoryGirl.define do
factory :user do
sequence(:username) { |n| "person#{n}" }
email { |u| "#{u.username}@example.com" }
sequence(:username) { |n| "person#{n}@example.com" }
email { |u| u.username }
password "secret"
end
end
2 changes: 1 addition & 1 deletion spec/features/grouper_integration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
object.read_groups = ["duke:library:repository:ddr:foo:bar"]
object.save!
Warden.on_next_request do |proxy|
proxy.env[Ddr::Auth.remote_groups_env_key] = "urn:mace:duke.edu:groups:library:repository:ddr:foo:bar"
proxy.env["ismemberof"] = "urn:mace:duke.edu:groups:library:repository:ddr:foo:bar"
proxy.set_user user
end
end
Expand Down
1 change: 1 addition & 0 deletions spec/features/policy_views_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
let(:user) { FactoryGirl.create(:user) }
let(:object) { FactoryGirl.create(:collection) }
before do
allow(Ddr::Auth::Groups).to receive(:all) { ["public", "registered", "repositoryEditor", "repositoryAdmin" ] }
object.edit_users = [user.user_key]
object.default_permissions = [{type: "group", access: "read", name: "registered"},
{type: "group", access: "edit", name: "repositoryEditor"}]
Expand Down
2 changes: 1 addition & 1 deletion spec/models/ingest_folder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@
context "collection has no admin policy" do
context "collection has individual permissions" do
before do
collection.permissions_attributes = [ { type: 'user', name: 'person1', access: 'read' } ]
collection.permissions_attributes = [ { type: 'user', name: 'person1@example.com', access: 'read' } ]
collection.save(validate: false)
ingest_folder.procezz
objects, atts, dss, rels = populate_comparison_hashes(user.batches.first.batch_objects)
Expand Down
2 changes: 1 addition & 1 deletion spec/scripts/batch_fixity_check_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ module Scripts
end
describe "the report" do
let(:csv) { CSV.read(report.path, headers: true) }
let(:datastreams_with_content) { ["DC", "RELS-EXT", "descMetadata", "content", "thumbnail", "adminMetadata", "structMetadata"] }
let(:datastreams_with_content) { ["DC", "RELS-EXT", "descMetadata", "content", "thumbnail", "multiresImage", "adminMetadata", "structMetadata"] }
before do
@objects = FactoryGirl.create_list(:component, 5)
bfc.execute
Expand Down
10 changes: 7 additions & 3 deletions spec/scripts/thumbnails_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,22 @@ module DulHydra::Scripts
item.reload
end
it "should populate the thumbnail datastream from the child thumbnail" do
expect(item.datastreams['thumbnail'].content).to eq(component.datastreams['thumbnail'].content)
expect(item.datastreams['thumbnail'].checksum).to eq(component.datastreams['thumbnail'].checksum)
end
end

context "child does not have thumbnail" do
before do
component.thumbnail.delete
component.datastreams['content'].delete
component.save!
component.reload
component.datastreams['thumbnail'].delete
component.save!
thumbnails_script.execute
item.reload
end
it "should not populate the thumbnail datastream" do
expect(item.datastreams["thumbnail"].content).to be_nil
expect(item.datastreams["thumbnail"]).to_not have_content
end
end

Expand Down
5 changes: 5 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
require 'capybara/rspec'
require 'dul_hydra'
require 'database_cleaner'
require "ddr/auth/test_helpers"

DatabaseCleaner.strategy = :truncation

Expand Down Expand Up @@ -55,13 +56,17 @@
ActiveFedora::Base.destroy_all
Ddr::Models.configure do |config|
config.external_file_store = Dir.mktmpdir
config.multires_image_external_file_store = Dir.mktmpdir
config.external_file_subpath_pattern = "--"
end
end
config.after(:suite) do
if Ddr::Models.external_file_store && Dir.exist?(Ddr::Models.external_file_store)
FileUtils.remove_entry_secure(Ddr::Models.external_file_store)
end
if Ddr::Models.multires_image_external_file_store && Dir.exist?(Ddr::Models.multires_image_external_file_store)
FileUtils.remove_entry_secure(Ddr::Models.multires_image_external_file_store)
end
end
config.after(:each) { ActiveFedora::Base.destroy_all }
config.after(:each, type: :feature) { Warden.test_reset! }
Expand Down
8 changes: 4 additions & 4 deletions spec/support/shared_examples_for_repository_controllers.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
def update_rights
patch :permissions, id: object, permissions: {"discover" => ["group:public", "user:Sally", "user:Mitch"], "read" => ["group:registered", "user:Gil", "user:Ben"], "edit" => ["group:editors", "group:managers", "user:Rocky", "user:Gwen", "user:Teresa"]}, license: {"title" => "No Access", "description" => "No one can get to it", "url" => "http://www.example.com"}
patch :permissions, id: object, permissions: {"discover" => ["group:public", "user:Sally@example.com", "user:Mitch@example.com"], "read" => ["group:registered", "user:Gil@example.com", "user:Ben@example.com"], "edit" => ["group:editors", "group:managers", "user:Rocky@example.com", "user:Gwen@example.com", "user:Teresa@example.com"]}, license: {"title" => "No Access", "description" => "No one can get to it", "url" => "http://www.example.com"}
end

def object_symbol
Expand Down Expand Up @@ -60,9 +60,9 @@ def update_metadata
expect(object.discover_groups).to eq(["public"])
expect(object.read_groups).to eq(["registered"])
expect(object.edit_groups).to eq(["editors", "managers"])
expect(object.discover_users).to eq(["Sally", "Mitch"])
expect(object.read_users).to eq(["Gil", "Ben"])
expect(object.edit_users).to eq(["Rocky", "Gwen", "Teresa"])
expect(object.discover_users).to eq(["Sally@example.com", "Mitch@example.com"])
expect(object.read_users).to eq(["Gil@example.com", "Ben@example.com"])
expect(object.edit_users).to eq(["Rocky@example.com", "Gwen@example.com", "Teresa@example.com"])
expect(object.license_title).to eq("No Access")
expect(object.license_description).to eq("No one can get to it")
expect(object.license_url).to eq("http://www.example.com")
Expand Down
10 changes: 5 additions & 5 deletions spec/support/shared_examples_for_repository_views.rb
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def setup
setup
object.roles.downloader << user.principal_name # require for Components
object.save
allow(user).to receive(:groups) { ["public", "registered"] }
allow(user).to receive(:groups) { Ddr::Auth::Groups.new(["public", "registered"]) }
end
it "should have a download link" do
visit url_for(object)
Expand Down Expand Up @@ -302,17 +302,17 @@ def setup
let(:user) { FactoryGirl.create(:user) }
before do
setup
coll.default_permissions = [{type: "user", name: "Bob", access: "read"},
{type: "group", name: "Special People", access: "edit"}]
coll.default_permissions = [{type: "user", name: "Bob@example.com", access: "read"},
{type: "group", name: "SpecialPeople", access: "edit"}]
coll.save
object.edit_users = [user.user_key]
object.admin_policy = coll
object.save
end
it "should display the inherited permissions" do
visit url_for(controller: object.controller_name, action: "permissions", id: object)
expect(find('#access-level-read')).to have_content("Bob")
expect(find('#access-level-edit')).to have_content("Special People")
expect(find('#access-level-read')).to have_content("Bob@example.com")
expect(find('#access-level-edit')).to have_content("SpecialPeople")
end
end
end

0 comments on commit c9657c9

Please sign in to comment.