Skip to content

Commit

Permalink
remove unnecessary association that is breaking things (#353)
Browse files Browse the repository at this point in the history
* remove unnecessary association that is breaking things

* fix specs
stepchud authored Jan 10, 2025

Verified

This commit was signed with the committer’s verified signature.
arvindh123 Arvindh
1 parent 366795e commit d541aca
Showing 7 changed files with 14 additions and 16 deletions.
1 change: 0 additions & 1 deletion app/models/submission.rb
Original file line number Diff line number Diff line change
@@ -33,7 +33,6 @@ class Submission < ApplicationRecord
belongs_to :challenge
belongs_to :phase, counter_cache: true
belongs_to :submitter, class_name: 'User'
belongs_to :manager, class_name: 'User'
has_many :evaluator_submission_assignments, dependent: :destroy
has_many :evaluators, through: :evaluator_submission_assignments, class_name: "User"
has_many :evaluations, dependent: :destroy
12 changes: 6 additions & 6 deletions app/views/phases/_submissions_stats.html.erb
Original file line number Diff line number Diff line change
@@ -11,9 +11,9 @@
<span class="font-sans-3xl text-primary text-bold"><%= @submissions_count %></span>
</div>
<div>
<h3 class="usa-summary-box__heading text-primary margin-bottom-05" id="summary-box-key-information">
<h2 class="usa-summary-box__heading text-primary margin-bottom-05" id="summary-box-key-information">
Total Submissions
</h3>
</h2>
<p class="usa-summary-box__text text-primary-darker text-bold">
Evaluations due by <%= @phase.evaluation_form&.closing_date&.strftime('%m/%d/%Y') || "N/A" %>
</p>
@@ -26,15 +26,15 @@
<div class="display-flex flex-row tablet:margin-left-auto">
<div class="text-center margin-right-5">
<span class="font-sans-xl text-green text-bold"><%= @submissions_by_status[:completed] || 0 %></span><br>
<span class="text-base-sm text-green text-bold">Completed</span>
<span class="font-sans-lg text-green text-bold">Completed</span>
</div>
<div class="text-center margin-right-5">
<span class="font-sans-xl text-orange text-bold"><%= @submissions_by_status[:in_progress] || 0 %></span><br>
<span class="text-base-sm text-orange text-bold">In Progress</span>
<span class="font-sans-xl text-accent-warm-dark text-bold"><%= @submissions_by_status[:in_progress] || 0 %></span><br>
<span class="font-sans-lg text-accent-warm-dark text-bold">In Progress</span>
</div>
<div class="text-center margin-right-2">
<span class="font-sans-xl text-secondary-dark text-bold"><%= @submissions_by_status[:not_started] || 0 %></span><br>
<span class="text-base-sm text-secondary-dark text-bold">Not Started</span>
<span class="font-sans-lg text-secondary-dark text-bold">Not Started</span>
</div>
</div>
</div>
1 change: 0 additions & 1 deletion spec/factories/submission.rb
Original file line number Diff line number Diff line change
@@ -4,7 +4,6 @@
association :challenge
association :phase
association :submitter, factory: :user
association :manager, factory: :user

title { Faker::Lorem.sentence }
status { "draft" }
2 changes: 1 addition & 1 deletion spec/models/evaluation_spec.rb
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@

RSpec.describe Evaluation, type: :model do
let(:user) { create(:user, :evaluator) }
let(:submission) { create(:submission, manager: user) }
let(:submission) { create(:submission) }
let(:evaluator_submission_assignment) { create(:evaluator_submission_assignment, evaluator: user) }
let(:evaluation_form) { create(:evaluation_form) }
let(:evaluation) { create(:evaluation, user:, evaluation_form:, submission:, evaluator_submission_assignment:) }
8 changes: 4 additions & 4 deletions spec/requests/submissions_spec.rb
Original file line number Diff line number Diff line change
@@ -190,7 +190,7 @@
get submissions_phase_path(phase)
expect(response.body).to include("Boston Tea Party Cleanup")
# total submission count
expect(response.body).to have_css("h3.text-primary", text: "Total Submissions")
expect(response.body).to have_css("h2.text-primary", text: "Total Submissions")
expect(response.body).to have_css("span.font-sans-3xl.text-primary.text-bold", text: "2")
# selected to advance
expect(response.body).to have_css("span.text-primary", text: "1 of 2")
@@ -229,9 +229,9 @@
expect(response.body).to have_css("[data-submission-id='#{submission.id}']")
end

expect(response.body).to have_css('.text-secondary-dark.text-bold', text: '2') # not_started, eligible
expect(response.body).to have_css('.text-orange.text-bold', text: '1') # in_progress
expect(response.body).to have_css('.text-green.text-bold', text: '2') # completed, selected
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
expect(response.body).to have_css('.text-green.text-bold', text: '2') # completed, selected
end

context 'when filtering submissions' do
2 changes: 1 addition & 1 deletion spec/system/submission_details_spec.rb
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@
let(:user) { create_user(role: "challenge_manager") }
let(:challenge) { create_challenge(user: user, title: "Boston Tea Party Cleanup") }
let(:phase) { create(:phase, challenge: challenge) }
let(:submission) { create(:submission, challenge:, phase:, manager: user, status: "submitted") }
let(:submission) { create(:submission, challenge:, phase:, status: "submitted") }
let(:fake_comments) { Faker::Lorem.sentence }

before do
4 changes: 2 additions & 2 deletions spec/system/submissions_spec.rb
Original file line number Diff line number Diff line change
@@ -11,14 +11,14 @@
it "manage submissions by challenge phase page is accessible with one challenge" do
challenge = create_challenge(user: user, title: "Boston Tea Party Cleanup")
phase = create_phase(challenge_id: challenge.id)
create(:submission, manager: user, challenge: challenge, phase: phase)
create(:submission, challenge: challenge, phase: phase)

visit submissions_phase_path(phase)
expect(user.role).to eq("challenge_manager")
expect(page).to have_content("Boston Tea Party Cleanup")
expect(page).to have_content("Total Submissions")
# commenting out for now, switch this back on soon
# expect(page).to(be_axe_clean)
expect(page).to(be_axe_clean)
end
end
end

0 comments on commit d541aca

Please sign in to comment.