summaryrefslogtreecommitdiff
path: root/spec/requests/api/repositories_spec.rb
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-05-27 11:27:42 +0300
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-05-27 11:27:42 +0300
commitc7e00aca2d68a15c901506f1af4242df92670b6a (patch)
tree22367329b942180ae17e7fc87406c1383e1d906c /spec/requests/api/repositories_spec.rb
parent10ee137e9c13271d49d7046723b1e473d62a578f (diff)
downloadgitlab-ce-c7e00aca2d68a15c901506f1af4242df92670b6a.tar.gz
Better specs for Compare API
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'spec/requests/api/repositories_spec.rb')
-rw-r--r--spec/requests/api/repositories_spec.rb34
1 files changed, 25 insertions, 9 deletions
diff --git a/spec/requests/api/repositories_spec.rb b/spec/requests/api/repositories_spec.rb
index eaf217f0af4..a902a1542cc 100644
--- a/spec/requests/api/repositories_spec.rb
+++ b/spec/requests/api/repositories_spec.rb
@@ -114,25 +114,41 @@ describe API::API, api: true do
end
describe 'GET /GET /projects/:id/repository/compare' do
- it "should compare 2 branches" do
+ it "should compare branches" do
get api("/projects/#{project.id}/repository/compare", user), from: 'master', to: 'simple_merge_request'
response.status.should == 200
- json_response['commits'].size.should == 3
- json_response['diffs'].size.should == 1
+ json_response['commits'].should be_present
+ json_response['diffs'].should be_present
end
- it "should compare 2 commits" do
+ it "should compare tags" do
+ get api("/projects/#{project.id}/repository/compare", user), from: 'v1.0.1', to: 'v1.0.2'
+ response.status.should == 200
+ json_response['commits'].should be_present
+ json_response['diffs'].should be_present
+ end
+
+ it "should compare commits" do
get api("/projects/#{project.id}/repository/compare", user), from: 'b1e6a9dbf1c85', to: '1e689bfba395'
response.status.should == 200
- json_response['commits'].size.should == 0
- json_response['diffs'].size.should == 0
+ json_response['commits'].should be_empty
+ json_response['diffs'].should be_empty
+ json_response['compare_same_ref'].should be_false
end
- it "should compare 2 commits" do
+ it "should compare commits in reverse order" do
get api("/projects/#{project.id}/repository/compare", user), from: '1e689bfba395', to: 'b1e6a9dbf1c85'
response.status.should == 200
- json_response['commits'].size.should == 4
- json_response['diffs'].size.should == 9
+ json_response['commits'].should be_present
+ json_response['diffs'].should be_present
+ end
+
+ it "should compare same refs" do
+ get api("/projects/#{project.id}/repository/compare", user), from: 'master', to: 'master'
+ response.status.should == 200
+ json_response['commits'].should be_empty
+ json_response['diffs'].should be_empty
+ json_response['compare_same_ref'].should be_true
end
end
end