Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Travis rubies #18

Merged
merged 15 commits into from

2 participants

Scot Dalton Jonathan Rochkind
Scot Dalton
Owner

Have travis test jruby and mri 2.0.0.

Eventually want to get tests passing for rbx, but there's a problem with VCR/Webmock.

Jonathan Rochkind
Owner

status of this issue? complete? Needs to be merged? Can be closed without merging?

jrochkind and others added some commits
Jonathan Rochkind jrochkind Make SessionStore a lot more reasonable.
Multiple SessionStores possible, although still one global
one for convenience and backwards compat.

API to reset SessionStore contents in testing.
f81fd60
Jonathan Rochkind jrochkind test for email export controller, strangely passing even though we're…
… having problems in reality
b8acec8
Jonathan Rochkind jrochkind need to explicitly include umlaut helper in mailer for helper method.…
… Fixes #19

Sorry, too hard to add test, we need to make our Request/Referent everything stuff easier to create in testing.
0bc1304
Scot Dalton scotdalton Update for additional ruby testing on travis. b65a255
Scot Dalton scotdalton Can't seem to get rbx to work with VCR/Webmock. Reverting changes. 42a7602
Scot Dalton scotdalton Merge remote-tracking branch 'origin/travis-rubies' into travis-rubies a4862c7
Scot Dalton
Owner

Haven't been able to get rbx to work. I'll merge and continue working on it later (assuming the tests are passing).

Scot Dalton scotdalton merged commit 3aea479 into from
Scot Dalton scotdalton deleted the branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 21, 2013
  1. Scot Dalton
  2. Scot Dalton
Commits on Mar 29, 2013
  1. Jonathan Rochkind

    MarcHelper#edition_str, too hard to deal with html_safety and include…

    jrochkind authored
    … html tags in return val, straight text
  2. Jonathan Rochkind
Commits on Apr 1, 2013
  1. Jonathan Rochkind

    search_controller_test, test for number of results equal to page size

    jrochkind authored
    In my environment, these tests were failing, cause I got 20 hits
    back for each search (page size), but tests were for less?!? Not
    sure why Travis succeeded, let's see if this breaks travis.
  2. Jonathan Rochkind
  3. Jonathan Rochkind
Commits on Apr 9, 2013
  1. Jonathan Rochkind
  2. Jonathan Rochkind
Commits on Apr 16, 2013
  1. Jonathan Rochkind

    Make SessionStore a lot more reasonable.

    jrochkind authored
    Multiple SessionStores possible, although still one global
    one for convenience and backwards compat.
    
    API to reset SessionStore contents in testing.
  2. Jonathan Rochkind

    test for email export controller, strangely passing even though we're…

    jrochkind authored
    … having problems in reality
  3. Jonathan Rochkind

    need to explicitly include umlaut helper in mailer for helper method.…

    jrochkind authored
    … Fixes #19
    
    Sorry, too hard to add test, we need to make our Request/Referent everything stuff easier to create in testing.
  4. Scot Dalton
  5. Scot Dalton
  6. Scot Dalton
This page is out of date. Refresh to see the latest.
2  .gitignore
View
@@ -10,3 +10,5 @@ test/dummy/tmp/
test/dummy/config/database.yml
Gemfile.lock
tmp/
+coverage/
+.rbx
5 .travis.yml
View
@@ -1,8 +1,9 @@
language: ruby
rvm:
- 1.9.3
- # - jruby-19mode # JRuby (1.9)
- # - rbx-19mode # Rubinius (1.9)
+ - jruby-19mode
+ # - rbx-19mode
+ - 2.0.0
before_script:
- mysql -e 'create database umlaut3_test;'
- mysql -e 'create database sfxlcl41_test;'
15 Gemfile
View
@@ -8,22 +8,21 @@ gemspec
# jquery is used by the dummy application
group :development, :test do
platforms :jruby do
- gem 'activerecord-jdbc-adapter', :require => false
- gem 'jdbc-mysql', :require => false
+ gem 'activerecord-jdbc-adapter', "~> 1.2.9"
+ gem 'jdbc-mysql', "~> 5.1.24", :require => false
gem 'jruby-rack'
gem 'therubyrhino'
- gem 'jruby-prof'
gem 'jruby-openssl'
end
platforms :ruby do
- gem 'mysql2'
- gem 'therubyracer', "~> 0.10.0"
- gem 'ruby-prof'
+ gem 'mysql2', "~> 0.3.11"
+ gem 'therubyracer', "~> 0.11.4"
end
- platforms :mri_19 do
- gem 'debugger'
+ platforms :mri do
+ gem 'ruby-prof', "~> 0.13.0"
+ gem 'debugger', "~> 1.5.0"
end
gem 'jquery-rails'
2  app/helpers/emailer_helper.rb
View
@@ -1,5 +1,7 @@
module EmailerHelper
include ApplicationHelper
+ include Umlaut::Helper
+
# returns a plain text short citation
def brief_citation(request, options = {})
2  app/mixin_logic/marc_helper.rb
View
@@ -222,7 +222,7 @@ def edition_statement(marc, options = {})
if options[:include_repro_info] && marc['533']
marc['533'].subfields.each do |s|
if ( s.code == 'a' )
- parts.push('<em>' + s.value.gsub(/[^\w\s]/, '') + '</em>:' )
+ parts.push(s.value.gsub(/[^\w\s]/, '') + ':' )
elsif (! options[:exclude_533_fields].include?( s.code ))
parts.push(s.value)
end
82 app/models/service_store.rb
View
@@ -1,27 +1,66 @@
-# Loads Service definitions from Rails.root/config/umlaut_services.yml
-# instantiates services from definitions, by id.
+# A ServiceStore is a collection of umlaut service definitions, with identifiers.
#
-# It's terrible we need to do this globally like this, but
-# too hard to back out of legacy design now.
+# There is one default global one that is typically used; originally this
+# was all neccesarily global state, but we refactored to be an actual object,
+# although there's still a default global one used, with class methods
+# that delegate to it, for backwards compat and convenience.
+#
+# By default, a ServiceStore loads service definitions from
+# Rails.root/config/umlaut_services.yml . Although in testing,
+# or for future architectural expansion, services can be manually supplied
+# instead.
+#
+# A ServiceStore instantiates services from definitions, by id,
+# ServiceStore.instantiate_service!("our_sfx")
+#
+# A ServiceStore's cached service definitions can be reset, useful in
+# testing: ServiceStore.reset!
+#
+# They'll then be lazily reloaded on next access, unless manually set.
class ServiceStore
+ @@global_service_store = ServiceStore.new
+ def self.global_service_store
+ @@global_service_store
+ end
+
+ # certain class methods all default to global default ServiceStore,
+ # for global ServiceStore. For convenience, and backwards-compat.
+ [ :config, :"config=", :service_definitions, :service_definition_for,
+ :'instantiate_service!', :'reset!' ].each do |method|
+ self.define_singleton_method(method) do |*args|
+ global_service_store.send(method, *args)
+ end
+ end
+
# Returns complete hash loaded from services.yml
- def self.config
+ def config
# cache hash loaded from YAML, ensure it has the keys we expect.
- unless defined? @@services_config_list
+ unless defined? @services_config_list
yaml_path = File.expand_path("config/umlaut_services.yml", Rails.root)
- @@services_config_list = (File.exists? yaml_path) ? YAML::load(File.open(yaml_path)) : {}
- @@services_config_list["default"] ||= {}
- @@services_config_list["default"]["services"] ||= {}
+ @services_config_list = (File.exists? yaml_path) ? YAML::load(File.open(yaml_path)) : {}
+ @services_config_list["default"] ||= {}
+ @services_config_list["default"]["services"] ||= {}
end
- return @@services_config_list
+ return @services_config_list
+ end
+
+ # Manually set a config hash, as would normally be found serialized
+ # in config/umlaut_services.yml. Useful in testing. All keys
+ # should be strings!!
+ #
+ # Needs to have the somewhat cumbersome expected structure:
+ # ["default"]["services"] => { "service_id" => definition_hash }
+ def config=(hash)
+ reset!
+ @services_config_list = hash
end
# Returns hash keyed by unique service name, value service definition
# hash.
- def self.service_definitions
- unless defined? @@service_definitions
- @@service_definitions = {}
+ def service_definitions
+ unless defined? @service_definitions
+ @service_definitions = {}
config.each_pair do |group_name, group|
if group["services"]
# Add the group name to each service
@@ -30,25 +69,32 @@ def self.service_definitions
service["group"] = group_name
end
# Merge the group's services into the service definitions.
- @@service_definitions.merge!( group["services"] )
+ @service_definitions.merge!( group["services"] )
end
end
# set service_id key in each based on hash key
- @@service_definitions.each_pair do |key, hash|
+ @service_definitions.each_pair do |key, hash|
hash["service_id"] = key
end
end
- return @@service_definitions
+ return @service_definitions
+ end
+
+ # Reset cached service definitions. They'll be lazily loaded when asked for,
+ # typically by being looked up from disk again. Typically used for testing.
+ def reset!
+ remove_instance_variable "@service_definitions" if defined? @service_definitions
+ remove_instance_variable "@services_config_list" if defined? @services_config_list
end
- def self.service_definition_for(service_id)
+ def service_definition_for(service_id)
return service_definitions[service_id]
end
# pass in string unique key OR a service definition hash,
# and a current UmlautRequest.
# get back instantiated Service object.
- def self.instantiate_service!(service, request)
+ def instantiate_service!(service, request)
definition = service.kind_of?(Hash) ? service : service_definition_for(service.to_s)
raise "Service '#{service}'' does not exist in umlaut-services.yml" if definition.nil?
className = definition["type"] || definition["service_id"]
35 app/service_adaptors/isi.rb
View
@@ -18,6 +18,8 @@
# http://scientific.thomson.com/scientific/techsupport/cpe/form.html.
# to request a change.
#
+# File support/outage tickets at http://ip-science.thomsonreuters.com/support/
+#
# Note, as of 13 april 09, there's a bug in ISI where journal titles including
# ampersands cause an error. We will catch those errors and output a 'warning'
# instead of an 'error', since it's a known problem.
@@ -61,7 +63,16 @@ def handle(request)
begin
- add_responses( request, isi_response )
+ #raise if it's an error HTTP response
+ isi_response.value
+
+ response_xml = Nokogiri::XML(isi_response.body)
+ # Check for errors.
+ if (error = (response_xml.at('val[@name = "error"]') || response_xml.at("error") || response_xml.at('null[@name = "error"]')))
+ raise IsiResponseException.new("ISI service reported error: #{error.inner_text}")
+ end
+
+ add_responses( request, response_xml )
rescue IsiResponseException => e
# Is this the known problem with ampersands?
# if so, output a warning, but report success not exception,
@@ -73,7 +84,14 @@ def handle(request)
return request.dispatched(self, true)
else
# Log the error, return exception condition.
- Rails.logger.error("#{e.message} ; OpenURL: ?#{request.to_context_object.kev}")
+
+ error_parts = []
+ error_parts << "ISI URI: #{@api_url}"
+ error_parts << "Request XML: #{xml}"
+ error_parts << "ISI Response body: #{response_xml}"
+
+
+ Rails.logger.error("#{e.message} ; " + error_parts.join("\n ") )
return request.dispatched(self, false, e)
end
end
@@ -193,17 +211,8 @@ def do_lamr_request(xml)
return http.post(uri.request_uri, xml, headers)
end
- def add_responses(request, isi_response)
- #raise if it's an error HTTP response
- isi_response.value
-
- response_xml = Nokogiri::XML(isi_response.body)
-
- # Check for errors.
- if (error = (response_xml.at('val[@name = "error"]') || response_xml.at("error") || response_xml.at('null[@name = "error"]')))
- raise IsiResponseException.new("ISI service reported error: #{error.inner_text}")
- end
-
+ def add_responses(request, response_xml)
+
results = response_xml.at('map[@name ="cite_id"] map[@name="WOS"]')
unless (results)
error_message = "#{self.id}: "
2  test/dummy/config/application.rb
View
@@ -6,6 +6,8 @@
require "umlaut"
require "sunspot_rails"
+require 'jquery-rails' # Oddly neccesary in our dummy app see http://www.ruby-forum.com/topic/2484569#1021529
+
module Dummy
class Application < Rails::Application
# Settings in config/environments/* take precedence over those specified here.
10 test/dummy/config/travis_database.yml
View
@@ -32,7 +32,7 @@
# pool: 30
development:
- adapter: mysql2
+ adapter: <%= defined?(JRUBY_VERSION) ? "mysql" : "mysql2" %>
encoding: utf8
reconnect: false
database: umlaut3_development
@@ -44,14 +44,14 @@ development:
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
- adapter: mysql2
+ adapter: <%= defined?(JRUBY_VERSION) ? "mysql" : "mysql2" %>
database: umlaut3_test
pool: 5
username: root
encoding: utf8
production:
- adapter: mysql2
+ adapter: <%= defined?(JRUBY_VERSION) ? "mysql" : "mysql2" %>
encoding: utf8
reconnect: false
database: umlaut3
@@ -69,7 +69,7 @@ production:
# In this dummy app, the sfx_db configuation is used for SFX search testing.
# DO NOT SET THIS FOR ANYTHING LIKE A REAL SFX DATABASE.
sfx_db:
- adapter: mysql2
+ adapter: <%= defined?(JRUBY_VERSION) ? "mysql" : "mysql2" %>
database: sfxlcl41_test # or other sfx instance db
username: root
password:
@@ -83,7 +83,7 @@ sfx_db:
# This is used for SFX search testing.
# DO NOT SET THIS FOR ANYTHING LIKE A REAL SFX DATABASE.
sfx4_global:
- adapter: mysql2
+ adapter: <%= defined?(JRUBY_VERSION) ? "mysql" : "mysql2" %>
database: sfxglb41_test
username: root
password:
18 test/functional/export_email_controller_test.rb
View
@@ -1,4 +1,8 @@
require 'test_helper'
+
+
+# The ExportEmailController provides custom interactions
+# for the ExportEmail service.
class ExportEmailControllerTest < ActionController::TestCase
fixtures :requests, :referents, :referent_values, :dispatched_services, :service_responses
@@ -22,4 +26,18 @@ class ExportEmailControllerTest < ActionController::TestCase
assert_select "div.umlaut.container", 0
assert_select "div.email", 1
end
+
+ test "send email" do
+ to_addr = "nobody@example.org"
+ post :send_email, :id => @email_service_response.id, :email => to_addr
+
+
+ # Mail was sent
+ assert !ActionMailer::Base.deliveries.empty?
+ assert ActionMailer::Base.deliveries.find do |message|
+ message.to.include? to_addr
+ end
+
+ assert_select "div", :text => /Sent to #{to_addr}/
+ end
end
6 test/functional/search_controller_test.rb
View
@@ -21,7 +21,7 @@ class SearchControllerTest < ActionController::TestCase
assert_select "title", "Find It | Journal titles that begin with &#x27;Account&#x27;"
assert_select ".citationLinker", 1
assert_select ".list", 1
- assert_select ".list .citation", 5
+ assert_select ".list .citation", :minimum => 1
assert_select ".pagination", 2
assert_select ".azNav", 0
end
@@ -33,8 +33,8 @@ class SearchControllerTest < ActionController::TestCase
assert_select "title", "Find It | Browse by Journal Title: A"
assert_select ".citationLinker", 1
assert_select ".list", 1
- assert_select ".list .citation", 16
+ assert_select ".list .citation", :minimum => 1
assert_select ".pagination", 2
assert_select ".azNav", 2
end
-end
+end
43 test/unit/service_store_test.rb
View
@@ -1,12 +1,8 @@
require 'test_helper'
class ServiceStoreTest < ActiveSupport::TestCase
- setup :reset_service_store_classvars
-
- teardown do
- reset_service_store_classvars
- ServiceStore.config
- ServiceStore.service_definitions
- end
+ setup :reset_service_store
+ teardown :reset_service_store, :force_lazy_load_service_store
+
test "missing umlaut services yaml" do
FileUtils.mv(File.join(Rails.root, "config", "umlaut_services.yml"), File.join(Rails.root, "config", "umlaut_services.yml.moved"))
@@ -19,12 +15,33 @@ class ServiceStoreTest < ActiveSupport::TestCase
assert_equal("default", sfx_definition["group"])
assert_equal("default", ServiceStore.instantiate_service!(sfx_definition, nil).group)
end
+
+ test "manually set services" do
+ # force original from disk to load
+ ServiceStore.config
+ ServiceStore.service_definitions
+
+ # But then set our own instead
+ ServiceStore.config = {
+ "default" => {
+ "services" => {
+ "dummy" => {"type" => "DummyService", "priority" => 3}
+ }
+ }
+ }
+
+ assert_length 1, ServiceStore.service_definitions
+ assert_present ServiceStore.service_definition_for("dummy")
+ end
+
- def reset_service_store_classvars
- # Reset ServiceStore class vars
- ["services_config_list", "service_definitions"].each do |class_var|
- class_var = "@@#{class_var}".to_sym
- ServiceStore.remove_class_variable(class_var) if ServiceStore.class_variable_defined?(class_var)
- end
+ def reset_service_store
+ ServiceStore.reset!
+ end
+ def force_lazy_load_service_store
+ ServiceStore.config
+ ServiceStore.service_definitions
end
+
+
end
2  test/unit/sfx/sfx_target_roll_up_test.rb
View
@@ -231,7 +231,7 @@ def test_roll_up_responses_non_coverage_sensitive
assert new_list.find {|r| r[:sfx_target_name] == "HIGHWIRE_PRESS_JOURNALS"}
end
- def test_roll_up_responses_yes_coverage_sensitive
+ def test_roll_up_responses_yes_coverage_sensitive_starts_with
sfx = Sfx.new({'priority' => 1,
'base_url' => "http://example.org",
'roll_up_prefixes' => ["EBSCOHOST_", "JSTOR_", "PROQUEST_", "NODATES_", "UNBOUNDED_"]
44 test/vcr_cassettes/resolve/fulltext_with_edition_warning.yml
View
@@ -0,0 +1,44 @@
+---
+http_interactions:
+- request:
+ method: !binary |-
+ Z2V0
+ uri: http://www.archive.org/advancedsearch.php?fl%5B0%5D=*&fmt=json&q=title:%22momo%22%20AND%20creator:(ende)%20AND%20(mediatype:texts%20OR%20mediatype:audio)&rows=999&xmlsearch=Search
+ body:
+ encoding: !binary |-
+ VVMtQVNDSUk=
+ string: ''
+ headers:
+ Accept:
+ - ! '*/*'
+ User-Agent:
+ - Ruby
+ response:
+ status:
+ code: 302
+ message: Moved Temporarily
+ headers:
+ Server:
+ - nginx/1.1.19
+ Date:
+ - Thu, 21 Mar 2013 19:18:49 GMT
+ Content-Type:
+ - text/html
+ Content-Length:
+ - '161'
+ Connection:
+ - keep-alive
+ Location:
+ - http://archive.org/advancedsearch.php?fl%5B%5D=*&fmt=json&xmlsearch=Search&rows=999&q=title:%22momo%22+AND+creator:%28ende%29+AND+(mediatype:texts+OR+mediatype:audio)
+ Expires:
+ - Fri, 22 Mar 2013 01:18:49 GMT
+ Cache-Control:
+ - max-age=21600
+ body:
+ encoding: !binary |-
+ VVMtQVNDSUk=
+ string: ! "<html>\r\n<head><title>302 Found</title></head>\r\n<body bgcolor=\"white\">\r\n<center><h1>302
+ Found</h1></center>\r\n<hr><center>nginx/1.1.19</center>\r\n</body>\r\n</html>\r\n"
+ http_version:
+ recorded_at: Thu, 21 Mar 2013 19:18:49 GMT
+recorded_with: VCR 2.4.0
Something went wrong with that request. Please try again.