diff --git a/app/assets/javascripts/hyrax/select_work_type.es6 b/app/assets/javascripts/hyrax/select_work_type.es6 index fcecd616fe..dc5d28696a 100644 --- a/app/assets/javascripts/hyrax/select_work_type.es6 +++ b/app/assets/javascripts/hyrax/select_work_type.es6 @@ -42,12 +42,9 @@ export default class SelectWorkType { let url = this.form.find('input[type="radio"]:checked').data(this.type) const select = this.form.find('select') - // Only append admin_set_id if the select exists and has a value. - // Pick the right separator: URLs lose their locale query string when - // I18n.locale == I18n.default_locale, so we cannot assume `?` is present. + // Only append admin_set_id if the select exists and has a value if (select.length && select.val()) { - const separator = url.indexOf('?') === -1 ? '?' : '&' - url = url + separator + "admin_set_id=" + select.val() + url = url + "&admin_set_id=" + select.val() } return url } diff --git a/app/controllers/concerns/hyrax/controller.rb b/app/controllers/concerns/hyrax/controller.rb index c730093905..32dc37813c 100644 --- a/app/controllers/concerns/hyrax/controller.rb +++ b/app/controllers/concerns/hyrax/controller.rb @@ -27,15 +27,9 @@ def user_root_path hyrax.dashboard_path end - # Ensure that the locale choice is persistent across requests, but only - # when it differs from the default. Appending +?locale=+ for the default - # locale on every URL pollutes sitemaps, canonical tags, and outbound - # links, which causes search engines to index and rank duplicate - # locale-parameterized URLs as canonical. + # Ensure that the locale choice is persistent across requests def default_url_options - opts = super - opts[:locale] = I18n.locale unless I18n.locale == I18n.default_locale - opts + super.merge(locale: I18n.locale) end # @note for Blacklight 6/7 compatibility diff --git a/app/presenters/hyrax/admin_set_presenter.rb b/app/presenters/hyrax/admin_set_presenter.rb index 8be56dce2c..607a43574d 100644 --- a/app/presenters/hyrax/admin_set_presenter.rb +++ b/app/presenters/hyrax/admin_set_presenter.rb @@ -51,7 +51,7 @@ def collection_type_gid end def show_path - Hyrax::Engine.routes.url_helpers.admin_admin_set_path(id, locale: (I18n.locale unless I18n.locale == I18n.default_locale)) + Hyrax::Engine.routes.url_helpers.admin_admin_set_path(id, locale: I18n.locale) end def available_parent_collections(*) diff --git a/app/presenters/hyrax/collection_presenter.rb b/app/presenters/hyrax/collection_presenter.rb index 4b5ce5ddec..a4a567f301 100644 --- a/app/presenters/hyrax/collection_presenter.rb +++ b/app/presenters/hyrax/collection_presenter.rb @@ -138,7 +138,7 @@ def user_can_create_new_nest_collection? end def show_path - Hyrax::Engine.routes.url_helpers.dashboard_collection_path(id, locale: (I18n.locale unless I18n.locale == I18n.default_locale)) + Hyrax::Engine.routes.url_helpers.dashboard_collection_path(id, locale: I18n.locale) end ## diff --git a/app/presenters/hyrax/file_set_presenter.rb b/app/presenters/hyrax/file_set_presenter.rb index 783f1a549a..703716aa56 100644 --- a/app/presenters/hyrax/file_set_presenter.rb +++ b/app/presenters/hyrax/file_set_presenter.rb @@ -69,7 +69,7 @@ def license end def stats_path - Hyrax::Engine.routes.url_helpers.stats_file_path(self, locale: (I18n.locale unless I18n.locale == I18n.default_locale)) + Hyrax::Engine.routes.url_helpers.stats_file_path(self, locale: I18n.locale) end def events(size = 100) diff --git a/app/presenters/hyrax/work_show_presenter.rb b/app/presenters/hyrax/work_show_presenter.rb index 996decbe8f..8457617077 100644 --- a/app/presenters/hyrax/work_show_presenter.rb +++ b/app/presenters/hyrax/work_show_presenter.rb @@ -199,7 +199,7 @@ def display_unfeature_link? end def stats_path - Hyrax::Engine.routes.url_helpers.stats_work_path(self, locale: (I18n.locale unless I18n.locale == I18n.default_locale)) + Hyrax::Engine.routes.url_helpers.stats_work_path(self, locale: I18n.locale) end def model diff --git a/app/renderers/hyrax/renderers/faceted_attribute_renderer.rb b/app/renderers/hyrax/renderers/faceted_attribute_renderer.rb index 6fb9d2dca2..f24fbbda60 100644 --- a/app/renderers/hyrax/renderers/faceted_attribute_renderer.rb +++ b/app/renderers/hyrax/renderers/faceted_attribute_renderer.rb @@ -9,7 +9,7 @@ def li_value(value) end def search_path(value) - Rails.application.routes.url_helpers.search_catalog_path("f[#{search_field}][]": value, locale: (I18n.locale unless I18n.locale == I18n.default_locale)) + Rails.application.routes.url_helpers.search_catalog_path("f[#{search_field}][]": value, locale: I18n.locale) end def search_field diff --git a/app/renderers/hyrax/renderers/linked_attribute_renderer.rb b/app/renderers/hyrax/renderers/linked_attribute_renderer.rb index 481c4453d7..9c6047ee3d 100644 --- a/app/renderers/hyrax/renderers/linked_attribute_renderer.rb +++ b/app/renderers/hyrax/renderers/linked_attribute_renderer.rb @@ -10,7 +10,7 @@ def li_value(value) def search_path(value) Rails.application.routes.url_helpers.search_catalog_path( - search_field: search_field, q: ERB::Util.h(value), locale: (I18n.locale unless I18n.locale == I18n.default_locale) + search_field: search_field, q: ERB::Util.h(value), locale: I18n.locale ) end diff --git a/spec/controllers/concerns/hyrax/controller_spec.rb b/spec/controllers/concerns/hyrax/controller_spec.rb deleted file mode 100644 index 2aa5e44bc8..0000000000 --- a/spec/controllers/concerns/hyrax/controller_spec.rb +++ /dev/null @@ -1,33 +0,0 @@ -# frozen_string_literal: true -RSpec.describe Hyrax::Controller, type: :controller do - controller(ApplicationController) do - def index - render plain: 'ok' - end - end - - describe '#default_url_options' do - around do |example| - original_locale = I18n.locale - example.run - I18n.locale = original_locale - end - - context 'when the current locale is the default' do - it 'omits :locale so URLs are not polluted with ?locale=' do - I18n.locale = I18n.default_locale - expect(controller.default_url_options).not_to have_key(:locale) - end - end - - context 'when the current locale differs from the default' do - it 'includes :locale to preserve user locale across requests' do - non_default = (I18n.available_locales - [I18n.default_locale]).first - skip 'no non-default locale available' if non_default.nil? - - I18n.locale = non_default - expect(controller.default_url_options[:locale]).to eq(non_default) - end - end - end -end diff --git a/spec/controllers/concerns/hyrax/works_controller_behavior_spec.rb b/spec/controllers/concerns/hyrax/works_controller_behavior_spec.rb index 96bf9f17a1..be1e88a5fe 100644 --- a/spec/controllers/concerns/hyrax/works_controller_behavior_spec.rb +++ b/spec/controllers/concerns/hyrax/works_controller_behavior_spec.rb @@ -70,7 +70,7 @@ it 'redirects to new user login' do get :create, params: {} - expect(response).to redirect_to paths.new_user_session_path + expect(response).to redirect_to paths.new_user_session_path(locale: :en) end context 'with a logged in user' do @@ -82,7 +82,7 @@ get :create, params: { test_simple_work: { title: 'comet in moominland' } } expect(response) - .to redirect_to paths.send(work_route_path, id: assigns(:curation_concern).id) + .to redirect_to paths.send(work_route_path, id: assigns(:curation_concern).id, locale: :en) end it 'sets current user as depositor' do @@ -306,7 +306,7 @@ describe '#destroy' do it 'redirect to user login' do delete :destroy, params: { id: work.id } - expect(response).to redirect_to paths.new_user_session_path + expect(response).to redirect_to paths.new_user_session_path(locale: :en) end context 'with a logged in user' do @@ -361,7 +361,7 @@ it 'redirects to new user login' do get :edit, params: { id: work.id } - expect(response).to redirect_to paths.new_user_session_path + expect(response).to redirect_to paths.new_user_session_path(locale: :en) end context 'with a logged in user' do @@ -433,7 +433,7 @@ describe '#new' do it 'redirect to user login' do get :new - expect(response).to redirect_to paths.new_user_session_path + expect(response).to redirect_to paths.new_user_session_path(locale: :en) end context 'with a logged in user' do @@ -521,7 +521,7 @@ it 'redirects to new user login' do get :show, params: { id: work.id } - expect(response).to redirect_to paths.new_user_session_path + expect(response).to redirect_to paths.new_user_session_path(locale: :en) end context 'when indexed as public' do @@ -549,7 +549,7 @@ it 'redirects to new user login' do patch :update, params: { id: work.id } - expect(response).to redirect_to paths.new_user_session_path + expect(response).to redirect_to paths.new_user_session_path(locale: :en) end context 'when the user has edit access' do @@ -561,7 +561,7 @@ patch :update, params: { id: work.id, test_simple_work: { title: 'new title' } } expect(response) - .to redirect_to paths.send(work_route_path, id: work.id) + .to redirect_to paths.send(work_route_path, id: work.id, locale: :en) end it 'updates the work metadata' do diff --git a/spec/controllers/hyrax/admin/permission_template_accesses_controller_spec.rb b/spec/controllers/hyrax/admin/permission_template_accesses_controller_spec.rb index 2bf3836a14..8d888a17fe 100644 --- a/spec/controllers/hyrax/admin/permission_template_accesses_controller_spec.rb +++ b/spec/controllers/hyrax/admin/permission_template_accesses_controller_spec.rb @@ -69,6 +69,7 @@ expect(response) .to redirect_to(hyrax.edit_admin_admin_set_path(source_id, + locale: 'en', anchor: 'participants')) end @@ -106,6 +107,7 @@ expect(response) .to redirect_to(hyrax.edit_admin_admin_set_path(source_id, + locale: 'en', anchor: 'participants')) end @@ -148,6 +150,7 @@ expect(response) .to redirect_to(hyrax.edit_dashboard_collection_path(source_id, + locale: 'en', anchor: 'sharing')) end @@ -179,6 +182,7 @@ expect(response) .to redirect_to(hyrax.edit_dashboard_collection_path(source_id, + locale: 'en', anchor: 'sharing')) end diff --git a/spec/controllers/hyrax/admin/permission_templates_controller_spec.rb b/spec/controllers/hyrax/admin/permission_templates_controller_spec.rb index 0174a6e53a..7001ff808c 100644 --- a/spec/controllers/hyrax/admin/permission_templates_controller_spec.rb +++ b/spec/controllers/hyrax/admin/permission_templates_controller_spec.rb @@ -49,7 +49,7 @@ expect(controller).to receive(:authorize!).with(:update, Hyrax::PermissionTemplate) expect(form).to receive(:update).with(ActionController::Parameters.new(form_attributes).permit!).and_return(updated: true, content_tab: 'participants') put :update, params: input_params - expect(response).to redirect_to(hyrax.edit_admin_admin_set_path(permission_template.source_id, anchor: 'participants')) + expect(response).to redirect_to(hyrax.edit_admin_admin_set_path(permission_template.source_id, locale: 'en', anchor: 'participants')) expect(flash[:notice]).to eq(I18n.t('participants', scope: 'hyrax.admin.admin_sets.form.permission_update_notices')) end end @@ -64,7 +64,7 @@ expect(controller).to receive(:authorize!).with(:update, Hyrax::PermissionTemplate) expect(form).to receive(:update).with(ActionController::Parameters.new(form_attributes).permit!).and_return(updated: true, content_tab: 'sharing') put :update, params: input_params - expect(response).to redirect_to(hyrax.edit_dashboard_collection_path(permission_template.source_id, anchor: 'sharing')) + expect(response).to redirect_to(hyrax.edit_dashboard_collection_path(permission_template.source_id, locale: 'en', anchor: 'sharing')) expect(flash[:notice]).to eq(I18n.t('sharing', scope: 'hyrax.dashboard.collections.form.permission_update_notices')) end @@ -79,7 +79,7 @@ expect(controller).to receive(:authorize!).with(:update, Hyrax::PermissionTemplate) expect(form).to receive(:update).with(ActionController::Parameters.new(form_attributes).permit!).and_return(updated: true, content_tab: 'sharing') put :update, params: input_params - expect(response).to redirect_to(hyrax.edit_dashboard_collection_path(permission_template.source_id, anchor: 'sharing')) + expect(response).to redirect_to(hyrax.edit_dashboard_collection_path(permission_template.source_id, locale: 'en', anchor: 'sharing')) updated = Hyrax::PermissionTemplate.find_by(id: permission_template.id) expect(updated.release_date.strftime('%Y-%m-%d')).to eq(release_date) diff --git a/spec/controllers/hyrax/admin/strategies_controller_spec.rb b/spec/controllers/hyrax/admin/strategies_controller_spec.rb index 3321027f9e..ec95b6f95c 100644 --- a/spec/controllers/hyrax/admin/strategies_controller_spec.rb +++ b/spec/controllers/hyrax/admin/strategies_controller_spec.rb @@ -35,7 +35,7 @@ patch :update, params: { feature_id: feature.id, id: strategy } expect(response.location) - .to include Hyrax::Engine.routes.url_helpers.admin_features_path + .to include Hyrax::Engine.routes.url_helpers.admin_features_path(locale: 'en') end end end diff --git a/spec/controllers/hyrax/admin/workflow_roles_controller_spec.rb b/spec/controllers/hyrax/admin/workflow_roles_controller_spec.rb index 01aa7ba610..fe88f659a0 100644 --- a/spec/controllers/hyrax/admin/workflow_roles_controller_spec.rb +++ b/spec/controllers/hyrax/admin/workflow_roles_controller_spec.rb @@ -7,9 +7,9 @@ end it "is successful" do - expect(controller).to receive(:add_breadcrumb).with('Home', root_path) - expect(controller).to receive(:add_breadcrumb).with('Dashboard', dashboard_path) - expect(controller).to receive(:add_breadcrumb).with('Workflow Roles', admin_workflow_roles_path) + expect(controller).to receive(:add_breadcrumb).with('Home', root_path(locale: 'en')) + expect(controller).to receive(:add_breadcrumb).with('Dashboard', dashboard_path(locale: 'en')) + expect(controller).to receive(:add_breadcrumb).with('Workflow Roles', admin_workflow_roles_path(locale: 'en')) get :index expect(response).to be_successful expect(assigns[:presenter]).to be_kind_of Hyrax::Admin::WorkflowRolesPresenter @@ -20,7 +20,7 @@ context "when they don't have permission" do it "throws a CanCan error" do get :index - expect(response).to redirect_to main_app.new_user_session_path + expect(response).to redirect_to main_app.new_user_session_path(locale: 'en') end end end @@ -46,7 +46,7 @@ context "when they don't have permission" do it 'throws a CanCan error' do post :create, params: { sipity_workflow_responsibility: {} } - expect(response).to redirect_to main_app.new_user_session_path + expect(response).to redirect_to main_app.new_user_session_path(locale: 'en') end end end @@ -70,7 +70,7 @@ context "when they don't have permission" do it "throws a CanCan error" do get :index - expect(response).to redirect_to main_app.new_user_session_path + expect(response).to redirect_to main_app.new_user_session_path(locale: 'en') end end end diff --git a/spec/controllers/hyrax/api/zotero_controller_spec.rb b/spec/controllers/hyrax/api/zotero_controller_spec.rb index 93842eea67..af9450e85d 100644 --- a/spec/controllers/hyrax/api/zotero_controller_spec.rb +++ b/spec/controllers/hyrax/api/zotero_controller_spec.rb @@ -112,7 +112,7 @@ specify do expect(subject).to have_http_status(:found) - expect(subject).to redirect_to(routes.url_helpers.edit_dashboard_profile_path(user)) + expect(subject).to redirect_to(routes.url_helpers.edit_dashboard_profile_path(user, locale: 'en')) expect(flash[:alert]).to eq 'Malformed request from Zotero' end end @@ -125,7 +125,7 @@ specify do expect(subject).to have_http_status(:found) - expect(subject).to redirect_to(routes.url_helpers.edit_dashboard_profile_path(user)) + expect(subject).to redirect_to(routes.url_helpers.edit_dashboard_profile_path(user, locale: 'en')) expect(flash[:alert]).to eq 'You have not yet connected to Zotero' end end @@ -153,7 +153,7 @@ specify do expect(subject).to have_http_status(:found) expect(Hyrax::Arkivo::CreateSubscriptionJob).to have_received(:perform_later) - expect(subject).to redirect_to(routes.url_helpers.dashboard_profile_path(user)) + expect(subject).to redirect_to(routes.url_helpers.dashboard_profile_path(user, locale: 'en')) expect(flash[:alert]).to be_nil expect(flash[:notice]).to eq 'Successfully connected to Zotero!' expect(user.reload.zotero_userid).to eq zuserid diff --git a/spec/controllers/hyrax/batch_edits_controller_spec.rb b/spec/controllers/hyrax/batch_edits_controller_spec.rb index 81d9b40239..4aa71a8d54 100644 --- a/spec/controllers/hyrax/batch_edits_controller_spec.rb +++ b/spec/controllers/hyrax/batch_edits_controller_spec.rb @@ -12,9 +12,9 @@ shared_examples('tests that edit page loads') do it "is successful" do - expect(controller).to receive(:add_breadcrumb).with('Home', Hyrax::Engine.routes.url_helpers.root_path) - expect(controller).to receive(:add_breadcrumb).with(I18n.t('hyrax.dashboard.title'), Hyrax::Engine.routes.url_helpers.dashboard_path) - expect(controller).to receive(:add_breadcrumb).with(I18n.t('hyrax.dashboard.my.works'), Hyrax::Engine.routes.url_helpers.my_works_path) + expect(controller).to receive(:add_breadcrumb).with('Home', Hyrax::Engine.routes.url_helpers.root_path(locale: 'en')) + expect(controller).to receive(:add_breadcrumb).with(I18n.t('hyrax.dashboard.title'), Hyrax::Engine.routes.url_helpers.dashboard_path(locale: 'en')) + expect(controller).to receive(:add_breadcrumb).with(I18n.t('hyrax.dashboard.my.works'), Hyrax::Engine.routes.url_helpers.my_works_path(locale: 'en')) get :edit expect(response).to be_successful expect(response).to render_template('dashboard') @@ -75,7 +75,7 @@ it "is successful" do put :update, params: { update_type: "delete_all" } - expect(response).to redirect_to(dashboard_path) + expect(response).to redirect_to(dashboard_path(locale: 'en')) expect { GenericWork.find(one.id) }.to raise_error(Ldp::Gone) expect { GenericWork.find(two.id) }.to raise_error(Ldp::Gone) expect(GenericWork).to exist(three.id) @@ -83,7 +83,7 @@ it "redirects to the return controller" do put :update, params: { update_type: "delete_all", return_controller: mycontroller } - expect(response).to redirect_to(Hyrax::Engine.routes.url_for(controller: mycontroller, only_path: true)) + expect(response).to redirect_to(Hyrax::Engine.routes.url_for(controller: mycontroller, only_path: true, locale: 'en')) end it "updates the records" do @@ -190,7 +190,7 @@ it "is successful" do put :update, params: { update_type: "delete_all" } - expect(response).to redirect_to(dashboard_path) + expect(response).to redirect_to(dashboard_path(locale: 'en')) expect { work1 }.to raise_error(Valkyrie::Persistence::ObjectNotFoundError) expect { work2 }.to raise_error(Valkyrie::Persistence::ObjectNotFoundError) expect { work3 }.not_to raise_error(Valkyrie::Persistence::ObjectNotFoundError) @@ -198,7 +198,7 @@ it "redirects to the return controller" do put :update, params: { update_type: "delete_all", return_controller: mycontroller } - expect(response).to redirect_to(Hyrax::Engine.routes.url_for(controller: mycontroller, only_path: true)) + expect(response).to redirect_to(Hyrax::Engine.routes.url_for(controller: mycontroller, only_path: true, locale: 'en')) end it "updates the records" do diff --git a/spec/controllers/hyrax/batch_uploads_controller_spec.rb b/spec/controllers/hyrax/batch_uploads_controller_spec.rb index 6a74025641..48ac887129 100644 --- a/spec/controllers/hyrax/batch_uploads_controller_spec.rb +++ b/spec/controllers/hyrax/batch_uploads_controller_spec.rb @@ -33,9 +33,9 @@ let(:curation_concern) { double(human_readable_type: 'Works by Batch') } it "is successful" do - expect(controller).to receive(:add_breadcrumb).with(I18n.t('hyrax.controls.home'), Hyrax::Engine.routes.url_helpers.root_path) - expect(controller).to receive(:add_breadcrumb).with(I18n.t('hyrax.dashboard.title'), Hyrax::Engine.routes.url_helpers.dashboard_path) - expect(controller).to receive(:add_breadcrumb).with(I18n.t('hyrax.dashboard.my.works'), Hyrax::Engine.routes.url_helpers.my_works_path) + expect(controller).to receive(:add_breadcrumb).with(I18n.t('hyrax.controls.home'), Hyrax::Engine.routes.url_helpers.root_path(locale: 'en')) + expect(controller).to receive(:add_breadcrumb).with(I18n.t('hyrax.dashboard.title'), Hyrax::Engine.routes.url_helpers.dashboard_path(locale: 'en')) + expect(controller).to receive(:add_breadcrumb).with(I18n.t('hyrax.dashboard.my.works'), Hyrax::Engine.routes.url_helpers.my_works_path(locale: 'en')) expect(controller).to receive(:add_breadcrumb).with(I18n.t('hyrax.batch_uploads.new.breadcrumb'), Hyrax::Engine.routes.url_helpers.new_batch_upload_path) get :new expect(response).to be_successful @@ -51,7 +51,7 @@ end it 'redirects with an error message' do post :create, params: post_params.merge(format: :html) - expect(response).to redirect_to Hyrax::Engine.routes.url_helpers.my_works_path + expect(response).to redirect_to Hyrax::Engine.routes.url_helpers.my_works_path(locale: 'en') expect(flash[:alert]).to include('Feature disabled by administrator') end context 'when json is requested' do @@ -73,7 +73,7 @@ expected_shared_params, Hyrax::BatchCreateOperation) post :create, params: post_params - expect(response).to redirect_to Hyrax::Engine.routes.url_helpers.my_works_path + expect(response).to redirect_to Hyrax::Engine.routes.url_helpers.my_works_path(locale: 'en') expect(flash[:notice]).to be_html_safe expect(flash[:notice]).to include("Your files are being processed") end @@ -97,7 +97,7 @@ expected_shared_params, a_kind_of(Hyrax::BatchCreateOperation)) post :create, params: post_params - expect(response).to redirect_to Hyrax::Engine.routes.url_helpers.my_works_path + expect(response).to redirect_to Hyrax::Engine.routes.url_helpers.my_works_path(locale: 'en') expect(flash[:notice]).to include("Your files are being processed") end end @@ -116,7 +116,7 @@ it 'redirects to managed works page' do allow(BatchCreateJob).to receive(:perform_later) post :create, params: post_params - expect(response).to redirect_to Hyrax::Engine.routes.url_helpers.dashboard_works_path + expect(response).to redirect_to Hyrax::Engine.routes.url_helpers.dashboard_works_path(locale: 'en') end end end diff --git a/spec/controllers/hyrax/citations_controller_spec.rb b/spec/controllers/hyrax/citations_controller_spec.rb index 0df7b50dc1..1edfb46450 100644 --- a/spec/controllers/hyrax/citations_controller_spec.rb +++ b/spec/controllers/hyrax/citations_controller_spec.rb @@ -12,8 +12,8 @@ end it "is successful" do - expect(controller).to receive(:add_breadcrumb).with('Home', Hyrax::Engine.routes.url_helpers.root_path) - expect(controller).to receive(:add_breadcrumb).with('Dashboard', Hyrax::Engine.routes.url_helpers.dashboard_path) + expect(controller).to receive(:add_breadcrumb).with('Home', Hyrax::Engine.routes.url_helpers.root_path(locale: 'en')) + expect(controller).to receive(:add_breadcrumb).with('Dashboard', Hyrax::Engine.routes.url_helpers.dashboard_path(locale: 'en')) get :work, params: { id: work } expect(response).to be_successful expect(response).to render_template('layouts/hyrax/1_column') @@ -30,7 +30,7 @@ it "redirects to the home page" do get :work, params: { id: work } - expect(response).to redirect_to main_app.root_path + expect(response).to redirect_to main_app.root_path(locale: 'en') expect(flash[:alert]).to eq "You are not authorized to access this page." end end @@ -38,7 +38,7 @@ context "when a user is not logged in" do it "redirects to the user login page" do get :work, params: { id: work } - expect(response).to redirect_to main_app.new_user_session_path + expect(response).to redirect_to main_app.new_user_session_path(locale: 'en') expect(flash[:alert]).to eq "You are not authorized to access this page." expect(session['user_return_to']).to eq request.url end @@ -51,8 +51,8 @@ end it "is successful" do - expect(controller).to receive(:add_breadcrumb).with('Home', Hyrax::Engine.routes.url_helpers.root_path) - expect(controller).to receive(:add_breadcrumb).with('Dashboard', Hyrax::Engine.routes.url_helpers.dashboard_path) + expect(controller).to receive(:add_breadcrumb).with('Home', Hyrax::Engine.routes.url_helpers.root_path(locale: 'en')) + expect(controller).to receive(:add_breadcrumb).with('Dashboard', Hyrax::Engine.routes.url_helpers.dashboard_path(locale: 'en')) get :work, params: { id: work } expect(response).to be_successful expect(response).to render_template('layouts/hyrax/1_column') @@ -71,8 +71,8 @@ end it "is successful" do - expect(controller).to receive(:add_breadcrumb).with('Home', Hyrax::Engine.routes.url_helpers.root_path) - expect(controller).to receive(:add_breadcrumb).with('Dashboard', Hyrax::Engine.routes.url_helpers.dashboard_path) + expect(controller).to receive(:add_breadcrumb).with('Home', Hyrax::Engine.routes.url_helpers.root_path(locale: 'en')) + expect(controller).to receive(:add_breadcrumb).with('Dashboard', Hyrax::Engine.routes.url_helpers.dashboard_path(locale: 'en')) get :file, params: { id: file_set } expect(response).to be_successful expect(response).to render_template('layouts/hyrax/1_column') @@ -83,7 +83,7 @@ context "with an unauthenticated user" do it "is not successful" do get :file, params: { id: file_set } - expect(response).to redirect_to main_app.new_user_session_path + expect(response).to redirect_to main_app.new_user_session_path(locale: 'en') expect(flash[:alert]).to eq "You are not authorized to access this page." expect(session['user_return_to']).to eq request.url end diff --git a/spec/controllers/hyrax/collections_controller_spec.rb b/spec/controllers/hyrax/collections_controller_spec.rb index 4997ad2ad9..93d270fe0d 100644 --- a/spec/controllers/hyrax/collections_controller_spec.rb +++ b/spec/controllers/hyrax/collections_controller_spec.rb @@ -39,10 +39,10 @@ end it "returns the collection and its members" do # rubocop:disable RSpec/ExampleLength - expect(controller).to receive(:add_breadcrumb).with('Home', Hyrax::Engine.routes.url_helpers.root_path) - expect(controller).to receive(:add_breadcrumb).with('Dashboard', Hyrax::Engine.routes.url_helpers.dashboard_path) - expect(controller).to receive(:add_breadcrumb).with('Collections', Hyrax::Engine.routes.url_helpers.my_collections_path) - expect(controller).to receive(:add_breadcrumb).with('My collection', collection_path(collection.id), { "aria-current" => "page" }) + expect(controller).to receive(:add_breadcrumb).with('Home', Hyrax::Engine.routes.url_helpers.root_path(locale: 'en')) + expect(controller).to receive(:add_breadcrumb).with('Dashboard', Hyrax::Engine.routes.url_helpers.dashboard_path(locale: 'en')) + expect(controller).to receive(:add_breadcrumb).with('Collections', Hyrax::Engine.routes.url_helpers.my_collections_path(locale: 'en')) + expect(controller).to receive(:add_breadcrumb).with('My collection', collection_path(collection.id, locale: 'en'), { "aria-current" => "page" }) get :show, params: { id: collection } expect(response).to be_successful expect(response).to render_template("layouts/hyrax/1_column") @@ -77,10 +77,10 @@ context "without a referer" do it "sets breadcrumbs" do - expect(controller).to receive(:add_breadcrumb).with('Home', Hyrax::Engine.routes.url_helpers.root_path) - expect(controller).to receive(:add_breadcrumb).with('Dashboard', Hyrax::Engine.routes.url_helpers.dashboard_path) - expect(controller).to receive(:add_breadcrumb).with('Collections', Hyrax::Engine.routes.url_helpers.my_collections_path) - expect(controller).to receive(:add_breadcrumb).with('My collection', collection_path(collection.id), { "aria-current" => "page" }) + expect(controller).to receive(:add_breadcrumb).with('Home', Hyrax::Engine.routes.url_helpers.root_path(locale: 'en')) + expect(controller).to receive(:add_breadcrumb).with('Dashboard', Hyrax::Engine.routes.url_helpers.dashboard_path(locale: 'en')) + expect(controller).to receive(:add_breadcrumb).with('Collections', Hyrax::Engine.routes.url_helpers.my_collections_path(locale: 'en')) + expect(controller).to receive(:add_breadcrumb).with('My collection', collection_path(collection.id, locale: 'en'), { "aria-current" => "page" }) get :show, params: { id: collection } expect(response).to be_successful end @@ -92,10 +92,10 @@ end it "sets breadcrumbs" do - expect(controller).to receive(:add_breadcrumb).with('Home', Hyrax::Engine.routes.url_helpers.root_path) - expect(controller).to receive(:add_breadcrumb).with('Dashboard', Hyrax::Engine.routes.url_helpers.dashboard_path) - expect(controller).to receive(:add_breadcrumb).with('Collections', Hyrax::Engine.routes.url_helpers.my_collections_path) - expect(controller).to receive(:add_breadcrumb).with('My collection', collection_path(collection.id), { "aria-current" => "page" }) + expect(controller).to receive(:add_breadcrumb).with('Home', Hyrax::Engine.routes.url_helpers.root_path(locale: 'en')) + expect(controller).to receive(:add_breadcrumb).with('Dashboard', Hyrax::Engine.routes.url_helpers.dashboard_path(locale: 'en')) + expect(controller).to receive(:add_breadcrumb).with('Collections', Hyrax::Engine.routes.url_helpers.my_collections_path(locale: 'en')) + expect(controller).to receive(:add_breadcrumb).with('My collection', collection_path(collection.id, locale: 'en'), { "aria-current" => "page" }) get :show, params: { id: collection } expect(response).to be_successful end @@ -112,9 +112,9 @@ context "without a referer" do it "sets breadcrumbs" do - expect(controller).not_to receive(:add_breadcrumb).with(I18n.t('hyrax.dashboard.title'), Hyrax::Engine.routes.url_helpers.dashboard_path) - expect(controller).not_to receive(:add_breadcrumb).with('Your Collections', Hyrax::Engine.routes.url_helpers.my_collections_path) - expect(controller).not_to receive(:add_breadcrumb).with('My collection', collection_path(collection.id)) + expect(controller).not_to receive(:add_breadcrumb).with(I18n.t('hyrax.dashboard.title'), Hyrax::Engine.routes.url_helpers.dashboard_path(locale: 'en')) + expect(controller).not_to receive(:add_breadcrumb).with('Your Collections', Hyrax::Engine.routes.url_helpers.my_collections_path(locale: 'en')) + expect(controller).not_to receive(:add_breadcrumb).with('My collection', collection_path(collection.id, locale: 'en')) get :show, params: { id: collection } expect(response).to be_successful @@ -127,9 +127,9 @@ end it "sets breadcrumbs" do - expect(controller).not_to receive(:add_breadcrumb).with(I18n.t('hyrax.dashboard.title'), Hyrax::Engine.routes.url_helpers.dashboard_path) - expect(controller).not_to receive(:add_breadcrumb).with('Your Collections', Hyrax::Engine.routes.url_helpers.my_collections_path) - expect(controller).to receive(:add_breadcrumb).with('My collection', collection_path(collection.id), { "aria-current" => "page" }) + expect(controller).not_to receive(:add_breadcrumb).with(I18n.t('hyrax.dashboard.title'), Hyrax::Engine.routes.url_helpers.dashboard_path(locale: 'en')) + expect(controller).not_to receive(:add_breadcrumb).with('Your Collections', Hyrax::Engine.routes.url_helpers.my_collections_path(locale: 'en')) + expect(controller).to receive(:add_breadcrumb).with('My collection', collection_path(collection.id, locale: 'en'), { "aria-current" => "page" }) get :show, params: { id: collection } expect(response).to be_successful end diff --git a/spec/controllers/hyrax/dashboard/collection_members_controller_spec.rb b/spec/controllers/hyrax/dashboard/collection_members_controller_spec.rb index ac728e90cd..bf8441e429 100644 --- a/spec/controllers/hyrax/dashboard/collection_members_controller_spec.rb +++ b/spec/controllers/hyrax/dashboard/collection_members_controller_spec.rb @@ -84,7 +84,7 @@ post :update_members, params: parameters expect(response) - .to redirect_to routes.url_helpers.dashboard_collection_path(collection) + .to redirect_to routes.url_helpers.dashboard_collection_path(collection, locale: 'en') end end @@ -153,7 +153,7 @@ post(:update_members, params: parameters) expect(response) - .to redirect_to routes.url_helpers.dashboard_collection_path(collection) + .to redirect_to routes.url_helpers.dashboard_collection_path(collection, locale: 'en') end end @@ -199,7 +199,7 @@ post(:update_members, params: parameters) expect(flash[:alert]).to eq 'You do not have sufficient privileges to any of the selected members' - expect(response).to redirect_to routes.url_helpers.dashboard_collections_path + expect(response).to redirect_to routes.url_helpers.dashboard_collections_path(locale: 'en') end end end @@ -234,7 +234,7 @@ post :update_members, params: parameters expect(response) - .to redirect_to routes.url_helpers.dashboard_collection_path(collection) + .to redirect_to routes.url_helpers.dashboard_collection_path(collection, locale: 'en') end end @@ -303,7 +303,7 @@ post(:update_members, params: parameters) expect(response) - .to redirect_to routes.url_helpers.dashboard_collection_path(collection) + .to redirect_to routes.url_helpers.dashboard_collection_path(collection, locale: 'en') end end @@ -349,7 +349,7 @@ post(:update_members, params: parameters) expect(flash[:alert]).to eq 'You do not have sufficient privileges to any of the selected members' - expect(response).to redirect_to routes.url_helpers.dashboard_collections_path + expect(response).to redirect_to routes.url_helpers.dashboard_collections_path(locale: 'en') end end end @@ -463,7 +463,7 @@ expect(flash[:alert]) .to eq 'You do not have sufficient privileges to any of the selected members' expect(response) - .to redirect_to routes.url_helpers.dashboard_collections_path + .to redirect_to routes.url_helpers.dashboard_collections_path(locale: 'en') end end end @@ -485,7 +485,7 @@ expect(flash[:alert]) .to eq 'You do not have sufficient privileges to add members to the collection' expect(response) - .to redirect_to routes.url_helpers.dashboard_collections_path + .to redirect_to routes.url_helpers.dashboard_collections_path(locale: 'en') end end @@ -541,7 +541,7 @@ #{other_collection_of_type.title.first.gsub(' ', '\s')})}x expect(response) - .to redirect_to routes.url_helpers.dashboard_collection_path(collection) + .to redirect_to routes.url_helpers.dashboard_collection_path(collection, locale: 'en') end end end diff --git a/spec/controllers/hyrax/dashboard/collections_controller_spec.rb b/spec/controllers/hyrax/dashboard/collections_controller_spec.rb index 60a4439348..da829a1722 100644 --- a/spec/controllers/hyrax/dashboard/collections_controller_spec.rb +++ b/spec/controllers/hyrax/dashboard/collections_controller_spec.rb @@ -304,7 +304,7 @@ .to change { queries.find_members_of(collection: collection).map(&:id) } .to contain_exactly(asset1.id, asset2.id, asset3.id) - expect(response).to redirect_to routes.url_helpers.edit_dashboard_collection_path(collection) + expect(response).to redirect_to routes.url_helpers.edit_dashboard_collection_path(collection, locale: 'en') end it "adds members to the collection from other than the edit form" do @@ -315,7 +315,7 @@ .to change { queries.find_members_of(collection: collection).map(&:id) } .to contain_exactly(asset1.id, asset2.id, asset3.id) - expect(response).to redirect_to routes.url_helpers.dashboard_collection_path(collection) + expect(response).to redirect_to routes.url_helpers.dashboard_collection_path(collection, locale: 'en') end it "removes members from the collection" do @@ -616,16 +616,16 @@ it "returns the collection and its members" do expect(controller) .to receive(:add_breadcrumb) - .with('Home', Hyrax::Engine.routes.url_helpers.root_path) + .with('Home', Hyrax::Engine.routes.url_helpers.root_path(locale: 'en')) expect(controller) .to receive(:add_breadcrumb) - .with('Dashboard', Hyrax::Engine.routes.url_helpers.dashboard_path) + .with('Dashboard', Hyrax::Engine.routes.url_helpers.dashboard_path(locale: 'en')) expect(controller) .to receive(:add_breadcrumb) - .with('Collections', Hyrax::Engine.routes.url_helpers.my_collections_path) + .with('Collections', Hyrax::Engine.routes.url_helpers.my_collections_path(locale: 'en')) expect(controller) .to receive(:add_breadcrumb) - .with('My collection', collection_path(collection.id), { "aria-current" => "page" }) + .with('My collection', collection_path(collection.id, locale: 'en'), { "aria-current" => "page" }) get :show, params: { id: collection } @@ -661,10 +661,10 @@ context "without a referer" do it "sets breadcrumbs" do - expect(controller).to receive(:add_breadcrumb).with('Home', Hyrax::Engine.routes.url_helpers.root_path) - expect(controller).to receive(:add_breadcrumb).with('Dashboard', Hyrax::Engine.routes.url_helpers.dashboard_path) - expect(controller).to receive(:add_breadcrumb).with('Collections', Hyrax::Engine.routes.url_helpers.my_collections_path) - expect(controller).to receive(:add_breadcrumb).with('My collection', collection_path(collection.id), { "aria-current" => "page" }) + expect(controller).to receive(:add_breadcrumb).with('Home', Hyrax::Engine.routes.url_helpers.root_path(locale: 'en')) + expect(controller).to receive(:add_breadcrumb).with('Dashboard', Hyrax::Engine.routes.url_helpers.dashboard_path(locale: 'en')) + expect(controller).to receive(:add_breadcrumb).with('Collections', Hyrax::Engine.routes.url_helpers.my_collections_path(locale: 'en')) + expect(controller).to receive(:add_breadcrumb).with('My collection', collection_path(collection.id, locale: 'en'), { "aria-current" => "page" }) get :show, params: { id: collection } expect(response).to be_successful end @@ -676,10 +676,10 @@ end it "sets breadcrumbs" do - expect(controller).to receive(:add_breadcrumb).with('Home', Hyrax::Engine.routes.url_helpers.root_path) - expect(controller).to receive(:add_breadcrumb).with('Dashboard', Hyrax::Engine.routes.url_helpers.dashboard_path) - expect(controller).to receive(:add_breadcrumb).with('Collections', Hyrax::Engine.routes.url_helpers.my_collections_path) - expect(controller).to receive(:add_breadcrumb).with('My collection', collection_path(collection.id), { "aria-current" => "page" }) + expect(controller).to receive(:add_breadcrumb).with('Home', Hyrax::Engine.routes.url_helpers.root_path(locale: 'en')) + expect(controller).to receive(:add_breadcrumb).with('Dashboard', Hyrax::Engine.routes.url_helpers.dashboard_path(locale: 'en')) + expect(controller).to receive(:add_breadcrumb).with('Collections', Hyrax::Engine.routes.url_helpers.my_collections_path(locale: 'en')) + expect(controller).to receive(:add_breadcrumb).with('My collection', collection_path(collection.id, locale: 'en'), { "aria-current" => "page" }) get :show, params: { id: collection } expect(response).to be_successful end @@ -727,7 +727,7 @@ delete :destroy, params: { id: collection } expect(response).to have_http_status(:found) - expect(response).to redirect_to(Hyrax::Engine.routes.url_helpers.my_collections_path) + expect(response).to redirect_to(Hyrax::Engine.routes.url_helpers.my_collections_path(locale: 'en')) expect(flash[:notice]).to eq "Collection was successfully deleted" end @@ -776,10 +776,10 @@ context "without a referer" do it "sets breadcrumbs" do - expect(controller).to receive(:add_breadcrumb).with('Home', Hyrax::Engine.routes.url_helpers.root_path) - expect(controller).to receive(:add_breadcrumb).with('Dashboard', Hyrax::Engine.routes.url_helpers.dashboard_path) - expect(controller).to receive(:add_breadcrumb).with('Collections', Hyrax::Engine.routes.url_helpers.my_collections_path) - expect(controller).to receive(:add_breadcrumb).with(I18n.t("hyrax.collection.edit_view"), collection_path(collection.id), { "aria-current" => "page" }) + expect(controller).to receive(:add_breadcrumb).with('Home', Hyrax::Engine.routes.url_helpers.root_path(locale: 'en')) + expect(controller).to receive(:add_breadcrumb).with('Dashboard', Hyrax::Engine.routes.url_helpers.dashboard_path(locale: 'en')) + expect(controller).to receive(:add_breadcrumb).with('Collections', Hyrax::Engine.routes.url_helpers.my_collections_path(locale: 'en')) + expect(controller).to receive(:add_breadcrumb).with(I18n.t("hyrax.collection.edit_view"), collection_path(collection.id, locale: 'en'), { "aria-current" => "page" }) get :edit, params: { id: collection } expect(response).to be_successful end @@ -789,10 +789,10 @@ before { request.env['HTTP_REFERER'] = 'http://test.host/foo' } it "sets breadcrumbs" do - expect(controller).to receive(:add_breadcrumb).with('Home', Hyrax::Engine.routes.url_helpers.root_path) - expect(controller).to receive(:add_breadcrumb).with('Dashboard', Hyrax::Engine.routes.url_helpers.dashboard_path) - expect(controller).to receive(:add_breadcrumb).with('Collections', Hyrax::Engine.routes.url_helpers.my_collections_path) - expect(controller).to receive(:add_breadcrumb).with(I18n.t("hyrax.collection.edit_view"), collection_path(collection.id), { "aria-current" => "page" }) + expect(controller).to receive(:add_breadcrumb).with('Home', Hyrax::Engine.routes.url_helpers.root_path(locale: 'en')) + expect(controller).to receive(:add_breadcrumb).with('Dashboard', Hyrax::Engine.routes.url_helpers.dashboard_path(locale: 'en')) + expect(controller).to receive(:add_breadcrumb).with('Collections', Hyrax::Engine.routes.url_helpers.my_collections_path(locale: 'en')) + expect(controller).to receive(:add_breadcrumb).with(I18n.t("hyrax.collection.edit_view"), collection_path(collection.id, locale: 'en'), { "aria-current" => "page" }) get :edit, params: { id: collection } @@ -826,9 +826,9 @@ end it "sets breadcrumbs" do - expect(controller).to receive(:add_breadcrumb).with('Home', root_path) - expect(controller).to receive(:add_breadcrumb).with('Dashboard', dashboard_path) - expect(controller).to receive(:add_breadcrumb).with('Collections', my_collections_path) + expect(controller).to receive(:add_breadcrumb).with('Home', root_path(locale: 'en')) + expect(controller).to receive(:add_breadcrumb).with('Dashboard', dashboard_path(locale: 'en')) + expect(controller).to receive(:add_breadcrumb).with('Collections', my_collections_path(locale: 'en')) get :index, params: { per_page: 1 } end end diff --git a/spec/controllers/hyrax/dashboard/profiles_controller_spec.rb b/spec/controllers/hyrax/dashboard/profiles_controller_spec.rb index ee278164f4..a58a371f8f 100644 --- a/spec/controllers/hyrax/dashboard/profiles_controller_spec.rb +++ b/spec/controllers/hyrax/dashboard/profiles_controller_spec.rb @@ -47,7 +47,7 @@ it "allows user to edit another user's profile" do get :edit, params: { id: another_user.to_param } expect(response).to be_successful - expect(response).not_to redirect_to(routes.url_helpers.dashboard_profile_path(another_user.to_param)) + expect(response).not_to redirect_to(routes.url_helpers.dashboard_profile_path(another_user.to_param, locale: 'en')) expect(flash[:alert]).to be_nil end end @@ -85,7 +85,7 @@ expect(UserEditProfileEventJob).to receive(:perform_later).with(user) f = fixture_file_upload('/1.5mb-avatar.jpg', 'image/jpg') post :update, params: { id: user.user_key, user: { avatar: f } } - expect(response).to redirect_to(routes.url_helpers.dashboard_profile_path(user.to_param)) + expect(response).to redirect_to(routes.url_helpers.dashboard_profile_path(user.to_param, locale: 'en')) expect(flash[:notice]).to include("Your profile has been updated") expect(User.find_by_user_key(user.user_key).avatar?).to be true end @@ -93,14 +93,14 @@ expect(UserEditProfileEventJob).to receive(:perform_later).never f = fixture_file_upload('/image.jp2', 'image/jp2') post :update, params: { id: user.user_key, user: { avatar: f } } - expect(response).to redirect_to(routes.url_helpers.edit_dashboard_profile_path(user.to_param)) + expect(response).to redirect_to(routes.url_helpers.edit_dashboard_profile_path(user.to_param, locale: 'en')) expect(flash[:alert]).to include("Avatar You are not allowed to upload \"jp2\" files, allowed types: jpg, jpeg, png, gif, bmp, tif, tiff") end it "validates the size of an avatar" do f = fixture_file_upload('/4-20.png', 'image/png') expect(UserEditProfileEventJob).to receive(:perform_later).never post :update, params: { id: user.user_key, user: { avatar: f } } - expect(response).to redirect_to(routes.url_helpers.edit_dashboard_profile_path(user.to_param)) + expect(response).to redirect_to(routes.url_helpers.edit_dashboard_profile_path(user.to_param, locale: 'en')) expect(flash[:alert]).to include("Avatar file size must be less than 2MB") end @@ -113,7 +113,7 @@ it "deletes an avatar" do expect(UserEditProfileEventJob).to receive(:perform_later).with(user) post :update, params: { id: user.user_key, user: { remove_avatar: 'true' } } - expect(response).to redirect_to(routes.url_helpers.dashboard_profile_path(user.to_param)) + expect(response).to redirect_to(routes.url_helpers.dashboard_profile_path(user.to_param, locale: 'en')) expect(flash[:notice]).to include("Your profile has been updated") expect(User.find_by_user_key(user.user_key).avatar?).to be false end @@ -121,7 +121,7 @@ it "sets an social handles" do post :update, params: { id: user.user_key, user: { twitter_handle: 'twit', facebook_handle: 'face', linkedin_handle: "link", orcid: '0000-0000-1111-2222' } } - expect(response).to redirect_to(routes.url_helpers.dashboard_profile_path(user.to_param)) + expect(response).to redirect_to(routes.url_helpers.dashboard_profile_path(user.to_param, locale: 'en')) expect(flash[:notice]).to include("Your profile has been updated") u = User.find_by_user_key(user.user_key) expect(u.twitter_handle).to eq 'twit' @@ -133,7 +133,7 @@ it 'displays a flash when invalid ORCID is entered' do expect(user.orcid).to be_blank post :update, params: { id: user.user_key, user: { orcid: 'foobar' } } - expect(response).to redirect_to(routes.url_helpers.edit_dashboard_profile_path(user.to_param)) + expect(response).to redirect_to(routes.url_helpers.edit_dashboard_profile_path(user.to_param, locale: 'en')) expect(flash[:alert]).to include('Orcid must be a string of 19 characters, e.g., "0000-0000-0000-0000"') end @@ -147,7 +147,7 @@ expect do post :update, params: { id: user.user_key, 'remove_trophy_' + work.id => 'yes' } end.to change { user.trophies.count }.by(-1) - expect(response).to redirect_to(routes.url_helpers.dashboard_profile_path(user.to_param)) + expect(response).to redirect_to(routes.url_helpers.dashboard_profile_path(user.to_param, locale: 'en')) expect(flash[:notice]).to include("Your profile has been updated") end end diff --git a/spec/controllers/hyrax/dashboard/works_controller_spec.rb b/spec/controllers/hyrax/dashboard/works_controller_spec.rb index 3a67c54445..2175881d46 100644 --- a/spec/controllers/hyrax/dashboard/works_controller_spec.rb +++ b/spec/controllers/hyrax/dashboard/works_controller_spec.rb @@ -9,6 +9,6 @@ describe "#search_facet_path" do subject { controller.send(:search_facet_path, id: 'keyword_sim') } - it { is_expected.to eq "/dashboard/works/facet/keyword_sim" } + it { is_expected.to eq "/dashboard/works/facet/keyword_sim?locale=en" } end end diff --git a/spec/controllers/hyrax/file_sets_controller_spec.rb b/spec/controllers/hyrax/file_sets_controller_spec.rb index 45e8084fdf..94c9ff8fc7 100644 --- a/spec/controllers/hyrax/file_sets_controller_spec.rb +++ b/spec/controllers/hyrax/file_sets_controller_spec.rb @@ -31,7 +31,7 @@ .from(true) .to(false) - expect(response).to redirect_to main_app.hyrax_generic_work_path(work) + expect(response).to redirect_to main_app.hyrax_generic_work_path(work, locale: 'en') end end end @@ -58,16 +58,16 @@ expect(controller) .to receive(:add_breadcrumb) - .with('Home', Hyrax::Engine.routes.url_helpers.root_path) + .with('Home', Hyrax::Engine.routes.url_helpers.root_path(locale: 'en')) expect(controller) .to receive(:add_breadcrumb) - .with(I18n.t('hyrax.dashboard.title'), engine_helpers.dashboard_path) + .with(I18n.t('hyrax.dashboard.title'), engine_helpers.dashboard_path(locale: 'en')) expect(controller) .to receive(:add_breadcrumb) - .with(I18n.t('hyrax.dashboard.my.works'), engine_helpers.my_works_path) + .with(I18n.t('hyrax.dashboard.my.works'), engine_helpers.my_works_path(locale: 'en')) expect(controller) .to receive(:add_breadcrumb) - .with(I18n.t('hyrax.file_set.browse_view'), app_helpers.hyrax_file_set_path(file_set)) + .with(I18n.t('hyrax.file_set.browse_view'), app_helpers.hyrax_file_set_path(file_set, locale: 'en')) get :edit, params: { id: file_set } @@ -110,7 +110,7 @@ end.to have_enqueued_job(ContentUpdateEventJob).exactly(:once) expect(response) - .to redirect_to main_app.hyrax_file_set_path(file_set) + .to redirect_to main_app.hyrax_file_set_path(file_set, locale: 'en') expect(assigns[:file_set].modified_date) .not_to be file_set.modified_date end @@ -330,11 +330,11 @@ end it "shows me the file and set breadcrumbs" do - expect(controller).to receive(:add_breadcrumb).with('Home', Hyrax::Engine.routes.url_helpers.root_path) - expect(controller).to receive(:add_breadcrumb).with('Dashboard', Hyrax::Engine.routes.url_helpers.dashboard_path) - expect(controller).to receive(:add_breadcrumb).with('Works', Hyrax::Engine.routes.url_helpers.my_works_path) - expect(controller).to receive(:add_breadcrumb).with('test title', main_app.hyrax_generic_work_path(work.id)) - expect(controller).to receive(:add_breadcrumb).with('test file', main_app.hyrax_file_set_path(file_set)) + expect(controller).to receive(:add_breadcrumb).with('Home', Hyrax::Engine.routes.url_helpers.root_path(locale: 'en')) + expect(controller).to receive(:add_breadcrumb).with('Dashboard', Hyrax::Engine.routes.url_helpers.dashboard_path(locale: 'en')) + expect(controller).to receive(:add_breadcrumb).with('Works', Hyrax::Engine.routes.url_helpers.my_works_path(locale: 'en')) + expect(controller).to receive(:add_breadcrumb).with('test title', main_app.hyrax_generic_work_path(work.id, locale: 'en')) + expect(controller).to receive(:add_breadcrumb).with('test file', main_app.hyrax_file_set_path(file_set, locale: 'en')) get :show, params: { id: file_set } expect(response).to be_successful expect(flash).to be_empty @@ -354,11 +354,11 @@ end it "shows me the breadcrumbs" do - expect(controller).to receive(:add_breadcrumb).with('Home', Hyrax::Engine.routes.url_helpers.root_path) - expect(controller).to receive(:add_breadcrumb).with('Dashboard', Hyrax::Engine.routes.url_helpers.dashboard_path) - expect(controller).to receive(:add_breadcrumb).with('Works', Hyrax::Engine.routes.url_helpers.my_works_path) - expect(controller).to receive(:add_breadcrumb).with('test title', main_app.hyrax_generic_work_path(work.id)) - expect(controller).to receive(:add_breadcrumb).with('test file', main_app.hyrax_file_set_path(file_set)) + expect(controller).to receive(:add_breadcrumb).with('Home', Hyrax::Engine.routes.url_helpers.root_path(locale: 'en')) + expect(controller).to receive(:add_breadcrumb).with('Dashboard', Hyrax::Engine.routes.url_helpers.dashboard_path(locale: 'en')) + expect(controller).to receive(:add_breadcrumb).with('Works', Hyrax::Engine.routes.url_helpers.my_works_path(locale: 'en')) + expect(controller).to receive(:add_breadcrumb).with('test title', main_app.hyrax_generic_work_path(work.id, locale: 'en')) + expect(controller).to receive(:add_breadcrumb).with('test file', main_app.hyrax_file_set_path(file_set, locale: 'en')) get :show, params: { id: file_set } expect(response).to be_successful end @@ -447,7 +447,7 @@ get :show, params: { id: private_file_set } expect(response) - .to fail_redirect_and_flash(main_app.new_user_session_path, + .to fail_redirect_and_flash(main_app.new_user_session_path(locale: 'en'), 'You are not authorized to access this page.') end @@ -586,16 +586,16 @@ expect(controller) .to receive(:add_breadcrumb) - .with('Home', Hyrax::Engine.routes.url_helpers.root_path) + .with('Home', Hyrax::Engine.routes.url_helpers.root_path(locale: 'en')) expect(controller) .to receive(:add_breadcrumb) - .with(I18n.t('hyrax.dashboard.title'), engine_helpers.dashboard_path) + .with(I18n.t('hyrax.dashboard.title'), engine_helpers.dashboard_path(locale: 'en')) expect(controller) .to receive(:add_breadcrumb) - .with(I18n.t('hyrax.dashboard.my.works'), engine_helpers.my_works_path) + .with(I18n.t('hyrax.dashboard.my.works'), engine_helpers.my_works_path(locale: 'en')) expect(controller) .to receive(:add_breadcrumb) - .with(I18n.t('hyrax.file_set.browse_view'), app_helpers.hyrax_file_set_path(file_set)) + .with(I18n.t('hyrax.file_set.browse_view'), app_helpers.hyrax_file_set_path(file_set, locale: 'en')) get :edit, params: { id: file_set } @@ -783,13 +783,13 @@ describe "#show" do context "without a referer" do it "shows me the file and set breadcrumbs" do - expect(controller).to receive(:add_breadcrumb).with('Home', Hyrax::Engine.routes.url_helpers.root_path) - expect(controller).to receive(:add_breadcrumb).with('Dashboard', Hyrax::Engine.routes.url_helpers.dashboard_path) - expect(controller).to receive(:add_breadcrumb).with('Works', Hyrax::Engine.routes.url_helpers.my_works_path) - expect(controller).to receive(:add_breadcrumb).with('test title', main_app.hyrax_generic_work_path(work.id)) - expect(controller).to receive(:add_breadcrumb).with('image.jp2', main_app.hyrax_file_set_path(file_set)) + expect(controller).to receive(:add_breadcrumb).with('Home', Hyrax::Engine.routes.url_helpers.root_path(locale: 'en')) + expect(controller).to receive(:add_breadcrumb).with('Dashboard', Hyrax::Engine.routes.url_helpers.dashboard_path(locale: 'en')) + expect(controller).to receive(:add_breadcrumb).with('Works', Hyrax::Engine.routes.url_helpers.my_works_path(locale: 'en')) + expect(controller).to receive(:add_breadcrumb).with('test title', main_app.hyrax_generic_work_path(work.id, locale: 'en')) + expect(controller).to receive(:add_breadcrumb).with('image.jp2', main_app.hyrax_file_set_path(file_set, locale: 'en')) allow(controller.main_app).to receive(:polymorphic_path).and_call_original - allow(controller.main_app).to receive(:polymorphic_path).with(instance_of(Hyrax::WorkShowPresenter)).and_return("/concern/generic_works/#{work.id}") + allow(controller.main_app).to receive(:polymorphic_path).with(instance_of(Hyrax::WorkShowPresenter)).and_return("/concern/generic_works/#{work.id}?locale=en") get :show, params: { id: file_set } expect(response).to be_successful expect(flash).to be_empty @@ -806,13 +806,13 @@ end it "shows me the breadcrumbs" do - expect(controller).to receive(:add_breadcrumb).with('Home', Hyrax::Engine.routes.url_helpers.root_path) - expect(controller).to receive(:add_breadcrumb).with('Dashboard', Hyrax::Engine.routes.url_helpers.dashboard_path) - expect(controller).to receive(:add_breadcrumb).with('Works', Hyrax::Engine.routes.url_helpers.my_works_path) - expect(controller).to receive(:add_breadcrumb).with('test title', main_app.hyrax_generic_work_path(work.id)) - expect(controller).to receive(:add_breadcrumb).with('image.jp2', main_app.hyrax_file_set_path(file_set)) + expect(controller).to receive(:add_breadcrumb).with('Home', Hyrax::Engine.routes.url_helpers.root_path(locale: 'en')) + expect(controller).to receive(:add_breadcrumb).with('Dashboard', Hyrax::Engine.routes.url_helpers.dashboard_path(locale: 'en')) + expect(controller).to receive(:add_breadcrumb).with('Works', Hyrax::Engine.routes.url_helpers.my_works_path(locale: 'en')) + expect(controller).to receive(:add_breadcrumb).with('test title', main_app.hyrax_generic_work_path(work.id, locale: 'en')) + expect(controller).to receive(:add_breadcrumb).with('image.jp2', main_app.hyrax_file_set_path(file_set, locale: 'en')) allow(controller.main_app).to receive(:polymorphic_path).and_call_original - allow(controller.main_app).to receive(:polymorphic_path).with(instance_of(Hyrax::WorkShowPresenter)).and_return("/concern/generic_works/#{work.id}") + allow(controller.main_app).to receive(:polymorphic_path).with(instance_of(Hyrax::WorkShowPresenter)).and_return("/concern/generic_works/#{work.id}?locale=en") get :show, params: { id: file_set } expect(response).to be_successful end @@ -847,7 +847,7 @@ describe '#show' do it 'allows access to the file' do allow(controller.main_app).to receive(:polymorphic_path).and_call_original - allow(controller.main_app).to receive(:polymorphic_path).with(instance_of(Hyrax::WorkShowPresenter)).and_return("/concern/generic_works/#{work.id}") + allow(controller.main_app).to receive(:polymorphic_path).with(instance_of(Hyrax::WorkShowPresenter)).and_return("/concern/generic_works/#{work.id}?locale=en") get :show, params: { id: file_set } @@ -868,7 +868,7 @@ let(:query_service) { Hyrax.query_service } before do allow(controller.main_app).to receive(:polymorphic_path).and_call_original - allow(controller.main_app).to receive(:polymorphic_path).with(instance_of(Hyrax::WorkShowPresenter)).and_return("/concern/generic_works/#{public_work.id}") + allow(controller.main_app).to receive(:polymorphic_path).with(instance_of(Hyrax::WorkShowPresenter)).and_return("/concern/generic_works/#{public_work.id}?locale=en") allow(controller) .to receive(:additional_response_formats) .with(ActionController::MimeResponds::Collector) @@ -889,7 +889,7 @@ get :show, params: { id: private_file_set } expect(response) - .to fail_redirect_and_flash(main_app.new_user_session_path, + .to fail_redirect_and_flash(main_app.new_user_session_path(locale: 'en'), 'You are not authorized to access this page.') end @@ -919,7 +919,7 @@ .to receive(:additional_response_formats) .with(ActionController::MimeResponds::Collector) allow(controller.main_app).to receive(:polymorphic_path).and_call_original - allow(controller.main_app).to receive(:polymorphic_path).with(instance_of(Hyrax::WorkShowPresenter)).and_return("/concern/generic_works/#{active_work.id}") + allow(controller.main_app).to receive(:polymorphic_path).with(instance_of(Hyrax::WorkShowPresenter)).and_return("/concern/generic_works/#{active_work.id}?locale=en") end it "shows active parent" do get :show, params: { id: active_file_set } diff --git a/spec/controllers/hyrax/generic_works_controller_json_spec.rb b/spec/controllers/hyrax/generic_works_controller_json_spec.rb index 3b271e6b15..c32656e3da 100644 --- a/spec/controllers/hyrax/generic_works_controller_json_spec.rb +++ b/spec/controllers/hyrax/generic_works_controller_json_spec.rb @@ -47,7 +47,7 @@ expect(assigns[:curation_concern]).to be_instance_of GenericWork expect(controller).to render_template('hyrax/base/show') expect(response.code).to eq "201" - expect(response.location).to eq main_app.hyrax_generic_work_path(model) + expect(response.location).to eq main_app.hyrax_generic_work_path(model, locale: 'en') end end @@ -82,7 +82,7 @@ expect(controller).to render_template('hyrax/base/show') expect(response.code).to eq "200" created_resource = assigns[:curation_concern] - expect(response.location).to eq main_app.hyrax_generic_work_path(created_resource) + expect(response.location).to eq main_app.hyrax_generic_work_path(created_resource, locale: 'en') end end diff --git a/spec/controllers/hyrax/generic_works_controller_spec.rb b/spec/controllers/hyrax/generic_works_controller_spec.rb index 3dc2f6f088..43c889feea 100644 --- a/spec/controllers/hyrax/generic_works_controller_spec.rb +++ b/spec/controllers/hyrax/generic_works_controller_spec.rb @@ -58,10 +58,10 @@ context "without a referer" do it "sets breadcrumbs with complete path" do - expect(controller).to receive(:add_breadcrumb).with('Home', main_app.root_path) - expect(controller).not_to receive(:add_breadcrumb).with('Dashboard', hyrax.dashboard_path) - expect(controller).not_to receive(:add_breadcrumb).with('Your Works', hyrax.my_works_path) - expect(controller).to receive(:add_breadcrumb).with('public thing', main_app.hyrax_generic_work_path(work.id)) + expect(controller).to receive(:add_breadcrumb).with('Home', main_app.root_path(locale: 'en')) + expect(controller).not_to receive(:add_breadcrumb).with('Dashboard', hyrax.dashboard_path(locale: 'en')) + expect(controller).not_to receive(:add_breadcrumb).with('Your Works', hyrax.my_works_path(locale: 'en')) + expect(controller).to receive(:add_breadcrumb).with('public thing', main_app.hyrax_generic_work_path(work.id, locale: 'en')) get :show, params: { id: work } expect(response).to be_successful expect(response).to render_template("layouts/hyrax/1_column") @@ -74,10 +74,10 @@ end it "sets breadcrumbs to authorized pages" do - expect(controller).to receive(:add_breadcrumb).with('Home', main_app.root_path) - expect(controller).not_to receive(:add_breadcrumb).with('Dashboard', hyrax.dashboard_path) - expect(controller).not_to receive(:add_breadcrumb).with('Your Works', hyrax.my_works_path) - expect(controller).to receive(:add_breadcrumb).with('public thing', main_app.hyrax_generic_work_path(work.id)) + expect(controller).to receive(:add_breadcrumb).with('Home', main_app.root_path(locale: 'en')) + expect(controller).not_to receive(:add_breadcrumb).with('Dashboard', hyrax.dashboard_path(locale: 'en')) + expect(controller).not_to receive(:add_breadcrumb).with('Your Works', hyrax.my_works_path(locale: 'en')) + expect(controller).to receive(:add_breadcrumb).with('public thing', main_app.hyrax_generic_work_path(work.id, locale: 'en')) get :show, params: { id: work } expect(response).to be_successful expect(response).to render_template("layouts/hyrax/1_column") @@ -96,10 +96,10 @@ context "without a referer" do it "sets breadcrumbs" do - expect(controller).to receive(:add_breadcrumb).with('Home', Hyrax::Engine.routes.url_helpers.root_path) - expect(controller).to receive(:add_breadcrumb).with('Dashboard', hyrax.dashboard_path) - expect(controller).to receive(:add_breadcrumb).with('Works', hyrax.my_works_path) - expect(controller).to receive(:add_breadcrumb).with('test title', main_app.hyrax_generic_work_path(work.id)) + expect(controller).to receive(:add_breadcrumb).with('Home', Hyrax::Engine.routes.url_helpers.root_path(locale: 'en')) + expect(controller).to receive(:add_breadcrumb).with('Dashboard', hyrax.dashboard_path(locale: 'en')) + expect(controller).to receive(:add_breadcrumb).with('Works', hyrax.my_works_path(locale: 'en')) + expect(controller).to receive(:add_breadcrumb).with('test title', main_app.hyrax_generic_work_path(work.id, locale: 'en')) get :show, params: { id: work } expect(response).to be_successful end @@ -111,10 +111,10 @@ end it "sets breadcrumbs" do - expect(controller).to receive(:add_breadcrumb).with('Home', Hyrax::Engine.routes.url_helpers.root_path) - expect(controller).to receive(:add_breadcrumb).with('Dashboard', hyrax.dashboard_path) - expect(controller).to receive(:add_breadcrumb).with('Works', hyrax.my_works_path) - expect(controller).to receive(:add_breadcrumb).with('test title', main_app.hyrax_generic_work_path(work.id)) + expect(controller).to receive(:add_breadcrumb).with('Home', Hyrax::Engine.routes.url_helpers.root_path(locale: 'en')) + expect(controller).to receive(:add_breadcrumb).with('Dashboard', hyrax.dashboard_path(locale: 'en')) + expect(controller).to receive(:add_breadcrumb).with('Works', hyrax.my_works_path(locale: 'en')) + expect(controller).to receive(:add_breadcrumb).with('test title', main_app.hyrax_generic_work_path(work.id, locale: 'en')) get :show, params: { id: work } expect(response).to be_successful expect(response).to render_template("layouts/hyrax/1_column") @@ -284,7 +284,7 @@ it 'creates a work' do allow(controller).to receive(:curation_concern).and_return(work) post :create, params: { generic_work: { title: ['a title'] } } - expect(response).to redirect_to main_app.hyrax_generic_work_path(work) + expect(response).to redirect_to main_app.hyrax_generic_work_path(work, locale: 'en') end end @@ -337,7 +337,7 @@ expect(flash[:notice]).to eq "Your files are being processed by Hyrax in the background. " \ "The metadata and access controls you specified are being applied. " \ "You may need to refresh this page to see these updates." - expect(response).to redirect_to main_app.hyrax_generic_work_path(work) + expect(response).to redirect_to main_app.hyrax_generic_work_path(work, locale: 'en') end context "from browse everything" do @@ -391,7 +391,7 @@ expect(flash[:notice]).to eq "Your files are being processed by Hyrax in the background. " \ "The metadata and access controls you specified are being applied. " \ "You may need to refresh this page to see these updates." - expect(response).to redirect_to main_app.hyrax_generic_work_path(work) + expect(response).to redirect_to main_app.hyrax_generic_work_path(work, locale: 'en') end end end @@ -403,10 +403,10 @@ let(:work) { create(:private_generic_work, user: user) } it 'shows me the page and sets breadcrumbs' do - expect(controller).to receive(:add_breadcrumb).with("Home", root_path) - expect(controller).to receive(:add_breadcrumb).with("Dashboard", hyrax.dashboard_path) - expect(controller).to receive(:add_breadcrumb).with("Works", hyrax.my_works_path) - expect(controller).to receive(:add_breadcrumb).with(work.title.first, main_app.hyrax_generic_work_path(work.id)) + expect(controller).to receive(:add_breadcrumb).with("Home", root_path(locale: 'en')) + expect(controller).to receive(:add_breadcrumb).with("Dashboard", hyrax.dashboard_path(locale: 'en')) + expect(controller).to receive(:add_breadcrumb).with("Works", hyrax.my_works_path(locale: 'en')) + expect(controller).to receive(:add_breadcrumb).with(work.title.first, main_app.hyrax_generic_work_path(work.id, locale: 'en')) expect(controller).to receive(:add_breadcrumb).with('Edit', main_app.edit_hyrax_generic_work_path(work.id)) get :edit, params: { id: work } @@ -459,7 +459,7 @@ context "when the work has no file sets" do it 'updates the work' do patch :update, params: { id: work, generic_work: {} } - expect(response).to redirect_to main_app.hyrax_generic_work_path(work) + expect(response).to redirect_to main_app.hyrax_generic_work_path(work, locale: 'en') end end @@ -469,7 +469,7 @@ end it 'updates the work' do patch :update, params: { id: work, generic_work: {} } - expect(response).to redirect_to main_app.hyrax_generic_work_path(work) + expect(response).to redirect_to main_app.hyrax_generic_work_path(work, locale: 'en') end end @@ -487,14 +487,14 @@ it 'prompts to change the files access' do patch :update, params: { id: work, generic_work: { visibility: 'restricted' } } - expect(response).to redirect_to hyrax.confirm_access_permission_path(controller.curation_concern) + expect(response).to redirect_to hyrax.confirm_access_permission_path(controller.curation_concern, locale: 'en') end end context 'when the work has no file sets' do it "doesn't prompt to change the files access" do patch :update, params: { id: work, generic_work: {} } - expect(response).to redirect_to main_app.hyrax_generic_work_path(work) + expect(response).to redirect_to main_app.hyrax_generic_work_path(work, locale: 'en') end end end @@ -528,7 +528,7 @@ it 'someone elses private work should update the work' do patch :update, params: { id: work, generic_work: {} } - expect(response).to redirect_to main_app.hyrax_generic_work_path(work) + expect(response).to redirect_to main_app.hyrax_generic_work_path(work, locale: 'en') end end end @@ -544,7 +544,7 @@ it 'deletes the work' do delete :destroy, params: { id: work_to_be_deleted } - expect(response).to redirect_to Hyrax::Engine.routes.url_helpers.my_works_path + expect(response).to redirect_to Hyrax::Engine.routes.url_helpers.my_works_path(locale: 'en') expect(GenericWork).not_to exist(work_to_be_deleted.id) end @@ -556,7 +556,7 @@ it 'deletes the work and updates the parent collection' do delete :destroy, params: { id: work_to_be_deleted } expect(GenericWork).not_to exist(work_to_be_deleted.id) - expect(response).to redirect_to Hyrax::Engine.routes.url_helpers.my_works_path + expect(response).to redirect_to Hyrax::Engine.routes.url_helpers.my_works_path(locale: 'en') expect(parent_collection.reload.members).to eq [] end end diff --git a/spec/controllers/hyrax/my/collections_controller_spec.rb b/spec/controllers/hyrax/my/collections_controller_spec.rb index 1c98c5e8e7..d911591bf2 100644 --- a/spec/controllers/hyrax/my/collections_controller_spec.rb +++ b/spec/controllers/hyrax/my/collections_controller_spec.rb @@ -7,9 +7,9 @@ describe "#index" do it "sets breadcrumbs" do - expect(controller).to receive(:add_breadcrumb).with('Home', root_path) - expect(controller).to receive(:add_breadcrumb).with('Dashboard', dashboard_path) - expect(controller).to receive(:add_breadcrumb).with('Collections', my_collections_path) + expect(controller).to receive(:add_breadcrumb).with('Home', root_path(locale: 'en')) + expect(controller).to receive(:add_breadcrumb).with('Dashboard', dashboard_path(locale: 'en')) + expect(controller).to receive(:add_breadcrumb).with('Collections', my_collections_path(locale: 'en')) get :index, params: { per_page: 1 } end @@ -44,7 +44,7 @@ describe "#search_facet_path" do it do expect(controller.send(:search_facet_path, id: 'keyword_sim')) - .to eq "/dashboard/my/collections/facet/keyword_sim" + .to eq "/dashboard/my/collections/facet/keyword_sim?locale=en" end end diff --git a/spec/controllers/hyrax/my/shares_controller_spec.rb b/spec/controllers/hyrax/my/shares_controller_spec.rb index fd687b65ec..62cc69623d 100644 --- a/spec/controllers/hyrax/my/shares_controller_spec.rb +++ b/spec/controllers/hyrax/my/shares_controller_spec.rb @@ -52,6 +52,6 @@ describe "#search_facet_path" do subject { controller.send(:search_facet_path, id: 'keyword_sim') } - it { is_expected.to eq "/dashboard/shares/facet/keyword_sim" } + it { is_expected.to eq "/dashboard/shares/facet/keyword_sim?locale=en" } end end diff --git a/spec/controllers/hyrax/my/works_controller_spec.rb b/spec/controllers/hyrax/my/works_controller_spec.rb index 3fd95263e3..6e7fe54075 100644 --- a/spec/controllers/hyrax/my/works_controller_spec.rb +++ b/spec/controllers/hyrax/my/works_controller_spec.rb @@ -17,9 +17,9 @@ it "shows search results and breadcrumbs" do expect_any_instance_of(Hyrax::SearchService).to receive(:search_results).and_return([response, doc_list]) - expect(controller).to receive(:add_breadcrumb).with('Home', root_path) - expect(controller).to receive(:add_breadcrumb).with('Dashboard', dashboard_path) - expect(controller).to receive(:add_breadcrumb).with('Works', my_works_path) + expect(controller).to receive(:add_breadcrumb).with('Home', root_path(locale: 'en')) + expect(controller).to receive(:add_breadcrumb).with('Dashboard', dashboard_path(locale: 'en')) + expect(controller).to receive(:add_breadcrumb).with('Works', my_works_path(locale: 'en')) expect(collection_service).to receive(:all_search_results).with(:deposit).and_return([my_collection]) get :index, params: { per_page: 2 } expect(assigns[:document_list].length).to eq 2 @@ -50,6 +50,6 @@ describe "#search_facet_path" do subject { controller.send(:search_facet_path, id: 'keyword_sim') } - it { is_expected.to eq "/dashboard/my/works/facet/keyword_sim" } + it { is_expected.to eq "/dashboard/my/works/facet/keyword_sim?locale=en" } end end diff --git a/spec/controllers/hyrax/notifications_controller_spec.rb b/spec/controllers/hyrax/notifications_controller_spec.rb index 5076829ba4..880268e0d2 100644 --- a/spec/controllers/hyrax/notifications_controller_spec.rb +++ b/spec/controllers/hyrax/notifications_controller_spec.rb @@ -28,7 +28,7 @@ it "deletes message" do expect(mock_box).to receive(:destroy).with("4") delete :destroy, params: { id: "4" } - expect(response).to redirect_to(routes.url_helpers.notifications_path) + expect(response).to redirect_to(routes.url_helpers.notifications_path(locale: 'en')) end end end diff --git a/spec/controllers/hyrax/permissions_controller_spec.rb b/spec/controllers/hyrax/permissions_controller_spec.rb index 4476c1c98c..0aa72fc862 100644 --- a/spec/controllers/hyrax/permissions_controller_spec.rb +++ b/spec/controllers/hyrax/permissions_controller_spec.rb @@ -22,7 +22,7 @@ .to have_enqueued_job(VisibilityCopyJob) .with(work) - expect(response).to redirect_to main_app.hyrax_monograph_path(work) + expect(response).to redirect_to main_app.hyrax_monograph_path(work, locale: 'en') expect(flash[:notice]).to eq 'Updating file permissions. This may take a few minutes. You may want to refresh your browser or return to this record later to see the updated file permissions.' end end @@ -35,7 +35,7 @@ .to have_enqueued_job(VisibilityCopyJob) .with(work) - expect(response).to redirect_to main_app.hyrax_monograph_path(work) + expect(response).to redirect_to main_app.hyrax_monograph_path(work, locale: 'en') expect(flash[:notice]).to eq 'Updating file access levels. This may take a few minutes. ' \ 'You may want to refresh your browser or return to this record ' \ 'later to see the updated file access levels.' diff --git a/spec/controllers/hyrax/single_use_links_controller_spec.rb b/spec/controllers/hyrax/single_use_links_controller_spec.rb index 2df267c5a4..24607af6e8 100644 --- a/spec/controllers/hyrax/single_use_links_controller_spec.rb +++ b/spec/controllers/hyrax/single_use_links_controller_spec.rb @@ -27,7 +27,7 @@ it "returns a link for downloading" do post 'create_download', params: { id: file } expect(response).to be_successful - expect(response.body).to eq Hyrax::Engine.routes.url_helpers.download_single_use_link_url(hash, host: request.host) + expect(response.body).to eq Hyrax::Engine.routes.url_helpers.download_single_use_link_url(hash, host: request.host, locale: 'en') end end @@ -35,7 +35,7 @@ it "returns a link for showing" do post 'create_show', params: { id: file } expect(response).to be_successful - expect(response.body).to eq Hyrax::Engine.routes.url_helpers.show_single_use_link_url(hash, host: request.host) + expect(response.body).to eq Hyrax::Engine.routes.url_helpers.show_single_use_link_url(hash, host: request.host, locale: 'en') end end end diff --git a/spec/controllers/hyrax/single_use_links_viewer_controller_spec.rb b/spec/controllers/hyrax/single_use_links_viewer_controller_spec.rb index a8beb415f7..368bce9df8 100644 --- a/spec/controllers/hyrax/single_use_links_viewer_controller_spec.rb +++ b/spec/controllers/hyrax/single_use_links_viewer_controller_spec.rb @@ -13,11 +13,11 @@ describe "retrieval links" do let :show_link do - SingleUseLink.create item_id: file.id, path: Rails.application.routes.url_helpers.hyrax_file_set_path(id: file) + SingleUseLink.create item_id: file.id, path: Rails.application.routes.url_helpers.hyrax_file_set_path(id: file, locale: 'en') end let :download_link do - SingleUseLink.create item_id: file.id, path: Hyrax::Engine.routes.url_helpers.download_path(id: file.id.to_s) + SingleUseLink.create item_id: file.id, path: Hyrax::Engine.routes.url_helpers.download_path(id: file.id.to_s, locale: 'en') end let(:show_link_hash) { show_link.download_key } diff --git a/spec/controllers/hyrax/stats_controller_spec.rb b/spec/controllers/hyrax/stats_controller_spec.rb index ec259dc0f5..224c9f839a 100644 --- a/spec/controllers/hyrax/stats_controller_spec.rb +++ b/spec/controllers/hyrax/stats_controller_spec.rb @@ -17,10 +17,10 @@ def test_loading_file_set_with_user_access # rubocop:disable Metrics/AbcSize expect(Hyrax::FileUsage).to receive(:new).with(file_set.id).and_return(usage) - expect(controller).to receive(:add_breadcrumb).with('Home', Hyrax::Engine.routes.url_helpers.root_path) - expect(controller).to receive(:add_breadcrumb).with(I18n.t('hyrax.dashboard.title'), Hyrax::Engine.routes.url_helpers.dashboard_path) - expect(controller).to receive(:add_breadcrumb).with(I18n.t('hyrax.dashboard.my.works'), Hyrax::Engine.routes.url_helpers.my_works_path) - expect(controller).to receive(:add_breadcrumb).with(I18n.t('hyrax.file_set.browse_view'), Rails.application.routes.url_helpers.hyrax_file_set_path(file_set)) + expect(controller).to receive(:add_breadcrumb).with('Home', Hyrax::Engine.routes.url_helpers.root_path(locale: 'en')) + expect(controller).to receive(:add_breadcrumb).with(I18n.t('hyrax.dashboard.title'), Hyrax::Engine.routes.url_helpers.dashboard_path(locale: 'en')) + expect(controller).to receive(:add_breadcrumb).with(I18n.t('hyrax.dashboard.my.works'), Hyrax::Engine.routes.url_helpers.my_works_path(locale: 'en')) + expect(controller).to receive(:add_breadcrumb).with(I18n.t('hyrax.file_set.browse_view'), Rails.application.routes.url_helpers.hyrax_file_set_path(file_set, locale: 'en')) get :file, params: { id: file_set } expect(response).to be_successful expect(response).to render_template('stats/file') @@ -34,7 +34,7 @@ def test_loading_public_file_no_user_signed_in def test_loading_file_user_no_access_signed_in get :file, params: { id: file_set } - expect(response).to redirect_to(Hyrax::Engine.routes.url_helpers.root_path) + expect(response).to redirect_to(Hyrax::Engine.routes.url_helpers.root_path(locale: 'en')) end context 'with ActiveFedora objects', :active_fedora do @@ -76,10 +76,10 @@ def test_loading_file_user_no_access_signed_in it 'renders the stats view' do expect(Hyrax::Analytics).to receive(:daily_events_for_id).with(work.id, 'work-view').and_return([]) expect(Hyrax::Analytics).to receive(:daily_events_for_id).with(work.id, 'file-set-in-work-download').and_return([]) - expect(controller).to receive(:add_breadcrumb).with('Home', Hyrax::Engine.routes.url_helpers.root_path) - expect(controller).to receive(:add_breadcrumb).with(I18n.t('hyrax.dashboard.my.works'), Hyrax::Engine.routes.url_helpers.my_works_path) - expect(controller).to receive(:add_breadcrumb).with(I18n.t('hyrax.dashboard.title'), Hyrax::Engine.routes.url_helpers.dashboard_path) - expect(controller).to receive(:add_breadcrumb).with('Test title', main_app.hyrax_generic_work_path(work)) + expect(controller).to receive(:add_breadcrumb).with('Home', Hyrax::Engine.routes.url_helpers.root_path(locale: 'en')) + expect(controller).to receive(:add_breadcrumb).with(I18n.t('hyrax.dashboard.my.works'), Hyrax::Engine.routes.url_helpers.my_works_path(locale: 'en')) + expect(controller).to receive(:add_breadcrumb).with(I18n.t('hyrax.dashboard.title'), Hyrax::Engine.routes.url_helpers.dashboard_path(locale: 'en')) + expect(controller).to receive(:add_breadcrumb).with('Test title', main_app.hyrax_generic_work_path(work, locale: 'en')) get :work, params: { id: work } expect(response).to be_successful expect(response).to render_template('stats/work') @@ -128,10 +128,10 @@ def test_loading_file_user_no_access_signed_in xit 'renders the stats view' do expect(Hyrax::Analytics).to receive(:daily_events_for_id).with(work.id, 'work-view').and_return([]) expect(Hyrax::Analytics).to receive(:daily_events_for_id).with(work.id, 'file-set-in-work-download').and_return([]) - expect(controller).to receive(:add_breadcrumb).with('Home', Hyrax::Engine.routes.url_helpers.root_path) - expect(controller).to receive(:add_breadcrumb).with(I18n.t('hyrax.dashboard.my.works'), Hyrax::Engine.routes.url_helpers.my_works_path) - expect(controller).to receive(:add_breadcrumb).with(I18n.t('hyrax.dashboard.title'), Hyrax::Engine.routes.url_helpers.dashboard_path) - expect(controller).to receive(:add_breadcrumb).with('Test title', main_app.hyrax_monograph_path(work)) + expect(controller).to receive(:add_breadcrumb).with('Home', Hyrax::Engine.routes.url_helpers.root_path(locale: 'en')) + expect(controller).to receive(:add_breadcrumb).with(I18n.t('hyrax.dashboard.my.works'), Hyrax::Engine.routes.url_helpers.my_works_path(locale: 'en')) + expect(controller).to receive(:add_breadcrumb).with(I18n.t('hyrax.dashboard.title'), Hyrax::Engine.routes.url_helpers.dashboard_path(locale: 'en')) + expect(controller).to receive(:add_breadcrumb).with('Test title', main_app.hyrax_monograph_path(work, locale: 'en')) get :work, params: { id: work } expect(response).to be_successful expect(response).to render_template('stats/work') diff --git a/spec/controllers/hyrax/transfers_controller_spec.rb b/spec/controllers/hyrax/transfers_controller_spec.rb index 5860f7b0d1..abd9a6c61b 100644 --- a/spec/controllers/hyrax/transfers_controller_spec.rb +++ b/spec/controllers/hyrax/transfers_controller_spec.rb @@ -64,7 +64,7 @@ } } end.to change(ProxyDepositRequest, :count).by(1) - expect(response).to redirect_to routes.url_helpers.transfers_path + expect(response).to redirect_to routes.url_helpers.transfers_path(locale: 'en') expect(flash[:notice]).to eq('Transfer request created') proxy_request = another_user.proxy_deposit_requests.first expect(proxy_request.work_id).to eq(work.id) @@ -130,7 +130,7 @@ end def common_response_tests - expect(response).to redirect_to routes.url_helpers.transfers_path + expect(response).to redirect_to routes.url_helpers.transfers_path(locale: 'en') expect(flash[:notice]).to eq("Transfer complete") expect(assigns[:proxy_deposit_request].status).to eq('accepted') end @@ -233,7 +233,7 @@ def common_redirect_tests end def common_rejection_tests - expect(response).to redirect_to routes.url_helpers.transfers_path + expect(response).to redirect_to routes.url_helpers.transfers_path(locale: 'en') expect(flash[:notice]).to eq("Transfer rejected") expect(assigns[:proxy_deposit_request].status).to eq('rejected') end @@ -281,7 +281,7 @@ def common_rejection_tests end def common_cancellation_tests - expect(response).to redirect_to routes.url_helpers.transfers_path + expect(response).to redirect_to routes.url_helpers.transfers_path(locale: 'en') expect(flash[:notice]).to eq("Transfer canceled") end diff --git a/spec/controllers/hyrax/uploads_controller_spec.rb b/spec/controllers/hyrax/uploads_controller_spec.rb index 9ac9548c78..c3437c1c72 100644 --- a/spec/controllers/hyrax/uploads_controller_spec.rb +++ b/spec/controllers/hyrax/uploads_controller_spec.rb @@ -128,7 +128,7 @@ context "when not signed in" do it "is redirected to sign in" do delete :destroy, params: { id: uploaded_file } - expect(response).to redirect_to main_app.new_user_session_path + expect(response).to redirect_to main_app.new_user_session_path(locale: 'en') end end end diff --git a/spec/controllers/hyrax/workflow_actions_controller_spec.rb b/spec/controllers/hyrax/workflow_actions_controller_spec.rb index 389ff137d1..5c8d825269 100644 --- a/spec/controllers/hyrax/workflow_actions_controller_spec.rb +++ b/spec/controllers/hyrax/workflow_actions_controller_spec.rb @@ -29,7 +29,7 @@ sign_in(user) put :update, params: { id: work.to_param, workflow_action: { name: 'advance', comment: '' } } - expect(response).to redirect_to(main_app.hyrax_monograph_path(work)) + expect(response).to redirect_to(main_app.hyrax_monograph_path(work, locale: 'en')) end context 'when responding to json' do diff --git a/spec/features/browse_dashboard_works_spec.rb b/spec/features/browse_dashboard_works_spec.rb index 95943167ed..8435d3be82 100644 --- a/spec/features/browse_dashboard_works_spec.rb +++ b/spec/features/browse_dashboard_works_spec.rb @@ -58,7 +58,7 @@ click_link "Published" within("#document_#{mp3_work.id}") do expect(page).to have_link("Display all details of Test Document MP3", - href: hyrax_monograph_path(mp3_work)) + href: hyrax_monograph_path(mp3_work, locale: 'en')) end click_link("Remove constraint Status: Published") diff --git a/spec/features/collection_type_spec.rb b/spec/features/collection_type_spec.rb index cd00505024..c1abec76d5 100644 --- a/spec/features/collection_type_spec.rb +++ b/spec/features/collection_type_spec.rb @@ -35,9 +35,9 @@ expect(page).to have_content 'Collection Type' expect(page).to have_link('Edit', count: 3) - expect(page).to have_link('Edit', href: hyrax.edit_admin_collection_type_path(admin_set_type.id)) - expect(page).to have_link('Edit', href: hyrax.edit_admin_collection_type_path(user_collection_type.id)) - expect(page).to have_link('Edit', href: hyrax.edit_admin_collection_type_path(exhibit_collection_type.id)) + expect(page).to have_link('Edit', href: hyrax.edit_admin_collection_type_path(admin_set_type.id, locale: 'en')) + expect(page).to have_link('Edit', href: hyrax.edit_admin_collection_type_path(user_collection_type.id, locale: 'en')) + expect(page).to have_link('Edit', href: hyrax.edit_admin_collection_type_path(exhibit_collection_type.id, locale: 'en')) expect(page).to have_button('Delete', count: 2) # 1: Collection Type, 2: delete modal end end diff --git a/spec/features/dashboard/collection_spec.rb b/spec/features/dashboard/collection_spec.rb index 39e2e61b8c..a9f5b1c2a3 100644 --- a/spec/features/dashboard/collection_spec.rb +++ b/spec/features/dashboard/collection_spec.rb @@ -275,7 +275,7 @@ it "has properly formed collection type buttons" do expect(page).not_to have_selector("input[data-path$='collections/new&collection_type_id=#{collection_type.id}']") - expect(page).to have_selector("input[data-path$='collections/new?collection_type_id=#{collection_type.id}']") + expect(page).to have_selector("input[data-path$='collections/new?locale=en&collection_type_id=#{collection_type.id}']") end end @@ -371,15 +371,15 @@ def check_tr_data_attributes(id, type) url_fragment = get_url_fragment(type) expect(page).to have_selector("tr[data-id='#{id}'][data-colls-hash]") - expect(page).to have_selector("tr[data-post-url='/dashboard/collections/#{id}/within']") - expect(page).to have_selector("tr[data-post-delete-url='/#{url_fragment}/#{id}']") + expect(page).to have_selector("tr[data-post-url='/dashboard/collections/#{id}/within?locale=en']") + expect(page).to have_selector("tr[data-post-delete-url='/#{url_fragment}/#{id}?locale=en']") end # Check data attributes have been transferred from table row to the modal def check_modal_data_attributes(id, type) url_fragment = get_url_fragment(type) expect(page).to have_selector("div[data-id='#{id}']") - expect(page).to have_selector("div[data-post-delete-url='/#{url_fragment}/#{id}']") + expect(page).to have_selector("div[data-post-delete-url='/#{url_fragment}/#{id}?locale=en']") end def get_url_fragment(type) diff --git a/spec/features/edit_work_spec.rb b/spec/features/edit_work_spec.rb index 2e10087d86..95ec6c2ef2 100644 --- a/spec/features/edit_work_spec.rb +++ b/spec/features/edit_work_spec.rb @@ -40,7 +40,7 @@ choose('monograph_visibility_open') check('agreement') click_on('Save changes') - expect(page).to have_current_path(hyrax_monograph_path(work)) + expect(page).to have_current_path(hyrax_monograph_path(work, locale: 'en')) within(".work-title-wrapper") do expect(page).to have_content('Public') end diff --git a/spec/features/file_manager_spec.rb b/spec/features/file_manager_spec.rb index 975dfaa09e..a001a1e3ee 100644 --- a/spec/features/file_manager_spec.rb +++ b/spec/features/file_manager_spec.rb @@ -24,7 +24,7 @@ expect(page).to have_selector("a[href='/concern/parent/#{work.id}/file_sets/#{file_set.id}']") # has a link back to parent - expect(page).to have_link work.title.first, href: hyrax_monograph_path(id: work.id) + expect(page).to have_link work.title.first, href: hyrax_monograph_path(id: work.id, locale: :en) # renders a form for each member expect(page).to have_selector("#sortable form", count: work.member_ids.length) diff --git a/spec/features/search_spec.rb b/spec/features/search_spec.rb index 9f4e1b1b48..3da9da7288 100644 --- a/spec/features/search_spec.rb +++ b/spec/features/search_spec.rb @@ -70,8 +70,8 @@ # profile property name ("keyword") rather than the original catalog # controller value ("keywords"). kw_itemprop = Hyrax.config.flexible? ? "keyword" : "keywords" - expect(page.body).to include "taco" - expect(page.body).to include "mustache" + expect(page.body).to include "taco" + expect(page.body).to include "mustache" end end end diff --git a/spec/features/users_spec.rb b/spec/features/users_spec.rb index 2ecfcebafd..bee7a6dbc0 100644 --- a/spec/features/users_spec.rb +++ b/spec/features/users_spec.rb @@ -4,7 +4,7 @@ sign_in user end let(:user) { create(:user) } - let(:profile_path) { Hyrax::Engine.routes.url_helpers.user_path(user) } + let(:profile_path) { Hyrax::Engine.routes.url_helpers.user_path(user, locale: 'en') } context 'when visiting user profile with highlighted works' do let(:work) { valkyrie_create(:monograph, title: 'Test Monograph 123', depositor: user.user_key) } @@ -18,7 +18,7 @@ expect(page).to have_content(user.email) within '.highlighted-works' do - expect(page).to have_link('Test Monograph 123', href: "/concern/monographs/#{work.id}") + expect(page).to have_link('Test Monograph 123', href: "/concern/monographs/#{work.id}?locale=en") end within '.panel-user' do @@ -33,7 +33,7 @@ context 'user profile' do let!(:dewey) { create(:user, display_name: 'Melvil Dewey') } - let(:dewey_path) { Hyrax::Engine.routes.url_helpers.user_path(dewey) } + let(:dewey_path) { Hyrax::Engine.routes.url_helpers.user_path(dewey, locale: 'en') } it 'is searchable' do visit profile_path diff --git a/spec/javascripts/settings_spec.js b/spec/javascripts/settings_spec.js index f4343e2fdb..bb2cdd3850 100644 --- a/spec/javascripts/settings_spec.js +++ b/spec/javascripts/settings_spec.js @@ -40,7 +40,7 @@ describe("Settings", function() { // Generate a form that collection type settings function settingsForm() { - return '