Commit 5ba79f49 authored by Alfredo Sumaran's avatar Alfredo Sumaran
Browse files

Syntax and code improvements

parent 7f263ca1
......@@ -129,6 +129,18 @@ def diff_btn(title, name, selected)
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 @@ def params_with_whitespace
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
......@@ -9,13 +9,14 @@
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
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment