summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorRobert Speicher <robert@gitlab.com>2016-02-18 19:07:13 +0000
committerRobert Speicher <robert@gitlab.com>2016-02-18 19:07:13 +0000
commit94a0a00f408ffcd324701309effa6c727cb6f65d (patch)
tree4874f0a792b93764bdc96259ab33f585547d4e37 /spec
parent7f7eef2aef31f9cd4297d25d4416515182aa9482 (diff)
parent5b6d347fcdb915a977369721bbc2545f17467cbb (diff)
downloadgitlab-ce-94a0a00f408ffcd324701309effa6c727cb6f65d.tar.gz
Merge branch 'autocrlf-lazy' into 'master'
Only set autocrlf when creating/updating files Related issue: gitlab-org/gitlab-ce#13457 Details: 5619a6de1dd6fc1dfd4053810c7b11c677b7a495 See merge request !2859
Diffstat (limited to 'spec')
-rw-r--r--spec/models/repository_spec.rb59
1 files changed, 57 insertions, 2 deletions
diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb
index 2cd0606a61d..ed91b62c534 100644
--- a/spec/models/repository_spec.rb
+++ b/spec/models/repository_spec.rb
@@ -200,13 +200,22 @@ describe Repository, models: true do
describe :commit_with_hooks do
context 'when pre hooks were successful' do
- it 'should run without errors' do
- expect_any_instance_of(GitHooksService).to receive(:execute).and_return(true)
+ before do
+ expect_any_instance_of(GitHooksService).to receive(:execute).
+ and_return(true)
+ end
+ it 'should run without errors' do
expect do
repository.commit_with_hooks(user, 'feature') { sample_commit.id }
end.not_to raise_error
end
+
+ it 'should ensure the autocrlf Git option is set to :input' do
+ expect(repository).to receive(:update_autocrlf_option)
+
+ repository.commit_with_hooks(user, 'feature') { sample_commit.id }
+ end
end
context 'when pre hooks failed' do
@@ -220,6 +229,25 @@ describe Repository, models: true do
end
end
+ describe '#exists?' do
+ it 'returns true when a repository exists' do
+ expect(repository.exists?).to eq(true)
+ end
+
+ it 'returns false when a repository does not exist' do
+ expect(repository.raw_repository).to receive(:rugged).
+ and_raise(Gitlab::Git::Repository::NoRepository)
+
+ expect(repository.exists?).to eq(false)
+ end
+
+ it 'returns false when there is no namespace' do
+ allow(repository).to receive(:path_with_namespace).and_return(nil)
+
+ expect(repository.exists?).to eq(false)
+ end
+ end
+
describe '#has_visible_content?' do
subject { repository.has_visible_content? }
@@ -249,6 +277,33 @@ describe Repository, models: true do
end
end
+ describe '#update_autocrlf_option' do
+ describe 'when autocrlf is not already set to :input' do
+ before do
+ repository.raw_repository.autocrlf = true
+ end
+
+ it 'sets autocrlf to :input' do
+ repository.update_autocrlf_option
+
+ expect(repository.raw_repository.autocrlf).to eq(:input)
+ end
+ end
+
+ describe 'when autocrlf is already set to :input' do
+ before do
+ repository.raw_repository.autocrlf = :input
+ end
+
+ it 'does nothing' do
+ expect(repository.raw_repository).to_not receive(:autocrlf=).
+ with(:input)
+
+ repository.update_autocrlf_option
+ end
+ end
+ end
+
describe '#empty?' do
let(:empty_repository) { create(:project_empty_repo).repository }