summaryrefslogtreecommitdiff
path: root/spec/controllers/projects
diff options
context:
space:
mode:
authorMinsik Yoon <yms9654@gmail.com>2015-10-22 09:55:35 +0900
committer윤민식 <minsik.yoon@samsung.com>2015-11-13 16:53:53 +0900
commit3d0efa8e0a359c84485a0fd7a3317745bf5648b8 (patch)
tree6bcc5739a8bba9a1bea8d787f687a56f3f919bb3 /spec/controllers/projects
parent23ed732e39d4e40e9a8643c015fd167b1e654470 (diff)
downloadgitlab-ce-3d0efa8e0a359c84485a0fd7a3317745bf5648b8.tar.gz
Add ignore white space option in merge request diff
fix this issue(https://gitlab.com/gitlab-org/gitlab-ce/issues/1393). Add ignore whitespace optoin to Commits Compare view
Diffstat (limited to 'spec/controllers/projects')
-rw-r--r--spec/controllers/projects/compare_controller_spec.rb16
-rw-r--r--spec/controllers/projects/merge_requests_controller_spec.rb28
2 files changed, 44 insertions, 0 deletions
diff --git a/spec/controllers/projects/compare_controller_spec.rb b/spec/controllers/projects/compare_controller_spec.rb
index 2a447248b70..be19f1abc53 100644
--- a/spec/controllers/projects/compare_controller_spec.rb
+++ b/spec/controllers/projects/compare_controller_spec.rb
@@ -23,6 +23,22 @@ describe Projects::CompareController do
expect(assigns(:commits).length).to be >= 1
end
+ it 'compare should show some diffs with ignore whitespace change option' do
+ get(:show,
+ namespace_id: project.namespace.to_param,
+ project_id: project.to_param,
+ from: '08f22f25',
+ to: '66eceea0',
+ w: 1)
+
+ expect(response).to be_success
+ expect(assigns(:diffs).length).to be >= 1
+ expect(assigns(:commits).length).to be >= 1
+ # without whitespace option, there are more than 2 diff_splits
+ diff_splits = assigns(:diffs)[0].diff.split("\n")
+ expect(diff_splits.length).to be <= 2
+ end
+
describe 'non-existent refs' do
it 'invalid source ref' do
get(:show,
diff --git a/spec/controllers/projects/merge_requests_controller_spec.rb b/spec/controllers/projects/merge_requests_controller_spec.rb
index b8db8591709..3e5e1fa87ae 100644
--- a/spec/controllers/projects/merge_requests_controller_spec.rb
+++ b/spec/controllers/projects/merge_requests_controller_spec.rb
@@ -147,6 +147,34 @@ describe Projects::MergeRequestsController do
end
end
+ describe 'GET diffs with ignore_whitespace_change' do
+ def go(format: 'html')
+ get :diffs,
+ namespace_id: project.namespace.to_param,
+ project_id: project.to_param,
+ id: merge_request.iid,
+ format: format,
+ w: 1
+ end
+
+ context 'as html' do
+ it 'renders the diff template' do
+ go
+
+ expect(response).to render_template('diffs')
+ end
+ end
+
+ context 'as json' do
+ it 'renders the diffs template to a string' do
+ go format: 'json'
+
+ expect(response).to render_template('projects/merge_requests/show/_diffs')
+ expect(JSON.parse(response.body)).to have_key('html')
+ end
+ end
+ end
+
describe 'GET commits' do
def go(format: 'html')
get :commits,