Skip to content
This repository has been archived by the owner on Feb 19, 2025. It is now read-only.

Commit

Permalink
Merge pull request #12 from ucsblibrary/feature_test
Browse files Browse the repository at this point in the history
 Feature test for creating an exhibit via the UI
  • Loading branch information
bess authored Dec 3, 2018
2 parents 2943cd6 + 11f6f51 commit 97478c4
Show file tree
Hide file tree
Showing 9 changed files with 198 additions and 50 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,3 @@

# site-specific settings
/config/import.yml
/config/secrets.yml
10 changes: 10 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
dist: trusty
language: ruby
cache: bundler
sudo: required
addons:
chrome: stable
rvm:
- 2.5.1
before_script:
- bin/rails db:test:prepare
before_install:
- openssl aes-256-cbc -K $encrypted_4d6950ff1422_key -iv $encrypted_4d6950ff1422_iv
-in geniza-cd-key.enc -out geniza-cd-key -d
- google-chrome-stable --headless --disable-gpu --remote-debugging-port=9222 http://localhost &
after_success:
- |
if [[ $TRAVIS_BRANCH == 'master' && $TRAVIS_PULL_REQUEST == 'false' ]]; then
bundle exec cap cd deploy
fi
script:
- bundle exec rake ci
10 changes: 7 additions & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ end
gem 'blacklight', ' ~> 6.0'
gem 'blacklight-gallery', '>= 0.3.0'
gem 'blacklight-oembed', '>= 0.1.0'
gem 'blacklight-spotlight',
git: 'https://github.com/dunn/spotlight.git',
branch: '75th'
gem 'blacklight-spotlight'
# gem 'blacklight-spotlight',
# git: 'https://github.com/dunn/spotlight.git',
# branch: '75th'
gem 'devise'
gem 'devise-guests', '~> 0.6'
gem 'devise_invitable'
Expand All @@ -33,7 +34,10 @@ group :development, :test do
gem 'capistrano-bundler'
gem 'capistrano-passenger'
gem 'capistrano-rails', '>= 1.1.3'
gem 'database_cleaner'
gem 'factory_bot_rails'
gem 'highline'
gem 'chromedriver-helper'

gem 'byebug'
gem 'capybara'
Expand Down
101 changes: 55 additions & 46 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,46 +1,3 @@
GIT
remote: https://github.com/dunn/spotlight.git
revision: a4f01b3406e2ce17b600120214133dccd7e5e9b0
branch: 75th
specs:
blacklight-spotlight (2.2.1)
acts-as-taggable-on (>= 5.0, < 7)
almond-rails (~> 0.1)
autoprefixer-rails
blacklight (~> 6.3)
blacklight-oembed (>= 0.0.3)
bootstrap_form (~> 2.2)
breadcrumbs_on_rails (~> 3.0)
cancancan
carrierwave
clipboard-rails (~> 1.5)
devise (>= 3.0)
devise_invitable (~> 1.6)
faraday
faraday_middleware
friendly_id (~> 5.2)
github-markup
i18n (< 1.1)
i18n-active_record
iiif-presentation
iiif_manifest
leaflet-rails
legato
mini_magick
nokogiri
oauth2
openseadragon
paper_trail (>= 7.0)
rails (~> 5.1)
riiif (~> 1.0)
roar (~> 1.1)
roar-rails
signet
sir_trevor_rails (~> 0.5)
sprockets-es6
tophat
underscore-rails (~> 1.6)

GEM
remote: https://rubygems.org/
specs:
Expand Down Expand Up @@ -89,6 +46,8 @@ GEM
sshkit (>= 1.6.1, != 1.7.0)
almond-rails (0.1.0)
rails (>= 4.2, < 6)
archive-zip (0.11.0)
io-like (~> 0.3.0)
arel (8.0.0)
autoprefixer-rails (9.3.1)
execjs
Expand Down Expand Up @@ -117,6 +76,43 @@ GEM
bootstrap-sass (~> 3.0)
rails
ruby-oembed
blacklight-spotlight (2.3.0)
acts-as-taggable-on (>= 5.0, < 7)
almond-rails (~> 0.1)
autoprefixer-rails
blacklight (~> 6.3)
blacklight-oembed (>= 0.0.3)
bootstrap_form (~> 2.2)
breadcrumbs_on_rails (~> 3.0)
cancancan
carrierwave
clipboard-rails (~> 1.5)
devise (>= 3.0)
devise_invitable (~> 1.6)
faraday
faraday_middleware
friendly_id (~> 5.2)
github-markup
i18n (< 1.1)
i18n-active_record
iiif-presentation
iiif_manifest
leaflet-rails
legato
mini_magick
nokogiri
oauth2
openseadragon
paper_trail (~> 10.0)
rails (~> 5.1)
riiif (~> 1.0)
roar (~> 1.1)
roar-rails
signet
sir_trevor_rails (~> 0.5)
sprockets-es6
tophat
underscore-rails (~> 1.6)
bootstrap-sass (3.3.7)
autoprefixer-rails (>= 5.2.1)
sass (>= 3.3.4)
Expand Down Expand Up @@ -152,10 +148,14 @@ GEM
mime-types (>= 1.16)
childprocess (0.9.0)
ffi (~> 1.0, >= 1.0.11)
chromedriver-helper (2.1.0)
archive-zip (~> 0.10)
nokogiri (~> 1.8)
clipboard-rails (1.7.1)
coderay (1.1.2)
concurrent-ruby (1.1.1)
crass (1.0.4)
database_cleaner (1.7.0)
declarative (0.0.10)
declarative-option (0.1.0)
deprecation (1.0.0)
Expand All @@ -179,6 +179,11 @@ GEM
railties (>= 3.2, < 6.0)
erubi (1.7.1)
execjs (2.7.0)
factory_bot (4.11.1)
activesupport (>= 3.0.0)
factory_bot_rails (4.11.1)
factory_bot (~> 4.11.1)
railties (>= 3.0.0)
faraday (0.15.3)
multipart-post (>= 1.2, < 3)
faraday_middleware (0.12.2)
Expand All @@ -200,6 +205,7 @@ GEM
json
iiif_manifest (0.5.0)
activesupport (>= 4)
io-like (0.3.0)
jbuilder (2.8.0)
activesupport (>= 4.2.0)
multi_json (>= 1.2)
Expand Down Expand Up @@ -262,10 +268,10 @@ GEM
activerecord (>= 4.2, < 5.3)
request_store (~> 1.1)
pg (0.18.4)
pry (0.12.0)
pry (0.12.2)
coderay (~> 1.1.0)
method_source (~> 0.9.0)
pry-doc (0.13.4)
pry-doc (0.13.5)
pry (~> 0.11)
yard (~> 0.9.11)
public_suffix (3.0.3)
Expand Down Expand Up @@ -434,17 +440,20 @@ DEPENDENCIES
blacklight (~> 6.0)
blacklight-gallery (>= 0.3.0)
blacklight-oembed (>= 0.1.0)
blacklight-spotlight!
blacklight-spotlight
byebug
capistrano (~> 3.8.0)
capistrano-bundler
capistrano-passenger
capistrano-rails (>= 1.1.3)
capybara
chromedriver-helper
database_cleaner
devise
devise-guests (~> 0.6)
devise_invitable
dotenv-rails
factory_bot_rails
friendly_id
highline
jquery-rails
Expand Down
44 changes: 44 additions & 0 deletions config/secrets.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Be sure to restart your server when you modify this file.

# Your secret key is used for verifying the integrity of signed cookies.
# If you change this key, all old signed cookies will become invalid!

# Make sure the secret is at least 30 characters and all random,
# no regular words or you'll be exposed to dictionary attacks.
# You can use `rails secret` to generate a secure secret key.

# Make sure the secrets in this file are kept private
# if you're sharing your code publicly.

# Shared secrets are available across all environments.

# shared:
# api_key: a1B2c3D4e5F6

# Environmental secrets are only available for that specific environment.

# Do not keep production secrets in the unencrypted secrets file.
# Instead, either read values from the environment.
# Or, use `bin/rails secrets:setup` to configure encrypted secrets
# and move the `production:` environment over there.
default: &default
ldap_host:
ldap_user:
ldap_pass:
ldap_group_base:
ldap_filter: samaccountname

development:
hostname: localhost
secret_key_base: 6e975aca3fb9aa34971bc073ab0f1b4587e4f3a008e99f91d7ec171e3a0ac57aeee35c725c6787543f62972159ad1825497fa51e210e8708920c7da398b3ac17
<<: *default

test:
hostname: localhost
secret_key_base: c98e58e67628a81f204177664023174f6bf514e194d6c9b188d555edc9148011e55145a50690fd63b2209a8ad97991156b509c51e00327ba7fcc6c1b755732ba

production:
hostname: localhost
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
smtp_host:
<<: *default
Empty file removed spec/examples.txt
Empty file.
39 changes: 39 additions & 0 deletions spec/features/create_exhibit_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# frozen_string_literal: true

require 'rails_helper'

RSpec.feature 'Import and Display a Work', :clean, js: true do
include Warden::Test::Helpers

let(:csv_file_path) { File.join(fixture_path, csv_file_name) }
let(:csv_file_name) { 'url_single_item_exhibit.csv' }
let(:site_admin) { FactoryBot.create(:site_admin) }

before do
allow(Spotlight::DefaultThumbnailJob).to receive(:perform_later)
login_as site_admin
end

context 'Create an exhibit' do
it 'creates and populates an exhibit via the UI' do
expect(Spotlight::Exhibit.count).to eq 0
visit '/'
click_link '[email protected]'
click_link 'Create new exhibit'
fill_in('Title', with: 'Test Exhibit')
fill_in('Tag list', with: 'testing')
click_button 'Save'
expect(page).to have_content 'The exhibit was created.'
expect(Spotlight::Exhibit.count).to eq 1
exhibit = Spotlight::Exhibit.first
expect(exhibit.title).to eq 'Test Exhibit'
visit('/spotlight/test-exhibit/resources/new')
click_link 'Upload multiple items'
expect(page).to have_content 'CSV File'
page.attach_file('resources_csv_upload[url]', csv_file_path)
click_button 'Add item'
visit '/spotlight/test-exhibit/catalog?utf8=%E2%9C%93&exhibit_id=test-exhibit&search_field=all_fields&q='
expect(page).to have_content 'A Cute Dog'
end
end
end
2 changes: 2 additions & 0 deletions spec/fixtures/url_single_item_exhibit.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
url,full_title_tesim,spotlight_upload_description_tesim,spotlight_upload_attribution_tesim,spotlight_upload_date_tesim
https://images.pexels.com/photos/551628/pexels-photo-551628.jpeg,"A Cute Dog","A freely available image of a cute dog","Kat Jayne"
41 changes: 41 additions & 0 deletions spec/rails_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,32 @@
#
# Dir[Rails.root.join('spec', 'support', '**', '*.rb')].each { |f| require f }

# Uses faster rack_test driver when JavaScript support not needed
Capybara.default_driver = :rack_test

Capybara.register_driver :chrome 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.javascript_driver = :chrome

Capybara.default_max_wait_time = 10


# These settings spin up a local browser and let you watch the tests in the browser
# Capybara.register_driver :selenium do |app|
# Capybara::Selenium::Driver.new(app, browser: :chrome)
# end
#
# Capybara.configure do |config|
# config.default_max_wait_time = 10 # seconds
# config.default_driver = :selenium
# end

# Checks for pending migrations and applies them before tests are run.
# If you are not using ActiveRecord, you can remove these lines.
begin
Expand All @@ -36,12 +62,27 @@
RSpec.configure do |config|
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
config.fixture_path = "#{::Rails.root}/spec/fixtures"
config.include FactoryBot::Syntax::Methods

# If you're not using ActiveRecord, or you'd prefer not to run each of your
# examples within a transaction, remove the following line or assign false
# instead of true.
config.use_transactional_fixtures = true

config.before :suite do
DatabaseCleaner.clean
end

config.before :each do
DatabaseCleaner.strategy = :truncation
DatabaseCleaner.start
Blacklight.default_index.connection.delete_by_query('*:*', params: { 'softCommit' => true })
end

config.after do
DatabaseCleaner.clean
end

# RSpec Rails can automatically mix in different behaviours to your tests
# based on their file location, for example enabling you to call `get` and
# `post` in specs under `spec/controllers`.
Expand Down

0 comments on commit 97478c4

Please sign in to comment.