summaryrefslogtreecommitdiff
path: root/spec/models/merge_request_diff_spec.rb
diff options
context:
space:
mode:
authorAdam Niedzielski <adamsunday@gmail.com>2016-12-01 12:17:30 +0100
committerAdam Niedzielski <adamsunday@gmail.com>2016-12-01 12:17:30 +0100
commitcb6f8cdfc23a18daf33288c95ae8badec63f53ad (patch)
treecad717c7ba416e3fc7974c833cff154d3a1449a2 /spec/models/merge_request_diff_spec.rb
parent2adc6568a6f94b2844c95a0b699a0be9bb8980d1 (diff)
downloadgitlab-ce-cb6f8cdfc23a18daf33288c95ae8badec63f53ad.tar.gz
Replace references to MergeRequestDiff#commits with st_commitsuse-st-commits-where-possible
when we care only about the number of commits We do not have to instantiate all objects in this case.
Diffstat (limited to 'spec/models/merge_request_diff_spec.rb')
-rw-r--r--spec/models/merge_request_diff_spec.rb34
1 files changed, 17 insertions, 17 deletions
diff --git a/spec/models/merge_request_diff_spec.rb b/spec/models/merge_request_diff_spec.rb
index e5007424041..eb876d105da 100644
--- a/spec/models/merge_request_diff_spec.rb
+++ b/spec/models/merge_request_diff_spec.rb
@@ -77,24 +77,13 @@ describe MergeRequestDiff, models: true do
end
describe '#commits_sha' do
- shared_examples 'returning all commits SHA' do
- it 'returns all commits SHA' do
- commits_sha = subject.commits_sha
+ it 'returns all commits SHA using serialized commits' do
+ subject.st_commits = [
+ { id: 'sha1' },
+ { id: 'sha2' }
+ ]
- expect(commits_sha).to eq(subject.commits.map(&:sha))
- end
- end
-
- context 'when commits were loaded' do
- before do
- subject.commits
- end
-
- it_behaves_like 'returning all commits SHA'
- end
-
- context 'when commits were not loaded' do
- it_behaves_like 'returning all commits SHA'
+ expect(subject.commits_sha).to eq(['sha1', 'sha2'])
end
end
@@ -113,4 +102,15 @@ describe MergeRequestDiff, models: true do
expect(diffs.size).to eq(3)
end
end
+
+ describe '#commits_count' do
+ it 'returns number of commits using serialized commits' do
+ subject.st_commits = [
+ { id: 'sha1' },
+ { id: 'sha2' }
+ ]
+
+ expect(subject.commits_count).to eq 2
+ end
+ end
end