diff options
author | Lin Jen-Shin <godfat@godfat.org> | 2016-11-05 02:48:58 +0800 |
---|---|---|
committer | Lin Jen-Shin <godfat@godfat.org> | 2016-11-05 02:48:58 +0800 |
commit | 92aa402882cb9e2badc8213dd88913ad21b49857 (patch) | |
tree | 896228d4ccd2f90d9fd51faed5bcd8b6b24de7c9 /spec/services/files | |
parent | 4b20cb5d74c0bf350ec4c041a912a78775722b3d (diff) | |
download | gitlab-ce-92aa402882cb9e2badc8213dd88913ad21b49857.tar.gz |
Add a test to make sure hooks are fire only once
when updating a file to a different branch.
Diffstat (limited to 'spec/services/files')
-rw-r--r-- | spec/services/files/update_service_spec.rb | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/spec/services/files/update_service_spec.rb b/spec/services/files/update_service_spec.rb index d3c37c7820f..6fadee9304b 100644 --- a/spec/services/files/update_service_spec.rb +++ b/spec/services/files/update_service_spec.rb @@ -6,7 +6,10 @@ describe Files::UpdateService do let(:project) { create(:project) } let(:user) { create(:user) } let(:file_path) { 'files/ruby/popen.rb' } - let(:new_contents) { "New Content" } + let(:new_contents) { 'New Content' } + let(:target_branch) { project.default_branch } + let(:last_commit_sha) { nil } + let(:commit_params) do { file_path: file_path, @@ -16,7 +19,7 @@ describe Files::UpdateService do last_commit_sha: last_commit_sha, source_project: project, source_branch: project.default_branch, - target_branch: project.default_branch, + target_branch: target_branch } end @@ -54,18 +57,6 @@ describe Files::UpdateService do end context "when the last_commit_sha is not supplied" do - let(:commit_params) do - { - file_path: file_path, - commit_message: "Update File", - file_content: new_contents, - file_content_encoding: "text", - source_project: project, - source_branch: project.default_branch, - target_branch: project.default_branch, - } - end - it "returns a hash with the :success status " do results = subject.execute @@ -80,5 +71,15 @@ describe Files::UpdateService do expect(results.data).to eq(new_contents) end end + + context 'when target branch is different than source branch' do + let(:target_branch) { "#{project.default_branch}-new" } + + it 'fires hooks only once' do + expect(GitHooksService).to receive(:new).once.and_call_original + + subject.execute + end + end end end |