about summary refs log tree commit diff
path: root/app/helpers
diff options
context:
space:
mode:
authorJoël Quenneville <joel.quen@gmail.com>2017-04-23 00:04:32 -0400
committerEugen <eugen@zeonfederated.com>2017-04-23 06:04:32 +0200
commit0c2fe22bc19a82899c7577410bc869db7d42955a (patch)
tree10961704fdb4a80524a00cd180864c3d9a16e578 /app/helpers
parent6f0b3b069f3ee9a9eceec77666fc124b9695f124 (diff)
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`
Diffstat (limited to 'app/helpers')
-rw-r--r--app/helpers/stream_entries_helper.rb10
1 files changed, 7 insertions, 3 deletions
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)