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