Skip to content

Commit

Permalink
Merge pull request #264 from curationexperts/refactoring-agencies
Browse files Browse the repository at this point in the history
refactoring partnering services
  • Loading branch information
bess committed May 30, 2017
2 parents ad81d6a + c934c11 commit 4ec1a0c
Show file tree
Hide file tree
Showing 10 changed files with 53 additions and 43 deletions.
4 changes: 4 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,7 @@ RSpec/ExampleLength:

RSpec/MultipleExpectations:
Enabled: false

# complaining about the Capfile name. Wants it to be snake_case
Style/FileName:
Enabled: false
10 changes: 5 additions & 5 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,10 @@ GEM
declarative-option (0.1.0)
deprecation (1.0.0)
activesupport
devise (4.2.1)
devise (4.3.0)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 4.1.0, < 5.1)
railties (>= 4.1.0, < 5.2)
responders
warden (~> 1.2.3)
devise-guests (0.6.0)
Expand Down Expand Up @@ -656,7 +656,7 @@ GEM
docile (~> 1.1.0)
json (>= 1.8, < 3)
simplecov-html (~> 0.10.0)
simplecov-html (0.10.0)
simplecov-html (0.10.1)
sinatra (2.0.0.rc2)
mustermann (= 1.0.0)
rack (~> 2.0)
Expand All @@ -678,7 +678,7 @@ GEM
nokogiri
stomp
xml-simple
spring (2.0.1)
spring (2.0.2)
activesupport (>= 4.2)
spring-watcher-listen (2.0.1)
listen (>= 2.7, < 4.0)
Expand Down Expand Up @@ -710,7 +710,7 @@ GEM
thor (0.19.4)
thread_safe (0.3.6)
tilt (2.0.7)
tins (1.13.2)
tins (1.14.0)
tinymce-rails (4.6.2)
railties (>= 3.1.1)
tinymce-rails-imageupload (4.0.17.beta.3)
Expand Down
5 changes: 4 additions & 1 deletion app/controllers/catalog_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,10 @@ def self.modified_field
config.add_show_field solr_name("resource_type", :stored_searchable), label: "Resource Type"
config.add_show_field solr_name("format", :stored_searchable), label: "File Format"
config.add_show_field solr_name("identifier", :stored_searchable), label: "Identifier"

config.add_show_field solr_name("degree", :stored_searchable), label: "Degree"
config.add_show_field solr_name("department", :stored_searchable), label: "Department"
config.add_show_field solr_name("school", :stored_searchable), label: "School"
config.add_show_field solr_name("partnering_agency", :stored_searchable), label: "Partnering Agency"
# "fielded" search configuration. Used by pulldown among other places.
# For supported keys in hash, see rdoc for Blacklight::SearchFields
#
Expand Down
16 changes: 16 additions & 0 deletions app/services/hyrax/partners_service.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# services/partners_service.rb
module Hyrax
class PartnersService < Hyrax::QaSelectService
def initialize
super('partnering_agencies')
end

def include_current_value(value, _index, render_options, html_options)
unless value.blank? || active?(value)
html_options[:class] << ' force-select'
render_options += [[label(value), value]]
end
[render_options, html_options]
end
end
end
15 changes: 0 additions & 15 deletions app/services/partners_service.rb

This file was deleted.

9 changes: 5 additions & 4 deletions app/views/records/edit_fields/_partnering_agency.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<%= f.input :partnering_agency, as: :select,
collection: PartnersService.select_all_options,
<% partnering_service = Hyrax::PartnersService.new %>
<%= f.input :partnering_agency, as: :multi_value_select,
collection: partnering_service.select_all_options,
include_blank: true,
input_html: { class: 'form-control' }
%>
item_helper: partnering_service.method(:include_current_value),
input_html: { class: 'form-control' } %>
1 change: 1 addition & 0 deletions capfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

# Load DSL and set up stages
require "capistrano/setup"

Expand Down
1 change: 1 addition & 0 deletions spec/features/create_etd_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
fill_in "School", with: "Emory College of Arts and Sciences"
fill_in "Degree", with: "Bachelor of Arts with Honors"
select('All rights reserved', from: 'Rights')
select('CDC', from: 'Partnering agency')
choose('open')
check('agreement')
click_on('My PDF')
Expand Down
17 changes: 17 additions & 0 deletions spec/services/hyrax/partners_service_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
require 'spec_helper'

RSpec.describe Hyrax::PartnersService do
before do
# Configure QA to use fixtures
qa_fixtures = { local_path: File.expand_path('config/authorities') }
allow(Qa::Authorities::Local).to receive(:config).and_return(qa_fixtures)
end

let(:service) { described_class.new }

describe "#select_all_options" do
it "has a select list" do
expect(service.select_all_options).to include(["Does not apply (no collaborating organization)", "Does not apply (no collaborating organization)"])
end
end
end
18 changes: 0 additions & 18 deletions spec/services/partners_service_spec.rb

This file was deleted.

0 comments on commit 4ec1a0c

Please sign in to comment.