From 3c6fd4a121ca4b2165a1bebffeb762e0d625ed8b Mon Sep 17 00:00:00 2001 From: Alexander Kuznetsov Date: Tue, 30 Nov 2021 15:52:36 +0200 Subject: [PATCH] Fix Admin panel routes Update calls to the routes to use _mount point_ - that way we can avoid the errors when engine is used in mixed setup with host application. And some parts of the Admin panel is overridden. Also disable Sprocket concurency (see https://github.com/rails/sprockets/issues/581) --- .../engine/admin/access_codes_controller.rb | 11 ++++++--- .../engine/admin/curriculums_controller.rb | 2 +- .../admin/resource_bulk_edits_controller.rb | 4 ++-- .../lcms/engine/admin/resources_controller.rb | 12 +++++----- .../lcms/engine/admin/settings_controller.rb | 2 +- .../lcms/engine/admin/standards_controller.rb | 2 +- .../lcms/engine/admin/users_controller.rb | 13 ++++++---- .../lcms/engine/resources_controller.rb | 10 ++++---- .../engine/admin/access_codes/_form.html.erb | 2 +- .../engine/admin/access_codes/index.html.erb | 6 ++--- .../batch_reimports/_search_form.html.erb | 2 +- .../admin/documents/_search_form.html.erb | 2 +- .../engine/admin/documents/index.html.erb | 2 +- .../admin/materials/_search_form.html.erb | 2 +- .../engine/admin/materials/index.html.erb | 2 +- .../admin/resource_bulk_edits/new.html.erb | 2 +- .../engine/admin/resources/_form.html.erb | 2 +- .../admin/resources/_search_form.html.erb | 2 +- .../lcms/engine/admin/shared/_header.html.erb | 24 +++++++++---------- .../engine/admin/standards/_form.html.erb | 2 +- .../admin/standards/_search_form.html.erb | 2 +- .../lcms/engine/admin/users/_form.html.erb | 2 +- .../engine/admin/users/_search_form.html.erb | 2 +- .../lcms/engine/admin/users/index.html.erb | 12 +++++----- .../resource_bulk_edit_controller_spec.rb | 2 +- .../admin/resources_controller_spec.rb | 2 +- .../admin/settings_controller_spec.rb | 2 +- .../admin/standards_controller_spec.rb | 2 +- .../admin/welcome_controller_spec.rb | 2 +- spec/controllers/resources_controller_spec.rb | 6 ++--- spec/dummy/config/initializers/assets.rb | 6 +++++ spec/features/admin/users_spec.rb | 2 +- spec/support/routes.rb | 4 ++++ 33 files changed, 85 insertions(+), 67 deletions(-) diff --git a/app/controllers/lcms/engine/admin/access_codes_controller.rb b/app/controllers/lcms/engine/admin/access_codes_controller.rb index df537964..d0de5c19 100644 --- a/app/controllers/lcms/engine/admin/access_codes_controller.rb +++ b/app/controllers/lcms/engine/admin/access_codes_controller.rb @@ -9,7 +9,7 @@ class AccessCodesController < AdminController def create @access_code = AccessCode.new(permitted_params) if @access_code.save - redirect_to({ action: :index }, notice: t('.success')) + redirect_to lcms_engine.admin_access_codes_path, notice: t('.success') else render :new end @@ -17,7 +17,11 @@ def create def destroy @access_code.destroy - redirect_to({ action: :index }, notice: t('.success')) + redirect_to lcms_engine.admin_access_codes_path, notice: t('.success') + end + + def edit + @url = lcms_engine.admin_access_code_path(@access_code) end def index @@ -30,8 +34,9 @@ def new def update if @access_code.update(permitted_params) - redirect_to({ action: :index }, notice: t('.success')) + redirect_to lcms_engine.admin_access_codes_path, notice: t('.success') else + @url = lcms_engine.admin_access_code_path(@access_code) render :edit end end diff --git a/app/controllers/lcms/engine/admin/curriculums_controller.rb b/app/controllers/lcms/engine/admin/curriculums_controller.rb index 7567e2a4..3d074899 100644 --- a/app/controllers/lcms/engine/admin/curriculums_controller.rb +++ b/app/controllers/lcms/engine/admin/curriculums_controller.rb @@ -11,7 +11,7 @@ def edit def update @form = CurriculumForm.new(params[:curriculum]) if @form.save - redirect_to admin_path, notice: t('.success') + redirect_to lcms_engine.root_path, notice: t('.success') else @curriculum = CurriculumPresenter.new render :edit, alert: t('.error') diff --git a/app/controllers/lcms/engine/admin/resource_bulk_edits_controller.rb b/app/controllers/lcms/engine/admin/resource_bulk_edits_controller.rb index d92b79fb..e84573c6 100644 --- a/app/controllers/lcms/engine/admin/resource_bulk_edits_controller.rb +++ b/app/controllers/lcms/engine/admin/resource_bulk_edits_controller.rb @@ -10,7 +10,7 @@ def new if @resources.any? @resource = BulkEditResourcesService.new(@resources).init_sample else - redirect_to :admin_resources, alert: t('.no_resources') + redirect_to lcms_engine.admin_resources_path, alert: t('.no_resources') end end @@ -18,7 +18,7 @@ def create BulkEditResourcesService.new(@resources, resource_params).edit! resources_count_msg = t(:resources_count, count: @resources.count) notice = t('.success', count: @resources.count, resources_count: resources_count_msg) - redirect_to :admin_resources, notice: notice + redirect_to lcms_engine.admin_resources_path, notice: notice end private diff --git a/app/controllers/lcms/engine/admin/resources_controller.rb b/app/controllers/lcms/engine/admin/resources_controller.rb index 0e3db489..0900a356 100644 --- a/app/controllers/lcms/engine/admin/resources_controller.rb +++ b/app/controllers/lcms/engine/admin/resources_controller.rb @@ -30,7 +30,7 @@ def create if @resource.save create_tags - redirect_to :admin_resources, notice: t('.success', resource_id: @resource.id) + redirect_to lcms_engine.admin_resources_path, notice: t('.success', resource_id: @resource.id) else render :new end @@ -50,17 +50,17 @@ def export_to_lti_cc end def bundle - return redirect_to :admin_resources, notice: t('.fail') unless can_bundle?(@resource) + return redirect_to lcms_engine.admin_resources_path, notice: t('.fail') unless can_bundle?(@resource) # see settings loaded via `lcms.yml` generator = DocTemplate.config.dig('bundles', @resource.curriculum_type).constantize generator.perform(@resource) - redirect_to :admin_resources, notice: t('.success') + redirect_to lcms_engine.admin_resources_path, notice: t('.success') end def update unless Settings[:editing_enabled] - return redirect_to(:admin_resources, alert: t('admin.common.editing_disabled')) + return redirect_to(lcms_engine.admin_resources_path, alert: t('admin.common.editing_disabled')) end create_tags @@ -70,7 +70,7 @@ def update end if @resource.update(resource_params) - redirect_to :admin_resources, notice: t('.success', resource_id: @resource.id) + redirect_to lcms_engine.admin_resources_path, notice: t('.success', resource_id: @resource.id) else render :edit end @@ -78,7 +78,7 @@ def update def destroy @resource.destroy - redirect_to :admin_resources, notice: t('.success', resource_id: @resource.id) + redirect_to lcms_engine.admin_resources_path, notice: t('.success', resource_id: @resource.id) end protected diff --git a/app/controllers/lcms/engine/admin/settings_controller.rb b/app/controllers/lcms/engine/admin/settings_controller.rb index 80c5220d..1448f61f 100644 --- a/app/controllers/lcms/engine/admin/settings_controller.rb +++ b/app/controllers/lcms/engine/admin/settings_controller.rb @@ -7,7 +7,7 @@ class SettingsController < AdminController def toggle_editing_enabled Settings[:editing_enabled] = !Settings[:editing_enabled] notice = Settings[:editing_enabled] ? t('.enabled') : t('.disabled') - redirect_to :admin_resources, notice: notice + redirect_to lcms_engine.admin_resources_path, notice: notice end end end diff --git a/app/controllers/lcms/engine/admin/standards_controller.rb b/app/controllers/lcms/engine/admin/standards_controller.rb index 06e2de4c..022b54af 100644 --- a/app/controllers/lcms/engine/admin/standards_controller.rb +++ b/app/controllers/lcms/engine/admin/standards_controller.rb @@ -20,7 +20,7 @@ def index def update if @standard.update(standard_params) - redirect_to admin_standards_path, notice: t('.success') + redirect_to lcms_engine.admin_standards_path, notice: t('.success') else render :edit end diff --git a/app/controllers/lcms/engine/admin/users_controller.rb b/app/controllers/lcms/engine/admin/users_controller.rb index c2c6de5a..b8173871 100644 --- a/app/controllers/lcms/engine/admin/users_controller.rb +++ b/app/controllers/lcms/engine/admin/users_controller.rb @@ -21,30 +21,33 @@ def create @user.generate_password if @user.save @user.send_reset_password_instructions - redirect_to(:admin_users, notice: t('.success', user: @user.email)) + redirect_to lcms_engine.admin_users_path, notice: t('.success', user: @user.email) else render :new end end - def edit; end + def edit + @url = lcms_engine.admin_user_path(@user) + end def update if @user.update(user_params) - redirect_to edit_admin_user_path(@user), notice: t('.success', user: @user.email) + redirect_to lcms_engine.admin_users_path, notice: t('.success', user: @user.email) else + @url = lcms_engine.admin_user_path(@user) render :edit end end def destroy @user.destroy - redirect_to :admin_users, notice: t('.success') + redirect_to lcms_engine.admin_users_path, notice: t('.success') end def reset_password @user.send_reset_password_instructions - redirect_to :admin_users, notice: t('.success') + redirect_to lcms_engine.admin_users_path, notice: t('.success') end private diff --git a/app/controllers/lcms/engine/resources_controller.rb b/app/controllers/lcms/engine/resources_controller.rb index 1ebe42f2..e1288287 100644 --- a/app/controllers/lcms/engine/resources_controller.rb +++ b/app/controllers/lcms/engine/resources_controller.rb @@ -7,13 +7,13 @@ def show @resource = find_resource # redirect to document if resource has it (#161) - return redirect_to document_path(@resource.document) if @resource.document? + return redirect_to dynamic_document_path(@resource.document) if @resource.document? # redirect grade and module to explore_curriculum (#122) - return redirect_to explore_curriculum_index_path(p: @resource.slug, e: 1) if grade_or_module? + return redirect_to lcms_engine.explore_curriculum_index_path(p: @resource.slug, e: 1) if grade_or_module? # redirect to the path with slug if we are using just the id - return redirect_to show_with_slug_path(@resource.slug), status: 301 if using_id? + return redirect_to lcms_engine.show_with_slug_path(@resource.slug), status: 301 if using_id? @related_instructions = related_instructions @props = CurriculumMap.new(@resource).props @@ -27,14 +27,14 @@ def related_instruction def media resource = Resource.find(params[:id]) - return redirect_to resource_path(resource) unless resource.media? + return redirect_to lcms_engine.resource_path(resource) unless resource.media? @resource = MediaPresenter.new(resource) end def generic resource = Resource.find(params[:id]) - return redirect_to resource_path(resource) unless resource.generic? + return redirect_to lcms_engine.resource_path(resource) unless resource.generic? @resource = GenericPresenter.new(resource) end diff --git a/app/views/lcms/engine/admin/access_codes/_form.html.erb b/app/views/lcms/engine/admin/access_codes/_form.html.erb index 1a2f2052..214e4142 100644 --- a/app/views/lcms/engine/admin/access_codes/_form.html.erb +++ b/app/views/lcms/engine/admin/access_codes/_form.html.erb @@ -1,4 +1,4 @@ -<%= simple_form_for [:admin, @access_code], html: { id: 'access_code_form' } do |f| %> +<%= simple_form_for @access_code, url: @url.presence || lcms_engine.admin_access_codes_path, html: { id: 'access_code_form' } do |f| %> <%= f.input :code %> <%= f.input :active %> <%= f.button :submit, t('ui.save'), name: nil %> diff --git a/app/views/lcms/engine/admin/access_codes/index.html.erb b/app/views/lcms/engine/admin/access_codes/index.html.erb index 19658d38..5b9f9b00 100644 --- a/app/views/lcms/engine/admin/access_codes/index.html.erb +++ b/app/views/lcms/engine/admin/access_codes/index.html.erb @@ -1,7 +1,7 @@
- <%= link_to t('.new_access_code'), :new_admin_access_code, class: 'button success', 'data-turbolinks' => false %> + <%= link_to t('.new_access_code'), lcms_engine.new_admin_access_code_path, class: 'button success', 'data-turbolinks' => false %>
@@ -19,10 +19,10 @@ <% @access_codes.each do |access_code| %> <% cache access_code do %> - <%= link_to access_code.code, edit_admin_access_code_path(access_code) %> + <%= link_to access_code.code, lcms_engine.edit_admin_access_code_path(access_code) %> <%= access_code.active ? 'YES' : 'NO' %> - <%= button_to t('ui.delete'), admin_access_code_path(access_code), class: 'button alert', data: { confirm: t('ui.are_you_sure') }, form_class: 'inline', method: :delete %> + <%= button_to t('ui.delete'), lcms_engine.admin_access_code_path(access_code), class: 'button alert', data: { confirm: t('ui.are_you_sure') }, form_class: 'inline', method: :delete %> <% end %> diff --git a/app/views/lcms/engine/admin/batch_reimports/_search_form.html.erb b/app/views/lcms/engine/admin/batch_reimports/_search_form.html.erb index 93a1558a..710a7ff2 100644 --- a/app/views/lcms/engine/admin/batch_reimports/_search_form.html.erb +++ b/app/views/lcms/engine/admin/batch_reimports/_search_form.html.erb @@ -1,4 +1,4 @@ -<%= simple_form_for :query, url: :admin_batch_reimport, html: { class: 'form-inline well o-admin-lessons-search', method: :post } do |f| %> +<%= simple_form_for :query, url: lcms_engine.admin_batch_reimport_path, html: { class: 'form-inline well o-admin-lessons-search', method: :post } do |f| %>
diff --git a/app/views/lcms/engine/admin/documents/_search_form.html.erb b/app/views/lcms/engine/admin/documents/_search_form.html.erb index 476dd983..36903dfd 100644 --- a/app/views/lcms/engine/admin/documents/_search_form.html.erb +++ b/app/views/lcms/engine/admin/documents/_search_form.html.erb @@ -1,4 +1,4 @@ -<%= simple_form_for :query, url: :admin_documents, html: { class: 'form-inline well o-admin-lessons-search', method: :get } do |f| %> +<%= simple_form_for :query, url: lcms_engine.admin_documents_path, html: { class: 'form-inline well o-admin-lessons-search', method: :get } do |f| %>
diff --git a/app/views/lcms/engine/admin/documents/index.html.erb b/app/views/lcms/engine/admin/documents/index.html.erb index 8a67fa55..93403d94 100644 --- a/app/views/lcms/engine/admin/documents/index.html.erb +++ b/app/views/lcms/engine/admin/documents/index.html.erb @@ -24,7 +24,7 @@ path: delete_selected_admin_documents_path(query: @query_params), btn_style: 'alert'} %> - <%= link_to t('.new_lesson'), :new_admin_document, class: 'button primary' %> + <%= link_to t('.new_lesson'), lcms_engine.new_admin_document_path, class: 'button primary' %>
diff --git a/app/views/lcms/engine/admin/materials/_search_form.html.erb b/app/views/lcms/engine/admin/materials/_search_form.html.erb index 94d03cea..a4f25e2f 100644 --- a/app/views/lcms/engine/admin/materials/_search_form.html.erb +++ b/app/views/lcms/engine/admin/materials/_search_form.html.erb @@ -1,4 +1,4 @@ -<%= simple_form_for :query, url: :admin_materials, html: { class: 'form-inline well o-admin-lessons-search', method: :get } do |f| %> +<%= simple_form_for :query, url: lcms_engine.admin_materials_path, html: { class: 'form-inline well o-admin-lessons-search', method: :get } do |f| %>
<%= f.input :search_term, label: 'Identifier', required: false, diff --git a/app/views/lcms/engine/admin/materials/index.html.erb b/app/views/lcms/engine/admin/materials/index.html.erb index ac581734..eeb656d8 100644 --- a/app/views/lcms/engine/admin/materials/index.html.erb +++ b/app/views/lcms/engine/admin/materials/index.html.erb @@ -24,7 +24,7 @@ path: delete_selected_admin_materials_path(query: @query_params), btn_style: 'alert'} %> <%# link_to t('.new_material_pdf'), new_admin_material_path(source_type: 'pdf'), class: 'button primary' %> - <%= link_to t('.new_material'), :new_admin_material, class: 'button primary' %> + <%= link_to t('.new_material'), lcms_engine.new_admin_material_path, class: 'button primary' %>
diff --git a/app/views/lcms/engine/admin/resource_bulk_edits/new.html.erb b/app/views/lcms/engine/admin/resource_bulk_edits/new.html.erb index 5f09177b..75882b58 100644 --- a/app/views/lcms/engine/admin/resource_bulk_edits/new.html.erb +++ b/app/views/lcms/engine/admin/resource_bulk_edits/new.html.erb @@ -1,7 +1,7 @@

<%= t('.page_title') %>

- <%= simple_form_for @resource, url: :admin_resource_bulk_edits do |f| %> + <%= simple_form_for @resource, url: lcms_engine.admin_resource_bulk_edits_path do |f| %> <% @resources.each do |resource| %> <%= hidden_field_tag 'ids[]', resource.id %> diff --git a/app/views/lcms/engine/admin/resources/_form.html.erb b/app/views/lcms/engine/admin/resources/_form.html.erb index 3aedc732..29a194bb 100644 --- a/app/views/lcms/engine/admin/resources/_form.html.erb +++ b/app/views/lcms/engine/admin/resources/_form.html.erb @@ -1,4 +1,4 @@ -<% url = @resource.new_record? ? :admin_resources : admin_resource_path(@resource) %> +<% url = @resource.new_record? ? lcms_engine.admin_resources_path : lcms_engine.admin_resource_path(@resource) %> <%= simple_nested_form_for @resource, url: url, html: { id: 'resource_form' } do |f| %>
diff --git a/app/views/lcms/engine/admin/resources/_search_form.html.erb b/app/views/lcms/engine/admin/resources/_search_form.html.erb index ecf5c888..07a7ca99 100644 --- a/app/views/lcms/engine/admin/resources/_search_form.html.erb +++ b/app/views/lcms/engine/admin/resources/_search_form.html.erb @@ -1,4 +1,4 @@ -<%= simple_form_for @query, url: :admin_resources, html: { class: 'form-inline well admin-resource-search', method: :get } do |f| %> +<%= simple_form_for @query, url: lcms_engine.admin_resources_path, html: { class: 'form-inline well admin-resource-search', method: :get } do |f| %>
<%= f.input :grades, as: :select, collection: Lcms::Engine::Grades.grades, input_html: { class: 'selectize resource-search-select', multiple: true }, label: t('.grades'), label_method: :humanize, required: false, wrapper_html: { class: 'resource-search-wrap' } %> diff --git a/app/views/lcms/engine/admin/shared/_header.html.erb b/app/views/lcms/engine/admin/shared/_header.html.erb index bacf0cc1..43bc9e13 100644 --- a/app/views/lcms/engine/admin/shared/_header.html.erb +++ b/app/views/lcms/engine/admin/shared/_header.html.erb @@ -13,36 +13,36 @@
diff --git a/app/views/lcms/engine/admin/standards/_form.html.erb b/app/views/lcms/engine/admin/standards/_form.html.erb index 532fc482..a6029783 100644 --- a/app/views/lcms/engine/admin/standards/_form.html.erb +++ b/app/views/lcms/engine/admin/standards/_form.html.erb @@ -1,4 +1,4 @@ -<%= simple_form_for @standard, as: :standard, url: admin_standard_path(@standard), html: { class: 'o-standard-form' } do |f| %> +<%= simple_form_for @standard, as: :standard, url: lcms_engine.admin_standard_path(@standard), html: { class: 'o-standard-form' } do |f| %>
diff --git a/app/views/lcms/engine/admin/standards/_search_form.html.erb b/app/views/lcms/engine/admin/standards/_search_form.html.erb index 96486660..4c6c4fb7 100644 --- a/app/views/lcms/engine/admin/standards/_search_form.html.erb +++ b/app/views/lcms/engine/admin/standards/_search_form.html.erb @@ -1,4 +1,4 @@ -<%= simple_form_for :query, url: :admin_standards, html: { class: 'form-inline well o-admin-standards-search', method: :get } do |f| %> +<%= simple_form_for :query, url: lcms_engine.admin_standards_path, html: { class: 'form-inline well o-admin-standards-search', method: :get } do |f| %>
<%= f.input :name, label: 'Name', required: false, wrapper_html: { class: 'resource-search-title' } %> diff --git a/app/views/lcms/engine/admin/users/_form.html.erb b/app/views/lcms/engine/admin/users/_form.html.erb index b874467f..bdb7d08e 100644 --- a/app/views/lcms/engine/admin/users/_form.html.erb +++ b/app/views/lcms/engine/admin/users/_form.html.erb @@ -1,4 +1,4 @@ -<%= simple_form_for [:admin, @user], html: { id: 'user_form' } do |f| %> +<%= simple_form_for @user, url: @url.presence || lcms_engine.admin_users_path, html: { id: 'user_form' } do |f| %> <%= f.input :id, disabled: true %> <%= f.input :name %> <%= f.input :email %> diff --git a/app/views/lcms/engine/admin/users/_search_form.html.erb b/app/views/lcms/engine/admin/users/_search_form.html.erb index 435da928..c1a2ce6a 100644 --- a/app/views/lcms/engine/admin/users/_search_form.html.erb +++ b/app/views/lcms/engine/admin/users/_search_form.html.erb @@ -1,4 +1,4 @@ -<%= simple_form_for :query, url: :admin_users, html: { class: 'form-inline well o-admin-users-search', method: :get } do |f| %> +<%= simple_form_for :query, url: lcms_engine.admin_users_path, html: { class: 'form-inline well o-admin-users-search', method: :get } do |f| %>
<%= f.input :email, label: false, required: false, placeholder: 'Search by E-mail', wrapper_html: { class: 'o-admin-search-term' } %> diff --git a/app/views/lcms/engine/admin/users/index.html.erb b/app/views/lcms/engine/admin/users/index.html.erb index ec1342aa..edb60496 100644 --- a/app/views/lcms/engine/admin/users/index.html.erb +++ b/app/views/lcms/engine/admin/users/index.html.erb @@ -7,7 +7,7 @@
- <%= link_to t('.new_user'), :new_admin_user, class: 'button success' %> + <%= link_to t('.new_user'), lcms_engine.new_admin_user_path, class: 'button success' %>
@@ -27,17 +27,17 @@ <% @users.each do |user| %> <% cache user do %> - + <% end %> <% end %> diff --git a/spec/controllers/admin/resource_bulk_edit_controller_spec.rb b/spec/controllers/admin/resource_bulk_edit_controller_spec.rb index cae307ca..f80a5c69 100644 --- a/spec/controllers/admin/resource_bulk_edit_controller_spec.rb +++ b/spec/controllers/admin/resource_bulk_edit_controller_spec.rb @@ -22,7 +22,7 @@ grades = resources.flat_map { |r| r.grades.list } expect(grades).to_not include('grade 11') post :create, params: { ids: ids, resource: { grades: ['grade 11'] } } - expect(response).to redirect_to(:admin_resources) + expect(response).to redirect_to(lcms_engine(admin_resources_path)) resources.each do |r| expect(r.reload.grades.list).to include('grade 11') end diff --git a/spec/controllers/admin/resources_controller_spec.rb b/spec/controllers/admin/resources_controller_spec.rb index d39bfa7f..2e14b185 100644 --- a/spec/controllers/admin/resources_controller_spec.rb +++ b/spec/controllers/admin/resources_controller_spec.rb @@ -27,7 +27,7 @@ subject { post :update, params: { id: resource.to_param, resource: params } } context 'with valid params' do - it { is_expected.to redirect_to admin_resources_path } + it { is_expected.to redirect_to lcms_engine(admin_resources_path) } it 'passes notice' do subject diff --git a/spec/controllers/admin/settings_controller_spec.rb b/spec/controllers/admin/settings_controller_spec.rb index 4b44e353..72796070 100644 --- a/spec/controllers/admin/settings_controller_spec.rb +++ b/spec/controllers/admin/settings_controller_spec.rb @@ -11,6 +11,6 @@ expect(Lcms::Engine::Settings[:editing_enabled]).to be true patch :toggle_editing_enabled expect(Lcms::Engine::Settings[:editing_enabled]).to be false - expect(response).to redirect_to(:admin_resources) + expect(response).to redirect_to(lcms_engine(admin_resources_path)) end end diff --git a/spec/controllers/admin/standards_controller_spec.rb b/spec/controllers/admin/standards_controller_spec.rb index b4d75e58..e9fb7125 100644 --- a/spec/controllers/admin/standards_controller_spec.rb +++ b/spec/controllers/admin/standards_controller_spec.rb @@ -60,7 +60,7 @@ subject { post :update, params: { id: standard.to_param, standard: params } } context 'with valid params' do - it { is_expected.to redirect_to admin_standards_path } + it { is_expected.to redirect_to lcms_engine(admin_standards_path) } it 'passes notice' do subject diff --git a/spec/controllers/admin/welcome_controller_spec.rb b/spec/controllers/admin/welcome_controller_spec.rb index a4c2ca67..79fde944 100644 --- a/spec/controllers/admin/welcome_controller_spec.rb +++ b/spec/controllers/admin/welcome_controller_spec.rb @@ -7,7 +7,7 @@ describe 'requires admin user' do before { get :index } - it { expect(response).to redirect_to new_user_session_path } + it { expect(response).to redirect_to lcms_engine(new_user_session_path) } end describe 'allow admin' do diff --git a/spec/controllers/resources_controller_spec.rb b/spec/controllers/resources_controller_spec.rb index b73c615a..d846987d 100644 --- a/spec/controllers/resources_controller_spec.rb +++ b/spec/controllers/resources_controller_spec.rb @@ -49,19 +49,19 @@ context 'with id' do before { get :show, id: resource.id } - it { expect(response).to redirect_to("/#{resource.slug}") } + it { expect(response).to redirect_to("/lcms-engine#{resource.slug}") } end context 'grade' do let(:resource) { create(:resource, :grade) } before { get :show, slug: resource.slug } - it { expect(response).to redirect_to explore_curriculum_index_path(p: resource.slug, e: 1) } + it { expect(response).to redirect_to lcms_engine(explore_curriculum_index_path(p: resource.slug, e: 1)) } end context 'module' do let(:resource) { create(:resource, :module) } before { get :show, slug: resource.slug } - it { expect(response).to redirect_to explore_curriculum_index_path(p: resource.slug, e: 1) } + it { expect(response).to redirect_to lcms_engine(explore_curriculum_index_path(p: resource.slug, e: 1)) } end end end diff --git a/spec/dummy/config/initializers/assets.rb b/spec/dummy/config/initializers/assets.rb index 362416f4..ef1dba95 100644 --- a/spec/dummy/config/initializers/assets.rb +++ b/spec/dummy/config/initializers/assets.rb @@ -14,3 +14,9 @@ # application.js, application.css, and all non-JS/CSS in the app/assets # folder are already added. # Rails.application.config.assets.precompile += %w( admin.js admin.css ) + +# To prevent Sass errors +# See https://github.com/rails/sprockets/issues/581 +Rails.application.config.assets.configure do |env| + env.export_concurrent = false +end diff --git a/spec/features/admin/users_spec.rb b/spec/features/admin/users_spec.rb index 563f7d2d..0332c3b8 100644 --- a/spec/features/admin/users_spec.rb +++ b/spec/features/admin/users_spec.rb @@ -57,7 +57,7 @@ click_button 'Save' user.reload - expect(current_path).to eq lcms_engine.edit_admin_user_path(user.id) + expect(current_path).to eq lcms_engine.admin_users_path expect(page.find('.callout.success').text).to include('saved successfully') expect(user.email).to eq "unbounded@#{domain}" expect(user.unconfirmed_email).to eq "joe@#{domain}" diff --git a/spec/support/routes.rb b/spec/support/routes.rb index 396d9acb..26170915 100644 --- a/spec/support/routes.rb +++ b/spec/support/routes.rb @@ -9,6 +9,10 @@ module ControllerRoutes included do routes { ::Lcms::Engine::Engine.routes } end + + def lcms_engine(path) + "/lcms-engine#{path}" + end end end end
<%= link_to user.id, edit_admin_user_path(user) %> - <%= link_to user.survey&.fetch('first_name', nil) || user.name, edit_admin_user_path(user) %> + <%= link_to user.id, lcms_engine.edit_admin_user_path(user) %> + <%= link_to user.survey&.fetch('first_name', nil) || user.name, lcms_engine.edit_admin_user_path(user) %> <%= raw user.survey&.fetch('last_name', nil) %> <%= user.email %> <%= user.role %> <%= user.access_code.presence || '-' %> <%= user.confirmed? ? 'YES' : 'NO' %> <%= user.created_at.to_s %> - <%= link_to content_tag(:i, nil, class: 'fas fa-pencil-alt').html_safe, edit_admin_user_path(user), class: 'button small primary' %> - <%= button_to t('.reset_password_btn'), reset_password_admin_user_path(user), class: 'button small', data: { confirm: t('ui.are_you_sure') }, form_class: 'inline', method: :post %> - <%= button_to t('ui.delete'), admin_user_path(user), class: 'button small alert', data: { confirm: t('ui.are_you_sure') }, form_class: 'inline', method: :delete %><%= link_to content_tag(:i, nil, class: 'fas fa-pencil-alt').html_safe, lcms_engine.edit_admin_user_path(user), class: 'button small primary' %> + <%= button_to t('.reset_password_btn'), lcms_engine.reset_password_admin_user_path(user), class: 'button small', data: { confirm: t('ui.are_you_sure') }, form_class: 'inline', method: :post %> + <%= button_to t('ui.delete'), lcms_engine.admin_user_path(user), class: 'button small alert', data: { confirm: t('ui.are_you_sure') }, form_class: 'inline', method: :delete %>