diaspora/spec/models/reference_spec.rb
2017-09-28 23:04:34 +02:00

22 lines
669 B
Ruby

# frozen_string_literal: true
describe Reference, type: :model do
context "validation" do
it "validates a valid reference" do
expect(FactoryGirl.build(:reference)).to be_valid
end
it "requires a source" do
expect(FactoryGirl.build(:reference, source: nil)).not_to be_valid
end
it "requires a target" do
expect(FactoryGirl.build(:reference, target: nil)).not_to be_valid
end
it "disallows to link the same target twice from one source" do
reference = FactoryGirl.create(:reference)
expect(FactoryGirl.build(:reference, source: reference.source, target: reference.target)).not_to be_valid
end
end
end