diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-07-21 18:10:40 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-07-21 18:10:40 +0300 |
commit | 10b6df25f1b23883bad078ada777307aea08402a (patch) | |
tree | 35c2106fd8b0a445773b6dd0bc3e3a67f7fe25f3 /spec/helpers/commits_helper_spec.rb | |
parent | 6c44b676312eb6cdffadef45f9ca3e29a8cc92ab (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/helpers/commits_helper_spec.rb')
-rw-r--r-- | spec/helpers/commits_helper_spec.rb | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/spec/helpers/commits_helper_spec.rb b/spec/helpers/commits_helper_spec.rb index ff4a312f1b5..49adba22ebe 100644 --- a/spec/helpers/commits_helper_spec.rb +++ b/spec/helpers/commits_helper_spec.rb @@ -357,4 +357,46 @@ RSpec.describe CommitsHelper do it { is_expected.to eq(expected_path) } end + + describe '#local_committed_date' do + let(:commit) { build(:commit, committed_date: time) } + let(:user) { build(:user) } + let(:time) { Time.find_zone('UTC').parse('2023-01-01') } + + subject { helper.local_committed_date(commit, user).to_s } + + it { is_expected.to eq('2023-01-01') } + + context 'when user has a custom timezone' do + let(:user) { build(:user, timezone: 'America/Mexico_City') } + + it 'selects timezone of the user' do + is_expected.to eq('2022-12-31') + end + end + + context "when user doesn't have a preferred timezone" do + let(:user) { build(:user, timezone: nil) } + + it 'uses system timezone' do + is_expected.to eq('2023-01-01') + end + end + + context 'when user timezone is not supported' do + let(:user) { build(:user, timezone: 'unknown') } + + it 'uses system timezone' do + is_expected.to eq('2023-01-01') + end + end + + context 'when user is missing' do + let(:user) { nil } + + it 'uses system timezone' do + is_expected.to eq('2023-01-01') + end + end + end end |