Commit c1908746 authored by Mark Chao's avatar Mark Chao

Make roadmap_layout lowercase

parent 0982bb4e
......@@ -12,10 +12,13 @@ module Groups
def persist_roadmap_layout
return unless current_user
return unless User.roadmap_layouts[params[:layout]]
return if current_user.roadmap_layout == params[:layout]
Users::UpdateService.new(current_user, user: current_user, roadmap_layout: params[:layout]).execute
roadmap_layout = params[:layout]&.downcase
return unless User.roadmap_layouts[roadmap_layout]
return if current_user.roadmap_layout == roadmap_layout
Users::UpdateService.new(current_user, user: current_user, roadmap_layout: roadmap_layout).execute
end
end
end
......@@ -2,6 +2,6 @@
module RoadmapsHelper
def roadmap_layout
current_user&.roadmap_layout || params[:layout].presence || EE::User::DEFAULT_ROADMAP_LAYOUT
(current_user&.roadmap_layout || params[:layout].presence || EE::User::DEFAULT_ROADMAP_LAYOUT).upcase
end
end
......@@ -7,7 +7,7 @@ module EE
extend ActiveSupport::Concern
include AuditorUserHelper
DEFAULT_ROADMAP_LAYOUT = 'MONTHS'.freeze
DEFAULT_ROADMAP_LAYOUT = 'months'.freeze
included do
EMAIL_OPT_IN_SOURCE_ID_GITLAB_COM = 1
......@@ -38,7 +38,7 @@ module EE
scope :excluding_guests, -> { joins(:members).where('members.access_level > ?', ::Gitlab::Access::GUEST).distinct }
enum roadmap_layout: { WEEKS: 1, MONTHS: 4, QUARTERS: 12 }
enum roadmap_layout: { weeks: 1, months: 4, quarters: 12 }
end
module ClassMethods
......
......@@ -28,7 +28,7 @@ describe RoadmapsHelper do
it 'is sourced from User#roadmap_layout' do
allow(helper).to receive(:params).and_return(layout: 'WEEKS')
expect(user).to receive(:roadmap_layout).and_return('QUARTERS')
expect(user).to receive(:roadmap_layout).and_return('quarters')
expect(helper.roadmap_layout).to eq('QUARTERS')
end
......
......@@ -229,10 +229,10 @@ describe EE::User do
end
context 'set' do
subject { build(:user, roadmap_layout: 'QUARTERS') }
subject { build(:user, roadmap_layout: 'quarters') }
it 'returns set value' do
expect(subject.roadmap_layout).to eq('QUARTERS')
expect(subject.roadmap_layout).to eq('quarters')
end
end
end
......
......@@ -51,12 +51,12 @@ describe Groups::RoadmapController do
context 'specifying layout' do
it 'persists roadmap_layout if different than current layout' do
expect(Users::UpdateService).to receive(:new).with(user, user: user, roadmap_layout: layout).once.and_call_original
expect(Users::UpdateService).to receive(:new).with(user, user: user, roadmap_layout: layout.downcase).once.and_call_original
expect do
get group_roadmap_path(group, layout: layout)
get group_roadmap_path(group, layout: layout)
end.to change { user.reload.roadmap_layout }.to(layout)
end.to change { user.reload.roadmap_layout }.to(layout.downcase)
expect(response).to have_gitlab_http_status(200)
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