Commit 8ff943c2 authored by Fabian Schneider's avatar Fabian Schneider

Add tests for preferences_helper

parent 15da40db
...@@ -50,10 +50,6 @@ module PreferencesHelper ...@@ -50,10 +50,6 @@ module PreferencesHelper
] ]
end end
def default_first_day_of_week
first_day_of_week_choices.rassoc(Gitlab::CurrentSettings.first_day_of_week).first
end
def first_day_of_week_choices_with_default def first_day_of_week_choices_with_default
first_day_of_week_choices.unshift([_('System default (%{default})') % { default: default_first_day_of_week }, nil]) first_day_of_week_choices.unshift([_('System default (%{default})') % { default: default_first_day_of_week }, nil])
end end
...@@ -81,4 +77,8 @@ module PreferencesHelper ...@@ -81,4 +77,8 @@ module PreferencesHelper
def excluded_dashboard_choices def excluded_dashboard_choices
['operations'] ['operations']
end end
def default_first_day_of_week
first_day_of_week_choices.rassoc(Gitlab::CurrentSettings.first_day_of_week).first
end
end end
...@@ -35,6 +35,30 @@ describe PreferencesHelper do ...@@ -35,6 +35,30 @@ describe PreferencesHelper do
end end
end end
describe '#first_day_of_week_choices' do
it 'returns Sunday and Monday as choices' do
expect(helper.first_day_of_week_choices).to eq [
['Sunday', 0],
['Monday', 1]
]
end
end
describe '#first_day_of_week_choices_with_default' do
it 'returns choices including system default' do
expect(helper.first_day_of_week_choices_with_default).to eq [
['System default (Sunday)', nil], ['Sunday', 0], ['Monday', 1]
]
end
it 'returns choices including system default set to Monday' do
stub_application_setting(first_day_of_week: 1)
expect(helper.first_day_of_week_choices_with_default).to eq [
['System default (Monday)', nil], ['Sunday', 0], ['Monday', 1]
]
end
end
describe '#user_application_theme' do describe '#user_application_theme' do
context 'with a user' do context 'with a user' do
it "returns user's theme's css_class" do it "returns user's theme's css_class" do
......
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