Commit 5a883915 authored by Nick Thomas's avatar Nick Thomas

Guard against regressions in commit email specs

parent 12f98792
...@@ -184,11 +184,12 @@ class ProjectWiki ...@@ -184,11 +184,12 @@ class ProjectWiki
def commit_details(action, message = nil, title = nil) def commit_details(action, message = nil, title = nil)
commit_message = message || default_message(action, title) commit_message = message || default_message(action, title)
git_user = Gitlab::Git::User.from_gitlab(@user)
Gitlab::Git::Wiki::CommitDetails.new(@user.id, Gitlab::Git::Wiki::CommitDetails.new(@user.id,
@user.username, git_user.username,
@user.name, git_user.name,
@user.commit_email, git_user.email,
commit_message) commit_message)
end end
......
...@@ -280,6 +280,7 @@ describe ProjectWiki do ...@@ -280,6 +280,7 @@ describe ProjectWiki do
it 'sets the correct commit email' do it 'sets the correct commit email' do
subject.create_page('test page', 'content') subject.create_page('test page', 'content')
expect(user.commit_email).not_to eq(user.email)
expect(commit.author_email).to eq(user.commit_email) expect(commit.author_email).to eq(user.commit_email)
expect(commit.committer_email).to eq(user.commit_email) expect(commit.committer_email).to eq(user.commit_email)
end end
...@@ -329,6 +330,7 @@ describe ProjectWiki do ...@@ -329,6 +330,7 @@ describe ProjectWiki do
end end
it 'sets the correct commit email' do it 'sets the correct commit email' do
expect(user.commit_email).not_to eq(user.email)
expect(commit.author_email).to eq(user.commit_email) expect(commit.author_email).to eq(user.commit_email)
expect(commit.committer_email).to eq(user.commit_email) expect(commit.committer_email).to eq(user.commit_email)
end end
...@@ -363,6 +365,7 @@ describe ProjectWiki do ...@@ -363,6 +365,7 @@ describe ProjectWiki do
it 'sets the correct commit email' do it 'sets the correct commit email' do
subject.delete_page(@page) subject.delete_page(@page)
expect(user.commit_email).not_to eq(user.email)
expect(commit.author_email).to eq(user.commit_email) expect(commit.author_email).to eq(user.commit_email)
expect(commit.committer_email).to eq(user.commit_email) expect(commit.committer_email).to eq(user.commit_email)
end end
......
...@@ -84,6 +84,7 @@ describe Files::CreateService do ...@@ -84,6 +84,7 @@ describe Files::CreateService do
it 'uses the commit email' do it 'uses the commit email' do
subject.execute subject.execute
expect(user.commit_email).not_to eq(user.email)
expect(commit.author_email).to eq(user.commit_email) expect(commit.author_email).to eq(user.commit_email)
expect(commit.committer_email).to eq(user.commit_email) expect(commit.committer_email).to eq(user.commit_email)
end end
......
...@@ -4,7 +4,7 @@ describe Files::DeleteService do ...@@ -4,7 +4,7 @@ describe Files::DeleteService do
subject { described_class.new(project, user, commit_params) } subject { described_class.new(project, user, commit_params) }
let(:project) { create(:project, :repository) } let(:project) { create(:project, :repository) }
let(:user) { create(:user) } let(:user) { create(:user, :commit_email) }
let(:file_path) { 'files/ruby/popen.rb' } let(:file_path) { 'files/ruby/popen.rb' }
let(:branch_name) { project.default_branch } let(:branch_name) { project.default_branch }
let(:last_commit_sha) { nil } let(:last_commit_sha) { nil }
...@@ -39,6 +39,7 @@ describe Files::DeleteService do ...@@ -39,6 +39,7 @@ describe Files::DeleteService do
it 'uses the commit email' do it 'uses the commit email' do
subject.execute subject.execute
expect(user.commit_email).not_to eq(user.email)
expect(commit.author_email).to eq(user.commit_email) expect(commit.author_email).to eq(user.commit_email)
expect(commit.committer_email).to eq(user.commit_email) expect(commit.committer_email).to eq(user.commit_email)
end end
......
...@@ -4,7 +4,7 @@ describe Files::UpdateService do ...@@ -4,7 +4,7 @@ describe Files::UpdateService do
subject { described_class.new(project, user, commit_params) } subject { described_class.new(project, user, commit_params) }
let(:project) { create(:project, :repository) } let(:project) { create(:project, :repository) }
let(:user) { create(:user) } let(:user) { create(:user, :commit_email) }
let(:file_path) { 'files/ruby/popen.rb' } let(:file_path) { 'files/ruby/popen.rb' }
let(:new_contents) { 'New Content' } let(:new_contents) { 'New Content' }
let(:branch_name) { project.default_branch } let(:branch_name) { project.default_branch }
...@@ -59,6 +59,7 @@ describe Files::UpdateService do ...@@ -59,6 +59,7 @@ describe Files::UpdateService do
it 'uses the commit email' do it 'uses the commit email' do
subject.execute subject.execute
expect(user.commit_email).not_to eq(user.email)
expect(commit.author_email).to eq(user.commit_email) expect(commit.author_email).to eq(user.commit_email)
expect(commit.committer_email).to eq(user.commit_email) expect(commit.committer_email).to eq(user.commit_email)
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment