debian-mirror-gitlab/spec/controllers/projects/find_file_controller_spec.rb

75 lines
1.5 KiB
Ruby
Raw Normal View History

2019-07-31 22:56:46 +05:30
# frozen_string_literal: true
require 'spec_helper'
describe Projects::FindFileController do
2017-08-17 22:00:37 +05:30
let(:project) { create(:project, :repository) }
let(:user) { create(:user) }
before do
sign_in(user)
2018-11-18 11:00:15 +05:30
project.add_maintainer(user)
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
})
end
context "valid branch" do
let(:id) { 'master' }
2020-03-13 15:44:24 +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
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
},
format: format
end
context "valid branch" do
let(:id) { 'master' }
2020-03-13 15:44:24 +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
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