Skip to content

Commit

Permalink
Paginate PreIngestWorks
Browse files Browse the repository at this point in the history
This paginates PreIngestWorks when viewing the
'Works & Files' page for an import.

Connected to https://github.com/curationexperts/in-house/issues/441
  • Loading branch information
little9 committed Nov 8, 2019
1 parent c3d48ee commit 6c8926f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/controllers/zizia/csv_import_details_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
module Zizia
class CsvImportDetailsController < ApplicationController
helper_method :sort_column, :sort_direction, :user

load_and_authorize_resource
with_themed_layout 'dashboard'

Expand All @@ -20,6 +19,7 @@ def index
def show
@csv_import_detail = Zizia::CsvImportDetail
.find(csv_import_detail_params[:id])
@pre_ingest_works = Kaminari.paginate_array(@csv_import_detail.pre_ingest_works, total_count: @csv_import_detail.pre_ingest_works.count).page(csv_import_detail_params[:page]).per(10)
end

private
Expand Down
3 changes: 2 additions & 1 deletion app/views/zizia/csv_import_details/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<th>Files</th>
<th>Date</th>
</tr>
<% @csv_import_detail.pre_ingest_works.each do |pre_ingest_work| %>
<% @pre_ingest_works.each do |pre_ingest_work| %>
<tr>
<td>
<%= pre_ingest_work.deduplication_key%>
Expand All @@ -33,4 +33,5 @@
</tr>
<% end %>
</table>
<%= paginate @pre_ingest_works %>
</div>
10 changes: 10 additions & 0 deletions spec/dummy/spec/system/csv_import_details_page_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
let(:csv_import_detail) { FactoryBot.create_list(:csv_import_detail, 12, created_at: Time.parse('Tue, 29 Oct 2019 14:20:02 UTC +00:00').utc, depositor_id: user.id) }
let(:csv_import_detail_second) { FactoryBot.create(:csv_import_detail, created_at: Time.parse('Thur, 31 Oct 2019 14:20:02 UTC +00:00').utc, status: 'zippy', update_actor_stack: 'ZiziaTesting', depositor_id: user.id) }
let(:csv_import_detail_third) { FactoryBot.create(:csv_import_detail, created_at: Time.parse('Wed, 30 Oct 2019 14:20:02 UTC +00:00').utc, depositor_id: second_user.id, csv_import_id: 2) }
let(:csv_pre_ingest_works) { FactoryBot.create_list(:pre_ingest_work, 12, csv_import_detail_id: 4) }

before do
user.save
Expand All @@ -23,6 +24,7 @@
csv_import_detail.each(&:save)
csv_import_detail_second.save
csv_import_detail_third.save
csv_pre_ingest_works.each(&:save)
login_as user
end

Expand Down Expand Up @@ -113,4 +115,12 @@
click_on 'View All Imports'
expect(page).to have_content('user@curationexperts.com')
end

it 'has pagination for PreIngestWorks at 10' do
visit('/csv_import_details/index')
click_on '4'
expect(page).to have_content 'Next'
click_on 'Next'
expect(page).to have_content 'Previous'
end
end
1 change: 0 additions & 1 deletion spec/factories/pre_ingest_work.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
# This will guess the User class
FactoryBot.define do
factory :pre_ingest_work, class: Zizia::PreIngestWork do
id { 1 }
created_at { Time.current }
updated_at { Time.current }
csv_import_detail_id { 1 }
Expand Down

0 comments on commit 6c8926f

Please sign in to comment.