From cd9bea770bd8a1e4b6590ba93a15f4ff75529f11 Mon Sep 17 00:00:00 2001 From: "http://jneen.net/" Date: Thu, 16 Jun 2016 11:07:22 -0700 Subject: [PATCH] fix the spec, using project.change_head --- spec/lib/gitlab/highlight_spec.rb | 12 +++++++++--- spec/support/test_env.rb | 1 + 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/spec/lib/gitlab/highlight_spec.rb b/spec/lib/gitlab/highlight_spec.rb index 303943606ff..9c54e53f402 100644 --- a/spec/lib/gitlab/highlight_spec.rb +++ b/spec/lib/gitlab/highlight_spec.rb @@ -4,6 +4,7 @@ describe Gitlab::Highlight, lib: true do include RepoHelpers let(:project) { create(:project) } + let(:repository) { project.repository } let(:commit) { project.commit(sample_commit.id) } describe '.highlight_lines' do @@ -19,13 +20,18 @@ describe Gitlab::Highlight, lib: true do end describe 'custom highlighting from .gitattributes' do - let(:blob) { project.blob_at_branch('master', 'custom-highlighting/test.gitlab-custom') } + let(:branch) { 'gitattributes' } + let(:path) { 'custom-highlighting/test.gitlab-custom' } + let(:blob) { repository.blob_at_branch(branch, path) } + let(:highlighter) { - Gitlab::Highlight.new(blob.path, blob.contents, repository: project.repository) + Gitlab::Highlight.new(blob.path, blob.data, repository: repository) } + before { project.change_head('gitattributes') } + it 'highlights as ruby' do - expect(highlighter.lexer).to be_an_instance_of Rouge::Lexers::Ruby + expect(highlighter.lexer).to be Rouge::Lexers::Ruby end end end diff --git a/spec/support/test_env.rb b/spec/support/test_env.rb index 498bd4bf800..8246be357a5 100644 --- a/spec/support/test_env.rb +++ b/spec/support/test_env.rb @@ -17,6 +17,7 @@ module TestEnv "'test'" => 'e56497b', 'orphaned-branch' => '45127a9', 'binary-encoding' => '7b1cf43', + 'gitattributes' => '281d3a76' } # gitlab-test-fork is a fork of gitlab-fork, but we don't necessarily