Skip to content

Commit

Permalink
Warn user when initial connection to Fedora fails and the URL does no…
Browse files Browse the repository at this point in the history
…t end with /rest
  • Loading branch information
hectorcorrea committed Jan 13, 2015
1 parent 80d34ac commit 7b55677
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/active_fedora/fedora.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ def init_base_path
ActiveFedora::Base.logger.info "Attempted to init base path `#{root_resource_path}`, but it already exists" if ActiveFedora::Base.logger
return false
rescue Ldp::NotFound
if !host.downcase.end_with?("/rest")
ActiveFedora::Base.logger.warn "Fedora URL (#{host}) does not end with /rest. This could be the problem. Check your fedora.yml config"
end
connection.put(root_resource_path, BLANK).success?
end

Expand Down
18 changes: 18 additions & 0 deletions spec/unit/active_fedora_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,24 @@
restore_spec_configuration
end

describe "validate Fedora URL" do

let(:good_url) { ActiveFedora.fedora_config.credentials[:url] }
let(:bad_url) { good_url.gsub('/rest', '/') }

it "should connect OK" do
expect(ActiveFedora::Base.logger).to_not receive(:warn)
ActiveFedora::Fedora.new(:url => good_url, :base_path => '/test')
end

it "should not connect and warn" do
expect {
expect(ActiveFedora::Base.logger).to receive(:warn)
ActiveFedora::Fedora.new(:url => bad_url, :base_path => '/test')
}.to raise_error Ldp::HttpError
end
end

describe "initialization methods" do
describe "environment" do
it "should use config_options[:environment] if set" do
Expand Down

0 comments on commit 7b55677

Please sign in to comment.