Merge pull request #3686 from consul/lowercase_tags

Fix flaky specs for uppercase tags
This commit is contained in:
Javier Martín
2019-09-10 15:04:17 +02:00
committed by GitHub
2 changed files with 37 additions and 17 deletions

View File

@@ -511,28 +511,29 @@ describe "Consul Schema" do
expect(received_tags).to match_array ["Parks", "Health"]
end
it "uppercase and lowercase tags work ok together for proposals" do
create(:tag, name: "Health")
create(:tag, name: "health")
create(:proposal, tag_list: "health")
create(:proposal, tag_list: "Health")
context "uppercase and lowercase tags" do
let(:uppercase_tag) { create(:tag, name: "Health") }
let(:lowercase_tag) { create(:tag, name: "health") }
response = execute("{ tags { edges { node { name } } } }")
received_tags = extract_fields(response, "tags", "name")
it "works OK when both tags are present for proposals" do
create(:proposal).tags = [uppercase_tag]
create(:proposal).tags = [lowercase_tag]
expect(received_tags).to match_array ["Health", "health"]
end
response = execute("{ tags { edges { node { name } } } }")
received_tags = extract_fields(response, "tags", "name")
it "uppercase and lowercase tags work ok together for debates" do
create(:tag, name: "Health")
create(:tag, name: "health")
create(:debate, tag_list: "Health")
create(:debate, tag_list: "health")
expect(received_tags).to match_array ["Health", "health"]
end
response = execute("{ tags { edges { node { name } } } }")
received_tags = extract_fields(response, "tags", "name")
it "works OK when both tags are present for proposals" do
create(:debate).tags = [uppercase_tag]
create(:debate).tags = [lowercase_tag]
expect(received_tags).to match_array ["Health", "health"]
response = execute("{ tags { edges { node { name } } } }")
received_tags = extract_fields(response, "tags", "name")
expect(received_tags).to match_array ["Health", "health"]
end
end
it "does not display tags for hidden proposals" do

View File

@@ -34,4 +34,23 @@ describe Tag do
expect(tag).to be_valid
end
end
context "Same tag uppercase and lowercase" do
before do
create(:tag, name: "Health")
create(:tag, name: "health")
end
it "assigns only one of the existing tags (we can't control which one)" do
debate = create(:debate, tag_list: "Health")
expect([["Health"], ["health"]]).to include debate.reload.tag_list
end
it "assigns existing tags instead of creating new similar ones" do
debate = create(:debate, tag_list: "hEaLth")
expect([["Health"], ["health"]]).to include debate.reload.tag_list
end
end
end