diff options
author | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2016-03-18 13:27:27 -0300 |
---|---|---|
committer | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2016-03-18 13:27:27 -0300 |
commit | 02b0c37cabf0456a4c36680fb1313b1107f35f54 (patch) | |
tree | e112e567c618bd8011038ba79f4a241f7117f67d /spec/models/todo_spec.rb | |
parent | 2a8858ca8adbc54d7e24e698fa8ce370a1e91157 (diff) | |
download | gitlab-ce-02b0c37cabf0456a4c36680fb1313b1107f35f54.tar.gz |
Refactor `Todo#target`
Diffstat (limited to 'spec/models/todo_spec.rb')
-rw-r--r-- | spec/models/todo_spec.rb | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/spec/models/todo_spec.rb b/spec/models/todo_spec.rb index 22acfdfe2c0..d9b86b9368f 100644 --- a/spec/models/todo_spec.rb +++ b/spec/models/todo_spec.rb @@ -99,13 +99,23 @@ describe Todo, models: true do end describe '#target' do - it 'returns an instance of Commit for commits' do - subject.project = project - subject.target_type = 'Commit' - subject.commit_id = commit.id - - expect(subject.target).to be_a(Commit) - expect(subject.target).to eq commit + context 'for commits' do + it 'returns an instance of Commit when exists' do + subject.project = project + subject.target_type = 'Commit' + subject.commit_id = commit.id + + expect(subject.target).to be_a(Commit) + expect(subject.target).to eq commit + end + + it 'returns nil when does not exists' do + subject.project = project + subject.target_type = 'Commit' + subject.commit_id = 'xxxx' + + expect(subject.target).to be_nil + end end it 'returns the issuable for issuables' do |