fix: fix icons

mciea-main
Nelson Jovel 1 year ago
parent c60281fc9a
commit 61a1b55960

@ -26,12 +26,12 @@ class CategoryPresenter
end end
def icon_class def icon_class
icon_suffix = classes[name.to_sym] icon_suffix = classes[id.to_sym]
"fas fa-#{icon_suffix}" "fas fa-#{icon_suffix}"
end end
def icon_color_class def icon_color_class
color_suffix = colors[name.to_sym] color_suffix = colors[id.to_sym]
"color-#{color_suffix}" "color-#{color_suffix}"
end end
@ -88,3 +88,4 @@ class CategoryPresenter
'5': "heart" } '5': "heart" }
end end
end end

@ -1,37 +1,37 @@
require "rails_helper" require 'rails_helper'
describe CategoryPresenter do describe CategoryPresenter do
let(:category_presenter) do let(:category_presenter) do
subcategory1 = Subcategory.create(name: "A subcategory", subcategory_id: "1") subcategory1 = Subcategory.create(name: 'A subcategory', subcategory_id: '1')
subcategory2 = Subcategory.create(name: "Another subcategory", subcategory_id: "2") subcategory2 = Subcategory.create(name: 'Another subcategory', subcategory_id: '2')
category = Category.create(name: "Some Category", subcategories: [subcategory1, subcategory2], category = Category.create(name: 'Some Category', subcategories: [subcategory1, subcategory2],
description: "A description for some Category", short_description: "A short description for some Category", category_id: "1") description: 'A description for some Category', short_description: 'A short description for some Category', category_id: '1')
return CategoryPresenter.new(category:) return CategoryPresenter.new(category:)
end end
let(:teachers_and_leadership_presenter) do let(:teachers_and_leadership_presenter) do
category = create(:category, name: "Teachers & Leadership") category = create(:category, name: 'Teachers & Leadership', category_id: '1')
return CategoryPresenter.new(category:) return CategoryPresenter.new(category:)
end end
let(:school_culture_presenter) do let(:school_culture_presenter) do
category = create(:category, name: "School Culture") category = create(:category, name: 'School Culture', category_id: '2')
return CategoryPresenter.new(category:) return CategoryPresenter.new(category:)
end end
let(:resources_presenter) do let(:resources_presenter) do
category = create(:category, name: "Resources") category = create(:category, name: 'Resources', category_id: '3')
return CategoryPresenter.new(category:) return CategoryPresenter.new(category:)
end end
let(:academic_learning_presenter) do let(:academic_learning_presenter) do
category = create(:category, name: "Academic Learning") category = create(:category, name: 'Perceptions of Learning', category_id: '4')
return CategoryPresenter.new(category:) return CategoryPresenter.new(category:)
end end
let(:community_and_wellbeing_presenter) do let(:community_and_wellbeing_presenter) do
category = create(:category, name: "Community & Wellbeing") category = create(:category, name: 'Community & Wellbeing', category_id: '5')
return CategoryPresenter.new(category:) return CategoryPresenter.new(category:)
end end
@ -39,33 +39,33 @@ describe CategoryPresenter do
DatabaseCleaner.clean DatabaseCleaner.clean
end end
it "returns the name, id and description of the category" do it 'returns the name, id and description of the category' do
expect(category_presenter.name).to eq "Some Category" expect(category_presenter.name).to eq 'Some Category'
expect(category_presenter.description).to eq "A description for some Category" expect(category_presenter.description).to eq 'A description for some Category'
expect(category_presenter.short_description).to eq "A short description for some Category" expect(category_presenter.short_description).to eq 'A short description for some Category'
expect(category_presenter.id).to eq "1" expect(category_presenter.id).to eq '1'
end end
it "maps subcategories to subcategory presenters" do it 'maps subcategories to subcategory presenters' do
expect(category_presenter.subcategories(academic_year: AcademicYear.new, expect(category_presenter.subcategories(academic_year: AcademicYear.new,
school: School.new).map(&:name)).to eq [ school: School.new).map(&:name)).to eq [
"A subcategory", "Another subcategory" 'A subcategory', 'Another subcategory'
] ]
end end
it "returns the correct icon for the given category" do it 'returns the correct icon for the given category' do
expect(teachers_and_leadership_presenter.icon_class).to eq "fas fa-apple-alt" expect(teachers_and_leadership_presenter.icon_class).to eq 'fas fa-apple-alt'
expect(school_culture_presenter.icon_class).to eq "fas fa-school" expect(school_culture_presenter.icon_class).to eq 'fas fa-school'
expect(resources_presenter.icon_class).to eq "fas fa-users-cog" expect(resources_presenter.icon_class).to eq 'fas fa-users-cog'
expect(academic_learning_presenter.icon_class).to eq "fas fa-graduation-cap" expect(academic_learning_presenter.icon_class).to eq 'fas fa-graduation-cap'
expect(community_and_wellbeing_presenter.icon_class).to eq "fas fa-heart" expect(community_and_wellbeing_presenter.icon_class).to eq 'fas fa-heart'
end end
it "returns the correct color for the given category" do it 'returns the correct color for the given category' do
expect(teachers_and_leadership_presenter.icon_color_class).to eq "color-blue" expect(teachers_and_leadership_presenter.icon_color_class).to eq 'color-blue'
expect(school_culture_presenter.icon_color_class).to eq "color-red" expect(school_culture_presenter.icon_color_class).to eq 'color-red'
expect(resources_presenter.icon_color_class).to eq "color-black" expect(resources_presenter.icon_color_class).to eq 'color-black'
expect(academic_learning_presenter.icon_color_class).to eq "color-lime" expect(academic_learning_presenter.icon_color_class).to eq 'color-lime'
expect(community_and_wellbeing_presenter.icon_color_class).to eq "color-teal" expect(community_and_wellbeing_presenter.icon_color_class).to eq 'color-teal'
end end
end end

Loading…
Cancel
Save