2016-01-07 06:56:18 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe Projects::FindFileController do
|
2017-01-25 16:44:33 -05:00
|
|
|
let(:project) { create(:project, :repository) }
|
2016-01-07 06:56:18 -05:00
|
|
|
let(:user) { create(:user) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
sign_in(user)
|
|
|
|
|
|
|
|
project.team << [user, :master]
|
|
|
|
controller.instance_variable_set(:@project, project)
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "GET #show" do
|
|
|
|
# Make sure any errors accessing the tree in our views bubble up to this spec
|
|
|
|
render_views
|
|
|
|
|
|
|
|
before do
|
|
|
|
get(:show,
|
2017-02-23 18:55:01 -05:00
|
|
|
namespace_id: project.namespace,
|
|
|
|
project_id: project,
|
2016-01-07 06:56:18 -05:00
|
|
|
id: id)
|
|
|
|
end
|
|
|
|
|
|
|
|
context "valid branch" do
|
|
|
|
let(:id) { 'master' }
|
|
|
|
it { is_expected.to respond_with(:success) }
|
|
|
|
end
|
|
|
|
|
|
|
|
context "invalid branch" do
|
|
|
|
let(:id) { 'invalid-branch' }
|
|
|
|
it { is_expected.to respond_with(:not_found) }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "GET #list" do
|
|
|
|
def go(format: 'json')
|
|
|
|
get :list,
|
2017-02-23 18:55:01 -05:00
|
|
|
namespace_id: project.namespace,
|
|
|
|
project_id: project,
|
2016-01-07 06:56:18 -05:00
|
|
|
id: id,
|
|
|
|
format: format
|
|
|
|
end
|
|
|
|
|
|
|
|
context "valid branch" do
|
|
|
|
let(:id) { 'master' }
|
|
|
|
it 'returns an array of file path list' do
|
|
|
|
go
|
|
|
|
|
|
|
|
json = JSON.parse(response.body)
|
|
|
|
is_expected.to respond_with(:success)
|
|
|
|
expect(json).not_to eq(nil)
|
|
|
|
expect(json.length).to be >= 0
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "invalid branch" do
|
|
|
|
let(:id) { 'invalid-branch' }
|
|
|
|
|
|
|
|
it 'responds with status 404' do
|
|
|
|
go
|
|
|
|
is_expected.to respond_with(:not_found)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|