Skip to content

Commit

Permalink
Sort by doi in 'Publications Requiring Preferred Version Check' table (
Browse files Browse the repository at this point in the history
…#1042)

* Working on tests for sorting preferred version check list

* Reogranized and fixed test
  • Loading branch information
ajkiessl authored Dec 9, 2024
1 parent 7256d6b commit 1559411
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

class ActivityInsightOAWorkflow::PreferredVersionCurationController < ActivityInsightOAWorkflowController
def index
@publications = Publication.needs_manual_preferred_version_check
@publications = Publication.needs_manual_preferred_version_check.order(:doi)
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<tr>
<th>Title</th>
<th>File metadata: Filename (Version)</th>
<th>DOI</th>
</tr>
</thead>
<tbody class='card-body'>
Expand All @@ -31,6 +32,11 @@
<% end %>
</ul>
</td>
<td class="col-sm-5">
<% if p.doi.present? %>
<%= p.doi %>
<% end %>
</td>
</tr>
<% end %>
</tbody>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@
let!(:aif2) { create(:activity_insight_oa_file, publication: pub2) }
let!(:aif4a) { create(:activity_insight_oa_file, publication: pub4) }
let!(:aif4b) { create(:activity_insight_oa_file, publication: pub4, version: 'acceptedVersion') }
let!(:aif5) { create(:activity_insight_oa_file, publication: pub5) }
let!(:pub1) {
create(
:publication,
title: 'Pub1',
permissions_last_checked_at: Time.now
permissions_last_checked_at: Time.now,
doi: 'https://doi.org/10.123/def123'
)
}
let!(:pub2) {
Expand All @@ -26,7 +28,16 @@
create(
:publication,
title: 'Pub4',
permissions_last_checked_at: Time.now
permissions_last_checked_at: Time.now,
doi: nil
)
}
let!(:pub5) {
create(
:publication,
title: 'Pub5',
permissions_last_checked_at: Time.now,
doi: 'https://doi.org/10.123/abc123'
)
}
let(:uploader) { double 'uploader', file: file }
Expand All @@ -40,14 +51,27 @@
end

describe 'listing publications that need their preferred version reviewed' do
it 'shows a table with header and the proper data for the publications in the table' do
it 'shows a table with header and the proper data for the publications in the table ordered by doi' do
within 'thead' do
expect(page).to have_text('Title')
expect(page).to have_text('File metadata: Filename (Version')
end

within "tr#publication_#{pub5.id}" do
expect(page).to have_link('Pub5')
expect(page).to have_text('10.123/abc123')

within 'td.files' do
expect(page).to have_link(
"#{aif5.download_filename} (unknown)",
href: rails_admin.edit_path(model_name: :activity_insight_oa_file, id: aif5.id)
)
end
end

within "tr#publication_#{pub1.id}" do
expect(page).to have_link('Pub1')
expect(page).to have_text('10.123/def123')

within 'td.files' do
expect(page).to have_link(
Expand All @@ -72,7 +96,12 @@
end
end

expect(page).to have_css('tr').exactly(3).times
tr_elements = all('tr')
expect(tr_elements[1][:id]).to eq "publication_#{pub5.id}"
expect(tr_elements[2][:id]).to eq "publication_#{pub1.id}"
expect(tr_elements[3][:id]).to eq "publication_#{pub4.id}"

expect(page).to have_css('tr').exactly(4).times
end
end

Expand Down

0 comments on commit 1559411

Please sign in to comment.