Add theme model spec
This commit is contained in:
parent
bd5995ef65
commit
d81641ac18
|
@ -50,7 +50,7 @@ module ThemeHelper
|
|||
def theme_color
|
||||
theme = get_active_theme
|
||||
if theme
|
||||
"##{get_hex_color_from_theme_value(theme.primary_color)}"
|
||||
theme.theme_color
|
||||
else
|
||||
'#5e35b1'
|
||||
end
|
||||
|
@ -59,7 +59,7 @@ module ThemeHelper
|
|||
def mobile_theme_color
|
||||
theme = get_active_theme
|
||||
if theme
|
||||
"##{get_hex_color_from_theme_value(theme.background_color)}"
|
||||
theme.mobile_theme_color
|
||||
else
|
||||
'#f0edf4'
|
||||
end
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
FactoryBot.define do
|
||||
factory :theme do
|
||||
primary_color { 9_342_168 }
|
||||
primary_text { 16_777_215 }
|
||||
danger_color { 14_257_035 }
|
||||
danger_text { 16_777_215 }
|
||||
success_color { 12_573_067 }
|
||||
success_text { 16_777_215 }
|
||||
warning_color { 14_261_899 }
|
||||
warning_text { 16_777_215 }
|
||||
info_color { 9_165_273 }
|
||||
info_text { 16_777_215 }
|
||||
dark_color { 6_710_886 }
|
||||
dark_text { 15_658_734 }
|
||||
raised_background { 16_777_215 }
|
||||
background_color { 13_026_795 }
|
||||
body_text { 3_355_443 }
|
||||
muted_text { 3_355_443 }
|
||||
input_color { 15_789_556 }
|
||||
input_text { 6_710_886 }
|
||||
raised_accent { 16_250_871 }
|
||||
light_color { 16_316_922 }
|
||||
light_text { 0 }
|
||||
end
|
||||
end
|
|
@ -0,0 +1,26 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe(Theme, type: :model) do
|
||||
context 'user-defined theme' do
|
||||
let(:user) { FactoryBot.create(:user) }
|
||||
let(:theme) { FactoryBot.create(:theme, user: user) }
|
||||
|
||||
describe '#theme_color' do
|
||||
subject { theme.theme_color }
|
||||
|
||||
it 'should return the theme\'s primary colour as a hex triplet' do
|
||||
expect(subject).to eq('#8e8cd8')
|
||||
end
|
||||
end
|
||||
|
||||
describe '#mobile_theme_color' do
|
||||
subject { theme.mobile_theme_color }
|
||||
|
||||
it 'should return the theme\'s background colour as a hex triplet' do
|
||||
expect(subject).to eq('#c6c5eb')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue