2019-07-31 22:56:46 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-01-14 18:37:52 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
RSpec.describe Projects::FindFileController do
|
2017-08-17 22:00:37 +05:30
|
|
|
let(:project) { create(:project, :repository) }
|
2016-01-14 18:37:52 +05:30
|
|
|
let(:user) { create(:user) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
sign_in(user)
|
|
|
|
|
2018-11-18 11:00:15 +05:30
|
|
|
project.add_maintainer(user)
|
2016-01-14 18:37:52 +05:30
|
|
|
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,
|
2019-02-15 15:39:39 +05:30
|
|
|
params: {
|
|
|
|
namespace_id: project.namespace,
|
|
|
|
project_id: project,
|
|
|
|
id: id
|
|
|
|
})
|
2016-01-14 18:37:52 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
context "valid branch" do
|
|
|
|
let(:id) { 'master' }
|
2020-03-13 15:44:24 +05:30
|
|
|
|
2016-01-14 18:37:52 +05:30
|
|
|
it { is_expected.to respond_with(:success) }
|
|
|
|
end
|
|
|
|
|
|
|
|
context "invalid branch" do
|
|
|
|
let(:id) { 'invalid-branch' }
|
2020-03-13 15:44:24 +05:30
|
|
|
|
2016-01-14 18:37:52 +05:30
|
|
|
it { is_expected.to respond_with(:not_found) }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "GET #list" do
|
|
|
|
def go(format: 'json')
|
|
|
|
get :list,
|
2019-02-15 15:39:39 +05:30
|
|
|
params: {
|
|
|
|
namespace_id: project.namespace,
|
|
|
|
project_id: project,
|
|
|
|
id: id
|
|
|
|
},
|
2016-01-14 18:37:52 +05:30
|
|
|
format: format
|
|
|
|
end
|
|
|
|
|
|
|
|
context "valid branch" do
|
|
|
|
let(:id) { 'master' }
|
2020-03-13 15:44:24 +05:30
|
|
|
|
2016-01-14 18:37:52 +05:30
|
|
|
it 'returns an array of file path list' do
|
|
|
|
go
|
|
|
|
|
|
|
|
is_expected.to respond_with(:success)
|
2019-09-30 21:07:59 +05:30
|
|
|
expect(json_response).not_to eq(nil)
|
|
|
|
expect(json_response.length).to be >= 0
|
2016-01-14 18:37:52 +05:30
|
|
|
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
|