Commit 3a63c005 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Fix file api tests

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent b9b9fe70
......@@ -49,9 +49,7 @@ describe API::API, api: true do
end
it "should create a new file in project repo" do
Gitlab::Satellite::NewFileAction.any_instance.stub(
commit!: true,
)
expect_any_instance_of(Gitlab::Satellite::NewFileAction).to receive(:commit!).and_return(true)
post api("/projects/#{project.id}/repository/files", user), valid_params
expect(response.status).to eq(201)
......@@ -64,9 +62,7 @@ describe API::API, api: true do
end
it "should return a 400 if satellite fails to create file" do
Gitlab::Satellite::NewFileAction.any_instance.stub(
commit!: false,
)
expect_any_instance_of(Gitlab::Satellite::NewFileAction).to receive(:commit!).and_return(false)
post api("/projects/#{project.id}/repository/files", user), valid_params
expect(response.status).to eq(400)
......@@ -84,9 +80,7 @@ describe API::API, api: true do
end
it "should update existing file in project repo" do
Gitlab::Satellite::EditFileAction.any_instance.stub(
commit!: true,
)
expect_any_instance_of(Gitlab::Satellite::EditFileAction).to receive(:commit!).and_return(true)
put api("/projects/#{project.id}/repository/files", user), valid_params
expect(response.status).to eq(200)
......@@ -99,8 +93,7 @@ describe API::API, api: true do
end
it 'should return a 400 if the checkout fails' do
Gitlab::Satellite::EditFileAction.any_instance.stub(:commit!)
.and_raise(Gitlab::Satellite::CheckoutFailed)
expect_any_instance_of(Gitlab::Satellite::EditFileAction).to receive(:commit!).and_raise(Gitlab::Satellite::CheckoutFailed)
put api("/projects/#{project.id}/repository/files", user), valid_params
expect(response.status).to eq(400)
......@@ -110,8 +103,7 @@ describe API::API, api: true do
end
it 'should return a 409 if the file was not modified' do
Gitlab::Satellite::EditFileAction.any_instance.stub(:commit!)
.and_raise(Gitlab::Satellite::CommitFailed)
expect_any_instance_of(Gitlab::Satellite::EditFileAction).to receive(:commit!).and_raise(Gitlab::Satellite::CommitFailed)
put api("/projects/#{project.id}/repository/files", user), valid_params
expect(response.status).to eq(409)
......@@ -119,8 +111,7 @@ describe API::API, api: true do
end
it 'should return a 409 if the push fails' do
Gitlab::Satellite::EditFileAction.any_instance.stub(:commit!)
.and_raise(Gitlab::Satellite::PushFailed)
expect_any_instance_of(Gitlab::Satellite::EditFileAction).to receive(:commit!).and_raise(Gitlab::Satellite::PushFailed)
put api("/projects/#{project.id}/repository/files", user), valid_params
expect(response.status).to eq(409)
......@@ -138,10 +129,7 @@ describe API::API, api: true do
end
it "should delete existing file in project repo" do
Gitlab::Satellite::DeleteFileAction.any_instance.stub(
commit!: true,
)
expect_any_instance_of(Gitlab::Satellite::DeleteFileAction).to receive(:commit!).and_return(true)
delete api("/projects/#{project.id}/repository/files", user), valid_params
expect(response.status).to eq(200)
expect(json_response['file_path']).to eq(file_path)
......@@ -153,9 +141,7 @@ describe API::API, api: true do
end
it "should return a 400 if satellite fails to create file" do
Gitlab::Satellite::DeleteFileAction.any_instance.stub(
commit!: false,
)
expect_any_instance_of(Gitlab::Satellite::DeleteFileAction).to receive(:commit!).and_return(false)
delete api("/projects/#{project.id}/repository/files", user), valid_params
expect(response.status).to eq(400)
......
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