-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add SolrEndpoint configuration to allow accounts to point at differen…
…t solr urls
- Loading branch information
Showing
14 changed files
with
184 additions
and
4 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
class Endpoint < ActiveRecord::Base | ||
has_one :account | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
class SolrEndpoint < Endpoint | ||
store :options, accessors: [:url] | ||
|
||
def self.default_options | ||
ActiveFedora::SolrService.instance.conn.options.slice(:url) | ||
end | ||
|
||
def connection | ||
RSolr.connect(connection_options) | ||
end | ||
|
||
def connection_options | ||
options.reverse_merge(ActiveFedora::SolrService.instance.conn.options) | ||
end | ||
|
||
def switch! | ||
ActiveFedora::SolrService.register(url, connection_options) | ||
Blacklight.instance_variable_set(:@default_index, connection) | ||
end | ||
end |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
class CreateEndpoints < ActiveRecord::Migration | ||
def change | ||
create_table :endpoints do |t| | ||
t.string :type | ||
t.binary :options | ||
|
||
t.timestamps null: false | ||
end | ||
end | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
class AddSolrEndpointToAccount < ActiveRecord::Migration | ||
def change | ||
add_column :accounts, :accounts, :string | ||
add_column :accounts, :solr_endpoint_id, :integer | ||
end | ||
end |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.describe 'Accounts administration' do | ||
context 'as an superadmin' do | ||
let(:user) { FactoryGirl.create(:superadmin) } | ||
let(:account) { FactoryGirl.create(:account) } | ||
|
||
before do | ||
login_as(user, scope: :user) | ||
end | ||
|
||
it 'changes the associated cname' do | ||
visit edit_account_path(account) | ||
|
||
fill_in 'Cname', with: 'example.com' | ||
|
||
click_on 'Update Account' | ||
|
||
account.reload | ||
|
||
expect(account.cname).to eq 'example.com' | ||
end | ||
|
||
it 'changes the solr endpoint url' do | ||
visit edit_account_path(account) | ||
|
||
fill_in 'Url', with: 'http://example.com/solr/' | ||
|
||
click_on 'Update Account' | ||
|
||
account.reload | ||
|
||
expect(account.solr_endpoint.url).to eq 'http://example.com/solr/' | ||
end | ||
end | ||
end |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.describe SolrEndpoint do | ||
subject { described_class.new url: 'http://example.com/solr/' } | ||
describe '.default_attributes' do | ||
it 'uses the configured application settings' do | ||
expect(described_class.default_options).to eq url: ActiveFedora::SolrService.instance.conn.options[:url] | ||
end | ||
end | ||
|
||
describe '#connection_options' do | ||
it 'merges the model attributes with the application settings' do | ||
expect(subject.connection_options).to include url: 'http://example.com/solr/', read_timeout: 120 | ||
end | ||
end | ||
|
||
describe '#connection' do | ||
it 'initializes an RSolr connection with the model options' do | ||
expect(subject.connection).to be_a_kind_of RSolr::Client | ||
expect(subject.connection.uri.to_s).to eq 'http://example.com/solr/' | ||
end | ||
end | ||
end |