summaryrefslogtreecommitdiff
path: root/spec/helpers/preferences_helper_spec.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-04-20 10:00:54 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2022-04-20 10:00:54 +0000
commit3cccd102ba543e02725d247893729e5c73b38295 (patch)
treef36a04ec38517f5deaaacb5acc7d949688d1e187 /spec/helpers/preferences_helper_spec.rb
parent205943281328046ef7b4528031b90fbda70c75ac (diff)
downloadgitlab-ce-3cccd102ba543e02725d247893729e5c73b38295.tar.gz
Add latest changes from gitlab-org/gitlab@14-10-stable-eev14.10.0-rc42
Diffstat (limited to 'spec/helpers/preferences_helper_spec.rb')
-rw-r--r--spec/helpers/preferences_helper_spec.rb61
1 files changed, 61 insertions, 0 deletions
diff --git a/spec/helpers/preferences_helper_spec.rb b/spec/helpers/preferences_helper_spec.rb
index 8c13afc2b45..01235c7bb51 100644
--- a/spec/helpers/preferences_helper_spec.rb
+++ b/spec/helpers/preferences_helper_spec.rb
@@ -145,6 +145,67 @@ RSpec.describe PreferencesHelper do
end
end
+ describe '#user_diffs_colors' do
+ context 'with a user' do
+ it "returns user's diffs colors" do
+ stub_user(diffs_addition_color: '#123456', diffs_deletion_color: '#abcdef')
+
+ expect(helper.user_diffs_colors).to eq({ addition: '#123456', deletion: '#abcdef' })
+ end
+
+ it 'omits property if nil' do
+ stub_user(diffs_addition_color: '#123456', diffs_deletion_color: nil)
+
+ expect(helper.user_diffs_colors).to eq({ addition: '#123456' })
+ end
+
+ it 'omits property if blank' do
+ stub_user(diffs_addition_color: '', diffs_deletion_color: '#abcdef')
+
+ expect(helper.user_diffs_colors).to eq({ deletion: '#abcdef' })
+ end
+ end
+
+ context 'without a user' do
+ it 'returns no properties' do
+ stub_user
+
+ expect(helper.user_diffs_colors).to eq({})
+ end
+ end
+ end
+
+ describe '#custom_diff_color_classes' do
+ context 'with a user' do
+ it 'returns color classes' do
+ stub_user(diffs_addition_color: '#123456', diffs_deletion_color: '#abcdef')
+
+ expect(helper.custom_diff_color_classes)
+ .to match_array(%w[diff-custom-addition-color diff-custom-deletion-color])
+ end
+
+ it 'omits property if nil' do
+ stub_user(diffs_addition_color: '#123456', diffs_deletion_color: nil)
+
+ expect(helper.custom_diff_color_classes).to match_array(['diff-custom-addition-color'])
+ end
+
+ it 'omits property if blank' do
+ stub_user(diffs_addition_color: '', diffs_deletion_color: '#abcdef')
+
+ expect(helper.custom_diff_color_classes).to match_array(['diff-custom-deletion-color'])
+ end
+ end
+
+ context 'without a user' do
+ it 'returns no classes' do
+ stub_user
+
+ expect(helper.custom_diff_color_classes).to match_array([])
+ end
+ end
+ end
+
describe '#language_choices' do
include StubLanguagesTranslationPercentage