diff --git a/.solr_wrapper.yml b/.solr_wrapper.yml index 53894b7..1925e79 100644 --- a/.solr_wrapper.yml +++ b/.solr_wrapper.yml @@ -1,5 +1,6 @@ -# Place any default configuration for solr_wrapper here -# port: 8983 +instance_dir: tmp/solr-development +download_dir: /var/tmp collection: + persist: true dir: solr/conf/ - name: blacklight-core + name: aster-development diff --git a/.travis.yml b/.travis.yml index 8bf29bb..7d5adea 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,9 +2,12 @@ language: ruby cache: bundler dist: trusty +jdk: +- oraclejdk8 + rvm: - 2.4.1 script: - - bundle exec rake aster:ci + - bundle exec rake aster:travis notifications: email: false diff --git a/config/blacklight.yml b/config/blacklight.yml index 0bdc49e..6859f0b 100644 --- a/config/blacklight.yml +++ b/config/blacklight.yml @@ -2,20 +2,20 @@ # each environment can have a jetty_path with absolute or relative # (to app root) path to a jetty/solr install. This is used # by the rake tasks that start up solr automatically for testing -# and by rake solr:marc:index. +# and by rake solr:marc:index. # # jetty_path is not used by a running Blacklight application # at all. In general you do NOT need to deploy solr in Jetty, you can deploy it -# however you want. +# however you want. # jetty_path is only required for rake tasks that need to know -# how to start up solr, generally for automated testing. +# how to start up solr, generally for automated testing. development: adapter: solr - url: <%= ENV['SOLR_URL'] || "http://127.0.0.1:8983/solr/blacklight-core" %> + url: http://127.0.0.1:<%= ENV['SOLR_TEST_PORT'] || 8983 %>/solr/aster-development test: &test adapter: solr - url: <%= ENV['SOLR_URL'] || "http://127.0.0.1:#{ENV['TEST_JETTY_PORT'] || 8983}/solr/blacklight-core" %> + url: <%= ENV['SOLR_URL'] || "http://127.0.0.1:#{ENV.fetch('SOLR_TEST_PORT', 8985)}/solr/aster-test" %> production: adapter: solr url: <%= ENV['SOLR_URL'] || "http://127.0.0.1:8983/solr/aster" %> diff --git a/config/solr.yml b/config/solr.yml index fdaf0f4..55a83a6 100644 --- a/config/solr.yml +++ b/config/solr.yml @@ -1,2 +1,6 @@ - production: +development: + url: http://127.0.0.1:<%= ENV['SOLR_TEST_PORT'] || 8983 %>/solr/aster-development +test: + url: http://127.0.0.1:<%= ENV['SOLR_TEST_PORT'] || 8985 %>/solr/aster-test +production: url: http://127.0.0.1:8983/solr/aster diff --git a/config/solr_wrapper_test.yml b/config/solr_wrapper_test.yml new file mode 100644 index 0000000..236025a --- /dev/null +++ b/config/solr_wrapper_test.yml @@ -0,0 +1,6 @@ +port: 8985 +instance_dir: tmp/solr-test +collection: + persist: false + dir: solr/conf/ + name: aster-test diff --git a/lib/tasks/spec.rake b/lib/tasks/spec.rake index af0b9a7..f72c01b 100644 --- a/lib/tasks/spec.rake +++ b/lib/tasks/spec.rake @@ -1,3 +1,4 @@ +# frozen_string_literal: true unless Rails.env.production? namespace :aster do task :spec do diff --git a/lib/tasks/travis.rake b/lib/tasks/travis.rake new file mode 100644 index 0000000..870ff91 --- /dev/null +++ b/lib/tasks/travis.rake @@ -0,0 +1,27 @@ +# frozen_string_literal: true + +unless Rails.env.production? + APP_ROOT = File.dirname(__FILE__) + require 'solr_wrapper' + require 'solr_wrapper/rake_task' + namespace :aster do + desc 'Run Continuous Integration' + task :travis do + ENV['environment'] = 'test' + solr_params = { + port: 8985, + verbose: true, + managed: true + } + SolrWrapper.wrap(solr_params) do |solr| + solr.with_collection( + name: 'aster-test', + persist: false, + dir: Rails.root.join('solr', 'conf') + ) do + Rake::Task['aster:ci'].invoke + end + end + end + end +end diff --git a/spec/features/home_page_spec.rb b/spec/features/home_page_spec.rb new file mode 100644 index 0000000..0000b1a --- /dev/null +++ b/spec/features/home_page_spec.rb @@ -0,0 +1,8 @@ +# frozen_string_literal: true +require 'spec_helper' +RSpec.describe 'viewing content on the aster home page', type: :feature do + scenario 'viewing the version' do + visit '/' + expect(page).to have_css '.version' + end +end diff --git a/spec/features/show_page_spec.rb b/spec/features/show_page_spec.rb new file mode 100644 index 0000000..eb5544d --- /dev/null +++ b/spec/features/show_page_spec.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true +require 'spec_helper' + +RSpec.describe 'viewing content on the aster show page', type: :feature do + before do + Rake::Task['geoblacklight:solr:seed'].invoke + end + scenario 'viewing the show page' do + visit solr_document_path 'gford-20140000-010015_belvegr' + expect(page).to have_content 'Vegetation, Maya Forest, Belize, 1995' + end +end diff --git a/spec/fixtures/solr_documents/maya_forest.json b/spec/fixtures/solr_documents/maya_forest.json new file mode 100644 index 0000000..ec4e697 --- /dev/null +++ b/spec/fixtures/solr_documents/maya_forest.json @@ -0,0 +1,19 @@ +[ + { + "geoblacklight_version": "1.0", + "dc_identifier_s": "ucsb:gford-20140000-010015_belvegr", + "layer_slug_s":"gford-20140000-010015_belvegr", + "dc_language_s": "English", + "dc_publisher_s": "University of California, Santa Barbara. Map and Imagery Laboratory", + "dc_rights_s": "Public", + "dc_title_s": "Vegetation, Maya Forest, Belize, 1995", + "dc_type_s": "Dataset", + "dct_references_s": "{\"http://www.opengis.net/def/serviceType/ogc/wfs\":\"http://geoservices-sandbox.library.ucsb.edu:8080/geoserver/ucsb/ows?service=WFS\",\"http://www.opengis.net/def/serviceType/ogc/wms\":\"http://geoservices-sandbox.library.ucsb.edu:8080/geoserver/ucsb/wms?service=WMS\"}", + "solr_geom": "ENVELOPE(-88.0804, -89.2587, 18.4977, 15.8808)", + "dct_spatial_sm": "Belize", + "dc_subject_sm":"Belize", + "dc_creator_sm":"UCSB", + "dct_provenance_s": "UCSB", + "layer_geom_type_s": "Polygon" + } +] diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index bbe1ba5..31dadea 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -1,12 +1,14 @@ # This file is copied to spec/ when you run 'rails generate rspec:install' -require 'spec_helper' ENV['RAILS_ENV'] ||= 'test' require File.expand_path('../../config/environment', __FILE__) # Prevent database truncation if the environment is production abort("The Rails environment is running in production mode!") if Rails.env.production? require 'rspec/rails' # Add additional requires below this line. Rails is not loaded until this point! - +require 'capybara/rspec' +require 'capybara/rails' +require 'rake' +Rails.application.load_tasks # Requires supporting ruby files with custom matchers and macros, etc, in # spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are # run as spec files by default. This means that files in spec/support that end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index c7f1c01..39852b6 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,20 +1,7 @@ require 'coveralls' Coveralls.wear!('rails') -# This file was generated by the `rails generate rspec:install` command. Conventionally, all -# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. -# The generated `.rspec` file contains `--require spec_helper` which will cause -# this file to always be loaded, without a need to explicitly require it in any -# files. -# -# Given that it is always loaded, you are encouraged to keep this file as -# light-weight as possible. Requiring heavyweight dependencies from this file -# will add to the boot time of your test suite on EVERY test run, even for an -# individual file that may not need all of that loaded. Instead, consider making -# a separate helper file that requires the additional dependencies and performs -# the additional setup, and require it from the spec files that actually need -# it. -# -# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration +require 'rails_helper' + RSpec.configure do |config| # rspec-expectations config goes here. You can use an alternate # assertion/expectation library such as wrong or the stdlib/minitest @@ -39,58 +26,25 @@ mocks.verify_partial_doubles = true end - # This option will default to `:apply_to_host_groups` in RSpec 4 (and will - # have no way to turn it off -- the option exists only for backwards - # compatibility in RSpec 3). It causes shared context metadata to be - # inherited by the metadata hash of host groups and examples, rather than - # triggering implicit auto-inclusion in groups with matching metadata. + # @note In January 2018, TravisCI disabled Chrome sandboxing in its Linux + # container build environments to mitigate Meltdown/Spectre + # vulnerabilities, at which point Hyrax could no longer use the + # Capybara-provided :selenium_chrome_headless driver (which does not + # include the `--no-sandbox` argument). + Capybara.register_driver :selenium_chrome_headless_sandboxless do |app| + browser_options = ::Selenium::WebDriver::Chrome::Options.new + browser_options.args << '--headless' + browser_options.args << '--disable-gpu' + browser_options.args << '--no-sandbox' + Capybara::Selenium::Driver.new(app, browser: :chrome, options: browser_options) + end + + Capybara.default_driver = :rack_test # This is a faster driver + Capybara.javascript_driver = :selenium_chrome_headless_sandboxless # This is slower + config.shared_context_metadata_behavior = :apply_to_host_groups - # The settings below are suggested to provide a good initial experience - # with RSpec, but feel free to customize to your heart's content. - # # This allows you to limit a spec run to individual examples or groups - # # you care about by tagging them with `:focus` metadata. When nothing - # # is tagged with `:focus`, all examples get run. RSpec also provides - # # aliases for `it`, `describe`, and `context` that include `:focus` - # # metadata: `fit`, `fdescribe` and `fcontext`, respectively. - # config.filter_run_when_matching :focus - # - # # Allows RSpec to persist some state between runs in order to support - # # the `--only-failures` and `--next-failure` CLI options. We recommend - # # you configure your source control system to ignore this file. - # config.example_status_persistence_file_path = "spec/examples.txt" - # - # # Limits the available syntax to the non-monkey patched syntax that is - # # recommended. For more details, see: - # # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/ - # # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/ - # # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode - # config.disable_monkey_patching! - # - # # Many RSpec users commonly either run the entire suite or an individual - # # file, and it's useful to allow more verbose output when running an - # # individual spec file. - # if config.files_to_run.one? - # # Use the documentation formatter for detailed output, - # # unless a formatter has already been configured - # # (e.g. via a command-line flag). - # config.default_formatter = "doc" - # end - # - # # Print the 10 slowest examples and example groups at the - # # end of the spec run, to help surface which specs are running - # # particularly slow. - # config.profile_examples = 10 - # - # # Run specs in random order to surface order dependencies. If you find an - # # order dependency and want to debug it, you can fix the order by providing - # # the seed, which is printed after each run. - # # --seed 1234 - # config.order = :random - # - # # Seed global randomization in this process using the `--seed` CLI option. - # # Setting this allows you to use `--seed` to deterministically reproduce - # # test failures related to randomization by passing the same `--seed` value - # # as the one that triggered the failure. - # Kernel.srand config.seed + config.order = :random + + Kernel.srand config.seed end