summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Thomas <nick@gitlab.com>2018-09-18 10:04:15 +0100
committerNick Thomas <nick@gitlab.com>2018-09-18 12:04:49 +0100
commit5a883915793f0f89f850d5393dce497ff9c5f893 (patch)
tree14a8e12d7554affbd48b29bc2e8efec082cbb128
parent12f9879295ac9abdd0d6aff47cc3828c9ca36dc7 (diff)
downloadgitlab-ce-5a883915793f0f89f850d5393dce497ff9c5f893.tar.gz
Guard against regressions in commit email specs
-rw-r--r--app/models/project_wiki.rb7
-rw-r--r--spec/models/project_wiki_spec.rb3
-rw-r--r--spec/services/files/create_service_spec.rb1
-rw-r--r--spec/services/files/delete_service_spec.rb3
-rw-r--r--spec/services/files/update_service_spec.rb3
5 files changed, 12 insertions, 5 deletions
diff --git a/app/models/project_wiki.rb b/app/models/project_wiki.rb
index d3c6312baf2..761359b3c9f 100644
--- a/app/models/project_wiki.rb
+++ b/app/models/project_wiki.rb
@@ -184,11 +184,12 @@ class ProjectWiki
def commit_details(action, message = nil, title = nil)
commit_message = message || default_message(action, title)
+ git_user = Gitlab::Git::User.from_gitlab(@user)
Gitlab::Git::Wiki::CommitDetails.new(@user.id,
- @user.username,
- @user.name,
- @user.commit_email,
+ git_user.username,
+ git_user.name,
+ git_user.email,
commit_message)
end
diff --git a/spec/models/project_wiki_spec.rb b/spec/models/project_wiki_spec.rb
index f607bb7a917..f38fc191943 100644
--- a/spec/models/project_wiki_spec.rb
+++ b/spec/models/project_wiki_spec.rb
@@ -280,6 +280,7 @@ describe ProjectWiki do
it 'sets the correct commit email' do
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.committer_email).to eq(user.commit_email)
end
@@ -329,6 +330,7 @@ describe ProjectWiki do
end
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.committer_email).to eq(user.commit_email)
end
@@ -363,6 +365,7 @@ describe ProjectWiki do
it 'sets the correct commit email' do
subject.delete_page(@page)
+ expect(user.commit_email).not_to eq(user.email)
expect(commit.author_email).to eq(user.commit_email)
expect(commit.committer_email).to eq(user.commit_email)
end
diff --git a/spec/services/files/create_service_spec.rb b/spec/services/files/create_service_spec.rb
index c8f899e6dff..751b7160276 100644
--- a/spec/services/files/create_service_spec.rb
+++ b/spec/services/files/create_service_spec.rb
@@ -84,6 +84,7 @@ describe Files::CreateService do
it 'uses the commit email' do
subject.execute
+ expect(user.commit_email).not_to eq(user.email)
expect(commit.author_email).to eq(user.commit_email)
expect(commit.committer_email).to eq(user.commit_email)
end
diff --git a/spec/services/files/delete_service_spec.rb b/spec/services/files/delete_service_spec.rb
index ba4a0594666..309802ce733 100644
--- a/spec/services/files/delete_service_spec.rb
+++ b/spec/services/files/delete_service_spec.rb
@@ -4,7 +4,7 @@ describe Files::DeleteService do
subject { described_class.new(project, user, commit_params) }
let(:project) { create(:project, :repository) }
- let(:user) { create(:user) }
+ let(:user) { create(:user, :commit_email) }
let(:file_path) { 'files/ruby/popen.rb' }
let(:branch_name) { project.default_branch }
let(:last_commit_sha) { nil }
@@ -39,6 +39,7 @@ describe Files::DeleteService do
it 'uses the commit email' do
subject.execute
+ expect(user.commit_email).not_to eq(user.email)
expect(commit.author_email).to eq(user.commit_email)
expect(commit.committer_email).to eq(user.commit_email)
end
diff --git a/spec/services/files/update_service_spec.rb b/spec/services/files/update_service_spec.rb
index 3bfa2717960..23db35c2418 100644
--- a/spec/services/files/update_service_spec.rb
+++ b/spec/services/files/update_service_spec.rb
@@ -4,7 +4,7 @@ describe Files::UpdateService do
subject { described_class.new(project, user, commit_params) }
let(:project) { create(:project, :repository) }
- let(:user) { create(:user) }
+ let(:user) { create(:user, :commit_email) }
let(:file_path) { 'files/ruby/popen.rb' }
let(:new_contents) { 'New Content' }
let(:branch_name) { project.default_branch }
@@ -59,6 +59,7 @@ describe Files::UpdateService do
it 'uses the commit email' do
subject.execute
+ expect(user.commit_email).not_to eq(user.email)
expect(commit.author_email).to eq(user.commit_email)
expect(commit.committer_email).to eq(user.commit_email)
end