From aeb990419705b81e280b547c8248f78068fa2f3b Mon Sep 17 00:00:00 2001 From: nicholas Date: Tue, 9 Oct 2018 10:51:25 -0500 Subject: [PATCH 1/4] update FactoryGirl to FactoryBot --- Gemfile | 2 +- Gemfile.lock | 10 ++-- .../account_sign_up_controller_spec.rb | 2 +- .../admin/accounts_controller_spec.rb | 4 +- .../admin/group_users_controller_spec.rb | 4 +- .../admin/groups_controller_spec.rb | 6 +- .../admin/users_controller_spec.rb | 4 +- .../hyrax/generic_works_controller_spec.rb | 6 +- spec/controllers/labels_controller_spec.rb | 4 +- .../proprietor/accounts_controller_spec.rb | 12 ++-- spec/controllers/roles_controller_spec.rb | 2 +- spec/factories/accounts.rb | 2 +- spec/factories/collection_types.rb | 58 +++++++++---------- spec/factories/collections.rb | 10 ++-- spec/factories/file_sets.rb | 4 +- spec/factories/generic_works.rb | 12 ++-- spec/factories/group.rb | 2 +- spec/factories/roles.rb | 2 +- spec/factories/users.rb | 6 +- spec/features/accounts_spec.rb | 4 +- spec/features/admin_dashboard_spec.rb | 4 +- spec/features/create_tenant_spec.rb | 2 +- spec/features/labels_spec.rb | 2 +- spec/features/proprietor_spec.rb | 2 +- spec/features/roles_spec.rb | 4 +- spec/forms/hyrax/generic_work_form_spec.rb | 2 +- spec/forms/hyrax/image_form_spec.rb | 2 +- spec/jobs/cleanup_account_job_spec.rb | 2 +- spec/jobs/create_account_inline_job_spec.rb | 2 +- .../jobs/create_default_admin_set_job_spec.rb | 2 +- spec/jobs/create_fcrepo_endpoint_job_spec.rb | 2 +- spec/jobs/create_redis_namespace_job_spec.rb | 2 +- spec/jobs/create_solr_collection_job_spec.rb | 2 +- spec/lib/active_job_tenant_spec.rb | 2 +- spec/lib/importer/mods_importer_spec.rb | 2 +- spec/middleware/account_elevator_spec.rb | 2 +- spec/models/ability_spec.rb | 6 +- spec/models/account_spec.rb | 6 +- spec/models/hyku/group_spec.rb | 24 ++++---- spec/models/site_spec.rb | 6 +- spec/models/user_spec.rb | 12 ++-- .../hyku/file_set_presenter_spec.rb | 2 +- ...nifest_enabled_work_show_presenter_spec.rb | 2 +- spec/rails_helper.rb | 2 +- spec/services/create_account_spec.rb | 2 +- spec/support/account_site_setup.rb | 2 +- spec/support/multitenancy_metadata.rb | 2 +- spec/tasks/rake_spec.rb | 4 +- spec/views/admin/groups/edit.html.erb_spec.rb | 2 +- .../views/admin/groups/index.html.erb_spec.rb | 4 +- spec/views/admin/groups/new.html.erb_spec.rb | 2 +- .../admin/groups/remove.html.erb_spec.rb | 2 +- .../views/admin/groups/users.html.erb_spec.rb | 6 +- .../hyrax/admin/users/index.html.erb_spec.rb | 6 +- .../base/_form_rendering.html.erb_spec.rb | 2 +- .../accounts/index.html.erb_spec.rb | 4 +- .../proprietor/accounts/show.html.erb_spec.rb | 2 +- 57 files changed, 146 insertions(+), 146 deletions(-) diff --git a/Gemfile b/Gemfile index 2cc7e6a51..1a9042b57 100644 --- a/Gemfile +++ b/Gemfile @@ -55,7 +55,7 @@ group :test do gem 'capybara' gem 'chromedriver-helper' gem 'database_cleaner' - gem 'factory_girl_rails' + gem 'factory_bot_rails' # rack-test >= 0.71 does not work with older Capybara versions (< 2.17). See #214 for more details gem 'rack-test', '0.7.0' gem 'rails-controller-testing' diff --git a/Gemfile.lock b/Gemfile.lock index 58a32f433..b445f164a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -244,10 +244,10 @@ GEM erubi (1.7.1) erubis (2.7.0) execjs (2.7.0) - factory_girl (4.8.0) + factory_bot (4.11.1) activesupport (>= 3.0.0) - factory_girl_rails (4.8.0) - factory_girl (~> 4.8.0) + factory_bot_rails (4.11.1) + factory_bot (~> 4.11.1) railties (>= 3.0.0) faraday (0.12.2) multipart-post (>= 1.2, < 3) @@ -917,7 +917,7 @@ DEPENDENCIES devise-guests (~> 0.3) devise-i18n devise_invitable (~> 1.6) - factory_girl_rails + factory_bot_rails fcrepo_wrapper (~> 0.4) flipflop (~> 2.3) honeybadger (~> 3.0) @@ -966,4 +966,4 @@ DEPENDENCIES zk BUNDLED WITH - 1.16.3 + 1.16.6 diff --git a/spec/controllers/account_sign_up_controller_spec.rb b/spec/controllers/account_sign_up_controller_spec.rb index c39ab36e7..c4a21f9b0 100644 --- a/spec/controllers/account_sign_up_controller_spec.rb +++ b/spec/controllers/account_sign_up_controller_spec.rb @@ -83,7 +83,7 @@ end context 'as admin with restricted access' do - let(:user) { FactoryGirl.create(:admin) } + let(:user) { FactoryBot.create(:admin) } before do allow(Settings.multitenancy).to receive(:admin_only_tenant_creation).and_return(true) diff --git a/spec/controllers/admin/accounts_controller_spec.rb b/spec/controllers/admin/accounts_controller_spec.rb index 816ee0c0f..b685e86a8 100644 --- a/spec/controllers/admin/accounts_controller_spec.rb +++ b/spec/controllers/admin/accounts_controller_spec.rb @@ -17,8 +17,8 @@ end context 'as an admin of a site' do - let(:user) { FactoryGirl.create(:user).tap { |u| u.add_role(:admin, Site.instance) } } - let(:account) { FactoryGirl.create(:account) } + let(:user) { FactoryBot.create(:user).tap { |u| u.add_role(:admin, Site.instance) } } + let(:account) { FactoryBot.create(:account) } before do Site.update(account: account) diff --git a/spec/controllers/admin/group_users_controller_spec.rb b/spec/controllers/admin/group_users_controller_spec.rb index 9cec0e300..91345063e 100644 --- a/spec/controllers/admin/group_users_controller_spec.rb +++ b/spec/controllers/admin/group_users_controller_spec.rb @@ -1,5 +1,5 @@ RSpec.describe Admin::GroupUsersController, faketenant: true do - let(:group) { FactoryGirl.create(:group) } + let(:group) { FactoryBot.create(:group) } context 'as an anonymous user' do describe 'GET #index' do @@ -20,7 +20,7 @@ end context 'modifying group membership' do - let(:user) { FactoryGirl.create(:user) } + let(:user) { FactoryBot.create(:user) } describe 'POST #add' do it 'adds a user to a group when it recieves a group ID' do diff --git a/spec/controllers/admin/groups_controller_spec.rb b/spec/controllers/admin/groups_controller_spec.rb index 9c9a2304f..bb02b7313 100644 --- a/spec/controllers/admin/groups_controller_spec.rb +++ b/spec/controllers/admin/groups_controller_spec.rb @@ -26,14 +26,14 @@ describe 'POST #create' do it 'creates a group when it recieves valid attribtes' do expect do - post :create, params: { hyku_group: FactoryGirl.attributes_for(:group) } + post :create, params: { hyku_group: FactoryBot.attributes_for(:group) } end.to change(Hyku::Group, :count).by(1) end end context 'with an existing group' do - let(:group) { FactoryGirl.create(:group) } - let(:new_attributes) { FactoryGirl.attributes_for(:group) } + let(:group) { FactoryBot.create(:group) } + let(:new_attributes) { FactoryBot.attributes_for(:group) } describe 'GET #edit' do subject { get :edit, params: { id: group.id } } diff --git a/spec/controllers/admin/users_controller_spec.rb b/spec/controllers/admin/users_controller_spec.rb index ed3e29fbd..b27db2982 100644 --- a/spec/controllers/admin/users_controller_spec.rb +++ b/spec/controllers/admin/users_controller_spec.rb @@ -1,6 +1,6 @@ RSpec.describe Admin::UsersController, type: :controller do context 'as an anonymous user' do - let(:user) { FactoryGirl.create(:user) } + let(:user) { FactoryBot.create(:user) } describe 'DELETE #destroy' do subject { User.find_by(id: user.id) } @@ -14,7 +14,7 @@ end context 'as an admin user' do - let(:user) { FactoryGirl.create(:user) } + let(:user) { FactoryBot.create(:user) } before { sign_in create(:admin) } diff --git a/spec/controllers/hyrax/generic_works_controller_spec.rb b/spec/controllers/hyrax/generic_works_controller_spec.rb index b30c66bcc..6a411a2aa 100644 --- a/spec/controllers/hyrax/generic_works_controller_spec.rb +++ b/spec/controllers/hyrax/generic_works_controller_spec.rb @@ -1,6 +1,6 @@ RSpec.describe Hyrax::GenericWorksController do - let(:user) { FactoryGirl.create(:user) } - let(:work) { FactoryGirl.create(:work_with_one_file, user: user) } + let(:user) { FactoryBot.create(:user) } + let(:work) { FactoryBot.create(:work_with_one_file, user: user) } let(:file_set) { work.ordered_members.to_a.first } before do @@ -25,7 +25,7 @@ end describe "#presenter" do - let(:solr_document) { SolrDocument.new(FactoryGirl.create(:generic_work).to_solr) } + let(:solr_document) { SolrDocument.new(FactoryBot.create(:generic_work).to_solr) } before do allow(controller).to receive(:curation_concern_from_search_results).and_return(solr_document) diff --git a/spec/controllers/labels_controller_spec.rb b/spec/controllers/labels_controller_spec.rb index 18e44b5ec..0c178ce22 100644 --- a/spec/controllers/labels_controller_spec.rb +++ b/spec/controllers/labels_controller_spec.rb @@ -34,7 +34,7 @@ end context 'with an unprivileged user' do - let(:user) { FactoryGirl.create(:user) } + let(:user) { FactoryBot.create(:user) } describe "GET #edit" do it "denies the request" do @@ -52,7 +52,7 @@ end context 'with an administrator' do - let(:user) { FactoryGirl.create(:admin) } + let(:user) { FactoryBot.create(:admin) } describe "GET #edit" do it "assigns the requested site as @site" do diff --git a/spec/controllers/proprietor/accounts_controller_spec.rb b/spec/controllers/proprietor/accounts_controller_spec.rb index d73d7236e..2b37ef2c4 100644 --- a/spec/controllers/proprietor/accounts_controller_spec.rb +++ b/spec/controllers/proprietor/accounts_controller_spec.rb @@ -42,8 +42,8 @@ end context 'as an admin of a site' do - let(:user) { FactoryGirl.create(:user).tap { |u| u.add_role(:admin, Site.instance) } } - let(:account) { FactoryGirl.create(:account) } + let(:user) { FactoryBot.create(:user).tap { |u| u.add_role(:admin, Site.instance) } } + let(:account) { FactoryBot.create(:account) } before do Site.update(account: account) @@ -117,7 +117,7 @@ end context 'editing another tenants account' do - let(:another_account) { FactoryGirl.create(:account) } + let(:another_account) { FactoryBot.create(:account) } describe "GET #show" do it "denies the request" do @@ -143,8 +143,8 @@ end context 'as a superadmin' do - let(:user) { FactoryGirl.create(:superadmin) } - let!(:account) { FactoryGirl.create(:account) } + let(:user) { FactoryBot.create(:superadmin) } + let!(:account) { FactoryBot.create(:account) } describe "GET #index" do it "assigns all accounts as @accounts" do @@ -177,7 +177,7 @@ end describe 'account dependency switching' do - let(:account) { FactoryGirl.create(:account) } + let(:account) { FactoryBot.create(:account) } before do Site.update(account: account) diff --git a/spec/controllers/roles_controller_spec.rb b/spec/controllers/roles_controller_spec.rb index bee42c3cf..0365fbd9c 100644 --- a/spec/controllers/roles_controller_spec.rb +++ b/spec/controllers/roles_controller_spec.rb @@ -26,7 +26,7 @@ end context 'with an administrator' do - let(:user) { FactoryGirl.create(:admin) } + let(:user) { FactoryBot.create(:admin) } describe "GET #index" do before do diff --git a/spec/factories/accounts.rb b/spec/factories/accounts.rb index 680a26d81..70b8f076d 100644 --- a/spec/factories/accounts.rb +++ b/spec/factories/accounts.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do factory :solr_endpoint do options { Hash.new(url: 'http://fakesolr.localhost:9876/solr/', collection: 'fakecore') } end diff --git a/spec/factories/collection_types.rb b/spec/factories/collection_types.rb index 4c273208b..f07ed2534 100644 --- a/spec/factories/collection_types.rb +++ b/spec/factories/collection_types.rb @@ -1,24 +1,24 @@ -FactoryGirl.define do +FactoryBot.define do factory :collection_type, class: Hyrax::CollectionType do sequence(:title) { |n| "Collection Type #{n}" } sequence(:machine_id) { |n| "title_#{n}" } - description 'Collection type with all options' - nestable true - discoverable true - sharable true - brandable true - share_applies_to_new_works true - allow_multiple_membership true - require_membership false - assigns_workflow false - assigns_visibility false + description { 'Collection type with all options' } + nestable { true } + discoverable { true } + sharable { true } + brandable { true } + share_applies_to_new_works { true } + allow_multiple_membership { true } + require_membership { false } + assigns_workflow { false } + assigns_visibility { false } transient do - creator_user nil - creator_group nil - manager_user nil - manager_group nil + creator_user { nil } + creator_group { nil } + manager_user { nil } + manager_group { nil } end after(:create) do |collection_type, evaluator| @@ -56,50 +56,50 @@ end trait :nestable do - nestable true + nestable { true } end trait :not_nestable do - nestable false + nestable { false } end trait :discoverable do - discoverable true + discoverable { true } end trait :not_discoverable do - discoverable false + discoverable { false } end trait :brandable do - brandable true + brandable { true } end trait :not_brandable do - brandable false + brandable { false } end trait :sharable do - sharable true - share_applies_to_new_works true + sharable { true } + share_applies_to_new_works { true } end trait :sharable_no_work_permissions do - sharable true - share_applies_to_new_works false + sharable { true } + share_applies_to_new_works { false } end trait :not_sharable do - sharable false - share_applies_to_new_works false + sharable { false } + share_applies_to_new_works { false } end trait :allow_multiple_membership do - allow_multiple_membership true + allow_multiple_membership { true } end trait :not_allow_multiple_membership do - allow_multiple_membership false + allow_multiple_membership { false } end end diff --git a/spec/factories/collections.rb b/spec/factories/collections.rb index 7b5a7f488..e6e68378c 100644 --- a/spec/factories/collections.rb +++ b/spec/factories/collections.rb @@ -1,13 +1,13 @@ -FactoryGirl.define do +FactoryBot.define do # TODO: swap this out for hyrax's collection_lw factory :collection do transient do user { create(:user) } # allow defaulting to default user collection - collection_type_settings nil - with_permission_template false - create_access false - with_nesting_attributes nil + collection_type_settings { nil } + with_permission_template { false } + create_access { false } + with_nesting_attributes { nil } end sequence(:title) { |n| ["Collection Title #{n}"] } diff --git a/spec/factories/file_sets.rb b/spec/factories/file_sets.rb index af68486a1..aaabb46f6 100644 --- a/spec/factories/file_sets.rb +++ b/spec/factories/file_sets.rb @@ -1,7 +1,7 @@ -FactoryGirl.define do +FactoryBot.define do factory :file_set do transient do - user { FactoryGirl.create(:user) } + user { FactoryBot.create(:user) } end after(:build) do |fs, evaluator| fs.apply_depositor_metadata evaluator.user diff --git a/spec/factories/generic_works.rb b/spec/factories/generic_works.rb index 171022fd2..fc5e1ecf7 100644 --- a/spec/factories/generic_works.rb +++ b/spec/factories/generic_works.rb @@ -1,19 +1,19 @@ -FactoryGirl.define do +FactoryBot.define do factory :generic_work, aliases: [:work] do transient do - user { FactoryGirl.create(:user) } + user { FactoryBot.create(:user) } end - title ["Test title"] + title { ["Test title"] } - identifier %w[ + identifier { %w[ ISBN:978-83-7659-303-6 978-3-540-49698-4 9790879392788 doi:10.1038/nphys1170 3-921099-34-X 3-540-49698-x 0-19-852663-6 - ] + ] } factory :work_with_one_file do before(:create) do |work, evaluator| - work.ordered_members << FactoryGirl.create(:file_set, + work.ordered_members << FactoryBot.create(:file_set, user: evaluator.user, title: ['A Contained Generic File']) end diff --git a/spec/factories/group.rb b/spec/factories/group.rb index 98fd99fc5..189e33e1a 100644 --- a/spec/factories/group.rb +++ b/spec/factories/group.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do factory :group, class: Hyku::Group do sequence(:name) { |_n| "group-#{srand}" } sequence(:description) { |_n| "Somthing about group-#{srand}" } diff --git a/spec/factories/roles.rb b/spec/factories/roles.rb index df78b38ef..5e9178e9b 100644 --- a/spec/factories/roles.rb +++ b/spec/factories/roles.rb @@ -1,4 +1,4 @@ -FactoryGirl.define do +FactoryBot.define do factory :role do end end diff --git a/spec/factories/users.rb b/spec/factories/users.rb index 1d558b121..5afabe863 100644 --- a/spec/factories/users.rb +++ b/spec/factories/users.rb @@ -1,8 +1,8 @@ -FactoryGirl.define do +FactoryBot.define do factory :base_user, class: User do sequence(:email) { |_n| "email-#{srand}@test.com" } - password 'a password' - password_confirmation 'a password' + password { 'a password' } + password_confirmation { 'a password' } factory :user do after(:create) { |user| user.remove_role(:admin) } diff --git a/spec/features/accounts_spec.rb b/spec/features/accounts_spec.rb index 0e539aaf1..d679905aa 100644 --- a/spec/features/accounts_spec.rb +++ b/spec/features/accounts_spec.rb @@ -1,8 +1,8 @@ RSpec.describe 'Accounts administration', multitenant: true do context 'as an superadmin' do - let(:user) { FactoryGirl.create(:superadmin) } + let(:user) { FactoryBot.create(:superadmin) } let(:account) do - FactoryGirl.create(:account, solr_endpoint_attributes: { url: 'http://localhost:8080/solr' }, + FactoryBot.create(:account, solr_endpoint_attributes: { url: 'http://localhost:8080/solr' }, fcrepo_endpoint_attributes: { url: 'http://localhost:8080/fcrepo' }) end diff --git a/spec/features/admin_dashboard_spec.rb b/spec/features/admin_dashboard_spec.rb index 1f4182f4a..27d5e3f46 100644 --- a/spec/features/admin_dashboard_spec.rb +++ b/spec/features/admin_dashboard_spec.rb @@ -1,7 +1,7 @@ RSpec.describe 'Admin Dashboard', type: :feature do context 'as an administrator' do - let(:user) { FactoryGirl.create(:admin) } - let(:group) { FactoryGirl.create(:group) } + let(:user) { FactoryBot.create(:admin) } + let(:group) { FactoryBot.create(:group) } before do login_as(user, scope: :user) diff --git a/spec/features/create_tenant_spec.rb b/spec/features/create_tenant_spec.rb index 4b1af5c32..c9c34389b 100644 --- a/spec/features/create_tenant_spec.rb +++ b/spec/features/create_tenant_spec.rb @@ -3,7 +3,7 @@ RSpec.describe 'creating a new tenant', multitenant: true do include ActiveJob::TestHelper - let(:user) { FactoryGirl.create(:superadmin) } + let(:user) { FactoryBot.create(:superadmin) } before do login_as(user, scope: :user) diff --git a/spec/features/labels_spec.rb b/spec/features/labels_spec.rb index a1b24e0cf..3c6f02f38 100644 --- a/spec/features/labels_spec.rb +++ b/spec/features/labels_spec.rb @@ -1,6 +1,6 @@ RSpec.describe 'Site labels configuration' do context 'as an administrator' do - let(:user) { FactoryGirl.create(:admin) } + let(:user) { FactoryBot.create(:admin) } before do login_as(user, scope: :user) diff --git a/spec/features/proprietor_spec.rb b/spec/features/proprietor_spec.rb index 6030334f4..4ca5499ac 100644 --- a/spec/features/proprietor_spec.rb +++ b/spec/features/proprietor_spec.rb @@ -1,6 +1,6 @@ RSpec.describe 'Proprietor administration', multitenant: true do context 'as an superadmin' do - let(:user) { FactoryGirl.create(:superadmin) } + let(:user) { FactoryBot.create(:superadmin) } before do login_as(user, scope: :user) diff --git a/spec/features/roles_spec.rb b/spec/features/roles_spec.rb index b5a53fa80..1a571f307 100644 --- a/spec/features/roles_spec.rb +++ b/spec/features/roles_spec.rb @@ -1,7 +1,7 @@ RSpec.describe 'Site Roles' do context 'as an administrator' do - let!(:user) { FactoryGirl.create(:admin) } - let!(:another_user) { FactoryGirl.create(:user) } + let!(:user) { FactoryBot.create(:admin) } + let!(:another_user) { FactoryBot.create(:user) } before do login_as(user, scope: :user) diff --git a/spec/forms/hyrax/generic_work_form_spec.rb b/spec/forms/hyrax/generic_work_form_spec.rb index 949a9be74..321908c5b 100644 --- a/spec/forms/hyrax/generic_work_form_spec.rb +++ b/spec/forms/hyrax/generic_work_form_spec.rb @@ -3,7 +3,7 @@ RSpec.describe Hyrax::GenericWorkForm do let(:work) { GenericWork.new } let(:form) { described_class.new(work, nil, nil) } - let(:file_set) { FactoryGirl.create(:file_set) } + let(:file_set) { FactoryBot.create(:file_set) } describe ".model_attributes" do subject { described_class.model_attributes(params) } diff --git a/spec/forms/hyrax/image_form_spec.rb b/spec/forms/hyrax/image_form_spec.rb index 700bbcca6..011db9a13 100644 --- a/spec/forms/hyrax/image_form_spec.rb +++ b/spec/forms/hyrax/image_form_spec.rb @@ -4,7 +4,7 @@ RSpec.describe Hyrax::ImageForm do let(:work) { Image.new } let(:form) { described_class.new(work, nil, nil) } - let(:file_set) { FactoryGirl.create(:file_set) } + let(:file_set) { FactoryBot.create(:file_set) } describe ".model_attributes" do subject { described_class.model_attributes(params) } diff --git a/spec/jobs/cleanup_account_job_spec.rb b/spec/jobs/cleanup_account_job_spec.rb index c87f186da..1d6b21d7a 100644 --- a/spec/jobs/cleanup_account_job_spec.rb +++ b/spec/jobs/cleanup_account_job_spec.rb @@ -1,6 +1,6 @@ RSpec.describe CleanupAccountJob do let!(:account) do - FactoryGirl.create(:account, solr_endpoint_attributes: { collection: 'x' }, + FactoryBot.create(:account, solr_endpoint_attributes: { collection: 'x' }, fcrepo_endpoint_attributes: { base_path: '/x' }, redis_endpoint_attributes: { namespace: 'x' }) end diff --git a/spec/jobs/create_account_inline_job_spec.rb b/spec/jobs/create_account_inline_job_spec.rb index 98f69807d..33ecd4ce1 100644 --- a/spec/jobs/create_account_inline_job_spec.rb +++ b/spec/jobs/create_account_inline_job_spec.rb @@ -1,5 +1,5 @@ RSpec.describe CreateAccountInlineJob do - let(:account) { FactoryGirl.create(:account) } + let(:account) { FactoryBot.create(:account) } describe '#perform' do it 'calls other jobs synchronously' do diff --git a/spec/jobs/create_default_admin_set_job_spec.rb b/spec/jobs/create_default_admin_set_job_spec.rb index e468e71c0..75845eeef 100644 --- a/spec/jobs/create_default_admin_set_job_spec.rb +++ b/spec/jobs/create_default_admin_set_job_spec.rb @@ -1,5 +1,5 @@ RSpec.describe CreateDefaultAdminSetJob do - let!(:account) { FactoryGirl.create(:account) } + let!(:account) { FactoryBot.create(:account) } describe '#perform' do it 'creates a new admin set for an account' do diff --git a/spec/jobs/create_fcrepo_endpoint_job_spec.rb b/spec/jobs/create_fcrepo_endpoint_job_spec.rb index 04c1152d4..afef683e7 100644 --- a/spec/jobs/create_fcrepo_endpoint_job_spec.rb +++ b/spec/jobs/create_fcrepo_endpoint_job_spec.rb @@ -1,5 +1,5 @@ RSpec.describe CreateFcrepoEndpointJob do - let(:account) { FactoryGirl.create(:account) } + let(:account) { FactoryBot.create(:account) } it 'sets the base path configuration for fcrepo' do described_class.perform_now(account) diff --git a/spec/jobs/create_redis_namespace_job_spec.rb b/spec/jobs/create_redis_namespace_job_spec.rb index ef00da74c..41a3fcdbc 100644 --- a/spec/jobs/create_redis_namespace_job_spec.rb +++ b/spec/jobs/create_redis_namespace_job_spec.rb @@ -1,5 +1,5 @@ RSpec.describe CreateRedisNamespaceJob do - let(:account) { FactoryGirl.create(:account) } + let(:account) { FactoryBot.create(:account) } describe '#perform' do it 'creates a new namespace for an account' do diff --git a/spec/jobs/create_solr_collection_job_spec.rb b/spec/jobs/create_solr_collection_job_spec.rb index 8a506c117..bae69aa94 100644 --- a/spec/jobs/create_solr_collection_job_spec.rb +++ b/spec/jobs/create_solr_collection_job_spec.rb @@ -1,5 +1,5 @@ RSpec.describe CreateSolrCollectionJob do - let(:account) { FactoryGirl.create(:account) } + let(:account) { FactoryBot.create(:account) } let(:client) { double } before do diff --git a/spec/lib/active_job_tenant_spec.rb b/spec/lib/active_job_tenant_spec.rb index e00e19395..cdbf861b7 100644 --- a/spec/lib/active_job_tenant_spec.rb +++ b/spec/lib/active_job_tenant_spec.rb @@ -7,7 +7,7 @@ end end - let(:account) { FactoryGirl.build(:account) } + let(:account) { FactoryBot.build(:account) } subject do Class.new(ActiveJob::Base) do diff --git a/spec/lib/importer/mods_importer_spec.rb b/spec/lib/importer/mods_importer_spec.rb index 0be5869f1..9265265ca 100644 --- a/spec/lib/importer/mods_importer_spec.rb +++ b/spec/lib/importer/mods_importer_spec.rb @@ -60,7 +60,7 @@ end context 'when the collection already exists' do - let!(:existing) { FactoryGirl.create(:collection, id: 'kx532cb7981', title: ['Test Collection']) } + let!(:existing) { FactoryBot.create(:collection, id: 'kx532cb7981', title: ['Test Collection']) } it 'adds metadata to existing collection' do coll = nil diff --git a/spec/middleware/account_elevator_spec.rb b/spec/middleware/account_elevator_spec.rb index eb78472d1..0ddb6d8fc 100644 --- a/spec/middleware/account_elevator_spec.rb +++ b/spec/middleware/account_elevator_spec.rb @@ -3,7 +3,7 @@ let(:request) { double(host: 'example.com') } let(:bad_request) { double(host: 'new.example.com') } - let!(:account) { FactoryGirl.create(:account, cname: 'example.com') } + let!(:account) { FactoryBot.create(:account, cname: 'example.com') } describe '#parse_tenant_name' do it 'retrieves the tenant name for the account' do diff --git a/spec/models/ability_spec.rb b/spec/models/ability_spec.rb index ad28ecfa3..fb776e7b6 100644 --- a/spec/models/ability_spec.rb +++ b/spec/models/ability_spec.rb @@ -12,13 +12,13 @@ end describe 'an ordinary user' do - let(:user) { FactoryGirl.create(:user) } + let(:user) { FactoryBot.create(:user) } it { is_expected.not_to be_able_to(:manage, :all) } end describe 'an administrative user' do - let(:user) { FactoryGirl.create(:admin) } + let(:user) { FactoryBot.create(:admin) } it { is_expected.not_to be_able_to(:manage, :all) } it { is_expected.not_to be_able_to(:manage, Account) } @@ -34,7 +34,7 @@ end describe 'a superadmin user' do - let(:user) { FactoryGirl.create(:superadmin) } + let(:user) { FactoryBot.create(:superadmin) } it { is_expected.to be_able_to(:manage, :all) } end diff --git a/spec/models/account_spec.rb b/spec/models/account_spec.rb index 57531f3b1..d173fae5f 100644 --- a/spec/models/account_spec.rb +++ b/spec/models/account_spec.rb @@ -168,7 +168,7 @@ end describe '#save' do - subject { FactoryGirl.create(:sign_up_account) } + subject { FactoryBot.create(:sign_up_account) } it 'canonicalizes the account cname' do subject.update cname: 'example.com.' @@ -255,7 +255,7 @@ end describe '#admin_emails' do - let!(:account) { FactoryGirl.create(:account, tenant: "mytenant") } + let!(:account) { FactoryBot.create(:account, tenant: "mytenant") } before do Site.update(account: account) @@ -268,7 +268,7 @@ end describe '#admin_emails=' do - let!(:account) { FactoryGirl.create(:account, tenant: "mytenant") } + let!(:account) { FactoryBot.create(:account, tenant: "mytenant") } before do Site.update(account: account) diff --git a/spec/models/hyku/group_spec.rb b/spec/models/hyku/group_spec.rb index 0a55b5567..6b2a388bc 100644 --- a/spec/models/hyku/group_spec.rb +++ b/spec/models/hyku/group_spec.rb @@ -19,8 +19,8 @@ module Hyku context '.search' do before(:context) do - FactoryGirl.create(:group, name: 'IMPORTANT-GROUP-NAME') - FactoryGirl.create(:group, description: 'IMPORTANT-GROUP-DESCRIPTION') + FactoryBot.create(:group, name: 'IMPORTANT-GROUP-NAME') + FactoryBot.create(:group, description: 'IMPORTANT-GROUP-DESCRIPTION') end after(:context) do @@ -45,10 +45,10 @@ module Hyku end context '#search_members' do - subject { FactoryGirl.create(:group) } + subject { FactoryBot.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') } + let(:known_user_name) { FactoryBot.create(:user, display_name: 'Tom Cramer') } + let(:known_user_email) { FactoryBot.create(:user, email: 'tom@project-hydra.com') } before { subject.add_members_by_id([known_user_name.id, known_user_email.id]) } @@ -70,9 +70,9 @@ module Hyku end describe '#add_members_by_id' do - subject { FactoryGirl.create(:group) } + subject { FactoryBot.create(:group) } - let(:user) { FactoryGirl.create(:user) } + let(:user) { FactoryBot.create(:user) } before { subject.add_members_by_id(user.id) } @@ -86,10 +86,10 @@ module Hyku end describe '#remove_members_by_id' do - subject { FactoryGirl.create(:group) } + subject { FactoryBot.create(:group) } context 'single user id' do - let(:user) { FactoryGirl.create(:user) } + let(:user) { FactoryBot.create(:user) } before { subject.add_members_by_id(user.id) } @@ -101,7 +101,7 @@ module Hyku end context 'collection of user ids' do - let(:user_list) { FactoryGirl.create_list(:user, 3) } + let(:user_list) { FactoryBot.create_list(:user, 3) } let(:user_ids) { user_list.collect(&:id) } before { subject.add_members_by_id(user_ids) } @@ -115,9 +115,9 @@ module Hyku end context '#number_of_users' do - subject { FactoryGirl.create(:group) } + subject { FactoryBot.create(:group) } - let(:user) { FactoryGirl.create(:user) } + let(:user) { FactoryBot.create(:user) } it 'starts out with 0 users' do expect(subject.number_of_users).to eq(0) diff --git a/spec/models/site_spec.rb b/spec/models/site_spec.rb index 51fa4c057..13a1f0f0f 100644 --- a/spec/models/site_spec.rb +++ b/spec/models/site_spec.rb @@ -1,7 +1,7 @@ RSpec.describe Site, type: :model do - let(:admin1) { FactoryGirl.create(:user, email: 'bob@was_here.net') } - let(:admin2) { FactoryGirl.create(:user, email: 'jane@was_here.net') } - let(:admin3) { FactoryGirl.create(:user, email: 'i@was_here.net') } + let(:admin1) { FactoryBot.create(:user, email: 'bob@was_here.net') } + let(:admin2) { FactoryBot.create(:user, email: 'jane@was_here.net') } + let(:admin3) { FactoryBot.create(:user, email: 'i@was_here.net') } describe ".instance" do context "on global tenant" do diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 2a4a2d794..7a2c3c921 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -1,6 +1,6 @@ RSpec.describe User, type: :model do context 'the first created user in global tenant' do - subject { FactoryGirl.create(:base_user) } + subject { FactoryBot.create(:base_user) } before do allow(Account).to receive(:global_tenant?).and_return true @@ -11,7 +11,7 @@ end context 'the first created user on a tenant' do - subject { FactoryGirl.create(:base_user) } + subject { FactoryBot.create(:base_user) } it 'is given the admin role' do expect(subject).to have_role :admin, Site.instance @@ -19,8 +19,8 @@ end context 'a subsequent user' do - let!(:first_user) { FactoryGirl.create(:base_user) } - let!(:next_user) { FactoryGirl.create(:base_user) } + let!(:first_user) { FactoryBot.create(:base_user) } + let!(:next_user) { FactoryBot.create(:base_user) } it 'does not get the admin role' do expect(next_user).not_to have_role :admin @@ -28,7 +28,7 @@ end describe '#site_roles' do - subject { FactoryGirl.create(:admin) } + subject { FactoryBot.create(:admin) } it 'fetches the global roles assigned to the user' do expect(subject.site_roles.pluck(:name)).to match_array ['admin'] @@ -36,7 +36,7 @@ end describe '#site_roles=' do - subject { FactoryGirl.create(:user) } + subject { FactoryBot.create(:user) } it 'assigns global roles to the user' do expect(subject.site_roles.pluck(:name)).to be_empty diff --git a/spec/presenters/hyku/file_set_presenter_spec.rb b/spec/presenters/hyku/file_set_presenter_spec.rb index b731dd35a..48a887608 100644 --- a/spec/presenters/hyku/file_set_presenter_spec.rb +++ b/spec/presenters/hyku/file_set_presenter_spec.rb @@ -1,6 +1,6 @@ require 'iiif_manifest' RSpec.describe Hyku::FileSetPresenter do - let(:file_set) { FactoryGirl.create(:file_set) } + let(:file_set) { FactoryBot.create(:file_set) } let(:solr_document) { SolrDocument.new(file_set.to_solr) } let(:request) { double(base_url: 'http://test.host') } let(:presenter) { described_class.new(solr_document, nil, request) } diff --git a/spec/presenters/hyku/manifest_enabled_work_show_presenter_spec.rb b/spec/presenters/hyku/manifest_enabled_work_show_presenter_spec.rb index cce6f87b0..a3ab29434 100644 --- a/spec/presenters/hyku/manifest_enabled_work_show_presenter_spec.rb +++ b/spec/presenters/hyku/manifest_enabled_work_show_presenter_spec.rb @@ -1,5 +1,5 @@ RSpec.describe Hyku::ManifestEnabledWorkShowPresenter do - let(:work) { FactoryGirl.create(:work_with_one_file) } + let(:work) { FactoryBot.create(:work_with_one_file) } let(:document) { work.to_solr } let(:solr_document) { SolrDocument.new(document) } let(:request) { double(base_url: 'http://test.host', host: 'http://test.host') } diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index c7d622b02..75a82a234 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -99,7 +99,7 @@ config.include Devise::Test::ControllerHelpers, type: :controller config.include Fixtures::FixtureFileUpload - config.include FactoryGirl::Syntax::Methods + config.include FactoryBot::Syntax::Methods config.include ApplicationHelper, type: :view config.include Warden::Test::Helpers, type: :feature diff --git a/spec/services/create_account_spec.rb b/spec/services/create_account_spec.rb index 5a82819ac..575363956 100644 --- a/spec/services/create_account_spec.rb +++ b/spec/services/create_account_spec.rb @@ -1,5 +1,5 @@ RSpec.describe CreateAccount do - let(:account) { FactoryGirl.build(:sign_up_account) } + let(:account) { FactoryBot.build(:sign_up_account) } subject { described_class.new(account) } diff --git a/spec/support/account_site_setup.rb b/spec/support/account_site_setup.rb index c307195c5..d167bd2ac 100644 --- a/spec/support/account_site_setup.rb +++ b/spec/support/account_site_setup.rb @@ -1,6 +1,6 @@ RSpec.configure do |config| config.before do - account = FactoryGirl.create(:sign_up_account) + account = FactoryBot.create(:sign_up_account) Site.update(account: account) end end diff --git a/spec/support/multitenancy_metadata.rb b/spec/support/multitenancy_metadata.rb index 0550505f5..182037953 100644 --- a/spec/support/multitenancy_metadata.rb +++ b/spec/support/multitenancy_metadata.rb @@ -32,7 +32,7 @@ Rails.application.reload_routes! elsif example.metadata[:faketenant] || example.metadata[:type] == :controller example.metadata[:faketenant] = true if example.metadata[:type] == :controller # flag for cleanup later - acct = FactoryGirl.build(:account, tenant: 'FakeTenant', cname: 'tenant1') + acct = FactoryBot.build(:account, tenant: 'FakeTenant', cname: 'tenant1') allow(acct).to receive(:persisted?).and_return true # nevertheless allow(Account).to receive(:from_request).and_return(acct) end diff --git a/spec/tasks/rake_spec.rb b/spec/tasks/rake_spec.rb index 646831fd9..5422f27a1 100644 --- a/spec/tasks/rake_spec.rb +++ b/spec/tasks/rake_spec.rb @@ -19,8 +19,8 @@ end describe "superadmin:grant" do - let!(:user1) { FactoryGirl.create(:user) } - let!(:user2) { FactoryGirl.create(:user) } + let!(:user1) { FactoryBot.create(:user) } + let!(:user2) { FactoryBot.create(:user) } before do user1.remove_role :superadmin diff --git a/spec/views/admin/groups/edit.html.erb_spec.rb b/spec/views/admin/groups/edit.html.erb_spec.rb index 2c268043b..249632392 100644 --- a/spec/views/admin/groups/edit.html.erb_spec.rb +++ b/spec/views/admin/groups/edit.html.erb_spec.rb @@ -1,6 +1,6 @@ RSpec.describe 'admin/groups/edit', type: :view do context 'groups index page' do - let(:group) { FactoryGirl.create(:group) } + let(:group) { FactoryBot.create(:group) } before do allow(controller).to receive(:params).and_return( diff --git a/spec/views/admin/groups/index.html.erb_spec.rb b/spec/views/admin/groups/index.html.erb_spec.rb index 81772aaec..ffe738200 100644 --- a/spec/views/admin/groups/index.html.erb_spec.rb +++ b/spec/views/admin/groups/index.html.erb_spec.rb @@ -1,7 +1,7 @@ RSpec.describe 'admin/groups/index', type: :view do context 'groups index page' do - let(:group_1) { FactoryGirl.create(:group) } - let(:group_2) { FactoryGirl.create(:group) } + let(:group_1) { FactoryBot.create(:group) } + let(:group_2) { FactoryBot.create(:group) } let(:groups) { double('groups') } before do diff --git a/spec/views/admin/groups/new.html.erb_spec.rb b/spec/views/admin/groups/new.html.erb_spec.rb index b587b6f92..f19622af4 100644 --- a/spec/views/admin/groups/new.html.erb_spec.rb +++ b/spec/views/admin/groups/new.html.erb_spec.rb @@ -1,6 +1,6 @@ RSpec.describe 'admin/groups/new', type: :view do context 'groups index page' do - let(:group) { FactoryGirl.build(:group) } + let(:group) { FactoryBot.build(:group) } before do assign(:group, group) diff --git a/spec/views/admin/groups/remove.html.erb_spec.rb b/spec/views/admin/groups/remove.html.erb_spec.rb index b3cd3f2c3..5471d31fa 100644 --- a/spec/views/admin/groups/remove.html.erb_spec.rb +++ b/spec/views/admin/groups/remove.html.erb_spec.rb @@ -1,6 +1,6 @@ RSpec.describe 'admin/groups/remove', type: :view do context 'groups index page' do - let(:group) { FactoryGirl.create(:group) } + let(:group) { FactoryBot.create(:group) } before do allow(controller).to receive(:params).and_return( diff --git a/spec/views/admin/groups/users.html.erb_spec.rb b/spec/views/admin/groups/users.html.erb_spec.rb index c8f281569..e2cba4235 100644 --- a/spec/views/admin/groups/users.html.erb_spec.rb +++ b/spec/views/admin/groups/users.html.erb_spec.rb @@ -1,8 +1,8 @@ RSpec.describe 'admin/groups/users', type: :view do context 'groups index page' do - let(:group) { FactoryGirl.create(:group) } - let(:user_1) { FactoryGirl.create(:user) } - let(:user_2) { FactoryGirl.create(:user) } + let(:group) { FactoryBot.create(:group) } + let(:user_1) { FactoryBot.create(:user) } + let(:user_2) { FactoryBot.create(:user) } let(:users) { double('users') } let(:path_parameters) do { diff --git a/spec/views/hyrax/admin/users/index.html.erb_spec.rb b/spec/views/hyrax/admin/users/index.html.erb_spec.rb index 530de2e4f..4a8c75171 100644 --- a/spec/views/hyrax/admin/users/index.html.erb_spec.rb +++ b/spec/views/hyrax/admin/users/index.html.erb_spec.rb @@ -6,7 +6,7 @@ before do # Create four normal user accounts (1..4).each do |i| - users << FactoryGirl.create(:user, + users << FactoryBot.create(:user, display_name: "user#{i}", email: "email#{i}@example.com", last_sign_in_at: Time.zone.now - 15.minutes, @@ -46,7 +46,7 @@ before do # Create two admin acccounts (5..6).each do |i| - users << FactoryGirl.create(:admin, + users << FactoryBot.create(:admin, display_name: "admin-user#{i}", email: "admin#{i}@example.com", last_sign_in_at: Time.zone.now - 15.minutes, @@ -67,7 +67,7 @@ before do # Create one invited (pending) user (7..7).each do |i| - users << FactoryGirl.create(:invited_user, + users << FactoryBot.create(:invited_user, display_name: "invitee#{i}", email: "invitee#{i}@example.com", last_sign_in_at: Time.zone.now - 15.minutes, diff --git a/spec/views/hyrax/base/_form_rendering.html.erb_spec.rb b/spec/views/hyrax/base/_form_rendering.html.erb_spec.rb index 2dacd4400..818166953 100644 --- a/spec/views/hyrax/base/_form_rendering.html.erb_spec.rb +++ b/spec/views/hyrax/base/_form_rendering.html.erb_spec.rb @@ -1,6 +1,6 @@ RSpec.describe 'hyrax/base/_form_rendering.html.erb', type: :view do let(:ability) { double } - let(:work) { FactoryGirl.create(:work_with_one_file) } + let(:work) { FactoryBot.create(:work_with_one_file) } let(:form) do Hyrax::GenericWorkForm.new(work, ability, controller) end diff --git a/spec/views/proprietor/accounts/index.html.erb_spec.rb b/spec/views/proprietor/accounts/index.html.erb_spec.rb index 7c1a49d5f..106586747 100644 --- a/spec/views/proprietor/accounts/index.html.erb_spec.rb +++ b/spec/views/proprietor/accounts/index.html.erb_spec.rb @@ -1,6 +1,6 @@ RSpec.describe "proprietor/accounts/index", type: :view do - let(:account_a) { FactoryGirl.create(:account) } - let(:account_b) { FactoryGirl.create(:account) } + let(:account_a) { FactoryBot.create(:account) } + let(:account_b) { FactoryBot.create(:account) } before do assign(:accounts, [account_a, account_b]) diff --git a/spec/views/proprietor/accounts/show.html.erb_spec.rb b/spec/views/proprietor/accounts/show.html.erb_spec.rb index fbb5b98d2..b3f60c610 100644 --- a/spec/views/proprietor/accounts/show.html.erb_spec.rb +++ b/spec/views/proprietor/accounts/show.html.erb_spec.rb @@ -1,5 +1,5 @@ RSpec.describe "proprietor/accounts/show", type: :view do - let(:account) { FactoryGirl.create(:account) } + let(:account) { FactoryBot.create(:account) } let(:admin1) { build(:user) } let(:admin2) { build(:user) } From 1b3c5ed012eaa394b899244e7c44a29cd42819f4 Mon Sep 17 00:00:00 2001 From: nicholas Date: Fri, 12 Oct 2018 13:35:48 -0500 Subject: [PATCH 2/4] rubocop fixes --- .../account_sign_up_controller_spec.rb | 6 ++++ .../admin/groups_controller_spec.rb | 1 + .../admin/users_controller_spec.rb | 2 ++ spec/controllers/catalog_controller_spec.rb | 1 + .../hyku/registrations_controller_spec.rb | 3 ++ .../admin/appearances_controller_spec.rb | 1 + .../hyrax/generic_works_controller_spec.rb | 2 ++ spec/factories/generic_works.rb | 11 ++++---- spec/features/accounts_spec.rb | 2 +- spec/features/labels_spec.rb | 2 ++ spec/jobs/cleanup_account_job_spec.rb | 4 +-- spec/jobs/import_work_from_purl_job_spec.rb | 3 +- spec/lib/importer/csv_importer_spec.rb | 4 +-- .../factory/string_literal_processor_spec.rb | 10 +++---- spec/lib/importer/mods_parser_spec.rb | 2 ++ spec/models/account_spec.rb | 8 ++++++ spec/models/nil_site_spec.rb | 4 ++- spec/models/site_spec.rb | 7 +++++ spec/models/solr_endpoint_spec.rb | 1 + spec/models/uploaded_file_spec.rb | 2 ++ spec/models/user_spec.rb | 1 + .../hyku/file_set_presenter_spec.rb | 4 +++ ...nifest_enabled_work_show_presenter_spec.rb | 1 + spec/presenters/hyku/menu_presenter_spec.rb | 19 +++++++++++-- spec/rails_helper.rb | 2 +- spec/requests/home_spec.rb | 2 ++ spec/requests/riiif_spec.rb | 1 + spec/services/create_account_spec.rb | 1 + .../iiif_authorization_service_spec.rb | 2 ++ spec/support/rake.rb | 2 +- spec/tasks/rake_spec.rb | 5 ++++ spec/values/universal_viewer_spec.rb | 1 + spec/views/_user_util_links.html.erb_spec.rb | 1 + .../account_sign_up/new.html.erb_spec.rb | 2 +- .../hyrax/admin/users/index.html.erb_spec.rb | 28 ++++++++++--------- .../proprietor/accounts/new.html.erb_spec.rb | 2 +- .../proprietor/accounts/show.html.erb_spec.rb | 2 ++ spec/views/splash/index.html.erb_spec.rb | 4 +++ 38 files changed, 119 insertions(+), 37 deletions(-) diff --git a/spec/controllers/account_sign_up_controller_spec.rb b/spec/controllers/account_sign_up_controller_spec.rb index c4a21f9b0..c8784299d 100644 --- a/spec/controllers/account_sign_up_controller_spec.rb +++ b/spec/controllers/account_sign_up_controller_spec.rb @@ -20,6 +20,7 @@ before do allow(Settings.multitenancy).to receive(:admin_only_tenant_creation).and_return(false) end + describe "GET #new" do it "assigns a new account as @account" do get :new @@ -68,12 +69,14 @@ before do allow(Settings.multitenancy).to receive(:admin_only_tenant_creation).and_return(true) end + describe "GET #new" do it "redirects to sign in" do get :new expect(response).to redirect_to new_user_session_path end end + describe "POST #create" do it "redirects to sign in" do post :create, params: { account: valid_attributes } @@ -88,6 +91,7 @@ before do allow(Settings.multitenancy).to receive(:admin_only_tenant_creation).and_return(true) end + describe "GET #new" do it "assigns a new account as @account" do get :new @@ -95,10 +99,12 @@ expect(assigns(:account)).to be_a_new(Account) end end + describe "POST #create" do before do allow_any_instance_of(CreateAccount).to receive(:create_external_resources) end + it "creates a new Account" do expect do post :create, params: { account: valid_attributes } diff --git a/spec/controllers/admin/groups_controller_spec.rb b/spec/controllers/admin/groups_controller_spec.rb index bb02b7313..c6139820c 100644 --- a/spec/controllers/admin/groups_controller_spec.rb +++ b/spec/controllers/admin/groups_controller_spec.rb @@ -62,6 +62,7 @@ subject { Hyku::Group.find_by(id: group.id) } before { delete :destroy, params: { id: group.id } } + it { is_expected.to be_nil } end end diff --git a/spec/controllers/admin/users_controller_spec.rb b/spec/controllers/admin/users_controller_spec.rb index b27db2982..312ce051f 100644 --- a/spec/controllers/admin/users_controller_spec.rb +++ b/spec/controllers/admin/users_controller_spec.rb @@ -6,6 +6,7 @@ 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 expect(response).to redirect_to root_path @@ -22,6 +23,7 @@ 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 expect(flash[:notice]).to eq "User \"#{user.email}\" has been successfully deleted." diff --git a/spec/controllers/catalog_controller_spec.rb b/spec/controllers/catalog_controller_spec.rb index 9043a32bd..e107b3a70 100644 --- a/spec/controllers/catalog_controller_spec.rb +++ b/spec/controllers/catalog_controller_spec.rb @@ -7,6 +7,7 @@ sign_in create(:user) allow(controller).to receive(:can?).and_return(true) end + it "is successful" do get :show, params: { id: file_set } expect(response).to be_successful diff --git a/spec/controllers/hyku/registrations_controller_spec.rb b/spec/controllers/hyku/registrations_controller_spec.rb index 430465889..77f9fb592 100644 --- a/spec/controllers/hyku/registrations_controller_spec.rb +++ b/spec/controllers/hyku/registrations_controller_spec.rb @@ -14,6 +14,7 @@ expect(response).to render_template('devise/registrations/new') end end + describe '#create' do it 'processes the form' do post :create, params: { @@ -28,6 +29,7 @@ end end end + context 'with account signup disabled' do let(:account_signup_enabled) { false } @@ -38,6 +40,7 @@ expect(flash[:alert]).to eq 'Account registration is disabled' end end + describe '#create' do it 'redirects with a flash message' do post :create diff --git a/spec/controllers/hyrax/admin/appearances_controller_spec.rb b/spec/controllers/hyrax/admin/appearances_controller_spec.rb index 504c4bfcf..950cb557e 100644 --- a/spec/controllers/hyrax/admin/appearances_controller_spec.rb +++ b/spec/controllers/hyrax/admin/appearances_controller_spec.rb @@ -1,5 +1,6 @@ RSpec.describe Hyrax::Admin::AppearancesController, type: :controller, singletenant: true do before { sign_in user } + routes { Hyrax::Engine.routes } context 'with an unprivileged user' do diff --git a/spec/controllers/hyrax/generic_works_controller_spec.rb b/spec/controllers/hyrax/generic_works_controller_spec.rb index 6a411a2aa..fea3dc98f 100644 --- a/spec/controllers/hyrax/generic_works_controller_spec.rb +++ b/spec/controllers/hyrax/generic_works_controller_spec.rb @@ -8,6 +8,7 @@ fixture_file('images/world.png'), :original_file) end + describe '#manifest' do let(:manifest_factory) { double(to_h: { test: 'manifest' }) } @@ -30,6 +31,7 @@ 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 diff --git a/spec/factories/generic_works.rb b/spec/factories/generic_works.rb index fc5e1ecf7..37fb9949f 100644 --- a/spec/factories/generic_works.rb +++ b/spec/factories/generic_works.rb @@ -7,15 +7,16 @@ title { ["Test title"] } identifier { %w[ - ISBN:978-83-7659-303-6 978-3-540-49698-4 9790879392788 - doi:10.1038/nphys1170 3-921099-34-X 3-540-49698-x 0-19-852663-6 - ] } + ISBN:978-83-7659-303-6 978-3-540-49698-4 9790879392788 + doi:10.1038/nphys1170 3-921099-34-X 3-540-49698-x 0-19-852663-6 + ] + } factory :work_with_one_file do before(:create) do |work, evaluator| work.ordered_members << FactoryBot.create(:file_set, - user: evaluator.user, - title: ['A Contained Generic File']) + user: evaluator.user, + title: ['A Contained Generic File']) end end diff --git a/spec/features/accounts_spec.rb b/spec/features/accounts_spec.rb index d679905aa..cd294b529 100644 --- a/spec/features/accounts_spec.rb +++ b/spec/features/accounts_spec.rb @@ -3,7 +3,7 @@ let(:user) { FactoryBot.create(:superadmin) } let(:account) do FactoryBot.create(:account, solr_endpoint_attributes: { url: 'http://localhost:8080/solr' }, - fcrepo_endpoint_attributes: { url: 'http://localhost:8080/fcrepo' }) + fcrepo_endpoint_attributes: { url: 'http://localhost:8080/fcrepo' }) end before do diff --git a/spec/features/labels_spec.rb b/spec/features/labels_spec.rb index 3c6f02f38..a826ac854 100644 --- a/spec/features/labels_spec.rb +++ b/spec/features/labels_spec.rb @@ -30,6 +30,7 @@ institution_name_full: 'fullname' ) end + it 'updates the institution name in the agreement text' do visit edit_site_labels_path fill_in 'Institution name', with: 'Custom Inst Name' @@ -47,6 +48,7 @@ institution_name: 'name' ) end + it 'updates the full institution name in the agreement text' do visit edit_site_labels_path fill_in 'Full institution name', with: 'Custom Full Inst Name' diff --git a/spec/jobs/cleanup_account_job_spec.rb b/spec/jobs/cleanup_account_job_spec.rb index 1d6b21d7a..8514f3b00 100644 --- a/spec/jobs/cleanup_account_job_spec.rb +++ b/spec/jobs/cleanup_account_job_spec.rb @@ -1,8 +1,8 @@ RSpec.describe CleanupAccountJob do let!(:account) do FactoryBot.create(:account, solr_endpoint_attributes: { collection: 'x' }, - fcrepo_endpoint_attributes: { base_path: '/x' }, - redis_endpoint_attributes: { namespace: 'x' }) + fcrepo_endpoint_attributes: { base_path: '/x' }, + redis_endpoint_attributes: { namespace: 'x' }) end before do diff --git a/spec/jobs/import_work_from_purl_job_spec.rb b/spec/jobs/import_work_from_purl_job_spec.rb index 874d6cece..a21004b8e 100644 --- a/spec/jobs/import_work_from_purl_job_spec.rb +++ b/spec/jobs/import_work_from_purl_job_spec.rb @@ -10,6 +10,7 @@ # Don't call load_workflows until the PermissionTemplate has been created Hyrax::Workflow::WorkflowImporter.load_workflows end + let(:purl_xml) do <<~EOF @@ -140,7 +141,7 @@ bc390xk2647/00007845_005.jp2 -EOF + EOF end it "works" do diff --git a/spec/lib/importer/csv_importer_spec.rb b/spec/lib/importer/csv_importer_spec.rb index a172bbc01..688ca843a 100644 --- a/spec/lib/importer/csv_importer_spec.rb +++ b/spec/lib/importer/csv_importer_spec.rb @@ -6,13 +6,13 @@ context 'when the model is passed' do let(:csv_file) { "#{fixture_path}/csv/gse_metadata.csv" } let(:importer) { described_class.new(csv_file, image_directory, fallback_class) } - let(:fallback_class) { Class.new { def initialize(_x, _y); end } } + let(:fallback_class) { Class.new { def initialize(_argx, _argy); end } } let(:factory) { double(run: true) } # note: 2 rows do not specify type, 17 do it 'creates new works' do expect(fallback_class).to receive(:new) - .with(any_args).and_return(factory).exactly(2).times + .with(any_args).and_return(factory).twice expect(Importer::Factory::ETDFactory).to receive(:new) .with(any_args).and_return(factory).exactly(17).times importer.import_all diff --git a/spec/lib/importer/factory/string_literal_processor_spec.rb b/spec/lib/importer/factory/string_literal_processor_spec.rb index 3b169b89d..4c7c7f9c0 100644 --- a/spec/lib/importer/factory/string_literal_processor_spec.rb +++ b/spec/lib/importer/factory/string_literal_processor_spec.rb @@ -12,8 +12,8 @@ let(:name) { ["Muybridge"] } it do - is_expected.to eq(title: ["Stanford residences"], - contributor: ['Muybridge']) + expect(subject).to eq(title: ["Stanford residences"], + contributor: ['Muybridge']) end end @@ -21,8 +21,8 @@ let(:name) { ["Stanford University", "Archives."] } it do - is_expected.to eq(title: ["Stanford residences"], - contributor: ['Stanford University — Archives.']) + expect(subject).to eq(title: ["Stanford residences"], + contributor: ['Stanford University — Archives.']) end end @@ -31,6 +31,6 @@ { title: ["Stanford residences"] } end - it { is_expected.to eq(title: ["Stanford residences"]) } + it { expect(subject).to eq(title: ["Stanford residences"]) } end end diff --git a/spec/lib/importer/mods_parser_spec.rb b/spec/lib/importer/mods_parser_spec.rb index 72be07886..d52373388 100644 --- a/spec/lib/importer/mods_parser_spec.rb +++ b/spec/lib/importer/mods_parser_spec.rb @@ -168,6 +168,7 @@ 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 [ { start: ['1985-12-01'], @@ -186,6 +187,7 @@ 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 [ { start: ['1989-12-01'], diff --git a/spec/models/account_spec.rb b/spec/models/account_spec.rb index d173fae5f..3c388cb5f 100644 --- a/spec/models/account_spec.rb +++ b/spec/models/account_spec.rb @@ -6,12 +6,14 @@ described_class.tenants(nil) end end + context 'when tenant_list param is empty' do it 'calls Account.all' do expect(Account).to receive(:all) described_class.tenants([]) end end + context 'when tenant_list param is a string' do it 'calls Account.where' do expect(Account).to receive(:where).with(cname: 'foo bar baz') @@ -261,6 +263,7 @@ Site.update(account: account) Site.instance.admin_emails = ["test@test.com", "test@test.org"] end + it 'switches to current tenant database and returns Site admin_emails' do expect(Apartment::Tenant).to receive(:switch).with(account.tenant).and_yield expect(account.admin_emails).to match_array(["test@test.com", "test@test.org"]) @@ -274,6 +277,7 @@ Site.update(account: account) Site.instance.admin_emails = ["test@test.com", "test@test.org"] end + it 'switches to current tenant database updates Site admin_emails' do expect(Apartment::Tenant).to receive(:switch).with(account.tenant).exactly(3).times.and_yield expect(account.admin_emails).to match_array(["test@test.com", "test@test.org"]) @@ -288,19 +292,23 @@ context 'default setting for test environment' do it { is_expected.to be false } end + context 'single tenant in production environment' do before do allow(Settings.multitenancy).to receive(:enabled).and_return false allow(Rails.env).to receive(:test?).and_return false end + it { is_expected.to be false } end + context 'default tenant in a multitenant production environment' do before do allow(Settings.multitenancy).to receive(:enabled).and_return true allow(Rails.env).to receive(:test?).and_return false allow(Apartment::Tenant).to receive(:current_tenant).and_return Apartment::Tenant.default_tenant end + it { is_expected.to be true } end end diff --git a/spec/models/nil_site_spec.rb b/spec/models/nil_site_spec.rb index 8d04137d3..8bdc155d2 100644 --- a/spec/models/nil_site_spec.rb +++ b/spec/models/nil_site_spec.rb @@ -56,10 +56,12 @@ it { is_expected.to be_empty } end + context "set a value" do - before { instance.admin_emails = "test@test.org" } subject { instance.admin_emails } + before { instance.admin_emails = "test@test.org" } + it { is_expected.to be_empty } end end diff --git a/spec/models/site_spec.rb b/spec/models/site_spec.rb index 13a1f0f0f..378608742 100644 --- a/spec/models/site_spec.rb +++ b/spec/models/site_spec.rb @@ -8,10 +8,12 @@ before do allow(Account).to receive(:global_tenant?).and_return true end + it "is a NilSite" do expect(described_class.instance).to eq(NilSite.instance) end end + context "on a specific tenant" do it "is a singleton site" do expect(described_class.instance).to eq(described_class.instance) @@ -27,11 +29,13 @@ expect(subject.admin_emails).to eq([]) end end + context "admins exist" do before do admin1.add_role :admin, subject admin2.add_role :admin, subject end + it "returns array of emails" do expect(subject.admin_emails).to match_array([admin1.email, admin2.email]) end @@ -46,17 +50,20 @@ admin1.add_role :admin, subject admin2.add_role :admin, subject end + it "clears out all admins" do expect(subject.admin_emails).to match_array([admin1.email, admin2.email]) subject.admin_emails = [] expect(subject.admin_emails).to eq([]) end end + context "passed a new set of admins" do before do admin1.add_role :admin, subject admin2.add_role :admin, subject end + it "overwrites existing admins with new set" do expect(subject.admin_emails).to match_array([admin1.email, admin2.email]) subject.admin_emails = [admin3.email, admin1.email] diff --git a/spec/models/solr_endpoint_spec.rb b/spec/models/solr_endpoint_spec.rb index 69643894d..eb312eba9 100644 --- a/spec/models/solr_endpoint_spec.rb +++ b/spec/models/solr_endpoint_spec.rb @@ -43,6 +43,7 @@ # Mocking on the subject, because mocking RSolr.connect causes doubles to leak for some reason allow(subject).to receive(:connection).and_return(mock_connection) end + it 'checks if the service is up' do allow(mock_connection).to receive(:get).with('admin/ping').and_return('status' => 'OK') expect(subject.ping).to be_truthy diff --git a/spec/models/uploaded_file_spec.rb b/spec/models/uploaded_file_spec.rb index 8e6733a34..ea5d41e00 100644 --- a/spec/models/uploaded_file_spec.rb +++ b/spec/models/uploaded_file_spec.rb @@ -30,6 +30,7 @@ describe CarrierWave::Storage::File do # default in dev/test before { expect(Hyrax::UploadedFileUploader).to receive(:storage).and_return(described_class) } + it_behaves_like 'Regular upload' it 'returns a SanitizedFile' do expect(upload.file.file).to be_a CarrierWave::SanitizedFile @@ -99,6 +100,7 @@ describe 'unlike our documented issue' do before { allow(upload.file.file).to receive(:url).and_return(bigurl) } + it 'can handle S3 URI' do expect(upload.file.file.filename).to eq 'image.png' end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 7a2c3c921..b65d7142e 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -5,6 +5,7 @@ before do allow(Account).to receive(:global_tenant?).and_return true end + it 'does not get the admin role' do expect(subject).not_to have_role :admin end diff --git a/spec/presenters/hyku/file_set_presenter_spec.rb b/spec/presenters/hyku/file_set_presenter_spec.rb index 48a887608..6652e6496 100644 --- a/spec/presenters/hyku/file_set_presenter_spec.rb +++ b/spec/presenters/hyku/file_set_presenter_spec.rb @@ -14,8 +14,10 @@ Hydra::Works::AddFileToFileSet.call(file_set, fixture_file('csv/sample.csv'), :original_file) end + it { is_expected.to be_nil } end + context "when the file is an image" do subject { presenter.display_image } @@ -23,6 +25,7 @@ Hydra::Works::AddFileToFileSet.call(file_set, fixture_file('images/world.png'), :original_file) end + it "creates a display image" do expect(subject).to be_instance_of IIIFManifest::DisplayImage expect(subject.url).to eq "http://test.host/images/#{id}/full/600,/0/default.jpg" @@ -37,6 +40,7 @@ Hydra::Works::AddFileToFileSet.call(file_set, fixture_file('images/world.png'), :original_file) end + it 'returns the url' do expect(subject.url).to eq "http://test.host/images/#{id}" end diff --git a/spec/presenters/hyku/manifest_enabled_work_show_presenter_spec.rb b/spec/presenters/hyku/manifest_enabled_work_show_presenter_spec.rb index a3ab29434..39d60f31e 100644 --- a/spec/presenters/hyku/manifest_enabled_work_show_presenter_spec.rb +++ b/spec/presenters/hyku/manifest_enabled_work_show_presenter_spec.rb @@ -22,6 +22,7 @@ before do work.representative_id = work.file_sets.first.id end + it "returns a presenter" do expect(subject).to be_kind_of Hyku::FileSetPresenter end diff --git a/spec/presenters/hyku/menu_presenter_spec.rb b/spec/presenters/hyku/menu_presenter_spec.rb index f21ecce84..3e01e0bf2 100644 --- a/spec/presenters/hyku/menu_presenter_spec.rb +++ b/spec/presenters/hyku/menu_presenter_spec.rb @@ -4,22 +4,25 @@ let(:controller_name) { controller.controller_name } describe "#repository_activity_section?" do + subject { instance.repository_activity_section? } + before do allow(context).to receive(:controller_name).and_return(controller_name) allow(context).to receive(:controller).and_return(controller) end - subject { instance.repository_activity_section? } 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 } @@ -28,17 +31,19 @@ end describe "#settings_section?" do + subject { instance.settings_section? } + before do allow(context).to receive(:controller_name).and_return(controller_name) 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 } @@ -47,22 +52,25 @@ end describe "#roles_and_permissions_section?" do + subject { instance.roles_and_permissions_section? } + before do allow(context).to receive(:controller_name).and_return(controller_name) 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 } @@ -77,12 +85,15 @@ before do allow(instance.view_context).to receive(:can?).and_return(false) end + it { is_expected.to be false } end + context "for a user who can manage users" do before do allow(instance.view_context).to receive(:can?).and_return(true) end + it { is_expected.to be true } end end @@ -94,6 +105,7 @@ before do allow(instance.view_context).to receive(:can?).with(:read, :admin_dashboard).and_return(false) end + it { is_expected.to be false } end @@ -101,6 +113,7 @@ before do allow(instance.view_context).to receive(:can?).with(:read, :admin_dashboard).and_return(true) end + it { is_expected.to be true } end end diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 75a82a234..d88008e9c 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -11,7 +11,7 @@ ) SimpleCov.start('rails') -require File.expand_path('../../config/environment', __FILE__) +require File.expand_path('../config/environment', __dir__) # Prevent database truncation if the environment is production abort("The Rails environment is running in production mode!") if Rails.env.production? require 'spec_helper' diff --git a/spec/requests/home_spec.rb b/spec/requests/home_spec.rb index d13a3ab72..953db30b1 100644 --- a/spec/requests/home_spec.rb +++ b/spec/requests/home_spec.rb @@ -3,6 +3,7 @@ describe 'GET /' do context 'on the primary host' do before { host! 'localhost' } + it 'redirects to the accounts landing page' do get root_path expect(response).to have_http_status(:ok) @@ -11,6 +12,7 @@ context 'on an unknown subhost' do before { host! 'mystery.localhost' } + it 'raises a 404' do expect { get root_path }.to raise_error(ActionController::RoutingError) end diff --git a/spec/requests/riiif_spec.rb b/spec/requests/riiif_spec.rb index f9feb2bc6..7401cbd44 100644 --- a/spec/requests/riiif_spec.rb +++ b/spec/requests/riiif_spec.rb @@ -7,6 +7,7 @@ fixture_file('images/world.png'), :original_file) end + let(:file) { file_set.original_file } let(:size) { '300,' } diff --git a/spec/services/create_account_spec.rb b/spec/services/create_account_spec.rb index 575363956..acf0bd9a7 100644 --- a/spec/services/create_account_spec.rb +++ b/spec/services/create_account_spec.rb @@ -36,6 +36,7 @@ allow(account1).to receive(:create_external_resources).and_return true allow(account2).to receive(:create_external_resources).and_return true end + it 'prevents duplicate accounts' do expect(account1.save).to be true expect(account2.save).to be false diff --git a/spec/services/iiif_authorization_service_spec.rb b/spec/services/iiif_authorization_service_spec.rb index 8920eddc0..acc67803e 100644 --- a/spec/services/iiif_authorization_service_spec.rb +++ b/spec/services/iiif_authorization_service_spec.rb @@ -10,6 +10,7 @@ describe "#can?" do context "when the user has read access to the FileSet" do before { allow(ability).to receive(:test_read).with(file_set_id).and_return(true) } + context "info" do subject { service.can?(:info, image) } @@ -25,6 +26,7 @@ context "when the user doesn't have read access to the FileSet" do before { allow(ability).to receive(:test_read).with(file_set_id).and_return(false) } + context "info" do subject { service.can?(:info, image) } diff --git a/spec/support/rake.rb b/spec/support/rake.rb index 40eb51a2b..1c1b795db 100644 --- a/spec/support/rake.rb +++ b/spec/support/rake.rb @@ -24,7 +24,7 @@ def capture_stdout_stderr rescue SystemExit => e puts "error = #{e.inspect}" end - return "Output: #{out.string}\n Errors:#{err.string}" + "Output: #{out.string}\n Errors:#{err.string}" ensure $stdout = STDOUT $stdout = STDERR diff --git a/spec/tasks/rake_spec.rb b/spec/tasks/rake_spec.rb index 5422f27a1..1ee5e64f6 100644 --- a/spec/tasks/rake_spec.rb +++ b/spec/tasks/rake_spec.rb @@ -57,14 +57,17 @@ CreateAccount.new(Account.new(name: 'first')).save CreateAccount.new(Account.new(name: 'second')).save end + after(:all) do Account.find_by(name: 'first').destroy Account.find_by(name: 'second').destroy end + before do # This omits a tenant that appears automatically created and is not switch-intoable allow(Account).to receive(:tenants).and_return(accounts) end + let(:accounts) { Account.where(name: ['first', 'second']) } let(:task) { double('task') } @@ -90,9 +93,11 @@ before do ENV['tenants'] = "garbage_value #{account.cname} other_garbage_value" end + after do ENV.delete('tenants') end + it 'runs against a single tenant and ignores bogus tenants' do expect(account).to receive(:switch).once.and_call_original allow(Rake::Task).to receive(:[]).with('hyrax:count').and_return(task) diff --git a/spec/values/universal_viewer_spec.rb b/spec/values/universal_viewer_spec.rb index f8ac6bca8..344f85798 100644 --- a/spec/values/universal_viewer_spec.rb +++ b/spec/values/universal_viewer_spec.rb @@ -6,6 +6,7 @@ expect(subject.viewer_version).to eq "2.0.1" end end + describe "#viewer_link" do it "is a relative link to the viewer" do expect(subject.viewer_link).to eq "/#{subject.viewer_root}/uv-2.0.1/lib/embed.js" diff --git a/spec/views/_user_util_links.html.erb_spec.rb b/spec/views/_user_util_links.html.erb_spec.rb index e5ca9b246..df8645327 100644 --- a/spec/views/_user_util_links.html.erb_spec.rb +++ b/spec/views/_user_util_links.html.erb_spec.rb @@ -6,6 +6,7 @@ allow(view).to receive(:current_user).and_return(user) render end + it 'links to edit registration path' do expect(rendered).to have_link 'Change password', href: edit_user_registration_path end diff --git a/spec/views/account_sign_up/new.html.erb_spec.rb b/spec/views/account_sign_up/new.html.erb_spec.rb index 00802ee25..16d73a49f 100644 --- a/spec/views/account_sign_up/new.html.erb_spec.rb +++ b/spec/views/account_sign_up/new.html.erb_spec.rb @@ -2,7 +2,7 @@ before do assign(:account, Account.new( name: "MyString" - )) + )) end it "renders new account form" do diff --git a/spec/views/hyrax/admin/users/index.html.erb_spec.rb b/spec/views/hyrax/admin/users/index.html.erb_spec.rb index 4a8c75171..96c3e5a69 100644 --- a/spec/views/hyrax/admin/users/index.html.erb_spec.rb +++ b/spec/views/hyrax/admin/users/index.html.erb_spec.rb @@ -6,11 +6,13 @@ before do # Create four normal user accounts (1..4).each do |i| - users << FactoryBot.create(:user, - display_name: "user#{i}", - email: "email#{i}@example.com", - last_sign_in_at: Time.zone.now - 15.minutes, - created_at: Time.zone.now - 3.days) + users << FactoryBot.create( + :user, + display_name: "user#{i}", + email: "email#{i}@example.com", + last_sign_in_at: Time.zone.now - 15.minutes, + created_at: Time.zone.now - 3.days + ) end allow(presenter).to receive(:users).and_return(users) assign(:presenter, presenter) @@ -47,10 +49,10 @@ # Create two admin acccounts (5..6).each do |i| users << FactoryBot.create(:admin, - display_name: "admin-user#{i}", - email: "admin#{i}@example.com", - last_sign_in_at: Time.zone.now - 15.minutes, - created_at: Time.zone.now - 3.days) + display_name: "admin-user#{i}", + email: "admin#{i}@example.com", + last_sign_in_at: Time.zone.now - 15.minutes, + created_at: Time.zone.now - 3.days) end render end @@ -68,10 +70,10 @@ # Create one invited (pending) user (7..7).each do |i| users << FactoryBot.create(:invited_user, - display_name: "invitee#{i}", - email: "invitee#{i}@example.com", - last_sign_in_at: Time.zone.now - 15.minutes, - created_at: Time.zone.now - 3.days) + display_name: "invitee#{i}", + email: "invitee#{i}@example.com", + last_sign_in_at: Time.zone.now - 15.minutes, + created_at: Time.zone.now - 3.days) end render end diff --git a/spec/views/proprietor/accounts/new.html.erb_spec.rb b/spec/views/proprietor/accounts/new.html.erb_spec.rb index 8aed5c062..172dadd86 100644 --- a/spec/views/proprietor/accounts/new.html.erb_spec.rb +++ b/spec/views/proprietor/accounts/new.html.erb_spec.rb @@ -2,7 +2,7 @@ before do assign(:account, Account.new( name: "MyString" - )) + )) end it "renders new account form" do diff --git a/spec/views/proprietor/accounts/show.html.erb_spec.rb b/spec/views/proprietor/accounts/show.html.erb_spec.rb index b3f60c610..cecf31c00 100644 --- a/spec/views/proprietor/accounts/show.html.erb_spec.rb +++ b/spec/views/proprietor/accounts/show.html.erb_spec.rb @@ -27,6 +27,7 @@ allow(account).to receive(:admin_emails).and_return([]) render end + it 'displays "No administrators exist"' do expect(rendered).to have_content('No administrators exist') end @@ -37,6 +38,7 @@ allow(account).to receive(:admin_emails).and_return([admin1.email, admin2.email]) render end + it 'displays each user email and a remove button' do expect(rendered).to have_content(admin1.email) expect(rendered).to have_content(admin2.email) diff --git a/spec/views/splash/index.html.erb_spec.rb b/spec/views/splash/index.html.erb_spec.rb index 0e6eb13c2..50de7b982 100644 --- a/spec/views/splash/index.html.erb_spec.rb +++ b/spec/views/splash/index.html.erb_spec.rb @@ -9,6 +9,7 @@ allow(controller).to receive(:can?).with(:manage, Account).and_return(false) render end + it "displays a 'Get Started' button" do expect(page).to have_selector('a.btn-sign-up', text: 'Get Started') assert_select "a.btn-sign-up[href=?]", account_sign_up_path @@ -22,6 +23,7 @@ allow(controller).to receive(:user_signed_in?).and_return(true) render end + it "displays a 'Get Started' button" do expect(page).to have_selector('a.btn-sign-up', text: 'Get Started') assert_select "a.btn-sign-up[href=?]", account_sign_up_path @@ -35,6 +37,7 @@ allow(controller).to receive(:user_signed_in?).and_return(false) render end + it "displays a 'Login to get started' button" do expect(page).to have_selector('a.btn-sign-up', text: 'Login to get started') assert_select "a.btn-sign-up[href=?]", main_app.new_user_session_path @@ -48,6 +51,7 @@ allow(controller).to receive(:user_signed_in?).and_return(true) render end + it "displays a 'You are not authorized to create tenants' message" do expect(page).to have_no_selector('a.btn-sign-up') expect(page).to have_selector('p', text: 'You are not authorized to create tenants') From 5df9d857cdbbc1f53b5d691843d4269859d3f7de Mon Sep 17 00:00:00 2001 From: nicholas Date: Fri, 12 Oct 2018 13:44:27 -0500 Subject: [PATCH 3/4] alignment errors, according to travis --- spec/views/account_sign_up/new.html.erb_spec.rb | 2 +- spec/views/proprietor/accounts/new.html.erb_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/views/account_sign_up/new.html.erb_spec.rb b/spec/views/account_sign_up/new.html.erb_spec.rb index 16d73a49f..00802ee25 100644 --- a/spec/views/account_sign_up/new.html.erb_spec.rb +++ b/spec/views/account_sign_up/new.html.erb_spec.rb @@ -2,7 +2,7 @@ before do assign(:account, Account.new( name: "MyString" - )) + )) end it "renders new account form" do diff --git a/spec/views/proprietor/accounts/new.html.erb_spec.rb b/spec/views/proprietor/accounts/new.html.erb_spec.rb index 172dadd86..8aed5c062 100644 --- a/spec/views/proprietor/accounts/new.html.erb_spec.rb +++ b/spec/views/proprietor/accounts/new.html.erb_spec.rb @@ -2,7 +2,7 @@ before do assign(:account, Account.new( name: "MyString" - )) + )) end it "renders new account form" do From 7bd263706531056939b3b3fb110654eb1ea053b7 Mon Sep 17 00:00:00 2001 From: nicholas Date: Fri, 12 Oct 2018 13:56:41 -0500 Subject: [PATCH 4/4] rubocop fix --- spec/factories/generic_works.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/spec/factories/generic_works.rb b/spec/factories/generic_works.rb index 37fb9949f..b357df6c6 100644 --- a/spec/factories/generic_works.rb +++ b/spec/factories/generic_works.rb @@ -6,11 +6,12 @@ title { ["Test title"] } - identifier { %w[ + identifier do + %w[ ISBN:978-83-7659-303-6 978-3-540-49698-4 9790879392788 doi:10.1038/nphys1170 3-921099-34-X 3-540-49698-x 0-19-852663-6 ] - } + end factory :work_with_one_file do before(:create) do |work, evaluator|