diff --git a/.rubocop.yml b/.rubocop.yml
index fbc871b82d..ca9e689764 100644
--- a/.rubocop.yml
+++ b/.rubocop.yml
@@ -85,6 +85,9 @@ Rails/FilePath:
Exclude:
- 'spec/routing/**/*'
+RSpec/ContextWording:
+ Enabled: false
+
RSpec/ExpectActual:
Exclude:
- 'spec/routing/**/*'
@@ -110,8 +113,11 @@ RSpec/NestedGroups:
RSpec/MultipleExpectations:
Enabled: false
+RSpec/ScatteredLet:
+ Enabled: false
+
Metrics/BlockLength:
Exclude:
- 'spec/**/*.rb'
- 'lib/tasks/*.rake'
- - 'app/controllers/catalog_controller.rb'
+ - 'app/controllers/catalog_controller.rb'
\ No newline at end of file
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index 846bfd7a98..38f338c0cd 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -23,6 +23,16 @@ RSpec/SubjectStub:
Exclude:
- 'spec/models/solr_endpoint_spec.rb'
+RSpec/BeforeAfterAll:
+ Exclude:
+ - 'spec/tasks/rake_spec.rb'
+ - 'spec/models/hyku/group_spec.rb'
+ - 'spec/models/uploaded_file_spec.rb'
+
+RSpec/IteratedExpectation:
+ Exclude:
+ - 'spec/tasks/rake_spec.rb'
+
# Offense count: 10
RSpec/LeadingSubject:
Exclude:
@@ -50,3 +60,33 @@ RSpec/LetSetup:
RSpec/NestedGroups:
Exclude:
- 'spec/services/iiif_authorization_service_spec.rb'
+
+RSpec/ExpectInHook:
+ Exclude:
+ - 'spec/controllers/sites_controller_spec.rb'
+ - 'spec/models/uploaded_file_spec.rb'
+
+Style/MixinUsage:
+ Exclude:
+ - 'spec/support/devise.rb'
+ - 'spec/features/create_image_spec.rb'
+
+Naming/HeredocDelimiterNaming:
+ Exclude:
+ - 'spec/jobs/import_work_from_purl_job_spec.rb'
+
+Style/FormatStringToken:
+ Exclude:
+ - 'app/models/account.rb'
+ - 'spec/models/account_spec.rb'
+
+Rails/HasManyOrHasOneDependent:
+ Exclude:
+ - 'app/models/endpoint.rb'
+
+FactoryBot/DynamicAttributeDefinedStatically:
+ Exclude:
+ - 'spec/factories/users.rb'
+
+Rails/ApplicationJob:
+ Enabled: false
\ No newline at end of file
diff --git a/Gemfile b/Gemfile
index 88c0224eda..97ee89643a 100644
--- a/Gemfile
+++ b/Gemfile
@@ -48,7 +48,7 @@ group :development, :test do
gem 'solr_wrapper', '~> 1.0'
gem 'rubocop', '~> 0.50', '<= 0.52.1'
- gem 'rubocop-rspec', '~> 1.10.0'
+ gem 'rubocop-rspec', '~> 1.23.0'
end
group :test do
diff --git a/Gemfile.lock b/Gemfile.lock
index de2f6bad5b..6d5e617d87 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -745,8 +745,8 @@ GEM
rainbow (>= 2.2.2, < 4.0)
ruby-progressbar (~> 1.7)
unicode-display_width (~> 1.0, >= 1.0.1)
- rubocop-rspec (1.10.0)
- rubocop (>= 0.42.0)
+ rubocop-rspec (1.23.0)
+ rubocop (>= 0.52.1)
ruby-box (1.15.0)
addressable
json
@@ -940,7 +940,7 @@ DEPENDENCIES
rspec
rspec-rails (>= 3.6.0)
rubocop (~> 0.50, <= 0.52.1)
- rubocop-rspec (~> 1.10.0)
+ rubocop-rspec (~> 1.23.0)
sass-rails (~> 5.0)
scss_lint
secure_headers
diff --git a/app/controllers/admin/groups_controller.rb b/app/controllers/admin/groups_controller.rb
index 5f011558eb..3c1898710b 100644
--- a/app/controllers/admin/groups_controller.rb
+++ b/app/controllers/admin/groups_controller.rb
@@ -1,6 +1,6 @@
module Admin
class GroupsController < AdminController
- before_action :load_group, only: [:edit, :update, :remove, :destroy]
+ before_action :load_group, only: %i[edit update remove destroy]
# rubocop:disable Metrics/AbcSize
def index
diff --git a/app/controllers/catalog_controller.rb b/app/controllers/catalog_controller.rb
index 2cd724eafd..ad9b6c0c59 100644
--- a/app/controllers/catalog_controller.rb
+++ b/app/controllers/catalog_controller.rb
@@ -14,7 +14,7 @@ def self.modified_field
end
configure_blacklight do |config|
- config.view.gallery.partials = [:index_header, :index]
+ config.view.gallery.partials = %i[index_header index]
config.view.masonry.partials = [:index]
config.view.slideshow.partials = [:index]
@@ -30,7 +30,7 @@ def self.modified_field
config.search_builder_class = Hyrax::CatalogSearchBuilder
# Show gallery view
- config.view.gallery.partials = [:index_header, :index]
+ config.view.gallery.partials = %i[index_header index]
config.view.slideshow.partials = [:index]
## Default parameters to send to solr for all search-like requests. See also SolrHelper#solr_search_params
diff --git a/app/controllers/proprietor/accounts_controller.rb b/app/controllers/proprietor/accounts_controller.rb
index c9aee888f6..5bfe482e65 100644
--- a/app/controllers/proprietor/accounts_controller.rb
+++ b/app/controllers/proprietor/accounts_controller.rb
@@ -83,8 +83,8 @@ def ensure_admin!
def account_params
params.require(:account).permit(:name, :cname, :title,
admin_emails: [],
- solr_endpoint_attributes: [:id, :url],
- fcrepo_endpoint_attributes: [:id, :url, :base_path])
+ solr_endpoint_attributes: %i[id url],
+ fcrepo_endpoint_attributes: %i[id url base_path])
end
end
end
diff --git a/app/forms/hyrax/generic_work_form.rb b/app/forms/hyrax/generic_work_form.rb
index 28ab2d4c9a..543604ad13 100644
--- a/app/forms/hyrax/generic_work_form.rb
+++ b/app/forms/hyrax/generic_work_form.rb
@@ -4,7 +4,7 @@ module Hyrax
class GenericWorkForm < Hyrax::Forms::WorkForm
self.model_class = ::GenericWork
include HydraEditor::Form::Permissions
- self.terms += [:resource_type, :rendering_ids]
+ self.terms += %i[resource_type rendering_ids]
def secondary_terms
super - [:rendering_ids]
diff --git a/app/forms/hyrax/image_form.rb b/app/forms/hyrax/image_form.rb
index 7769f7e592..5dbbee4663 100644
--- a/app/forms/hyrax/image_form.rb
+++ b/app/forms/hyrax/image_form.rb
@@ -3,7 +3,7 @@
module Hyrax
class ImageForm < Hyrax::Forms::WorkForm
self.model_class = ::Image
- self.terms += [:resource_type, :extent, :rendering_ids]
+ self.terms += %i[resource_type extent rendering_ids]
def secondary_terms
super - [:rendering_ids]
diff --git a/app/jobs/cleanup_account_job.rb b/app/jobs/cleanup_account_job.rb
index 58c5f8639c..c5832051bd 100644
--- a/app/jobs/cleanup_account_job.rb
+++ b/app/jobs/cleanup_account_job.rb
@@ -25,7 +25,7 @@ def cleanup_solr(account)
def cleanup_database(account)
Apartment::Tenant.drop(account.tenant)
- rescue
+ rescue StandardError
nil # ignore if account.tenant missing
end
end
diff --git a/app/jobs/import_work_from_purl_job.rb b/app/jobs/import_work_from_purl_job.rb
index 48a54e757b..675ee517d6 100644
--- a/app/jobs/import_work_from_purl_job.rb
+++ b/app/jobs/import_work_from_purl_job.rb
@@ -53,17 +53,17 @@ def process_attributes(attributes)
end
class_attribute :attributes_to_keep
- self.attributes_to_keep = [:title,
- :description,
- :subject,
- :language,
- :resource_type,
- :location,
- :rights,
- :visibility,
- :id,
- :collection,
- :files]
+ self.attributes_to_keep = %i[title
+ description
+ subject
+ language
+ resource_type
+ location
+ rights
+ visibility
+ id
+ collection
+ files]
def process_collection(attributes)
# rename :collection to :member_of_collection_ids
diff --git a/app/models/ability.rb b/app/models/ability.rb
index d48fa1b8e3..608194c22c 100644
--- a/app/models/ability.rb
+++ b/app/models/ability.rb
@@ -2,10 +2,10 @@ class Ability
include Hydra::Ability
include Hyrax::Ability
- self.ability_logic += [
- :everyone_can_create_curation_concerns,
- :group_permissions,
- :superadmin_permissions
+ self.ability_logic += %i[
+ everyone_can_create_curation_concerns
+ group_permissions
+ superadmin_permissions
]
# Define any customized permissions here.
diff --git a/app/models/account.rb b/app/models/account.rb
index 13622705df..75be5a7568 100644
--- a/app/models/account.rb
+++ b/app/models/account.rb
@@ -1,5 +1,5 @@
# Customer organization account
-class Account < ActiveRecord::Base
+class Account < ApplicationRecord
# @param [String] piece the tenant piece of the canonical name
# @return [String] full canonical name
# @raise [ArgumentError] if piece contains a trailing dot
diff --git a/app/models/endpoint.rb b/app/models/endpoint.rb
index 3ba7f57c14..0025e9f5c9 100644
--- a/app/models/endpoint.rb
+++ b/app/models/endpoint.rb
@@ -1,3 +1,3 @@
-class Endpoint < ActiveRecord::Base
+class Endpoint < ApplicationRecord
has_one :account
end
diff --git a/app/models/fcrepo_endpoint.rb b/app/models/fcrepo_endpoint.rb
index b8a485bb3d..33fdfe4f6d 100644
--- a/app/models/fcrepo_endpoint.rb
+++ b/app/models/fcrepo_endpoint.rb
@@ -1,5 +1,5 @@
class FcrepoEndpoint < Endpoint
- store :options, accessors: [:url, :base_path]
+ store :options, accessors: %i[url base_path]
def switch!
ActiveFedora::Fedora.register(options.symbolize_keys)
@@ -11,7 +11,7 @@ def self.reset!
def ping
ActiveFedora::Fedora.instance.connection.head('/').response.success?
- rescue
+ rescue StandardError
false
end
diff --git a/app/models/redis_endpoint.rb b/app/models/redis_endpoint.rb
index 8363d3865d..dbb1a7bb32 100644
--- a/app/models/redis_endpoint.rb
+++ b/app/models/redis_endpoint.rb
@@ -12,7 +12,7 @@ def self.reset!
def ping
redis_instance.ping
- rescue
+ rescue StandardError
false
end
diff --git a/app/models/role.rb b/app/models/role.rb
index 6de57fef02..f93191b8a2 100644
--- a/app/models/role.rb
+++ b/app/models/role.rb
@@ -1,4 +1,4 @@
-class Role < ActiveRecord::Base
+class Role < ApplicationRecord
has_and_belongs_to_many :users, join_table: :users_roles
belongs_to :resource,
@@ -10,5 +10,5 @@ class Role < ActiveRecord::Base
scopify
- scope :site, ->() { where(resource_type: "Site") }
+ scope :site, -> { where(resource_type: "Site") }
end
diff --git a/app/models/search_builder.rb b/app/models/search_builder.rb
index 9939502a3e..ad50b6e1ea 100644
--- a/app/models/search_builder.rb
+++ b/app/models/search_builder.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
class SearchBuilder < Blacklight::SearchBuilder
include Blacklight::Solr::SearchBuilderBehavior
include Hydra::AccessControlsEnforcement
diff --git a/app/models/site.rb b/app/models/site.rb
index 91acb73935..2a174f45cb 100644
--- a/app/models/site.rb
+++ b/app/models/site.rb
@@ -1,4 +1,4 @@
-class Site < ActiveRecord::Base
+class Site < ApplicationRecord
resourcify
validates :application_name, presence: true, allow_nil: true
diff --git a/app/models/solr_document.rb b/app/models/solr_document.rb
index e0b05c9697..e335887aed 100644
--- a/app/models/solr_document.rb
+++ b/app/models/solr_document.rb
@@ -1,4 +1,5 @@
# frozen_string_literal: true
+
class SolrDocument
include Blacklight::Solr::Document
include Blacklight::Gallery::OpenseadragonSolrDocument
diff --git a/app/models/solr_endpoint.rb b/app/models/solr_endpoint.rb
index 4e4abcbaa7..886ad06d9d 100644
--- a/app/models/solr_endpoint.rb
+++ b/app/models/solr_endpoint.rb
@@ -1,7 +1,7 @@
# frozen_string_literal: true
class SolrEndpoint < Endpoint
- store :options, accessors: [:url, :collection]
+ store :options, accessors: %i[url collection]
def connection
# We remove the adapter, otherwise RSolr 2 will try to use it as a Faraday middleware
diff --git a/app/models/user.rb b/app/models/user.rb
index 2193bb1a19..c6582a5012 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -1,4 +1,4 @@
-class User < ActiveRecord::Base
+class User < ApplicationRecord
# Includes lib/rolify from the rolify gem
rolify
# Connects this user object to Hydra behaviors.
diff --git a/app/presenters/hyku/manifest_enabled_work_show_presenter.rb b/app/presenters/hyku/manifest_enabled_work_show_presenter.rb
index b4ce5eacb0..9400e1325c 100644
--- a/app/presenters/hyku/manifest_enabled_work_show_presenter.rb
+++ b/app/presenters/hyku/manifest_enabled_work_show_presenter.rb
@@ -74,7 +74,7 @@ def metadata_fields
model = solr_document['has_model_ssim'].first
"#{ns}::#{model}Form".constantize.required_fields
- rescue
+ rescue StandardError
[]
end
diff --git a/app/presenters/hyku/menu_presenter.rb b/app/presenters/hyku/menu_presenter.rb
index bcd01c9601..16de8e79e1 100644
--- a/app/presenters/hyku/menu_presenter.rb
+++ b/app/presenters/hyku/menu_presenter.rb
@@ -4,7 +4,7 @@ class MenuPresenter < Hyrax::MenuPresenter
# Returns true if the current controller happens to be one of the controllers that deals
# with settings. This is used to keep the parent section on the sidebar open.
def settings_section?
- %w(appearances content_blocks labels features pages).include?(controller_name)
+ %w[appearances content_blocks labels features pages].include?(controller_name)
end
# Returns true if the current controller happens to be one of the controllers that deals
@@ -23,7 +23,7 @@ def roles_and_permissions_section?
# Returns true if the current controller happens to be one of the controllers that deals
# with repository activity This is used to keep the parent section on the sidebar open.
def repository_activity_section?
- %w(admin dashboard status).include?(controller_name)
+ %w[admin dashboard status].include?(controller_name)
end
# Returns true if we ought to show the user the 'Configuration' section
diff --git a/app/uploaders/banner_image_uploader.rb b/app/uploaders/banner_image_uploader.rb
index 4f281f34b7..244963a7bc 100644
--- a/app/uploaders/banner_image_uploader.rb
+++ b/app/uploaders/banner_image_uploader.rb
@@ -1,6 +1,6 @@
class BannerImageUploader < CarrierWave::Uploader::Base
# Define valid extensions for site banner image
def extension_white_list
- %w(jpg jpeg png gif)
+ %w[jpg jpeg png gif]
end
end
diff --git a/lib/importer/csv_importer.rb b/lib/importer/csv_importer.rb
index 04d7d09fb6..d6bdb7f536 100644
--- a/lib/importer/csv_importer.rb
+++ b/lib/importer/csv_importer.rb
@@ -33,7 +33,7 @@ def parser
def factory_class(model)
return model if model.is_a?(Class)
if model.empty?
- $stderr.puts 'ERROR: No model was specified'
+ warn 'ERROR: No model was specified'
exit(1) # rubocop:disable Rails/Exit
end
return Factory.for(model.to_s) if model.respond_to?(:to_s)
diff --git a/lib/importer/csv_parser.rb b/lib/importer/csv_parser.rb
index 094e550faa..74476d7799 100644
--- a/lib/importer/csv_parser.rb
+++ b/lib/importer/csv_parser.rb
@@ -37,7 +37,7 @@ def validate_headers(row)
# e.g. For an author, author_type might be 'Person'.
difference.delete_if { |h| h.match(type_header_pattern) }
- raise "Invalid headers: #{difference.join(', ')}" unless difference.blank?
+ raise "Invalid headers: #{difference.join(', ')}" if difference.present?
validate_header_pairs(row)
row
@@ -57,16 +57,16 @@ def validate_header_pairs(row)
errors << "Invalid headers: '#{header}' column must be immediately followed by '#{field_name}' column."
end
end
- raise errors.join(', ') unless errors.blank?
+ raise errors.join(', ') if errors.present?
end
# rubocop:enable Metrics/MethodLength
def valid_headers
- GenericWork.attribute_names + %w(id type file) + collection_headers
+ GenericWork.attribute_names + %w[id type file] + collection_headers
end
def collection_headers
- %w(collection_id collection_title collection_accession_number)
+ %w[collection_id collection_title collection_accession_number]
end
def attributes(headers, row)
@@ -143,7 +143,7 @@ def update_typed_field(header, val, processed)
end
def update_collection(collection, field, val)
- val = [val] unless %w(admin_policy_id id).include? field
+ val = [val] unless %w[admin_policy_id id].include? field
collection[field.to_sym] = val
end
diff --git a/lib/importer/factory/object_factory.rb b/lib/importer/factory/object_factory.rb
index 5ae10be22b..2d7520ef4e 100644
--- a/lib/importer/factory/object_factory.rb
+++ b/lib/importer/factory/object_factory.rb
@@ -119,7 +119,7 @@ def file_paths
# Regardless of what the MODS Parser gives us, these are the properties we are prepared to accept.
def permitted_attributes
- klass.properties.keys.map(&:to_sym) + [:id, :edit_users, :edit_groups, :read_groups, :visibility]
+ klass.properties.keys.map(&:to_sym) + %i[id edit_users edit_groups read_groups visibility]
end
end
end
diff --git a/lib/importer/mods_parser.rb b/lib/importer/mods_parser.rb
index 22c54bb7ed..e4c4fee895 100644
--- a/lib/importer/mods_parser.rb
+++ b/lib/importer/mods_parser.rb
@@ -101,11 +101,7 @@ def description
def language
mods.language.languageTerm.map do |term|
uris = term.valueURI.map { |uri| RDF::URI.new(uri) }
- if uris.present?
- uris
- else
- term.text
- end
+ uris.presence || term.text
end
end
diff --git a/lib/tasks/tenantize_task.rake b/lib/tasks/tenantize_task.rake
index 7b6b373dd0..cbe4659a66 100644
--- a/lib/tasks/tenantize_task.rake
+++ b/lib/tasks/tenantize_task.rake
@@ -2,7 +2,7 @@
namespace :tenantize do
desc 'Run given task on all or selected tenants'
task :task, [:task_name] => :environment do |_cmd, args|
- raise ArgumentError, 'A rake task name is required: `rake tenantize:task[do:the:thing,arg1,...]`' unless args.task_name.present?
+ raise ArgumentError, 'A rake task name is required: `rake tenantize:task[do:the:thing,arg1,...]`' if args.task_name.blank?
raise ArgumentError, "Rake task not found: #{args.task_name}. Are you sure this task is defined?" unless Rake::Task.task_defined?(args.task_name)
tenant_list = ENV.fetch('tenants', '').split
Account.tenants(tenant_list).each do |account|
diff --git a/lib/tasks/user.rake b/lib/tasks/user.rake
index fb73467691..e7dff03604 100644
--- a/lib/tasks/user.rake
+++ b/lib/tasks/user.rake
@@ -13,7 +13,7 @@ namespace :hyku do
puts 'User not found. Enter a password to create the user.'
u.password = prompt_for_password
end
- rescue => e
+ rescue StandardError => e
puts e
retry
end
diff --git a/spec/controllers/account_sign_up_controller_spec.rb b/spec/controllers/account_sign_up_controller_spec.rb
index a13bedaa74..c39ab36e7d 100644
--- a/spec/controllers/account_sign_up_controller_spec.rb
+++ b/spec/controllers/account_sign_up_controller_spec.rb
@@ -84,6 +84,7 @@
context 'as admin with restricted access' do
let(:user) { FactoryGirl.create(:admin) }
+
before do
allow(Settings.multitenancy).to receive(:admin_only_tenant_creation).and_return(true)
end
diff --git a/spec/controllers/admin/group_users_controller_spec.rb b/spec/controllers/admin/group_users_controller_spec.rb
index 89ac87c846..b09784a3ee 100644
--- a/spec/controllers/admin/group_users_controller_spec.rb
+++ b/spec/controllers/admin/group_users_controller_spec.rb
@@ -4,6 +4,7 @@
context 'as an anonymous user' do
describe 'GET #index' do
subject { get :index, params: { group_id: group.id } }
+
it { is_expected.to redirect_to root_path }
end
end
@@ -13,6 +14,7 @@
describe 'GET #index' do
subject { get :index, params: { group_id: group.id } }
+
it { is_expected.to render_template('layouts/dashboard') }
it { is_expected.to render_template('admin/groups/users') }
end
diff --git a/spec/controllers/admin/groups_controller_spec.rb b/spec/controllers/admin/groups_controller_spec.rb
index 335efe8db6..17d319c9e6 100644
--- a/spec/controllers/admin/groups_controller_spec.rb
+++ b/spec/controllers/admin/groups_controller_spec.rb
@@ -2,6 +2,7 @@
context 'as an anonymous user' do
describe 'GET #index' do
subject { get :index }
+
it { is_expected.to redirect_to root_path }
end
end
@@ -11,12 +12,14 @@
describe 'GET #index' do
subject { get :index }
+
it { is_expected.to render_template('layouts/dashboard') }
it { is_expected.to render_template('admin/groups/index') }
end
describe 'GET #new' do
subject { get :new }
+
it { is_expected.to render_template('admin/groups/new') }
end
@@ -34,11 +37,13 @@
describe 'GET #edit' do
subject { get :edit, params: { id: group.id } }
+
it { is_expected.to render_template('admin/groups/edit') }
end
describe 'PATCH #update' do
subject { Hyku::Group.find_by(id: group.id) }
+
before { patch :update, params: { id: group.id, hyku_group: new_attributes } }
it 'updates attribtes' do
@@ -49,11 +54,13 @@
describe 'GET #remove' do
subject { get :remove, params: { id: group.id } }
+
it { is_expected.to render_template('admin/groups/remove') }
end
describe 'DELETE #destroy' do
subject { Hyku::Group.find_by(id: group.id) }
+
before { delete :destroy, params: { id: group.id } }
it { is_expected.to be_nil }
end
diff --git a/spec/controllers/admin/users_controller_spec.rb b/spec/controllers/admin/users_controller_spec.rb
index be204e070e..ed3e29fbda 100644
--- a/spec/controllers/admin/users_controller_spec.rb
+++ b/spec/controllers/admin/users_controller_spec.rb
@@ -4,6 +4,7 @@
describe 'DELETE #destroy' do
subject { User.find_by(id: user.id) }
+
before { delete :destroy, params: { id: user.id } }
it "doesn't delete the user and redirects to login" do
expect(subject).not_to be_nil
@@ -14,10 +15,12 @@
context 'as an admin user' do
let(:user) { FactoryGirl.create(:user) }
+
before { sign_in create(:admin) }
describe 'DELETE #destroy' do
subject { User.find_by(id: user.id) }
+
before { delete :destroy, params: { id: user.to_param } }
it "deletes the user and displays success message" do
expect(subject).to be_nil
diff --git a/spec/controllers/hyku/registrations_controller_spec.rb b/spec/controllers/hyku/registrations_controller_spec.rb
index 7cdf9a3706..430465889e 100644
--- a/spec/controllers/hyku/registrations_controller_spec.rb
+++ b/spec/controllers/hyku/registrations_controller_spec.rb
@@ -7,6 +7,7 @@
context 'with account signup enabled' do
let(:account_signup_enabled) { true }
+
describe '#new' do
it 'renders the form' do
get :new
@@ -29,6 +30,7 @@
end
context 'with account signup disabled' do
let(:account_signup_enabled) { false }
+
describe '#new' do
it 'redirects with a flash message' do
get :new
diff --git a/spec/controllers/hyrax/admin/appearances_controller_spec.rb b/spec/controllers/hyrax/admin/appearances_controller_spec.rb
index a7f59692fc..504c4bfcf9 100644
--- a/spec/controllers/hyrax/admin/appearances_controller_spec.rb
+++ b/spec/controllers/hyrax/admin/appearances_controller_spec.rb
@@ -8,14 +8,14 @@
describe "GET #show" do
it "denies the request" do
get :show
- expect(response).to have_http_status(401)
+ expect(response).to have_http_status(:unauthorized)
end
end
describe "PUT #update" do
it "denies the request" do
put :update
- expect(response).to have_http_status(401)
+ expect(response).to have_http_status(:unauthorized)
end
end
end
diff --git a/spec/controllers/hyrax/file_sets_controller_spec.rb b/spec/controllers/hyrax/file_sets_controller_spec.rb
index 9d9d541aab..736f6707c6 100644
--- a/spec/controllers/hyrax/file_sets_controller_spec.rb
+++ b/spec/controllers/hyrax/file_sets_controller_spec.rb
@@ -1,6 +1,7 @@
RSpec.describe Hyrax::FileSetsController do
describe 'show_presenter' do
subject { described_class.show_presenter }
+
it { is_expected.to eq Hyku::FileSetPresenter }
end
end
diff --git a/spec/controllers/hyrax/generic_works_controller_spec.rb b/spec/controllers/hyrax/generic_works_controller_spec.rb
index 2b39259688..b30c66bccf 100644
--- a/spec/controllers/hyrax/generic_works_controller_spec.rb
+++ b/spec/controllers/hyrax/generic_works_controller_spec.rb
@@ -2,6 +2,7 @@
let(:user) { FactoryGirl.create(:user) }
let(:work) { FactoryGirl.create(:work_with_one_file, user: user) }
let(:file_set) { work.ordered_members.to_a.first }
+
before do
Hydra::Works::AddFileToFileSet.call(file_set,
fixture_file('images/world.png'),
@@ -9,6 +10,7 @@
end
describe '#manifest' do
let(:manifest_factory) { double(to_h: { test: 'manifest' }) }
+
before do
sign_in user
allow(IIIFManifest::ManifestFactory).to receive(:new)
@@ -24,10 +26,12 @@
describe "#presenter" do
let(:solr_document) { SolrDocument.new(FactoryGirl.create(:generic_work).to_solr) }
+
before do
allow(controller).to receive(:curation_concern_from_search_results).and_return(solr_document)
end
subject { controller.send :presenter }
+
it "initializes a presenter" do
expect(subject).to be_kind_of Hyku::ManifestEnabledWorkShowPresenter
expect(subject.manifest_url).to eq "http://test.host/concern/generic_works/#{solr_document.id}/manifest"
diff --git a/spec/controllers/labels_controller_spec.rb b/spec/controllers/labels_controller_spec.rb
index f9429947a0..18e44b5ec2 100644
--- a/spec/controllers/labels_controller_spec.rb
+++ b/spec/controllers/labels_controller_spec.rb
@@ -39,14 +39,14 @@
describe "GET #edit" do
it "denies the request" do
get :edit
- expect(response).to have_http_status(401)
+ expect(response).to have_http_status(:unauthorized)
end
end
describe "PUT #update" do
it "denies the request" do
put :update, params: { site: valid_attributes }
- expect(response).to have_http_status(401)
+ expect(response).to have_http_status(:unauthorized)
end
end
end
diff --git a/spec/controllers/proprietor/accounts_controller_spec.rb b/spec/controllers/proprietor/accounts_controller_spec.rb
index 5814fc948c..d73d7236e5 100644
--- a/spec/controllers/proprietor/accounts_controller_spec.rb
+++ b/spec/controllers/proprietor/accounts_controller_spec.rb
@@ -112,7 +112,7 @@
describe "DELETE #destroy" do
it "denies the request" do
delete :destroy, params: { id: account.to_param }
- expect(response).to have_http_status(401)
+ expect(response).to have_http_status(:unauthorized)
end
end
@@ -122,21 +122,21 @@
describe "GET #show" do
it "denies the request" do
get :show, params: { id: another_account.to_param }
- expect(response).to have_http_status(401)
+ expect(response).to have_http_status(:unauthorized)
end
end
describe "GET #edit" do
it "denies the request" do
get :edit, params: { id: another_account.to_param }
- expect(response).to have_http_status(401)
+ expect(response).to have_http_status(:unauthorized)
end
end
describe "PUT #update" do
it "denies the request" do
put :update, params: { id: another_account.to_param, account: valid_attributes }
- expect(response).to have_http_status(401)
+ expect(response).to have_http_status(:unauthorized)
end
end
end
diff --git a/spec/controllers/roles_controller_spec.rb b/spec/controllers/roles_controller_spec.rb
index f92fb96d80..bee42c3cf0 100644
--- a/spec/controllers/roles_controller_spec.rb
+++ b/spec/controllers/roles_controller_spec.rb
@@ -13,14 +13,14 @@
describe "GET #edit" do
it "denies the request" do
get :index
- expect(response).not_to have_http_status(200)
+ expect(response).not_to have_http_status(:ok)
end
end
describe "PUT #update" do
it "denies the request" do
put :update, params: { id: user.id }
- expect(response).not_to have_http_status(201)
+ expect(response).not_to have_http_status(:created)
end
end
end
diff --git a/spec/controllers/sites_controller_spec.rb b/spec/controllers/sites_controller_spec.rb
index 16c273fdc7..0b70d5088f 100644
--- a/spec/controllers/sites_controller_spec.rb
+++ b/spec/controllers/sites_controller_spec.rb
@@ -7,7 +7,7 @@
describe "POST #update" do
it "denies the request" do
post :update
- expect(response).to have_http_status(401)
+ expect(response).to have_http_status(:unauthorized)
end
end
end
diff --git a/spec/factories/accounts.rb b/spec/factories/accounts.rb
index c9fc9edc18..680a26d812 100644
--- a/spec/factories/accounts.rb
+++ b/spec/factories/accounts.rb
@@ -1,12 +1,12 @@
FactoryGirl.define do
factory :solr_endpoint do
- options Hash.new(url: 'http://fakesolr.localhost:9876/solr/', collection: 'fakecore')
+ options { Hash.new(url: 'http://fakesolr.localhost:9876/solr/', collection: 'fakecore') }
end
factory :fcrepo_endpoint do
- options Hash.new(url: 'http://fakefedora.localhost:8765/', base_path: 'fakebase')
+ options { Hash.new(url: 'http://fakefedora.localhost:8765/', base_path: 'fakebase') }
end
factory :redis_endpoint do
- options Hash.new(namespace: 'fakeNS')
+ options { Hash.new(namespace: 'fakeNS') }
end
factory :account do
sequence(:cname) { |_n| srand }
diff --git a/spec/features/create_image_spec.rb b/spec/features/create_image_spec.rb
index 5aee76d1e7..2e9490ac15 100644
--- a/spec/features/create_image_spec.rb
+++ b/spec/features/create_image_spec.rb
@@ -3,7 +3,7 @@
include Warden::Test::Helpers
# NOTE: If you generated more than one work, you have to set "js: true"
-RSpec.feature 'Create a Image', :clean, js: true do
+RSpec.describe 'Create a Image', :clean, js: true do
context 'a logged in user' do
let(:user) { create(:user) }
@@ -12,7 +12,7 @@
login_as user, scope: :user
end
- scenario do
+ it do
visit '/dashboard'
click_link "Works"
click_link "Add new work"
diff --git a/spec/features/create_work_spec.rb b/spec/features/create_work_spec.rb
index 296fa9d01e..4bef127d42 100644
--- a/spec/features/create_work_spec.rb
+++ b/spec/features/create_work_spec.rb
@@ -1,4 +1,4 @@
-RSpec.feature 'Creating a new Work', :clean do
+RSpec.describe 'Creating a new Work', :clean do
let(:user) { create(:user) }
before do
diff --git a/spec/helpers/admin_stats_helper_spec.rb b/spec/helpers/admin_stats_helper_spec.rb
index 904a61ae2c..df69e677fe 100644
--- a/spec/helpers/admin_stats_helper_spec.rb
+++ b/spec/helpers/admin_stats_helper_spec.rb
@@ -2,7 +2,9 @@
describe "#graph_tag" do
let(:data) { [{ "label" => "foo", "data" => 7 }] }
subject { helper.graph_tag('work', data, {}) }
+
let(:node) { Capybara::Node::Simple.new(subject) }
+
it 'draws html' do
expect(node).to have_selector '.graph-container > #work'
expect(node.find('.graph-container')['data-graph-data']).to eq "[{\"label\":\"foo\",\"data\":7}]"
diff --git a/spec/indexers/file_set_indexer_spec.rb b/spec/indexers/file_set_indexer_spec.rb
index 472414638d..5fab7729ea 100644
--- a/spec/indexers/file_set_indexer_spec.rb
+++ b/spec/indexers/file_set_indexer_spec.rb
@@ -1,6 +1,7 @@
RSpec.describe FileSetIndexer do
describe 'thumbnail_path_service' do
subject { described_class.thumbnail_path_service }
+
it { is_expected.to eq IIIFWorkThumbnailPathService }
end
end
diff --git a/spec/indexers/work_indexer_spec.rb b/spec/indexers/work_indexer_spec.rb
index 90fa5414b5..ae720a28c9 100644
--- a/spec/indexers/work_indexer_spec.rb
+++ b/spec/indexers/work_indexer_spec.rb
@@ -1,6 +1,7 @@
RSpec.describe WorkIndexer do
describe 'thumbnail_path_service' do
subject { described_class.thumbnail_path_service }
+
it { is_expected.to eq IIIFWorkThumbnailPathService }
end
diff --git a/spec/jobs/create_solr_collection_job_spec.rb b/spec/jobs/create_solr_collection_job_spec.rb
index ea5e73fa56..8a506c1172 100644
--- a/spec/jobs/create_solr_collection_job_spec.rb
+++ b/spec/jobs/create_solr_collection_job_spec.rb
@@ -33,6 +33,7 @@
describe CreateSolrCollectionJob::CollectionOptions do
describe '#to_h' do
subject { described_class.new(data).to_h }
+
let(:data) do
{
collection: { config_name: 'hyku', blank: '' },
diff --git a/spec/jobs/import_work_from_purl_job_spec.rb b/spec/jobs/import_work_from_purl_job_spec.rb
index e44a689fe7..90e47adfcf 100644
--- a/spec/jobs/import_work_from_purl_job_spec.rb
+++ b/spec/jobs/import_work_from_purl_job_spec.rb
@@ -5,148 +5,146 @@
before do
stub_request(:get, "https://purl.stanford.edu/bc390xk2647.xml")
.to_return(status: 200, body: purl_xml)
- if ActiveFedora::Base.exists? druid
- ActiveFedora::Base.find(druid).destroy(eradicate: true)
- end
+ ActiveFedora::Base.find(druid).destroy(eradicate: true) if ActiveFedora::Base.exists? druid
Hyrax::PermissionTemplate.create!(admin_set_id: AdminSet::DEFAULT_ID)
# Don't call load_workflows until the PermissionTemplate has been created
Hyrax::Workflow::WorkflowImporter.load_workflows
end
+ let(:purl_xml) do
+ <<~EOF
+
+
+
+ 12415
+ druid:bc390xk2647
+ DOR
+ Lake Lagunita
+ item
+ druid:kz949yf0754
+ 29164b40-9b88-11e2-bae9-0050569b52d5
+ Project : Stanford Historical Photograph Collection
+ Remediated By : 5.10.1
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ StillImage
+ Lake Lagunita
+ photographic prints
+ 1887-1996
+ 1 photograph; 4 in. x 6 in.
+ black and white photographic print
+ image/jpeg
+ eng
+ Digitized by Stanford University Libraries.
+ Lakes
+ Lake Lagunita (Calif.)
+ College campuses
+ 9650
+ Stanford University. Libraries. Department of Special Collections and University Archives Series: General Photographs, Box: 25, Folder: Lake Lagunita -- #3 SC1071
+ Stanford historical photograph collection, 1887-circa 1996 (inclusive)
+
+
+ still image
+
+ Lake Lagunita
+
+ photographic prints
+
+ 1887
+ 1996
+
+
+
+ 1 photograph; 4 in. x 6 in.
+ image/jpeg
+ reformatted digital
+
+
+ eng
+
+ Digitized by Stanford University Libraries.
+
+ Lakes
+
+
+ Lake Lagunita (Calif.)
+
+
+ College campuses
+
+ 9650
+
+ Stanford University. Libraries. Department of Special Collections and University Archives
+ Series: General Photographs, Box: 25, Folder: Lake Lagunita -- #3
+ SC1071
+
+
+
+ General Photographs
+
+
+
+ CSt
+ Transformed from legacy Luna Insight data, Luna Object ID 12415
+
+ eng
+
+
+
+
+ Stanford historical photograph collection, 1887-circa 1996 (inclusive)
+
+
+ https://purl.stanford.edu/kx532cb7981
+
+
+
+ Property rights reside with the repository. Literary rights reside with the creators of the documents or their heirs. To obtain permission to publish or reproduce, please contact the Special Collections Public Services Librarian at speccollref@stanford.edu.
+
+
+ true
+
+ bc390xk2647/00007845_005.jp2
+
+EOF
+ end
+
it "works" do
expect(CreateWorkJob).to receive(:perform_later)
described_class.perform_now(user, druid, log)
end
-
- let(:purl_xml) do
- <
-
-
- 12415
- druid:bc390xk2647
- DOR
- Lake Lagunita
- item
- druid:kz949yf0754
- 29164b40-9b88-11e2-bae9-0050569b52d5
- Project : Stanford Historical Photograph Collection
- Remediated By : 5.10.1
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- StillImage
- Lake Lagunita
- photographic prints
- 1887-1996
- 1 photograph; 4 in. x 6 in.
- black and white photographic print
- image/jpeg
- eng
- Digitized by Stanford University Libraries.
- Lakes
- Lake Lagunita (Calif.)
- College campuses
- 9650
- Stanford University. Libraries. Department of Special Collections and University Archives Series: General Photographs, Box: 25, Folder: Lake Lagunita -- #3 SC1071
- Stanford historical photograph collection, 1887-circa 1996 (inclusive)
-
-
- still image
-
- Lake Lagunita
-
- photographic prints
-
- 1887
- 1996
-
-
-
- 1 photograph; 4 in. x 6 in.
- image/jpeg
- reformatted digital
-
-
- eng
-
- Digitized by Stanford University Libraries.
-
- Lakes
-
-
- Lake Lagunita (Calif.)
-
-
- College campuses
-
- 9650
-
- Stanford University. Libraries. Department of Special Collections and University Archives
- Series: General Photographs, Box: 25, Folder: Lake Lagunita -- #3
- SC1071
-
-
-
- General Photographs
-
-
-
- CSt
- Transformed from legacy Luna Insight data, Luna Object ID 12415
-
- eng
-
-
-
-
- Stanford historical photograph collection, 1887-circa 1996 (inclusive)
-
-
- https://purl.stanford.edu/kx532cb7981
-
-
-
- Property rights reside with the repository. Literary rights reside with the creators of the documents or their heirs. To obtain permission to publish or reproduce, please contact the Special Collections Public Services Librarian at speccollref@stanford.edu.
-
-
- true
-
- bc390xk2647/00007845_005.jp2
-
-EOF
- end
end
diff --git a/spec/lib/importer/csv_parser_spec.rb b/spec/lib/importer/csv_parser_spec.rb
index 6c84cc1e8b..34952e6196 100644
--- a/spec/lib/importer/csv_parser_spec.rb
+++ b/spec/lib/importer/csv_parser_spec.rb
@@ -19,9 +19,9 @@
{ name: ["Brandao, Leonidas"] },
{ name: ["Brandao, Anarosa"] },
{ name: ["Isotani, Seiji"] }]
- expect(first_record.keys).to match_array [:id, :type, :title, :description,
- :subject, :resource_type, :contributor,
- :date_created, :file]
+ expect(first_record.keys).to match_array %i[id type title description
+ subject resource_type contributor
+ date_created file]
end
end
@@ -29,7 +29,8 @@
subject { parser.send(:validate_headers, headers) }
context 'with valid headers' do
- let(:headers) { %w(id title) }
+ let(:headers) { %w[id title] }
+
it { is_expected.to eq headers }
end
@@ -43,12 +44,14 @@
context 'with nil headers' do
let(:headers) { ['title', nil] }
+
it { is_expected.to eq headers }
end
# It doesn't expect a matching column for "resource_type"
context 'with resource_type column' do
- let(:headers) { %w(resource_type title) }
+ let(:headers) { %w[resource_type title] }
+
it { is_expected.to eq headers }
end
end
@@ -57,7 +60,8 @@
subject { parser.send(:validate_header_pairs, headers) }
context 'with "*_type" columns' do
- let(:headers) { %w(rights_holder rights_holder_type rights_holder title note_type note) }
+ let(:headers) { %w[rights_holder rights_holder_type rights_holder title note_type note] }
+
it { is_expected.to be_nil }
end
@@ -66,7 +70,7 @@
# authority. If the columns aren't in the correct order,
# raise an error.
context 'with columns in the wrong order' do
- let(:headers) { %w(note note_type rights_holder_type rights_holder_type rights_holder title) }
+ let(:headers) { %w[note note_type rights_holder_type rights_holder_type rights_holder title] }
it 'raises an error' do
expect { subject }.to raise_error "Invalid headers: 'note_type' column " \
diff --git a/spec/lib/importer/factory/etd_factory_spec.rb b/spec/lib/importer/factory/etd_factory_spec.rb
index 5b44c4f473..470e31d541 100644
--- a/spec/lib/importer/factory/etd_factory_spec.rb
+++ b/spec/lib/importer/factory/etd_factory_spec.rb
@@ -36,6 +36,7 @@
context "for an existing image without files" do
let(:work) { create(:generic_work) }
let(:factory) { described_class.new(attributes.merge(id: work.id), 'tmp/files', files) }
+
it 'creates file sets' do
expect(actor).to receive(:update).with(Hyrax::Actors::Environment) do |k|
expect(k.attributes).to include(member_of_collection_ids: [coll.id], files: ['tmp/files/img.png'])
@@ -54,7 +55,7 @@
end
expect do
factory.run
- end.to change { Collection.count }.by(0)
+ end.to change(Collection, :count).by(0)
end
end
end
diff --git a/spec/lib/importer/factory/image_factory_spec.rb b/spec/lib/importer/factory/image_factory_spec.rb
index 5b6cc20a7e..a7d1e388e5 100644
--- a/spec/lib/importer/factory/image_factory_spec.rb
+++ b/spec/lib/importer/factory/image_factory_spec.rb
@@ -36,6 +36,7 @@
context "for an existing image without files" do
let(:work) { create(:generic_work) }
let(:factory) { described_class.new(attributes.merge(id: work.id), 'tmp/files', files) }
+
it 'creates file sets' do
expect(actor).to receive(:update).with(Hyrax::Actors::Environment) do |k|
expect(k.attributes).to include(member_of_collection_ids: [coll.id], files: ['tmp/files/img.png'])
@@ -54,7 +55,7 @@
end
expect do
factory.run
- end.to change { Collection.count }.by(0)
+ end.to change(Collection, :count).by(0)
end
end
end
diff --git a/spec/lib/importer/factory/string_literal_processor_spec.rb b/spec/lib/importer/factory/string_literal_processor_spec.rb
index 57d1f7f55d..3b169b89d6 100644
--- a/spec/lib/importer/factory/string_literal_processor_spec.rb
+++ b/spec/lib/importer/factory/string_literal_processor_spec.rb
@@ -5,10 +5,12 @@
{ title: ["Stanford residences"],
contributor: [{ name: name, type: "corporate" }] }
end
+
subject { described_class.process(input) }
context "with a single name" do
let(:name) { ["Muybridge"] }
+
it do
is_expected.to eq(title: ["Stanford residences"],
contributor: ['Muybridge'])
@@ -17,6 +19,7 @@
context "with multiple name parts" do
let(:name) { ["Stanford University", "Archives."] }
+
it do
is_expected.to eq(title: ["Stanford residences"],
contributor: ['Stanford University — Archives.'])
@@ -27,6 +30,7 @@
let(:input) do
{ title: ["Stanford residences"] }
end
+
it { is_expected.to eq(title: ["Stanford residences"]) }
end
end
diff --git a/spec/lib/importer/mods_importer_spec.rb b/spec/lib/importer/mods_importer_spec.rb
index b8cc00117c..0be5869f1a 100644
--- a/spec/lib/importer/mods_importer_spec.rb
+++ b/spec/lib/importer/mods_importer_spec.rb
@@ -5,6 +5,7 @@
let(:image_directory) { 'spec/fixtures/images' }
let(:importer) { described_class.new(image_directory) }
let(:actor) { double }
+
before do
allow(Hyrax::CurationConcern).to receive(:actor).and_return(actor)
end
@@ -20,7 +21,7 @@
end
expect do
importer.import(file)
- end.to change { Collection.count }.by(1)
+ end.to change(Collection, :count).by(1)
coll = Collection.last
expect(coll.identifier).to eq ['kx532cb7981']
@@ -31,13 +32,13 @@
context 'when the collection already exists' do
let!(:coll) { create(:collection, id: 'kx532cb7981', title: ['Test Collection']) }
- it 'it adds image to existing collection' do
+ it 'adds image to existing collection' do
expect(actor).to receive(:create).with(Hyrax::Actors::Environment) do |k|
expect(k.attributes).to include(member_of_collection_ids: [coll.id])
end
expect do
importer.import(file)
- end.to change { Collection.count }.by(0)
+ end.to change(Collection, :count).by(0)
end
end
end
@@ -49,7 +50,7 @@
coll = nil
expect do
coll = importer.import(file)
- end.to change { Collection.count }.by(1)
+ end.to change(Collection, :count).by(1)
expect(coll.identifier).to eq ['kx532cb7981']
expect(coll.title).to eq ['Stanford historical photograph collection, 1887-circa 1996 (inclusive)']
@@ -61,11 +62,11 @@
context 'when the collection already exists' do
let!(:existing) { FactoryGirl.create(:collection, id: 'kx532cb7981', title: ['Test Collection']) }
- it 'it adds metadata to existing collection' do
+ it 'adds metadata to existing collection' do
coll = nil
expect do
coll = importer.import(file)
- end.to change { Collection.count }.by(0)
+ end.to change(Collection, :count).by(0)
expect(coll.id).to eq existing.id
expect(coll.identifier).to eq ['kx532cb7981']
diff --git a/spec/lib/importer/mods_parser_spec.rb b/spec/lib/importer/mods_parser_spec.rb
index 5228691f22..72be07886f 100644
--- a/spec/lib/importer/mods_parser_spec.rb
+++ b/spec/lib/importer/mods_parser_spec.rb
@@ -51,6 +51,7 @@
context 'with a file that has a general (untyped) note' do
let(:file) { 'spec/fixtures/mods/shpc/druid_xv169dn4538.mods' }
+
it 'imports notes' do
expect(attributes[:notes_attributes].first[:value]).to start_with(
"\"Left to right: Anna Maria Lathrop"
@@ -94,6 +95,7 @@
context 'with a file that has coordinates', skip: 'Need metadata with geo data' do
let(:file) { 'spec/fixtures/mods/shpc/druid_xv169dn4538.mods' }
+
it 'imports coordinates' do
expect(attributes[:latitude]).to eq ['34.442982']
expect(attributes[:longitude]).to eq ['-119.657362']
@@ -133,6 +135,7 @@
context 'with a file that has a range of dateIssued', skip: "no dates on this record" do
let(:file) { 'spec/fixtures/mods/shpc/druid_xv169dn4538.mods' }
+
it 'imports issued' do
expect(attributes[:issued_attributes]).to eq [
{ start: ['1900'],
@@ -146,6 +149,7 @@
context 'with a file that has a single dateIssued', skip: "no dates on this record" do
let(:file) { 'spec/fixtures/mods/shpc/druid_xv169dn4538.mods' }
+
it 'imports issued' do
expect(attributes[:issued_attributes]).to eq [
{ start: ['1925'],
@@ -162,6 +166,7 @@
let(:xml) do
"1985-12-01"
end
+
before { allow(parser).to receive(:mods).and_return(Mods::Record.new.from_str(xml)) }
it 'imports date_copyrighted' do
expect(attributes[:date_copyrighted_attributes]).to eq [
@@ -179,6 +184,7 @@
let(:xml) do
"1989-12-01"
end
+
before { allow(parser).to receive(:mods).and_return(Mods::Record.new.from_str(xml)) }
it 'imports date_valid' do
expect(attributes[:date_valid_attributes]).to eq [
@@ -193,6 +199,7 @@
context 'with a file that has an alternative title', skip: "Need a record with alt title" do
let(:file) { 'spec/fixtures/mods/shpc/druid_xv169dn4538.mods' }
+
it 'distinguishes between title and alternative title' do
expect(attributes[:title]).to eq ['Stanford residences -- Sacramento -- Muybridge']
expect(attributes[:alternative]).to eq ['An alternative']
@@ -201,6 +208,7 @@
context 'with a file that has placeTerm', skip: 'file has no originInfo' do
let(:file) { 'spec/fixtures/mods/shpc/druid_xv169dn4538.mods' }
+
it 'reads the place' do
expect(attributes[:place_of_publication]). to eq ['Santa Barbara, California']
end
diff --git a/spec/lib/stanford/importer/mods_parser_spec.rb b/spec/lib/stanford/importer/mods_parser_spec.rb
index f76b6e3dc8..94ff41d11b 100644
--- a/spec/lib/stanford/importer/mods_parser_spec.rb
+++ b/spec/lib/stanford/importer/mods_parser_spec.rb
@@ -7,6 +7,7 @@
describe '#collection_attributes' do
let(:file) { 'spec/fixtures/mods/shpc/kx532cb7981.mods' }
+
subject { parser.collection_attributes }
it "has visibility" do
@@ -16,7 +17,9 @@
describe '#record_attributes' do
let(:file) { 'spec/fixtures/mods/shpc/druid_xv169dn4538.mods' }
+
subject { parser.record_attributes }
+
it "has visibility" do
expect(subject[:visibility]).to eq 'open'
end
diff --git a/spec/mailers/devise/mailer_spec.rb b/spec/mailers/devise/mailer_spec.rb
index 87c2865214..3231c63d1c 100644
--- a/spec/mailers/devise/mailer_spec.rb
+++ b/spec/mailers/devise/mailer_spec.rb
@@ -6,6 +6,7 @@
describe "reset_password_instructions" do
let(:mail) { described_class.reset_password_instructions(user, token) }
+
it "renders the body" do
expect(mail.body.encoded).to match("http://localhost/users/password/edit")
end
diff --git a/spec/models/ability_spec.rb b/spec/models/ability_spec.rb
index 183dbfc531..ad28ecfa3c 100644
--- a/spec/models/ability_spec.rb
+++ b/spec/models/ability_spec.rb
@@ -2,20 +2,24 @@
RSpec.describe Ability do
subject { ability }
+
let(:ability) { described_class.new(user) }
describe 'an anonymous user' do
let(:user) { nil }
+
it { is_expected.not_to be_able_to(:manage, :all) }
end
describe 'an ordinary user' do
let(:user) { FactoryGirl.create(:user) }
+
it { is_expected.not_to be_able_to(:manage, :all) }
end
describe 'an administrative user' do
let(:user) { FactoryGirl.create(:admin) }
+
it { is_expected.not_to be_able_to(:manage, :all) }
it { is_expected.not_to be_able_to(:manage, Account) }
it { is_expected.to be_able_to(:manage, Site) }
@@ -31,6 +35,7 @@
describe 'a superadmin user' do
let(:user) { FactoryGirl.create(:superadmin) }
+
it { is_expected.to be_able_to(:manage, :all) }
end
end
diff --git a/spec/models/account_spec.rb b/spec/models/account_spec.rb
index 8edc8d8a5b..57531f3b12 100644
--- a/spec/models/account_spec.rb
+++ b/spec/models/account_spec.rb
@@ -210,6 +210,7 @@
describe 'prevents duplicate cname and tenant values' do
let!(:account1) { described_class.create(name: 'example', tenant: 'example_tenant', cname: 'example.dev') }
+
it 'on create' do
account2 = described_class.create(name: 'example', tenant: 'example_tenant', cname: 'example.dev')
expect(account1.errors).to be_empty
@@ -244,6 +245,7 @@
describe 'guarantees only one account can reference the same' do
let(:endpoint) { SolrEndpoint.new(url: 'solr') }
let!(:account1) { described_class.create(name: 'example', solr_endpoint: endpoint) }
+
it 'solr_endpoint' do
account2 = described_class.new(name: 'other', solr_endpoint: endpoint)
expect { account2.save }.to raise_error(ActiveRecord::RecordNotUnique)
@@ -254,6 +256,7 @@
describe '#admin_emails' do
let!(:account) { FactoryGirl.create(:account, tenant: "mytenant") }
+
before do
Site.update(account: account)
Site.instance.admin_emails = ["test@test.com", "test@test.org"]
@@ -266,6 +269,7 @@
describe '#admin_emails=' do
let!(:account) { FactoryGirl.create(:account, tenant: "mytenant") }
+
before do
Site.update(account: account)
Site.instance.admin_emails = ["test@test.com", "test@test.org"]
@@ -280,6 +284,7 @@
describe '#global_tenant?' do
subject { described_class.global_tenant? }
+
context 'default setting for test environment' do
it { is_expected.to be false }
end
diff --git a/spec/models/fcrepo_endpoint_spec.rb b/spec/models/fcrepo_endpoint_spec.rb
index 9892dfc655..d2e28a1bba 100644
--- a/spec/models/fcrepo_endpoint_spec.rb
+++ b/spec/models/fcrepo_endpoint_spec.rb
@@ -1,5 +1,6 @@
RSpec.describe FcrepoEndpoint do
let(:base_path) { 'foobar' }
+
describe '.options' do
subject { described_class.new base_path: base_path }
@@ -10,6 +11,7 @@
describe '#ping' do
let(:success_response) { double(response: double(success?: true)) }
+
it 'checks if the service is up' do
allow(ActiveFedora::Fedora.instance.connection).to receive(:head).with('/').and_return(success_response)
expect(subject.ping).to be_truthy
diff --git a/spec/models/file_set_spec.rb b/spec/models/file_set_spec.rb
index 570ae9f227..7f3c7398a8 100644
--- a/spec/models/file_set_spec.rb
+++ b/spec/models/file_set_spec.rb
@@ -3,6 +3,7 @@
RSpec.describe FileSet do
describe 'indexer' do
subject { described_class.indexer }
+
it { is_expected.to eq FileSetIndexer }
end
end
diff --git a/spec/models/generic_work_spec.rb b/spec/models/generic_work_spec.rb
index ad31487493..55d7b1f1de 100644
--- a/spec/models/generic_work_spec.rb
+++ b/spec/models/generic_work_spec.rb
@@ -1,6 +1,7 @@
RSpec.describe GenericWork do
describe 'indexer' do
subject { described_class.indexer }
+
it { is_expected.to eq WorkIndexer }
end
end
diff --git a/spec/models/hyku/group_spec.rb b/spec/models/hyku/group_spec.rb
index 2e0b1d57dd..0a55b55673 100644
--- a/spec/models/hyku/group_spec.rb
+++ b/spec/models/hyku/group_spec.rb
@@ -2,6 +2,7 @@ module Hyku
RSpec.describe Group do
describe 'group with no members' do
subject { described_class.new(name: name, description: description) }
+
let(:name) { 'Empty Group' }
let(:description) { 'Add members plz' }
let(:empty_group_attributes) do
@@ -11,6 +12,7 @@ module Hyku
number_of_users: 0
}
end
+
it { is_expected.to have_attributes(empty_group_attributes) }
it { is_expected.to respond_to(:created_at) }
end
@@ -44,6 +46,7 @@ module Hyku
context '#search_members' do
subject { FactoryGirl.create(:group) }
+
let(:known_user_name) { FactoryGirl.create(:user, display_name: 'Tom Cramer') }
let(:known_user_email) { FactoryGirl.create(:user, email: 'tom@project-hydra.com') }
@@ -68,7 +71,9 @@ module Hyku
describe '#add_members_by_id' do
subject { FactoryGirl.create(:group) }
+
let(:user) { FactoryGirl.create(:user) }
+
before { subject.add_members_by_id(user.id) }
it 'adds one user when passed a single user id' do
@@ -85,6 +90,7 @@ module Hyku
context 'single user id' do
let(:user) { FactoryGirl.create(:user) }
+
before { subject.add_members_by_id(user.id) }
it 'removes one user' do
@@ -97,6 +103,7 @@ module Hyku
context 'collection of user ids' do
let(:user_list) { FactoryGirl.create_list(:user, 3) }
let(:user_ids) { user_list.collect(&:id) }
+
before { subject.add_members_by_id(user_ids) }
it 'removes multiple users' do
@@ -109,6 +116,7 @@ module Hyku
context '#number_of_users' do
subject { FactoryGirl.create(:group) }
+
let(:user) { FactoryGirl.create(:user) }
it 'starts out with 0 users' do
diff --git a/spec/models/image_spec.rb b/spec/models/image_spec.rb
index 73a98f2705..bd1c9487df 100644
--- a/spec/models/image_spec.rb
+++ b/spec/models/image_spec.rb
@@ -4,6 +4,7 @@
RSpec.describe Image do
describe 'indexer' do
subject { described_class.indexer }
+
it { is_expected.to eq ImageIndexer }
end
end
diff --git a/spec/models/nil_fcrepo_endpoint_spec.rb b/spec/models/nil_fcrepo_endpoint_spec.rb
index b055360b1d..5a527a7909 100644
--- a/spec/models/nil_fcrepo_endpoint_spec.rb
+++ b/spec/models/nil_fcrepo_endpoint_spec.rb
@@ -2,8 +2,10 @@
RSpec.describe NilFcrepoEndpoint do
let(:instance) { described_class.new }
+
describe "#ping" do
subject { instance.ping }
+
it { is_expected.to be false }
end
@@ -13,11 +15,13 @@
describe "#url" do
subject { instance.url }
+
it { is_expected.to eq 'Fcrepo not initialized' }
end
describe "#base_path" do
subject { instance.base_path }
+
it { is_expected.to eq 'Fcrepo not initialized' }
end
end
diff --git a/spec/models/nil_redis_endpoint_spec.rb b/spec/models/nil_redis_endpoint_spec.rb
index 17f65818c5..50e5d47383 100644
--- a/spec/models/nil_redis_endpoint_spec.rb
+++ b/spec/models/nil_redis_endpoint_spec.rb
@@ -2,8 +2,10 @@
RSpec.describe NilRedisEndpoint do
let(:instance) { described_class.new }
+
describe "#ping" do
subject { instance.ping }
+
it { is_expected.to be false }
end
end
diff --git a/spec/models/nil_site_spec.rb b/spec/models/nil_site_spec.rb
index 789796a0a0..8d04137d3b 100644
--- a/spec/models/nil_site_spec.rb
+++ b/spec/models/nil_site_spec.rb
@@ -3,74 +3,88 @@
describe "#instance" do
subject { described_class.instance }
+
# 'instance' should always return same obj (i.e. singleton)
it { is_expected.to be instance }
end
describe "#id" do
subject { instance.id }
+
it { is_expected.to be nil }
end
describe "#account" do
subject { instance.account }
+
it { is_expected.to be nil }
end
describe "#application_name" do
subject { instance.application_name }
+
it { is_expected.to be nil }
end
describe "#institution_name" do
subject { instance.institution_name }
+
it { is_expected.to be nil }
end
describe "#institution_name_full" do
subject { instance.institution_name_full }
+
it { is_expected.to be nil }
end
describe "#reload" do
subject { instance.reload }
+
it { is_expected.to be described_class.instance }
end
describe "#update" do
subject { instance.update(param: 'one') }
+
it { is_expected.to be false }
end
describe "#admin_emails" do
context "default value" do
subject { instance.admin_emails }
+
it { is_expected.to be_empty }
end
context "set a value" do
before { instance.admin_emails = "test@test.org" }
subject { instance.admin_emails }
+
it { is_expected.to be_empty }
end
end
describe "#admin_emails=" do
subject { instance.admin_emails = "one@two.org" }
+
it { is_expected.to eq("one@two.org") }
end
describe "#banner_image?" do
subject { instance.banner_image? }
+
it { is_expected.to be false }
end
describe "#banner_image" do
subject { instance.banner_image }
+
it { is_expected.to be nil }
end
describe "#primary_key" do
subject { instance.primary_key }
+
it { is_expected.to be nil }
end
end
diff --git a/spec/models/nil_solr_endpoint_spec.rb b/spec/models/nil_solr_endpoint_spec.rb
index be59b685de..30adb18f72 100644
--- a/spec/models/nil_solr_endpoint_spec.rb
+++ b/spec/models/nil_solr_endpoint_spec.rb
@@ -2,8 +2,10 @@
RSpec.describe NilSolrEndpoint do
let(:instance) { described_class.new }
+
describe "#ping" do
subject { instance.ping }
+
it { is_expected.to be false }
end
@@ -13,6 +15,7 @@
describe "#url" do
subject { instance.url }
+
it { is_expected.to eq 'Solr not initialized' }
end
end
diff --git a/spec/models/qa/local_authority_spec.rb b/spec/models/qa/local_authority_spec.rb
index 4d0f64e3c8..714c370664 100644
--- a/spec/models/qa/local_authority_spec.rb
+++ b/spec/models/qa/local_authority_spec.rb
@@ -3,6 +3,6 @@
RSpec.describe Qa::LocalAuthority, type: :model do
it "can persist data" do
expect { described_class.create!(name: 'Language') }
- .to change { described_class.count }.by(1)
+ .to change(described_class, :count).by(1)
end
end
diff --git a/spec/models/redis_endpoint_spec.rb b/spec/models/redis_endpoint_spec.rb
index f390125c07..d59c2996e6 100644
--- a/spec/models/redis_endpoint_spec.rb
+++ b/spec/models/redis_endpoint_spec.rb
@@ -1,5 +1,6 @@
RSpec.describe RedisEndpoint do
let(:namespace) { 'foobar' }
+
describe '.options' do
subject { described_class.new namespace: namespace }
diff --git a/spec/models/search_builder_spec.rb b/spec/models/search_builder_spec.rb
index e05beb8b93..b1aeef2437 100644
--- a/spec/models/search_builder_spec.rb
+++ b/spec/models/search_builder_spec.rb
@@ -1,6 +1,7 @@
RSpec.describe SearchBuilder do
describe ".default_processor_chain" do
subject { described_class.default_processor_chain }
+
it { is_expected.to include :filter_models }
end
end
diff --git a/spec/models/site_spec.rb b/spec/models/site_spec.rb
index 15f4ef36db..51fa4c057f 100644
--- a/spec/models/site_spec.rb
+++ b/spec/models/site_spec.rb
@@ -21,6 +21,7 @@
describe ".admin_emails" do
subject { described_class.instance }
+
context "no admins exist" do
it "returns empty array" do
expect(subject.admin_emails).to eq([])
@@ -39,6 +40,7 @@
describe ".admin_emails=" do
subject { described_class.instance }
+
context "passed empty array" do
before do
admin1.add_role :admin, subject
diff --git a/spec/models/solr_endpoint_spec.rb b/spec/models/solr_endpoint_spec.rb
index 02e561f5d3..69643894d1 100644
--- a/spec/models/solr_endpoint_spec.rb
+++ b/spec/models/solr_endpoint_spec.rb
@@ -3,6 +3,7 @@
describe '#connection_options' do
subject(:options) { instance.connection_options }
+
it 'merges the model attributes with the application settings' do
expect(options).to include url: 'http://example.com/solr/', read_timeout: 120
end
@@ -10,6 +11,7 @@
describe '#connection' do
subject { instance.connection }
+
let(:result) { double }
let(:af_options) do
{ read_timeout: 120,
@@ -36,6 +38,7 @@
describe '#ping' do
let(:mock_connection) { instance_double(RSolr::Client, options: {}) }
+
before do
# Mocking on the subject, because mocking RSolr.connect causes doubles to leak for some reason
allow(subject).to receive(:connection).and_return(mock_connection)
diff --git a/spec/models/uploaded_file_spec.rb b/spec/models/uploaded_file_spec.rb
index 7618825060..316f450abf 100644
--- a/spec/models/uploaded_file_spec.rb
+++ b/spec/models/uploaded_file_spec.rb
@@ -106,3 +106,5 @@
end
end
end
+
+# rubocop:enable Metrics/LineLength
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
index 30d77aed32..2a4a2d7942 100644
--- a/spec/models/user_spec.rb
+++ b/spec/models/user_spec.rb
@@ -1,6 +1,7 @@
RSpec.describe User, type: :model do
context 'the first created user in global tenant' do
subject { FactoryGirl.create(:base_user) }
+
before do
allow(Account).to receive(:global_tenant?).and_return true
end
@@ -11,6 +12,7 @@
context 'the first created user on a tenant' do
subject { FactoryGirl.create(:base_user) }
+
it 'is given the admin role' do
expect(subject).to have_role :admin, Site.instance
end
diff --git a/spec/presenters/hyku/admin/group/navigation_presenter_spec.rb b/spec/presenters/hyku/admin/group/navigation_presenter_spec.rb
index d1952f63f2..5d362dec84 100644
--- a/spec/presenters/hyku/admin/group/navigation_presenter_spec.rb
+++ b/spec/presenters/hyku/admin/group/navigation_presenter_spec.rb
@@ -9,6 +9,7 @@
context 'edit page' do
subject { presenter.tabs }
+
let(:action) { 'edit' }
let(:params) { base_params.merge(action: action) }
let(:presenter) { described_class.new(params: params) }
@@ -24,6 +25,7 @@
context 'members page' do
subject { presenter.tabs }
+
let(:action) { 'index' }
let(:params) { base_params.merge(controller: 'admin/group_users', action: action) }
let(:presenter) { described_class.new(params: params) }
@@ -39,6 +41,7 @@
context 'remve page' do
subject { presenter.tabs }
+
let(:action) { 'remove' }
let(:params) { base_params.merge(action: action) }
let(:presenter) { described_class.new(params: params) }
diff --git a/spec/presenters/hyku/file_set_presenter_spec.rb b/spec/presenters/hyku/file_set_presenter_spec.rb
index 011d825084..b731dd35aa 100644
--- a/spec/presenters/hyku/file_set_presenter_spec.rb
+++ b/spec/presenters/hyku/file_set_presenter_spec.rb
@@ -9,6 +9,7 @@
describe "display_image" do
context "when the file is not an image" do
subject { presenter.display_image }
+
before do
Hydra::Works::AddFileToFileSet.call(file_set,
fixture_file('csv/sample.csv'), :original_file)
@@ -17,6 +18,7 @@
end
context "when the file is an image" do
subject { presenter.display_image }
+
before do
Hydra::Works::AddFileToFileSet.call(file_set,
fixture_file('images/world.png'), :original_file)
@@ -30,6 +32,7 @@
describe "iiif_endpoint" do
subject { presenter.send(:iiif_endpoint, file_set.original_file) }
+
before do
Hydra::Works::AddFileToFileSet.call(file_set,
fixture_file('images/world.png'), :original_file)
diff --git a/spec/presenters/hyku/menu_presenter_spec.rb b/spec/presenters/hyku/menu_presenter_spec.rb
index e5bf8d8ef8..f21ecce841 100644
--- a/spec/presenters/hyku/menu_presenter_spec.rb
+++ b/spec/presenters/hyku/menu_presenter_spec.rb
@@ -12,14 +12,17 @@
context "for the ContentBlocksController" do
let(:controller) { Hyrax::ContentBlocksController.new }
+
it { is_expected.to be false }
end
context "for the StatusController" do
let(:controller) { StatusController.new }
+
it { is_expected.to be true }
end
context "for the Hyrax::DashboardController" do
let(:controller) { Hyrax::DashboardController.new }
+
it { is_expected.to be true }
end
end
@@ -30,12 +33,15 @@
allow(context).to receive(:controller).and_return(controller)
end
subject { instance.settings_section? }
+
context "for the ContentBlocksController" do
let(:controller) { Hyrax::ContentBlocksController.new }
+
it { is_expected.to be true }
end
context "for the Admin::GroupsController" do
let(:controller) { Admin::GroupsController.new }
+
it { is_expected.to be false }
end
end
@@ -46,22 +52,27 @@
allow(context).to receive(:controller).and_return(controller)
end
subject { instance.roles_and_permissions_section? }
+
context "for the Hyrax::UsersController" do
let(:controller) { Hyrax::UsersController.new }
+
it { is_expected.to be false }
end
context "for the Hyrax::Admin::UsersController" do
let(:controller) { Hyrax::Admin::UsersController.new }
+
it { is_expected.to be true }
end
context "for the Admin::GroupsController" do
let(:controller) { Admin::GroupsController.new }
+
it { is_expected.to be true }
end
end
describe "#show_configuration?" do
subject { instance.show_configuration? }
+
context "for a regular user" do
before do
allow(instance.view_context).to receive(:can?).and_return(false)
diff --git a/spec/presenters/hyrax/member_presenter_factory_spec.rb b/spec/presenters/hyrax/member_presenter_factory_spec.rb
index 6084cbde64..8c3f64efa3 100644
--- a/spec/presenters/hyrax/member_presenter_factory_spec.rb
+++ b/spec/presenters/hyrax/member_presenter_factory_spec.rb
@@ -8,6 +8,7 @@
describe "file_presenter_class" do
subject { described_class.file_presenter_class }
+
it { is_expected.to eq Hyku::FileSetPresenter }
end
end
diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb
index 28adf2ba43..8375657718 100644
--- a/spec/rails_helper.rb
+++ b/spec/rails_helper.rb
@@ -111,7 +111,7 @@
DatabaseCleaner.clean_with(:truncation)
end
- config.before(:each) do |example|
+ config.before do |example|
# Pass `:clean' to destroy objects in fedora/solr and start from scratch
ActiveFedora::Cleaner.clean! if example.metadata[:clean]
diff --git a/spec/requests/home_spec.rb b/spec/requests/home_spec.rb
index 98281ff0c3..d13a3ab725 100644
--- a/spec/requests/home_spec.rb
+++ b/spec/requests/home_spec.rb
@@ -5,7 +5,7 @@
before { host! 'localhost' }
it 'redirects to the accounts landing page' do
get root_path
- expect(response).to have_http_status(200)
+ expect(response).to have_http_status(:ok)
end
end
@@ -22,7 +22,7 @@
describe 'GET /' do
it 'fields the request' do
get root_path
- expect(response).to have_http_status(200)
+ expect(response).to have_http_status(:ok)
end
end
end
diff --git a/spec/routing/proprietor/accounts_routing_spec.rb b/spec/routing/proprietor/accounts_routing_spec.rb
index c66ca36965..49823748a7 100644
--- a/spec/routing/proprietor/accounts_routing_spec.rb
+++ b/spec/routing/proprietor/accounts_routing_spec.rb
@@ -1,6 +1,7 @@
RSpec.describe Proprietor::AccountsController, type: :routing do
let(:admin_host) { Account.admin_host }
let(:admin_host_url) { "http://#{admin_host}" }
+
describe "routing" do
it "routes to #index" do
expect(get: "#{admin_host_url}/proprietor/accounts").to route_to("proprietor/accounts#index", host: admin_host)
diff --git a/spec/services/create_account_spec.rb b/spec/services/create_account_spec.rb
index 51c0a18493..5a82819ace 100644
--- a/spec/services/create_account_spec.rb
+++ b/spec/services/create_account_spec.rb
@@ -1,5 +1,6 @@
RSpec.describe CreateAccount do
let(:account) { FactoryGirl.build(:sign_up_account) }
+
subject { described_class.new(account) }
describe '#create_tenant' do
@@ -30,6 +31,7 @@
let(:resource2) { Account.new(name: 'example') }
let(:account1) { CreateAccount.new(resource1) }
let(:account2) { CreateAccount.new(resource2) }
+
before do
allow(account1).to receive(:create_external_resources).and_return true
allow(account2).to receive(:create_external_resources).and_return true
diff --git a/spec/services/iiif_authorization_service_spec.rb b/spec/services/iiif_authorization_service_spec.rb
index 8f6ee66d3a..8920eddc0f 100644
--- a/spec/services/iiif_authorization_service_spec.rb
+++ b/spec/services/iiif_authorization_service_spec.rb
@@ -18,6 +18,7 @@
context "show" do
subject { service.can?(:show, image) }
+
it { is_expected.to be true }
end
end
@@ -32,6 +33,7 @@
context "show" do
subject { service.can?(:show, image) }
+
it { is_expected.to be false }
end
end
diff --git a/spec/services/solr_config_uploader_spec.rb b/spec/services/solr_config_uploader_spec.rb
index 0a52cc41de..b49d4ae41d 100644
--- a/spec/services/solr_config_uploader_spec.rb
+++ b/spec/services/solr_config_uploader_spec.rb
@@ -1,5 +1,6 @@
RSpec.describe SolrConfigUploader do
let(:config_dir) { Rails.root.join('solr', 'config') }
+
subject { described_class.new('solr_config_uploader_test') }
describe 'round-tripping data to zookeeper' do
diff --git a/spec/support/account_site_setup.rb b/spec/support/account_site_setup.rb
index 69d6c34514..c307195c59 100644
--- a/spec/support/account_site_setup.rb
+++ b/spec/support/account_site_setup.rb
@@ -1,5 +1,5 @@
RSpec.configure do |config|
- config.before(:each) do
+ config.before do
account = FactoryGirl.create(:sign_up_account)
Site.update(account: account)
end
diff --git a/spec/tasks/rake_spec.rb b/spec/tasks/rake_spec.rb
index 7609743e1b..00dd60a6a7 100644
--- a/spec/tasks/rake_spec.rb
+++ b/spec/tasks/rake_spec.rb
@@ -54,6 +54,7 @@
end
let(:accounts) { Account.where(name: ['first', 'second']) }
let(:task) { double('task') }
+
it 'requires at least one argument' do
expect { run_task('tenantize:task') }.to raise_error(ArgumentError, /rake task name is required/)
end
@@ -72,6 +73,7 @@
context 'when run against specified tenants' do
let(:accounts) { [account] }
let(:account) { Account.find_by(name: 'first') }
+
before do
ENV['tenants'] = "garbage_value #{account.cname} other_garbage_value"
end
diff --git a/spec/values/universal_viewer_spec.rb b/spec/values/universal_viewer_spec.rb
index ace4c2d731..f8ac6bca8d 100644
--- a/spec/values/universal_viewer_spec.rb
+++ b/spec/values/universal_viewer_spec.rb
@@ -1,5 +1,6 @@
RSpec.describe UniversalViewer do
subject { described_class.instance }
+
describe "#viewer_version" do
it "calculates it from existing directories" do
expect(subject.viewer_version).to eq "2.0.1"
diff --git a/spec/views/_user_util_links.html.erb_spec.rb b/spec/views/_user_util_links.html.erb_spec.rb
index 89fed10bef..e5ca9b2462 100644
--- a/spec/views/_user_util_links.html.erb_spec.rb
+++ b/spec/views/_user_util_links.html.erb_spec.rb
@@ -1,5 +1,6 @@
RSpec.describe '/_user_util_links.html.erb', type: :view do
let(:user) { create(:user) }
+
before do
allow(view).to receive(:user_signed_in?).and_return(true)
allow(view).to receive(:current_user).and_return(user)
diff --git a/spec/views/proprietor/accounts/edit.html.erb_spec.rb b/spec/views/proprietor/accounts/edit.html.erb_spec.rb
index ccf1630d4f..89855683a7 100644
--- a/spec/views/proprietor/accounts/edit.html.erb_spec.rb
+++ b/spec/views/proprietor/accounts/edit.html.erb_spec.rb
@@ -6,6 +6,7 @@
context "with connections" do
let(:account) { create(:account) }
+
it "renders the edit account form" do
assert_select "form[action=?][method=?]", proprietor_account_path(account), "post" do
assert_select "input#account_tenant[name=?]", "account[tenant]"
@@ -16,6 +17,7 @@
context "without connections" do
let(:account) { create(:account, solr_endpoint: nil, fcrepo_endpoint: nil) }
+
it "renders the edit account form" do
assert_select "form[action=?][method=?]", proprietor_account_path(account), "post" do
assert_select "input#account_tenant[name=?]", "account[tenant]"