Skip to content

Commit

Permalink
Adding the submission counts to the dashboard (#1608)
Browse files Browse the repository at this point in the history
* submissions count

* Moving the number to the original header

* rubocopb changes

* pluralize submissions

* Adding additional test for multiple works counting

---------

Co-authored-by: Carolyn Cole <[email protected]>
  • Loading branch information
FavourNwogbo21 and carolyncole authored Nov 30, 2023
1 parent 26410c5 commit 2b8e495
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/views/users/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@
<% end %>
<% if @unfinished_works.count > 0 %>
<h2 class="dataset-section">Unfinished Submissions</h2>
<h2 class="dataset-section unfinished-submission"><%= pluralize(@unfinished_works.count, "Unfinished Submission")%></h2>
<%= render partial: "dataset_table", locals: {table_id: "unfinished_datasets", datasets: @unfinished_works} %>
<% end %>
<% if @completed_works.count > 0 %>
<h2 class="dataset-section">Completed Submissions</h2>
<h2 class="dataset-section completed-submission"><%= pluralize(@completed_works.count, "Completed Submission")%></h2>
<%= render partial: "dataset_table", locals: {table_id: "completed_datasets", datasets: @completed_works} %>
<% end %>
Expand Down
35 changes: 35 additions & 0 deletions spec/system/user_show_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,39 @@
expect(page.html.include?(user_admin.uid)).to be true
end
end
describe "dashboard shows finished and unfinished work" do
let(:user_admin) { FactoryBot.create :super_admin_user }
before do
FactoryBot.create :draft_work
FactoryBot.create :approved_work
end
it "shows the number of finished and unfinished works" do
sign_in user_admin
visit user_path(user_admin)
within("h2.unfinished-submission") do
expect(page.text).to eq("1 Unfinished Submission")
end
within("h2.completed-submission") do
expect(page.text).to eq("1 Completed Submission")
end
end
end

describe "dashboard shows multiple finished and unfinished works" do
let(:user_admin) { FactoryBot.create :super_admin_user }
before do
2.times { FactoryBot.create :draft_work }
3.times { FactoryBot.create :approved_work }
end
it "shows the number of finished and unfinished works" do
sign_in user_admin
visit user_path(user_admin)
within("h2.unfinished-submission") do
expect(page.text).to eq("2 Unfinished Submissions")
end
within("h2.completed-submission") do
expect(page.text).to eq("3 Completed Submissions")
end
end
end
end

0 comments on commit 2b8e495

Please sign in to comment.