Commit e4c6dbe3 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Fix api files specs

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent 8f1e60b0
...@@ -4,20 +4,22 @@ describe API::API, api: true do ...@@ -4,20 +4,22 @@ describe API::API, api: true do
include ApiHelpers include ApiHelpers
let(:user) { create(:user) } let(:user) { create(:user) }
let!(:project) { create(:project, namespace: user.namespace ) } let!(:project) { create(:project, namespace: user.namespace ) }
let(:file_path) { 'files/ruby/popen.rb' }
before { project.team << [user, :developer] } before { project.team << [user, :developer] }
describe "GET /projects/:id/repository/files" do describe "GET /projects/:id/repository/files" do
it "should return file info" do it "should return file info" do
params = { params = {
file_path: 'app/models/key.rb', file_path: file_path,
ref: 'master', ref: 'master',
} }
get api("/projects/#{project.id}/repository/files", user), params get api("/projects/#{project.id}/repository/files", user), params
response.status.should == 200 response.status.should == 200
json_response['file_path'].should == 'app/models/key.rb' json_response['file_path'].should == file_path
json_response['file_name'].should == 'key.rb' json_response['file_name'].should == 'popen.rb'
Base64.decode64(json_response['content']).lines.first.should == "class Key < ActiveRecord::Base\n" Base64.decode64(json_response['content']).lines.first.should == "require 'fileutils'\n"
end end
it "should return a 400 bad request if no params given" do it "should return a 400 bad request if no params given" do
...@@ -74,7 +76,7 @@ describe API::API, api: true do ...@@ -74,7 +76,7 @@ describe API::API, api: true do
describe "PUT /projects/:id/repository/files" do describe "PUT /projects/:id/repository/files" do
let(:valid_params) { let(:valid_params) {
{ {
file_path: 'spec/spec_helper.rb', file_path: file_path,
branch_name: 'master', branch_name: 'master',
content: 'puts 8', content: 'puts 8',
commit_message: 'Changed file' commit_message: 'Changed file'
...@@ -88,7 +90,7 @@ describe API::API, api: true do ...@@ -88,7 +90,7 @@ describe API::API, api: true do
put api("/projects/#{project.id}/repository/files", user), valid_params put api("/projects/#{project.id}/repository/files", user), valid_params
response.status.should == 200 response.status.should == 200
json_response['file_path'].should == 'spec/spec_helper.rb' json_response['file_path'].should == file_path
end end
it "should return a 400 bad request if no params given" do it "should return a 400 bad request if no params given" do
...@@ -109,7 +111,7 @@ describe API::API, api: true do ...@@ -109,7 +111,7 @@ describe API::API, api: true do
describe "DELETE /projects/:id/repository/files" do describe "DELETE /projects/:id/repository/files" do
let(:valid_params) { let(:valid_params) {
{ {
file_path: 'spec/spec_helper.rb', file_path: file_path,
branch_name: 'master', branch_name: 'master',
commit_message: 'Changed file' commit_message: 'Changed file'
} }
...@@ -122,7 +124,7 @@ describe API::API, api: true do ...@@ -122,7 +124,7 @@ describe API::API, api: true do
delete api("/projects/#{project.id}/repository/files", user), valid_params delete api("/projects/#{project.id}/repository/files", user), valid_params
response.status.should == 200 response.status.should == 200
json_response['file_path'].should == 'spec/spec_helper.rb' json_response['file_path'].should == file_path
end end
it "should return a 400 bad request if no params given" do it "should return a 400 bad request if no params given" do
......
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