diff options
author | micael.bergeron <micaelbergeron@gmail.com> | 2017-11-22 09:48:09 -0500 |
---|---|---|
committer | micael.bergeron <micaelbergeron@gmail.com> | 2017-12-07 09:01:37 -0500 |
commit | cb6f51ec9b2006f1040cca94119135c92e9a4cd1 (patch) | |
tree | 6331c54f8eab568e134c51ec85a0232372471a16 /spec | |
parent | 716f9cbb415cd425644b1aeae19844b26cc7d6b7 (diff) | |
download | gitlab-ce-cb6f51ec9b2006f1040cca94119135c92e9a4cd1.tar.gz |
add support for the commit reference filter
Diffstat (limited to 'spec')
-rw-r--r-- | spec/controllers/projects/commit_controller_spec.rb | 2 | ||||
-rw-r--r-- | spec/lib/gitlab/git_spec.rb | 25 | ||||
-rw-r--r-- | spec/models/merge_request_spec.rb | 2 | ||||
-rw-r--r-- | spec/services/system_note_service_spec.rb | 11 |
4 files changed, 28 insertions, 12 deletions
diff --git a/spec/controllers/projects/commit_controller_spec.rb b/spec/controllers/projects/commit_controller_spec.rb index a5b603d6bff..fa8533bc3d9 100644 --- a/spec/controllers/projects/commit_controller_spec.rb +++ b/spec/controllers/projects/commit_controller_spec.rb @@ -338,7 +338,7 @@ describe Projects::CommitController do context 'when the commit does not exist' do before do - diff_for_path(id: commit.id.succ, old_path: existing_path, new_path: existing_path) + diff_for_path(id: commit.id.reverse, old_path: existing_path, new_path: existing_path) end it 'returns a 404' do diff --git a/spec/lib/gitlab/git_spec.rb b/spec/lib/gitlab/git_spec.rb index 494dfe0e595..ce15057dd7d 100644 --- a/spec/lib/gitlab/git_spec.rb +++ b/spec/lib/gitlab/git_spec.rb @@ -38,4 +38,29 @@ describe Gitlab::Git do expect(described_class.ref_name(utf8_invalid_ref)).to eq("an_invalid_ref_å") end end + + describe '.shas_eql?' do + using RSpec::Parameterized::TableSyntax + + where(:sha1, :sha2, :result) do + sha = RepoHelpers.sample_commit.id + short_sha = sha[0, Gitlab::Git::Commit::MIN_SHA_LENGTH] + too_short_sha = sha[0, Gitlab::Git::Commit::MIN_SHA_LENGTH - 1] + + [ + [sha, sha, true], + [sha, short_sha, true], + [sha, sha.reverse, false], + [sha, too_short_sha, false], + [sha, nil, false] + ] + end + + with_them do + it { expect(described_class.shas_eql?(sha1, sha2)).to eq(result) } + it 'is commutative' do + expect(described_class.shas_eql?(sha2, sha1)).to eq(result) + end + end + end end diff --git a/spec/models/merge_request_spec.rb b/spec/models/merge_request_spec.rb index 71fbb82184c..30a5a3bbff7 100644 --- a/spec/models/merge_request_spec.rb +++ b/spec/models/merge_request_spec.rb @@ -967,7 +967,7 @@ describe MergeRequest do end shared_examples 'returning all SHA' do - it 'returns all SHA from all merge_request_diffs' do + it 'returns all SHAs from all merge_request_diffs' do expect(subject.merge_request_diffs.size).to eq(2) expect(subject.all_commit_shas).to match_array(all_commit_shas) end diff --git a/spec/services/system_note_service_spec.rb b/spec/services/system_note_service_spec.rb index 148f81b6a58..47412110b4b 100644 --- a/spec/services/system_note_service_spec.rb +++ b/spec/services/system_note_service_spec.rb @@ -690,20 +690,11 @@ describe SystemNoteService do end describe '.new_commit_summary' do - let(:merge_request) { create(:merge_request, :simple, target_project: project, source_project: project) } - it 'escapes HTML titles' do commit = double(title: '<pre>This is a test</pre>', short_id: '12345678') escaped = '<pre>This is a test</pre>' - expect(described_class.new_commit_summary(merge_request, [commit])).to all(match(%r[- #{escaped}])) - end - - it 'contains the MR diffs commit url' do - commit = merge_request.commits.last - url = %r[/merge_requests/#{merge_request.iid}/diffs\?commit_id=#{commit.id}] - - expect(described_class.new_commit_summary(merge_request, [commit])).to all(match(url)) + expect(described_class.new_commit_summary([commit])).to all(match(%r[- #{escaped}])) end end |