Commit e8d1aefe authored by Rémy Coutable's avatar Rémy Coutable

Add timezone information to the reviewer roulette

Signed-off-by: default avatarRémy Coutable <remy@rymai.me>
parent 42b06da0
...@@ -56,7 +56,7 @@ def note_for_spin_role(spin, role) ...@@ -56,7 +56,7 @@ def note_for_spin_role(spin, role)
return OPTIONAL_REVIEW_TEMPLATE % { role: role.capitalize, category: helper.label_for_category(spin.category) } return OPTIONAL_REVIEW_TEMPLATE % { role: role.capitalize, category: helper.label_for_category(spin.category) }
end end
spin.public_send(role)&.markdown_name(timezone_experiment: spin.timezone_experiment, author: roulette.team_mr_author) # rubocop:disable GitlabSecurity/PublicSend spin.public_send(role)&.markdown_name(author: roulette.team_mr_author) # rubocop:disable GitlabSecurity/PublicSend
end end
def markdown_row_for_spins(category, spins_array) def markdown_row_for_spins(category, spins_array)
......
...@@ -45,9 +45,7 @@ module Gitlab ...@@ -45,9 +45,7 @@ module Gitlab
has_capability?(project, category, :maintainer, labels) has_capability?(project, category, :maintainer, labels)
end end
def markdown_name(timezone_experiment: false, author: nil) def markdown_name(author: nil)
return @markdown_name unless timezone_experiment
"#{@markdown_name} (#{utc_offset_text(author)})" "#{@markdown_name} (#{utc_offset_text(author)})"
end end
......
...@@ -170,23 +170,15 @@ RSpec.describe Gitlab::Danger::Teammate do ...@@ -170,23 +170,15 @@ RSpec.describe Gitlab::Danger::Teammate do
end end
describe '#markdown_name' do describe '#markdown_name' do
context 'when timezone_experiment == false' do
it 'returns markdown name as-is' do
expect(subject.markdown_name).to eq(options['markdown_name'])
expect(subject.markdown_name(timezone_experiment: false)).to eq(options['markdown_name'])
end
end
context 'when timezone_experiment == true' do
it 'returns markdown name with timezone info' do it 'returns markdown name with timezone info' do
expect(subject.markdown_name(timezone_experiment: true)).to eq("#{options['markdown_name']} (UTC+2)") expect(subject.markdown_name).to eq("#{options['markdown_name']} (UTC+2)")
end end
context 'when offset is 1.5' do context 'when offset is 1.5' do
let(:tz_offset_hours) { 1.5 } let(:tz_offset_hours) { 1.5 }
it 'returns markdown name with timezone info, not truncated' do it 'returns markdown name with timezone info, not truncated' do
expect(subject.markdown_name(timezone_experiment: true)).to eq("#{options['markdown_name']} (UTC+1.5)") expect(subject.markdown_name).to eq("#{options['markdown_name']} (UTC+1.5)")
end end
end end
...@@ -209,8 +201,7 @@ RSpec.describe Gitlab::Danger::Teammate do ...@@ -209,8 +201,7 @@ RSpec.describe Gitlab::Danger::Teammate do
floored_offset_hours = subject.__send__(:floored_offset_hours) floored_offset_hours = subject.__send__(:floored_offset_hours)
utc_offset = floored_offset_hours >= 0 ? "+#{floored_offset_hours}" : floored_offset_hours utc_offset = floored_offset_hours >= 0 ? "+#{floored_offset_hours}" : floored_offset_hours
expect(subject.markdown_name(timezone_experiment: true, author: author)).to eq("#{options['markdown_name']} (UTC#{utc_offset}, #{diff_text})") expect(subject.markdown_name(author: author)).to eq("#{options['markdown_name']} (UTC#{utc_offset}, #{diff_text})")
end
end end
end end
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