Skip to content

Commit

Permalink
Fix exception case when a user tries to claim 2i whilst an edition is…
Browse files Browse the repository at this point in the history
… scheduled for publishing
  • Loading branch information
cynthia-anya committed Jan 16, 2024
1 parent 7573896 commit a187556
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 there is a validation error" 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 a187556

Please sign in to comment.