added models tests for tag_list count validation

This commit is contained in:
juandefelix
2015-10-03 11:59:54 -05:00
parent 03b0fceecc
commit 2503350526
2 changed files with 32 additions and 8 deletions

View File

@@ -57,10 +57,22 @@ describe Debate do
end
end
it "should sanitize the tag list" do
debate.tag_list = "user_id=1"
debate.valid?
expect(debate.tag_list).to eq(['user_id1'])
describe "#tag_list" do
it "should sanitize the tag list" do
debate.tag_list = "user_id=1"
debate.valid?
expect(debate.tag_list).to eq(['user_id1'])
end
it "should not be valid with a tag list of more than 6 elements" do
debate.tag_list = ["Hacienda", "Economía", "Medio Ambiente", "Corrupción", "Fiestas populares", "Prensa", "Huelgas"]
expect(debate).to_not be_valid
end
it "should be valid with a tag list of 6 elements" do
debate.tag_list = ["Hacienda", "Economía", "Medio Ambiente", "Corrupción", "Fiestas populares", "Prensa"]
expect(debate).to be_valid
end
end
it "should not be valid without accepting terms of service" do

View File

@@ -99,10 +99,22 @@ describe Proposal do
end
end
it "should sanitize the tag list" do
proposal.tag_list = "user_id=1"
proposal.valid?
expect(proposal.tag_list).to eq(['user_id1'])
describe "tag_list" do
it "should sanitize the tag list" do
proposal.tag_list = "user_id=1"
proposal.valid?
expect(proposal.tag_list).to eq(['user_id1'])
end
it "should not be valid with a tag list of more than 6 elements" do
proposal.tag_list = ["Hacienda", "Economía", "Medio Ambiente", "Corrupción", "Fiestas populares", "Prensa", "Huelgas"]
expect(proposal).to_not be_valid
end
it "should be valid with a tag list of more than 6 elements" do
proposal.tag_list = ["Hacienda", "Economía", "Medio Ambiente", "Corrupción", "Fiestas populares", "Prensa"]
expect(proposal).to be_valid
end
end
it "should not be valid without accepting terms of service" do