From 0c2fe22bc19a82899c7577410bc869db7d42955a Mon Sep 17 00:00:00 2001 From: Joël Quenneville Date: Sun, 23 Apr 2017 00:04:32 -0400 Subject: Add test coverage to CSS class generation (#2285) The code that generates CSS is based on a lot of boolean conditions. The possible combinations of these grows exponentially as we add more conditions. Since most of the code is conditional on a single boolean, we tested the following: 1. All `false` 2. All `true` 3. Each individual flag set to `true` The methods tested are: * `StreamEntriesHelper#style_classes` * `StreamEntriesHelper#microformats_classes` * `StreamEntriesHelper#microformats_h_class` --- app/helpers/stream_entries_helper.rb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'app') diff --git a/app/helpers/stream_entries_helper.rb b/app/helpers/stream_entries_helper.rb index daa4a48e4..a1dfe2ecf 100644 --- a/app/helpers/stream_entries_helper.rb +++ b/app/helpers/stream_entries_helper.rb @@ -31,9 +31,13 @@ module StreamEntriesHelper end def microformats_h_class(status, is_predecessor, is_successor, include_threads) - return 'h-cite' if is_predecessor || status.reblog || is_successor - return 'h-entry' unless include_threads - '' + if is_predecessor || status.reblog? || is_successor + 'h-cite' + elsif include_threads + '' + else + 'h-entry' + end end def rtl?(text) -- cgit