Skip to content
Snippets Groups Projects
Commit 6e08f0d4 authored by Z.J. van de Weg's avatar Z.J. van de Weg
Browse files

Update tests to pass

Former-commit-id: b795e3a0
parent a37c6e7f
No related branches found
No related tags found
No related merge requests found
require "spec_helper"
 
describe API::MergeRequests, api: true do
describe API::V3::MergeRequests, api: true do
include ApiHelpers
let(:base_time) { Time.now }
let(:user) { create(:user) }
Loading
Loading
Loading
Loading
@@ -328,11 +328,7 @@ describe API::V3::Notes, api: true do
end
 
it 'returns a 400 bad request error if body not given' do
<<<<<<< HEAD
put v3_api("/projects/#{project.id}/issues/#{issue.id}/"\
=======
put api("/projects/#{project.id}/issues/#{issue.id}/"\
>>>>>>> e306055d88... Pick API files from 8.16.6
"notes/#{issue_note.id}", user)
 
expect(response).to have_http_status(400)
Loading
Loading
@@ -341,11 +337,7 @@ describe API::V3::Notes, api: true do
 
context 'when noteable is a Snippet' do
it 'returns modified note' do
<<<<<<< HEAD
put v3_api("/projects/#{project.id}/snippets/#{snippet.id}/"\
=======
put api("/projects/#{project.id}/snippets/#{snippet.id}/"\
>>>>>>> e306055d88... Pick API files from 8.16.6
"notes/#{snippet_note.id}", user), body: 'Hello!'
 
expect(response).to have_http_status(200)
Loading
Loading
@@ -353,11 +345,7 @@ describe API::V3::Notes, api: true do
end
 
it 'returns a 404 error when note id not found' do
<<<<<<< HEAD
put v3_api("/projects/#{project.id}/snippets/#{snippet.id}/"\
=======
put api("/projects/#{project.id}/snippets/#{snippet.id}/"\
>>>>>>> e306055d88... Pick API files from 8.16.6
"notes/12345", user), body: "Hello!"
 
expect(response).to have_http_status(404)
Loading
Loading
@@ -366,11 +354,7 @@ describe API::V3::Notes, api: true do
 
context 'when noteable is a Merge Request' do
it 'returns modified note' do
<<<<<<< HEAD
put v3_api("/projects/#{project.id}/merge_requests/#{merge_request.id}/"\
=======
put api("/projects/#{project.id}/merge_requests/#{merge_request.id}/"\
>>>>>>> e306055d88... Pick API files from 8.16.6
"notes/#{merge_request_note.id}", user), body: 'Hello!'
 
expect(response).to have_http_status(200)
Loading
Loading
@@ -378,11 +362,7 @@ describe API::V3::Notes, api: true do
end
 
it 'returns a 404 error when note id not found' do
<<<<<<< HEAD
put v3_api("/projects/#{project.id}/merge_requests/#{merge_request.id}/"\
=======
put api("/projects/#{project.id}/merge_requests/#{merge_request.id}/"\
>>>>>>> e306055d88... Pick API files from 8.16.6
"notes/12345", user), body: "Hello!"
 
expect(response).to have_http_status(404)
Loading
Loading
@@ -393,7 +373,6 @@ describe API::V3::Notes, api: true do
describe 'DELETE /projects/:id/noteable/:noteable_id/notes/:note_id' do
context 'when noteable is an Issue' do
it 'deletes a note' do
<<<<<<< HEAD
delete v3_api("/projects/#{project.id}/issues/#{issue.id}/"\
"notes/#{issue_note.id}", user)
 
Loading
Loading
@@ -401,24 +380,11 @@ describe API::V3::Notes, api: true do
# Check if note is really deleted
delete v3_api("/projects/#{project.id}/issues/#{issue.id}/"\
"notes/#{issue_note.id}", user)
=======
delete api("/projects/#{project.id}/issues/#{issue.id}/"\
"notes/#{issue_note.id}", user)
expect(response).to have_http_status(200)
# Check if note is really deleted
delete api("/projects/#{project.id}/issues/#{issue.id}/"\
"notes/#{issue_note.id}", user)
>>>>>>> e306055d88... Pick API files from 8.16.6
expect(response).to have_http_status(404)
end
 
it 'returns a 404 error when note id not found' do
<<<<<<< HEAD
delete v3_api("/projects/#{project.id}/issues/#{issue.id}/notes/12345", user)
=======
delete api("/projects/#{project.id}/issues/#{issue.id}/notes/12345", user)
>>>>>>> e306055d88... Pick API files from 8.16.6
 
expect(response).to have_http_status(404)
end
Loading
Loading
@@ -426,7 +392,6 @@ describe API::V3::Notes, api: true do
 
context 'when noteable is a Snippet' do
it 'deletes a note' do
<<<<<<< HEAD
delete v3_api("/projects/#{project.id}/snippets/#{snippet.id}/"\
"notes/#{snippet_note.id}", user)
 
Loading
Loading
@@ -434,26 +399,12 @@ describe API::V3::Notes, api: true do
# Check if note is really deleted
delete v3_api("/projects/#{project.id}/snippets/#{snippet.id}/"\
"notes/#{snippet_note.id}", user)
=======
delete api("/projects/#{project.id}/snippets/#{snippet.id}/"\
"notes/#{snippet_note.id}", user)
expect(response).to have_http_status(200)
# Check if note is really deleted
delete api("/projects/#{project.id}/snippets/#{snippet.id}/"\
"notes/#{snippet_note.id}", user)
>>>>>>> e306055d88... Pick API files from 8.16.6
expect(response).to have_http_status(404)
end
 
it 'returns a 404 error when note id not found' do
<<<<<<< HEAD
delete v3_api("/projects/#{project.id}/snippets/#{snippet.id}/"\
"notes/12345", user)
=======
delete api("/projects/#{project.id}/snippets/#{snippet.id}/"\
"notes/12345", user)
>>>>>>> e306055d88... Pick API files from 8.16.6
 
expect(response).to have_http_status(404)
end
Loading
Loading
@@ -461,7 +412,6 @@ describe API::V3::Notes, api: true do
 
context 'when noteable is a Merge Request' do
it 'deletes a note' do
<<<<<<< HEAD
delete v3_api("/projects/#{project.id}/merge_requests/"\
"#{merge_request.id}/notes/#{merge_request_note.id}", user)
 
Loading
Loading
@@ -469,26 +419,12 @@ describe API::V3::Notes, api: true do
# Check if note is really deleted
delete v3_api("/projects/#{project.id}/merge_requests/"\
"#{merge_request.id}/notes/#{merge_request_note.id}", user)
=======
delete api("/projects/#{project.id}/merge_requests/"\
"#{merge_request.id}/notes/#{merge_request_note.id}", user)
expect(response).to have_http_status(200)
# Check if note is really deleted
delete api("/projects/#{project.id}/merge_requests/"\
"#{merge_request.id}/notes/#{merge_request_note.id}", user)
>>>>>>> e306055d88... Pick API files from 8.16.6
expect(response).to have_http_status(404)
end
 
it 'returns a 404 error when note id not found' do
<<<<<<< HEAD
delete v3_api("/projects/#{project.id}/merge_requests/"\
"#{merge_request.id}/notes/12345", user)
=======
delete api("/projects/#{project.id}/merge_requests/"\
"#{merge_request.id}/notes/12345", user)
>>>>>>> e306055d88... Pick API files from 8.16.6
 
expect(response).to have_http_status(404)
end
Loading
Loading
require 'spec_helper'
 
describe API::ProjectHooks, 'ProjectHooks', api: true do
describe API::V3::ProjectHooks, 'ProjectHooks', api: true do
include ApiHelpers
let(:user) { create(:user) }
let(:user3) { create(:user) }
Loading
Loading
@@ -21,7 +21,7 @@ describe API::ProjectHooks, 'ProjectHooks', api: true do
describe "GET /projects/:id/hooks" do
context "authorized user" do
it "returns project hooks" do
get api("/projects/#{project.id}/hooks", user)
get v3_api("/projects/#{project.id}/hooks", user)
expect(response).to have_http_status(200)
 
expect(json_response).to be_an Array
Loading
Loading
@@ -41,7 +41,7 @@ describe API::ProjectHooks, 'ProjectHooks', api: true do
 
context "unauthorized user" do
it "does not access project hooks" do
get api("/projects/#{project.id}/hooks", user3)
get v3_api("/projects/#{project.id}/hooks", user3)
expect(response).to have_http_status(403)
end
end
Loading
Loading
@@ -50,7 +50,7 @@ describe API::ProjectHooks, 'ProjectHooks', api: true do
describe "GET /projects/:id/hooks/:hook_id" do
context "authorized user" do
it "returns a project hook" do
get api("/projects/#{project.id}/hooks/#{hook.id}", user)
get v3_api("/projects/#{project.id}/hooks/#{hook.id}", user)
expect(response).to have_http_status(200)
expect(json_response['url']).to eq(hook.url)
expect(json_response['issues_events']).to eq(hook.issues_events)
Loading
Loading
@@ -65,20 +65,20 @@ describe API::ProjectHooks, 'ProjectHooks', api: true do
end
 
it "returns a 404 error if hook id is not available" do
get api("/projects/#{project.id}/hooks/1234", user)
get v3_api("/projects/#{project.id}/hooks/1234", user)
expect(response).to have_http_status(404)
end
end
 
context "unauthorized user" do
it "does not access an existing hook" do
get api("/projects/#{project.id}/hooks/#{hook.id}", user3)
get v3_api("/projects/#{project.id}/hooks/#{hook.id}", user3)
expect(response).to have_http_status(403)
end
end
 
it "returns a 404 error if hook id is not available" do
get api("/projects/#{project.id}/hooks/1234", user)
get v3_api("/projects/#{project.id}/hooks/1234", user)
expect(response).to have_http_status(404)
end
end
Loading
Loading
@@ -86,7 +86,7 @@ describe API::ProjectHooks, 'ProjectHooks', api: true do
describe "POST /projects/:id/hooks" do
it "adds hook to project" do
expect do
post api("/projects/#{project.id}/hooks", user),
post v3_api("/projects/#{project.id}/hooks", user),
url: "http://example.com", issues_events: true, wiki_page_events: true
end.to change {project.hooks.count}.by(1)
 
Loading
Loading
@@ -108,7 +108,7 @@ describe API::ProjectHooks, 'ProjectHooks', api: true do
token = "secret token"
 
expect do
post api("/projects/#{project.id}/hooks", user), url: "http://example.com", token: token
post v3_api("/projects/#{project.id}/hooks", user), url: "http://example.com", token: token
end.to change {project.hooks.count}.by(1)
 
expect(response).to have_http_status(201)
Loading
Loading
@@ -122,19 +122,19 @@ describe API::ProjectHooks, 'ProjectHooks', api: true do
end
 
it "returns a 400 error if url not given" do
post api("/projects/#{project.id}/hooks", user)
post v3_api("/projects/#{project.id}/hooks", user)
expect(response).to have_http_status(400)
end
 
it "returns a 422 error if url not valid" do
post api("/projects/#{project.id}/hooks", user), "url" => "ftp://example.com"
post v3_api("/projects/#{project.id}/hooks", user), "url" => "ftp://example.com"
expect(response).to have_http_status(422)
end
end
 
describe "PUT /projects/:id/hooks/:hook_id" do
it "updates an existing project hook" do
put api("/projects/#{project.id}/hooks/#{hook.id}", user),
put v3_api("/projects/#{project.id}/hooks/#{hook.id}", user),
url: 'http://example.org', push_events: false
expect(response).to have_http_status(200)
expect(json_response['url']).to eq('http://example.org')
Loading
Loading
@@ -152,7 +152,7 @@ describe API::ProjectHooks, 'ProjectHooks', api: true do
it "adds the token without including it in the response" do
token = "secret token"
 
put api("/projects/#{project.id}/hooks/#{hook.id}", user), url: "http://example.org", token: token
put v3_api("/projects/#{project.id}/hooks/#{hook.id}", user), url: "http://example.org", token: token
 
expect(response).to have_http_status(200)
expect(json_response["url"]).to eq("http://example.org")
Loading
Loading
@@ -163,17 +163,17 @@ describe API::ProjectHooks, 'ProjectHooks', api: true do
end
 
it "returns 404 error if hook id not found" do
put api("/projects/#{project.id}/hooks/1234", user), url: 'http://example.org'
put v3_api("/projects/#{project.id}/hooks/1234", user), url: 'http://example.org'
expect(response).to have_http_status(404)
end
 
it "returns 400 error if url is not given" do
put api("/projects/#{project.id}/hooks/#{hook.id}", user)
put v3_api("/projects/#{project.id}/hooks/#{hook.id}", user)
expect(response).to have_http_status(400)
end
 
it "returns a 422 error if url is not valid" do
put api("/projects/#{project.id}/hooks/#{hook.id}", user), url: 'ftp://example.com'
put v3_api("/projects/#{project.id}/hooks/#{hook.id}", user), url: 'ftp://example.com'
expect(response).to have_http_status(422)
end
end
Loading
Loading
@@ -181,23 +181,23 @@ describe API::ProjectHooks, 'ProjectHooks', api: true do
describe "DELETE /projects/:id/hooks/:hook_id" do
it "deletes hook from project" do
expect do
delete api("/projects/#{project.id}/hooks/#{hook.id}", user)
delete v3_api("/projects/#{project.id}/hooks/#{hook.id}", user)
end.to change {project.hooks.count}.by(-1)
expect(response).to have_http_status(200)
end
 
it "returns success when deleting hook" do
delete api("/projects/#{project.id}/hooks/#{hook.id}", user)
delete v3_api("/projects/#{project.id}/hooks/#{hook.id}", user)
expect(response).to have_http_status(200)
end
 
it "returns a 404 error when deleting non existent hook" do
delete api("/projects/#{project.id}/hooks/42", user)
delete v3_api("/projects/#{project.id}/hooks/42", user)
expect(response).to have_http_status(404)
end
 
it "returns a 404 error if hook id not given" do
delete api("/projects/#{project.id}/hooks", user)
delete v3_api("/projects/#{project.id}/hooks", user)
 
expect(response).to have_http_status(404)
end
Loading
Loading
@@ -207,7 +207,7 @@ describe API::ProjectHooks, 'ProjectHooks', api: true do
other_project = create(:project)
other_project.team << [test_user, :master]
 
delete api("/projects/#{other_project.id}/hooks/#{hook.id}", test_user)
delete v3_api("/projects/#{other_project.id}/hooks/#{hook.id}", test_user)
expect(response).to have_http_status(404)
expect(WebHook.exists?(hook.id)).to be_truthy
end
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment