diff --git a/app/helpers/diff_helper.rb b/app/helpers/diff_helper.rb
index 06e5b95297ec2ad437e7a52c3979cfab900a5f3a..5c7317bdd4028c050451216e1b5ebf65d2dd4a76 100644
--- a/app/helpers/diff_helper.rb
+++ b/app/helpers/diff_helper.rb
@@ -129,6 +129,18 @@ module DiffHelper
     end
   end
 
+  def commit_diff_whitespace_link(project, commit)
+    url = namespace_project_commit_path(project.namespace, project, commit.id, params_with_whitespace)
+    toggle_whitespace_link(url)
+  end
+
+  def diff_merge_request_whitespace_link(project, merge_request)
+    url = diffs_namespace_project_merge_request_path(project.namespace, project, merge_request, params_with_whitespace)
+    toggle_whitespace_link(url)
+  end
+
+  private
+
   def hide_whitespace?
     params[:w] == '1'
   end
@@ -138,16 +150,6 @@ module DiffHelper
   end
 
   def toggle_whitespace_link(url)
-    link_to "#{hide_whitespace? ? 'Show' : 'Hide'} whitespace changes", url, class: "btn btn-default"
-  end
-
-  def commit_diff_whitespace_link(project, commit)
-    url = namespace_project_commit_path(project.namespace, project, commit.id, params_with_whitespace)
-    toggle_whitespace_link(url)
-  end
-
-  def diff_merge_request_whitespace_link(project, merge_request)
-    url = diffs_namespace_project_merge_request_path(project.namespace, project, merge_request, params_with_whitespace)
-    toggle_whitespace_link(url)
+    link_to "#{hide_whitespace? ? 'Show' : 'Hide'} whitespace changes", url, class: 'btn btn-default'
   end
 end
diff --git a/spec/features/merge_requests/toggle_whitespace_changes.rb b/spec/features/merge_requests/toggle_whitespace_changes.rb
index bf4fd5289d141657552e87a10bb14443fca5d455..0f98737b7008959e510f4932d3c1c3bde4da78c8 100644
--- a/spec/features/merge_requests/toggle_whitespace_changes.rb
+++ b/spec/features/merge_requests/toggle_whitespace_changes.rb
@@ -9,13 +9,14 @@ feature 'Toggle Whitespace Changes', js: true, feature: true do
   end
 
   it 'has a button to toggle whitespace changes' do
-    expect(page).to have_content "Hide whitespace changes"
+    expect(page).to have_content 'Hide whitespace changes'
   end
 
   describe 'clicking "Hide whitespace changes" button' do
     it 'toggles the "Hide whitespace changes" button' do
-      click_link "Hide whitespace changes"
-      expect(page).to have_content "Show whitespace changes"
+      click_link 'Hide whitespace changes'
+
+      expect(page).to have_content 'Show whitespace changes'
     end
   end
 end