diff options
author | Jacob Vosmaer <contact@jacobvosmaer.nl> | 2016-01-07 12:56:18 +0100 |
---|---|---|
committer | Jacob Vosmaer <contact@jacobvosmaer.nl> | 2016-01-07 12:56:18 +0100 |
commit | 41b8a238ce4bd7f091d46fb9b89b7456fde17ddf (patch) | |
tree | 5f3ab03e9d8aec93cb53df744e9a9e19fc6a9d6f /spec/controllers | |
parent | da912c8f4ce6a8e828bc0ef4dd352fd54df0739f (diff) | |
download | gitlab-ce-41b8a238ce4bd7f091d46fb9b89b7456fde17ddf.tar.gz |
Merge branch 'master' of github.com:gitlabhq/gitlabhq
Diffstat (limited to 'spec/controllers')
-rw-r--r-- | spec/controllers/projects/find_file_controller_spec.rb | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/spec/controllers/projects/find_file_controller_spec.rb b/spec/controllers/projects/find_file_controller_spec.rb new file mode 100644 index 00000000000..038dfeb8466 --- /dev/null +++ b/spec/controllers/projects/find_file_controller_spec.rb @@ -0,0 +1,66 @@ +require 'spec_helper' + +describe Projects::FindFileController do + let(:project) { create(:project) } + 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, + namespace_id: project.namespace.to_param, + project_id: project.to_param, + 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, + namespace_id: project.namespace.to_param, + project_id: project.to_param, + 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 |