From 2247304b715bf57e8f0bfc69b1d79c4f90ca2605 Mon Sep 17 00:00:00 2001 From: Victor Costa Date: Fri, 8 Aug 2014 16:58:15 -0300 Subject: [PATCH] community_track: add color to track name --- plugins/community_track/lib/community_track_plugin/track_helper.rb | 5 +++++ plugins/community_track/test/unit/community_track_plugin/track_helper_test.rb | 6 ++++++ plugins/community_track/views/blocks/_track_card.html.erb | 2 +- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/plugins/community_track/lib/community_track_plugin/track_helper.rb b/plugins/community_track/lib/community_track_plugin/track_helper.rb index 4938978..c2249fe 100644 --- a/plugins/community_track/lib/community_track_plugin/track_helper.rb +++ b/plugins/community_track/lib/community_track_plugin/track_helper.rb @@ -15,4 +15,9 @@ module CommunityTrackPlugin::TrackHelper category_color_style(track.categories.first.with_color) if !track.categories.empty? end + def track_name_color_style(track) + category = track.categories.empty? ? nil : track.categories.first.with_color + category ? "color: ##{category.display_color};" : '' + end + end diff --git a/plugins/community_track/test/unit/community_track_plugin/track_helper_test.rb b/plugins/community_track/test/unit/community_track_plugin/track_helper_test.rb index 5d57520..69caa99 100644 --- a/plugins/community_track/test/unit/community_track_plugin/track_helper_test.rb +++ b/plugins/community_track/test/unit/community_track_plugin/track_helper_test.rb @@ -58,4 +58,10 @@ class TrackHelperTest < ActiveSupport::TestCase assert_equal 'background-color: #fbfbfb;', track_color_style(@track) end + should 'return category color for track name' do + category1 = fast_create(Category, :name => 'education', :display_color => 'fbfbfb') + @track.categories << category1 + assert_equal 'color: #fbfbfb;', track_name_color_style(@track) + end + end diff --git a/plugins/community_track/views/blocks/_track_card.html.erb b/plugins/community_track/views/blocks/_track_card.html.erb index e7e4a84..c50425a 100644 --- a/plugins/community_track/views/blocks/_track_card.html.erb +++ b/plugins/community_track/views/blocks/_track_card.html.erb @@ -8,7 +8,7 @@
<%= image_tag track_card.image.public_filename if track_card.image %>
-
+
<%= track_card.name %>
-- libgit2 0.21.2