Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[365] exclude draft submissions from challenge manager views #364

Merged
merged 2 commits into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/models/phase.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
class Phase < ApplicationRecord
belongs_to :challenge
# More relations from phoenix app
has_many :submissions, dependent: :destroy
has_many :all_submissions, class_name: "Submission", dependent: :destroy
has_many :submissions, -> { where(status: "submitted") }, inverse_of: :phase, dependent: :destroy
has_many :evaluator_submission_assignments, through: :submissions
has_one :evaluation_form, dependent: :destroy
# has_one :winner, class_name: 'PhaseWinner'
Expand Down
2 changes: 1 addition & 1 deletion spec/factories/submission.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
association :submitter, factory: :user

title { Faker::Lorem.sentence }
status { "draft" }
status { "submitted" }
external_url { "www.example.com" }
end
end
6 changes: 5 additions & 1 deletion spec/requests/submissions_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@

it "renders submission statistics" do
create(:submission, challenge: challenge, phase: phase)
create(:submission, challenge: challenge, phase: phase, status: "draft")
create(:submission, challenge: challenge, phase: phase, judging_status: "selected")

get submissions_phase_path(phase)
Expand All @@ -198,6 +199,7 @@
end

context 'when viewing submissions' do
let!(:draft_submission) { create(:submission, challenge: challenge, phase: phase, status: "draft") }
let!(:not_started_submission) { create(:submission, challenge: challenge, phase: phase) }
let!(:in_progress_submission) do
submission = create(:submission, challenge: challenge, phase: phase)
Expand All @@ -221,13 +223,15 @@
submission
end

it 'displays all submissions and their status counts' do
it 'displays all submissions with status: "submitted" and their status counts' do
get submissions_phase_path(phase)

[not_started_submission, in_progress_submission, completed_submission,
eligible_submission, selected_submission].each do |submission|
expect(response.body).to have_css("[data-submission-id='#{submission.id}']")
end
# except the drafts
expect(response.body).not_to have_css("[data-submission-id='#{draft_submission.id}']")

expect(response.body).to have_css('.text-secondary-dark.text-bold', text: '2') # not_started, eligible
expect(response.body).to have_css('.text-accent-warm-dark.text-bold', text: '1') # in_progress
Expand Down
Loading