Skip to content

Commit

Permalink
Merge pull request #2011 from alphagov/bug-validation-error-assigning…
Browse files Browse the repository at this point in the history
…-reviewer

Bug fix for claiming 2i on scheduled publication
  • Loading branch information
cynthia-anya authored Jan 17, 2024
2 parents f4e4bae + e9a5d60 commit 73a169f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/controllers/editions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def review
end

resource.reviewer = params[:edition][:reviewer]
if resource.save!
if resource.save
flash[:success] = "You are the reviewer of this #{description(resource).downcase}."
else
flash[:danger] = "Something went wrong when attempting to claim 2i."
Expand Down
14 changes: 14 additions & 0 deletions test/functional/editions_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -877,6 +877,20 @@ class EditionsControllerTest < ActionController::TestCase
assert_equal bob.name, @guide.reviewer
end

should "not be able to update the reviewer when edition is scheduled for publishing" do
bob = FactoryBot.create(:user, name: "bob")
edition = FactoryBot.create(:edition, :scheduled_for_publishing)

put :review,
params: {
id: edition.id,
edition: { reviewer: bob.name },
}

assert_response(302)
assert_equal "Something went wrong when attempting to claim 2i.", flash[:danger]
end

context "Welsh editors" do
setup do
@welsh_guide = FactoryBot.create(:guide_edition, :welsh, :in_review)
Expand Down

0 comments on commit 73a169f

Please sign in to comment.