summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorRobert Speicher <robert@gitlab.com>2017-05-07 22:59:30 +0000
committerRobert Speicher <robert@gitlab.com>2017-05-07 22:59:30 +0000
commit8b9cd3c072768ca810d2b33009e35d93a05e417f (patch)
tree702515a306348f8146c3eb29419f6e591e954e10 /spec
parentf7cf2a7be6908ff577432a8c6b520a71361d4860 (diff)
parent2f60a402d1fa98bb0090343f8180fc03b715467e (diff)
downloadgitlab-ce-8b9cd3c072768ca810d2b33009e35d93a05e417f.tar.gz
Merge branch 'fix/support-gitaly-commit-diff-flags' into 'master'
Add support for commit diff ignore_whitespace_change and paths flags Closes gitaly#198 See merge request !11028
Diffstat (limited to 'spec')
-rw-r--r--spec/lib/gitlab/gitaly_client/commit_spec.rb11
-rw-r--r--spec/models/commit_spec.rb55
2 files changed, 30 insertions, 36 deletions
diff --git a/spec/lib/gitlab/gitaly_client/commit_spec.rb b/spec/lib/gitlab/gitaly_client/commit_spec.rb
index 58f11ff8906..abe08ccdfa1 100644
--- a/spec/lib/gitlab/gitaly_client/commit_spec.rb
+++ b/spec/lib/gitlab/gitaly_client/commit_spec.rb
@@ -7,11 +7,6 @@ describe Gitlab::GitalyClient::Commit do
let(:repository_message) { project.repository.gitaly_repository }
let(:commit) { project.commit('913c66a37b4a45b9769037c55c2d238bd0942d2e') }
- before do
- allow(Gitaly::Diff::Stub).to receive(:new).and_return(diff_stub)
- allow(diff_stub).to receive(:commit_diff).and_return([])
- end
-
context 'when a commit has a parent' do
it 'sends an RPC request with the parent ID as left commit' do
request = Gitaly::CommitDiffRequest.new(
@@ -20,7 +15,7 @@ describe Gitlab::GitalyClient::Commit do
right_commit_id: commit.id,
)
- expect(diff_stub).to receive(:commit_diff).with(request)
+ expect_any_instance_of(Gitaly::Diff::Stub).to receive(:commit_diff).with(request)
described_class.diff_from_parent(commit)
end
@@ -35,7 +30,7 @@ describe Gitlab::GitalyClient::Commit do
right_commit_id: initial_commit.id,
)
- expect(diff_stub).to receive(:commit_diff).with(request)
+ expect_any_instance_of(Gitaly::Diff::Stub).to receive(:commit_diff).with(request)
described_class.diff_from_parent(initial_commit)
end
@@ -50,7 +45,7 @@ describe Gitlab::GitalyClient::Commit do
it 'passes options to Gitlab::Git::DiffCollection' do
options = { max_files: 31, max_lines: 13 }
- expect(Gitlab::Git::DiffCollection).to receive(:new).with([], options)
+ expect(Gitlab::Git::DiffCollection).to receive(:new).with(kind_of(Enumerable), options)
described_class.diff_from_parent(commit, options)
end
diff --git a/spec/models/commit_spec.rb b/spec/models/commit_spec.rb
index 08b2169fea7..852889d4540 100644
--- a/spec/models/commit_spec.rb
+++ b/spec/models/commit_spec.rb
@@ -389,32 +389,31 @@ eos
end
end
- # describe '#raw_diffs' do
- # TODO: Uncomment when feature is reenabled
- # context 'Gitaly commit_raw_diffs feature enabled' do
- # before do
- # allow(Gitlab::GitalyClient).to receive(:feature_enabled?).with(:commit_raw_diffs).and_return(true)
- # end
- #
- # context 'when a truthy deltas_only is not passed to args' do
- # it 'fetches diffs from Gitaly server' do
- # expect(Gitlab::GitalyClient::Commit).to receive(:diff_from_parent).
- # with(commit)
- #
- # commit.raw_diffs
- # end
- # end
- #
- # context 'when a truthy deltas_only is passed to args' do
- # it 'fetches diffs using Rugged' do
- # opts = { deltas_only: true }
- #
- # expect(Gitlab::GitalyClient::Commit).not_to receive(:diff_from_parent)
- # expect(commit.raw).to receive(:diffs).with(opts)
- #
- # commit.raw_diffs(opts)
- # end
- # end
- # end
- # end
+ describe '#raw_diffs' do
+ context 'Gitaly commit_raw_diffs feature enabled' do
+ before do
+ allow(Gitlab::GitalyClient).to receive(:feature_enabled?).with(:commit_raw_diffs).and_return(true)
+ end
+
+ context 'when a truthy deltas_only is not passed to args' do
+ it 'fetches diffs from Gitaly server' do
+ expect(Gitlab::GitalyClient::Commit).to receive(:diff_from_parent).
+ with(commit)
+
+ commit.raw_diffs
+ end
+ end
+
+ context 'when a truthy deltas_only is passed to args' do
+ it 'fetches diffs using Rugged' do
+ opts = { deltas_only: true }
+
+ expect(Gitlab::GitalyClient::Commit).not_to receive(:diff_from_parent)
+ expect(commit.raw).to receive(:diffs).with(opts)
+
+ commit.raw_diffs(opts)
+ end
+ end
+ end
+ end
end