From f65875ae7e852d4788bcaa743b6fd7e2c9faaa60 Mon Sep 17 00:00:00 2001 From: Karina Kwiatek Date: Fri, 13 Aug 2021 01:45:00 +0200 Subject: [PATCH] Add specs for theme-color helpers --- spec/helpers/theme_helper_spec.rb | 50 +++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/spec/helpers/theme_helper_spec.rb b/spec/helpers/theme_helper_spec.rb index 3776192d..663094d9 100644 --- a/spec/helpers/theme_helper_spec.rb +++ b/spec/helpers/theme_helper_spec.rb @@ -141,4 +141,54 @@ describe ThemeHelper, :type => :helper do end end end + + describe '#theme_color' do + subject { helper.theme_color } + + context 'when user is signed in' do + let(:user) { FactoryBot.create(:user) } + let(:theme) { FactoryBot.create(:theme, user: user) } + + before(:each) do + user.theme = theme + user.save! + sign_in(user) + end + + it 'should return the user theme\'s primary color' do + expect(subject).to eq('#8e8cd8') + end + end + + context 'user is not signed in' do + it 'should return the default primary color' do + expect(subject).to eq('#5e35b1') + end + end + end + + describe '#mobile_theme_color' do + subject { helper.mobile_theme_color } + + context 'when user is signed in' do + let(:user) { FactoryBot.create(:user) } + let(:theme) { FactoryBot.create(:theme, user: user) } + + before(:each) do + user.theme = theme + user.save! + sign_in(user) + end + + it 'should return the user theme\'s background color' do + expect(subject).to eq('#c6c5eb') + end + end + + context 'user is not signed in' do + it 'should return the default background color' do + expect(subject).to eq('#f0edf4') + end + end + end end