diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-07-20 12:55:51 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-07-20 12:55:51 +0300 |
commit | e8d2c2579383897a1dd7f9debd359abe8ae8373d (patch) | |
tree | c42be41678c2586d49a75cabce89322082698334 /spec/lib/gitlab/git/user_spec.rb | |
parent | fc845b37ec3a90aaa719975f607740c22ba6a113 (diff) |
Add latest changes from gitlab-org/gitlab@14-1-stable-eev14.1.0-rc42
Diffstat (limited to 'spec/lib/gitlab/git/user_spec.rb')
-rw-r--r-- | spec/lib/gitlab/git/user_spec.rb | 43 |
1 files changed, 28 insertions, 15 deletions
diff --git a/spec/lib/gitlab/git/user_spec.rb b/spec/lib/gitlab/git/user_spec.rb index 4414195ebf4..dfa68a7496c 100644 --- a/spec/lib/gitlab/git/user_spec.rb +++ b/spec/lib/gitlab/git/user_spec.rb @@ -7,15 +7,16 @@ RSpec.describe Gitlab::Git::User do let(:name) { 'Jane DoƩ' } let(:email) { 'janedoƩ@example.com' } let(:gl_id) { 'user-123' } + let(:timezone) { 'Asia/Shanghai' } let(:user) do - described_class.new(username, name, email, gl_id) + described_class.new(username, name, email, gl_id, timezone) end - subject { described_class.new(username, name, email, gl_id) } + subject { described_class.new(username, name, email, gl_id, timezone) } describe '.from_gitaly' do let(:gitaly_user) do - Gitaly::User.new(gl_username: username, name: name.b, email: email.b, gl_id: gl_id) + Gitaly::User.new(gl_username: username, name: name.b, email: email.b, gl_id: gl_id, timezone: timezone) end subject { described_class.from_gitaly(gitaly_user) } @@ -25,34 +26,45 @@ RSpec.describe Gitlab::Git::User do describe '.from_gitlab' do context 'when no commit_email has been set' do - let(:user) { build(:user, email: 'alice@example.com', commit_email: nil) } + let(:user) { build(:user, email: 'alice@example.com', commit_email: nil, timezone: timezone) } subject { described_class.from_gitlab(user) } - it { expect(subject).to eq(described_class.new(user.username, user.name, user.email, 'user-')) } + it { expect(subject).to eq(described_class.new(user.username, user.name, user.email, 'user-', timezone)) } end context 'when commit_email has been set' do - let(:user) { build(:user, email: 'alice@example.com', commit_email: 'bob@example.com') } + let(:user) { build(:user, email: 'alice@example.com', commit_email: 'bob@example.com', timezone: timezone) } subject { described_class.from_gitlab(user) } - it { expect(subject).to eq(described_class.new(user.username, user.name, user.commit_email, 'user-')) } + it { expect(subject).to eq(described_class.new(user.username, user.name, user.commit_email, 'user-', timezone)) } end end describe '#==' do - def eq_other(username, name, email, gl_id) - eq(described_class.new(username, name, email, gl_id)) + def eq_other(username, name, email, gl_id, timezone) + eq(described_class.new(username, name, email, gl_id, timezone)) end - it { expect(subject).to eq_other(username, name, email, gl_id) } + it { expect(subject).to eq_other(username, name, email, gl_id, timezone) } - it { expect(subject).not_to eq_other(nil, nil, nil, nil) } - it { expect(subject).not_to eq_other(username + 'x', name, email, gl_id) } - it { expect(subject).not_to eq_other(username, name + 'x', email, gl_id) } - it { expect(subject).not_to eq_other(username, name, email + 'x', gl_id) } - it { expect(subject).not_to eq_other(username, name, email, gl_id + 'x') } + it { expect(subject).not_to eq_other(nil, nil, nil, nil, timezone) } + it { expect(subject).not_to eq_other(username + 'x', name, email, gl_id, timezone) } + it { expect(subject).not_to eq_other(username, name + 'x', email, gl_id, timezone) } + it { expect(subject).not_to eq_other(username, name, email + 'x', gl_id, timezone) } + it { expect(subject).not_to eq_other(username, name, email, gl_id + 'x', timezone) } + it { expect(subject).not_to eq_other(username, name, email, gl_id, 'Etc/UTC') } + + context 'when add_timezone_to_web_operations is disabled' do + before do + stub_feature_flags(add_timezone_to_web_operations: false) + end + + it 'ignores timezone arg and sets Etc/UTC by default' do + expect(user.timezone).to eq('Etc/UTC') + end + end end describe '#to_gitaly' do @@ -69,6 +81,7 @@ RSpec.describe Gitlab::Git::User do expect(subject.email).to be_a_binary_string expect(subject.gl_id).to eq(gl_id) + expect(subject.timezone).to eq(timezone) end end end |