Commit 8a5b4e2f authored by Oswaldo Ferreira's avatar Oswaldo Ferreira

Add RelatedIssue model

parent c2c2628b
class RelatedIssue < ActiveRecord::Base
belongs_to :issue
belongs_to :related_issue, class_name: 'Issue'
validates :issue, presence: true, uniqueness: { scope: :related_issue_id }
validates :related_issue, presence: true
validates :issue_id, uniqueness: { scope: :related_issue_id }
end
\ No newline at end of file
require 'spec_helper'
describe RelatedIssue do
describe "Associations" do
it { is_expected.to belong_to(:issue) }
it { is_expected.to belong_to(:related_issue).class_name('Issue') }
end
describe "Validation" do
subject { build :related_issue }
it { is_expected.to validate_presence_of(:issue) }
it { is_expected.to validate_presence_of(:related_issue) }
it { is_expected.to validate_uniqueness_of(:issue_id).scoped_to(:related_issue_id) }
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment