diff options
author | Filipa Lacerda <filipa@gitlab.com> | 2017-08-04 19:38:37 +0100 |
---|---|---|
committer | Filipa Lacerda <filipa@gitlab.com> | 2017-08-04 19:38:37 +0100 |
commit | e4f8aa719bcde767793a82103f149cd37b4ad14c (patch) | |
tree | 8070383e2618d45907b33909e5f5020f5e92bcec /spec/lib/gitlab/git/blame_spec.rb | |
parent | a432ae9d06f7dc28d0825e87bafb33a04ae3cf20 (diff) | |
parent | 017550d482b0035dbec3ae93f8b0c73839772464 (diff) | |
download | gitlab-ce-e4f8aa719bcde767793a82103f149cd37b4ad14c.tar.gz |
Merge branch 'master' into issue-discussions-refactor
* master: (162 commits)
Since mysql is not a priority anymore, test it less
Add container registry and spam logs icons
Fix different Markdown styles
Backport to CE for:
Make new dropdown dividers full width
Bump GITLAB_SHELL_VERSION and GITALY_VERSION to support unhiding refs
Install yarn via apt in update guides
Use long curl options
Remove monkey-patched Array.prototype.first() and last() methods
Openshift Getting Started
35659 Rename Pipelines tab to CI / CD in new navigation
Don't bother going through an entire Banzai pipeline for empty text
Add active state for pipelines settings on old nav
Bump rspec to 3.6.0
Resolve "Specific Async Script Loading by using a Page Variable"
Revert "Merge branch 'rs-warm-capybara-only-in-ci' into 'master'"
another rubocop style fix
Use mixin for new dropdown style
Migrate Repository#last_commit_for_path to Gitaly
Migrate blame loading to Gitaly
...
Diffstat (limited to 'spec/lib/gitlab/git/blame_spec.rb')
-rw-r--r-- | spec/lib/gitlab/git/blame_spec.rb | 102 |
1 files changed, 56 insertions, 46 deletions
diff --git a/spec/lib/gitlab/git/blame_spec.rb b/spec/lib/gitlab/git/blame_spec.rb index 66c016d14b3..800c245b130 100644 --- a/spec/lib/gitlab/git/blame_spec.rb +++ b/spec/lib/gitlab/git/blame_spec.rb @@ -7,63 +7,73 @@ describe Gitlab::Git::Blame, seed_helper: true do Gitlab::Git::Blame.new(repository, SeedRepo::Commit::ID, "CONTRIBUTING.md") end - context "each count" do - it do - data = [] - blame.each do |commit, line| - data << { - commit: commit, - line: line - } - end - - expect(data.size).to eq(95) - expect(data.first[:commit]).to be_kind_of(Gitlab::Git::Commit) - expect(data.first[:line]).to eq("# Contribute to GitLab") - expect(data.first[:line]).to be_utf8 - end - end + shared_examples 'blaming a file' do + context "each count" do + it do + data = [] + blame.each do |commit, line| + data << { + commit: commit, + line: line + } + end - context "ISO-8859 encoding" do - let(:blame) do - Gitlab::Git::Blame.new(repository, SeedRepo::EncodingCommit::ID, "encoding/iso8859.txt") + expect(data.size).to eq(95) + expect(data.first[:commit]).to be_kind_of(Gitlab::Git::Commit) + expect(data.first[:line]).to eq("# Contribute to GitLab") + expect(data.first[:line]).to be_utf8 + end end - it 'converts to UTF-8' do - data = [] - blame.each do |commit, line| - data << { - commit: commit, - line: line - } + context "ISO-8859 encoding" do + let(:blame) do + Gitlab::Git::Blame.new(repository, SeedRepo::EncodingCommit::ID, "encoding/iso8859.txt") end - expect(data.size).to eq(1) - expect(data.first[:commit]).to be_kind_of(Gitlab::Git::Commit) - expect(data.first[:line]).to eq("Ä ü") - expect(data.first[:line]).to be_utf8 - end - end + it 'converts to UTF-8' do + data = [] + blame.each do |commit, line| + data << { + commit: commit, + line: line + } + end - context "unknown encoding" do - let(:blame) do - Gitlab::Git::Blame.new(repository, SeedRepo::EncodingCommit::ID, "encoding/iso8859.txt") + expect(data.size).to eq(1) + expect(data.first[:commit]).to be_kind_of(Gitlab::Git::Commit) + expect(data.first[:line]).to eq("Ä ü") + expect(data.first[:line]).to be_utf8 + end end - it 'converts to UTF-8' do - expect(CharlockHolmes::EncodingDetector).to receive(:detect).and_return(nil) - data = [] - blame.each do |commit, line| - data << { + context "unknown encoding" do + let(:blame) do + Gitlab::Git::Blame.new(repository, SeedRepo::EncodingCommit::ID, "encoding/iso8859.txt") + end + + it 'converts to UTF-8' do + expect(CharlockHolmes::EncodingDetector).to receive(:detect).and_return(nil) + data = [] + blame.each do |commit, line| + data << { commit: commit, line: line - } - end + } + end - expect(data.size).to eq(1) - expect(data.first[:commit]).to be_kind_of(Gitlab::Git::Commit) - expect(data.first[:line]).to eq(" ") - expect(data.first[:line]).to be_utf8 + expect(data.size).to eq(1) + expect(data.first[:commit]).to be_kind_of(Gitlab::Git::Commit) + expect(data.first[:line]).to eq(" ") + expect(data.first[:line]).to be_utf8 + end end end + + context 'when Gitaly blame feature is enabled' do + it_behaves_like 'blaming a file' + end + + context 'when Gitaly blame feature is disabled', skip_gitaly_mock: true do + it_behaves_like 'blaming a file' + end end |