diff options
author | Matt Oakes <matt@ribot.co.uk> | 2016-03-14 23:33:00 +0000 |
---|---|---|
committer | Matt Oakes <matt@ribot.co.uk> | 2016-04-29 12:45:15 +0100 |
commit | 28dcdb27795de79337df7aeff1107114cdffc2f9 (patch) | |
tree | f32671e2eda91e99eba67da189c2f52370da14a1 /spec | |
parent | 10f84f99cb663faae37139495f547bb68bd8aced (diff) | |
download | gitlab-ce-28dcdb27795de79337df7aeff1107114cdffc2f9.tar.gz |
Support supressing text file diffs on the default branch with .gitattributes
This is a combination of 3 commits.
- Update the bare repositories info/attributes if the default branch is updated
- Check the diff attributes of a file before showing a diff
- Update CHANGELOG
Diffstat (limited to 'spec')
-rw-r--r-- | spec/models/repository_spec.rb | 10 | ||||
-rw-r--r-- | spec/services/git_push_service_spec.rb | 30 |
2 files changed, 40 insertions, 0 deletions
diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb index a306cc4aef8..397bb5a8028 100644 --- a/spec/models/repository_spec.rb +++ b/spec/models/repository_spec.rb @@ -795,6 +795,16 @@ describe Repository, models: true do end + describe "#copy_gitattributes" do + it 'returns true with a valid ref' do + expect(repository.copy_gitattributes('master')).to be_truthy + end + + it 'returns false with an invalid ref' do + expect(repository.copy_gitattributes('invalid')).to be_falsey + end + end + describe "#main_language" do it 'shows the main language of the project' do expect(repository.main_language).to eq("Ruby") diff --git a/spec/services/git_push_service_spec.rb b/spec/services/git_push_service_spec.rb index b40a5c1c818..eeab540c2fd 100644 --- a/spec/services/git_push_service_spec.rb +++ b/spec/services/git_push_service_spec.rb @@ -201,6 +201,36 @@ describe GitPushService, services: true do end + describe "Updates git attributes" do + context "for default branch" do + it "calls the copy attributes method for the first push to the default branch" do + expect(project.repository).to receive(:copy_gitattributes).with('master') + + execute_service(project, user, @blankrev, 'newrev', 'refs/heads/master') + end + + it "calls the copy attributes method for changes to the default branch" do + expect(project.repository).to receive(:copy_gitattributes).with('refs/heads/master') + + execute_service(project, user, 'oldrev', 'newrev', 'refs/heads/master') + end + end + + context "for non-default branch" do + before do + # Make sure the "default" branch is different + allow(project).to receive(:default_branch).and_return('not-master') + end + + it "does not call copy attributes method" do + expect(project.repository).not_to receive(:copy_gitattributes) + + execute_service(project, user, @oldrev, @newrev, @ref) + end + end + end + + describe "Webhooks" do context "execute webhooks" do it "when pushing a branch for the first time" do |