BURs: remove ability to skip secondary validations.
Remove the ability to skip secondary validations when creating a BUR. The only skippable validation that still existed was the requirement that both tags in an implication must have wiki pages. It's now mandatory to write wiki pages for tags before you can request an implication. This doesn't apply to empty tags.
This commit is contained in:
@@ -4,6 +4,5 @@ FactoryBot.define do
|
||||
title {"xxx"}
|
||||
script {"create alias aaa -> bbb"}
|
||||
reason { FFaker::Lorem.sentences.join(" ") }
|
||||
skip_secondary_validations {true}
|
||||
end
|
||||
end
|
||||
|
||||
@@ -4,6 +4,5 @@ FactoryBot.define do
|
||||
antecedent_name {"#{FFaker::Name.first_name.downcase}#{rand(1000)}"}
|
||||
consequent_name {"#{FFaker::Name.first_name.downcase}#{rand(1000)}"}
|
||||
status {"active"}
|
||||
skip_secondary_validations {true}
|
||||
end
|
||||
end
|
||||
|
||||
@@ -4,6 +4,5 @@ FactoryBot.define do
|
||||
antecedent_name {"#{FFaker::Name.first_name.downcase}#{rand(1000)}"}
|
||||
consequent_name {"#{FFaker::Name.first_name.downcase}#{rand(1000)}"}
|
||||
status {"active"}
|
||||
skip_secondary_validations {true}
|
||||
end
|
||||
end
|
||||
|
||||
@@ -48,26 +48,14 @@ class BulkUpdateRequestsControllerTest < ActionDispatch::IntegrationTest
|
||||
end
|
||||
|
||||
context "#update" do
|
||||
should "still handle enabled secondary validations correctly" do
|
||||
put_auth bulk_update_request_path(@bulk_update_request.id), @user, params: {bulk_update_request: {script: "create alias zzz -> 222", skip_secondary_validations: "0"}}
|
||||
assert_response :redirect
|
||||
assert_equal("create alias zzz -> 222", @bulk_update_request.reload.script)
|
||||
end
|
||||
|
||||
should "still handle disabled secondary validations correctly" do
|
||||
put_auth bulk_update_request_path(@bulk_update_request.id), @user, params: {bulk_update_request: {script: "create alias zzz -> 222", skip_secondary_validations: "1"}}
|
||||
assert_response :redirect
|
||||
assert_equal("create alias zzz -> 222", @bulk_update_request.reload.script)
|
||||
end
|
||||
|
||||
should "allow builders to update other people's requests" do
|
||||
put_auth bulk_update_request_path(@bulk_update_request.id), create(:builder_user), params: {bulk_update_request: {script: "create alias zzz -> 222", skip_secondary_validations: "0"}}
|
||||
put_auth bulk_update_request_path(@bulk_update_request.id), create(:builder_user), params: {bulk_update_request: {script: "create alias zzz -> 222" }}
|
||||
assert_response :redirect
|
||||
assert_equal("create alias zzz -> 222", @bulk_update_request.reload.script)
|
||||
end
|
||||
|
||||
should "not allow members to update other people's requests" do
|
||||
put_auth bulk_update_request_path(@bulk_update_request.id), create(:user), params: {bulk_update_request: {script: "create alias zzz -> 222", skip_secondary_validations: "0"}}
|
||||
put_auth bulk_update_request_path(@bulk_update_request.id), create(:user), params: {bulk_update_request: {script: "create alias zzz -> 222" }}
|
||||
assert_response 403
|
||||
assert_equal("create alias aaa -> bbb", @bulk_update_request.reload.script)
|
||||
end
|
||||
|
||||
@@ -309,6 +309,24 @@ class BulkUpdateRequestTest < ActiveSupport::TestCase
|
||||
assert_equal(true, @bur.valid?)
|
||||
end
|
||||
end
|
||||
|
||||
context "requesting an implication for an empty tag without a wiki" do
|
||||
should "succeed" do
|
||||
@bur = create(:bulk_update_request, script: "imply a -> b")
|
||||
assert_equal(true, @bur.valid?)
|
||||
end
|
||||
end
|
||||
|
||||
context "requesting an implication for a populated tag without a wiki" do
|
||||
should "fail" do
|
||||
create(:tag, name: "a", post_count: 1)
|
||||
create(:tag, name: "b", post_count: 1)
|
||||
@bur = build(:bulk_update_request, script: "imply a -> b")
|
||||
|
||||
assert_equal(false, @bur.valid?)
|
||||
assert_equal(["'a' must have a wiki page; 'b' must have a wiki page"], @bur.errors.full_messages)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "when the script is updated" do
|
||||
|
||||
@@ -61,16 +61,6 @@ class TagImplicationTest < ActiveSupport::TestCase
|
||||
end
|
||||
end
|
||||
|
||||
context "on secondary validation" do
|
||||
should "warn if either tag is missing a wiki" do
|
||||
ti = FactoryBot.build(:tag_implication, antecedent_name: "aaa", consequent_name: "bbb", skip_secondary_validations: false)
|
||||
|
||||
assert(ti.invalid?)
|
||||
assert_includes(ti.errors[:base], "The aaa tag needs a corresponding wiki page")
|
||||
assert_includes(ti.errors[:base], "The bbb tag needs a corresponding wiki page")
|
||||
end
|
||||
end
|
||||
|
||||
should "populate the creator information" do
|
||||
ti = create(:tag_implication, antecedent_name: "aaa", consequent_name: "bbb", creator: CurrentUser.user)
|
||||
assert_equal(CurrentUser.user.id, ti.creator_id)
|
||||
|
||||
Reference in New Issue
Block a user