diff --git a/app/controllers/manage_submissions_controller.rb b/app/controllers/manage_submissions_controller.rb index 0af77c47..5b5f736e 100644 --- a/app/controllers/manage_submissions_controller.rb +++ b/app/controllers/manage_submissions_controller.rb @@ -9,18 +9,17 @@ def index def show @submission = Submission.find(params[:id]) end - + def update @submission = Submission.find(params[:id]) if @submission.update!(submission_params) - flash.now[:success] = "Comments saved." + flash.now[:success] = I18n.t("comments_saved") render :show, submission: @submission else - flash.now[:error] = "Unable to save comments." render :show, status: :unprocessable_entity, submission: @submission end - end + end def by_challenge_phase @phase = Phase.where(id: params[:phase_id], diff --git a/app/helpers/manage_submissions_helper.rb b/app/helpers/manage_submissions_helper.rb index 25735f5a..331a32ee 100644 --- a/app/helpers/manage_submissions_helper.rb +++ b/app/helpers/manage_submissions_helper.rb @@ -11,5 +11,5 @@ def selected_to_advance?(submission) def assigned_to_user?(user, submission) submission.challenge_id.in?(user.challenge_manager_challenges.collect(&:id)) - end + end end diff --git a/config/locales/en.yml b/config/locales/en.yml index 8e4b8602..09c060d5 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -32,6 +32,7 @@ en: already_logged_in_notice: "You are already logged in." evaluation_form_destroyed: "Evaluation form was successfully destroyed." evaluation_form_saved: "Evaluation form was saved successfully." + comments_saved: "Comments saved succesfully." login_error: "There was an issue with logging in. Please try again." please_try_again: "Please try again." session_expired_alert: "Your session has expired. Please log in again." diff --git a/spec/factories/submission.rb b/spec/factories/submission.rb index c51fdb6e..ab5b7bdd 100644 --- a/spec/factories/submission.rb +++ b/spec/factories/submission.rb @@ -4,7 +4,7 @@ association :challenge association :phase association :submitter, factory: :user - # don't think we need this anymore? + # don't think we need this anymore? # association :manager, factory: :user title { Faker::Lorem.sentence } diff --git a/spec/requests/manage_submissions_spec.rb b/spec/requests/manage_submissions_spec.rb index e8c5880a..0fb08198 100644 --- a/spec/requests/manage_submissions_spec.rb +++ b/spec/requests/manage_submissions_spec.rb @@ -95,16 +95,16 @@ expect(response.body).to include(submission.id.to_s) expect(response.body).to include(submission.brief_description) end - + it "does not render submission details for a challenge the user is not assigned to" do - challenge = create_challenge() + challenge = create_challenge phase = create_phase(challenge_id: challenge.id) submission = create(:submission, challenge: phase.challenge, brief_description: "This submission has teeth.") get manage_submission_path(submission) expect(response.body).not_to include(submission.brief_description) expect(response.body).to include("You are not assigned to manage this submission.") - end + end end context "when logged in as an evaluator" do