From 7a70b7614721bea315a619bebabd59d582549ec1 Mon Sep 17 00:00:00 2001 From: Max Kadel Date: Wed, 23 Oct 2024 15:33:45 -0400 Subject: [PATCH] Add section on indexing process Closes #2328 --- app/views/layouts/application.html.erb | 6 +++-- app/views/pages/index.html.erb | 21 ++++++++++++++++++ spec/views/pages/index.html.erb_spec.rb | 29 +++++++++++++++++++++++++ 3 files changed, 54 insertions(+), 2 deletions(-) create mode 100644 spec/views/pages/index.html.erb_spec.rb diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 2fe0ebd5..4bf8f0ab 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -10,9 +10,11 @@
<%= render partial: "shared/navbar" %> <%= render partial: "shared/flash_messages", flash: flash %> - <%= yield %> +
+ <%= yield %> +
-
+ diff --git a/app/views/pages/index.html.erb b/app/views/pages/index.html.erb index aacf0645..a7f772a6 100644 --- a/app/views/pages/index.html.erb +++ b/app/views/pages/index.html.erb @@ -1 +1,22 @@

PUL Bibliographic Data Web Service

+

Indexing Process

+ + + + + + + + + + + <% IndexManager.all.each do |index_manager| %> + + + + + + + <% end %> + +
Solr collectionLast dump indexedTimestampIn progress
<%= index_manager.solr_collection %><%= index_manager.last_dump_completed_id ? link_to(index_manager.last_dump_completed_id, dump_url(index_manager.last_dump_completed_id, format: :json)) : '' %><%= index_manager.updated_at %><%= index_manager.in_progress %>
diff --git a/spec/views/pages/index.html.erb_spec.rb b/spec/views/pages/index.html.erb_spec.rb new file mode 100644 index 00000000..0b9e8252 --- /dev/null +++ b/spec/views/pages/index.html.erb_spec.rb @@ -0,0 +1,29 @@ +# frozen_string_literal: true +require "rails_helper" + +RSpec.describe "pages/index", type: :view do + it 'renders the header' do + render + expect(rendered).to match(/

PUL Bibliographic Data Web Service<\/h1>/) + end + it 'includes a section on the indexing process' do + render + expect(rendered).to match(/

Indexing Process<\/h2>/) + expect(rendered).to match(/Last dump indexed<\/th>/) + expect(rendered).to match(/Timestamp<\/th>/) + expect(rendered).to match(/In progress<\/th>/) + end + context 'with index managers' do + let!(:index_manager1) { FactoryBot.create(:index_manager, solr_collection: 'daily_indexing', last_dump_completed: FactoryBot.create(:incremental_dump)) } + let!(:index_manager2) { FactoryBot.create(:index_manager, solr_collection: 'rebuild_indexing', last_dump_completed: FactoryBot.create(:full_dump)) } + + it 'includes the id of the last dump indexed' do + render + + expect(rendered).to match(/#{index_manager1.last_dump_completed_id}/) + expect(rendered).to match(/#{index_manager2.last_dump_completed_id}/) + expect(rendered).to match(index_manager1.solr_collection) + expect(rendered).to have_link(index_manager1.last_dump_completed_id.to_s, href: "http://test.host/dumps/#{index_manager1.last_dump_completed_id}.json") + end + end +end