OSDN Git Service

bb1232e6264b9f46445f854d02883868d938944b
[wvm/gitlab.git] / spec / controllers / tree_controller_spec.rb
1 require 'spec_helper'
2
3 describe Projects::TreeController do
4   let(:project) { create(:project_with_code) }
5   let(:user)    { create(:user) }
6
7   before do
8     sign_in(user)
9
10     project.team << [user, :master]
11
12     project.stub(:branches).and_return(['master', 'foo/bar/baz'])
13     project.stub(:tags).and_return(['v1.0.0', 'v2.0.0'])
14     controller.instance_variable_set(:@project, project)
15   end
16
17   describe "GET show" do
18     # Make sure any errors accessing the tree in our views bubble up to this spec
19     render_views
20
21     before { get :show, project_id: project.to_param, id: id }
22
23     context "valid branch, no path" do
24       let(:id) { 'master' }
25       it { should respond_with(:success) }
26     end
27
28     context "valid branch, valid path" do
29       let(:id) { 'master/app/' }
30       it { should respond_with(:success) }
31     end
32
33     context "valid branch, invalid path" do
34       let(:id) { 'master/invalid-path/' }
35       it { should respond_with(:not_found) }
36     end
37
38     context "invalid branch, valid path" do
39       let(:id) { 'invalid-branch/app/' }
40       it { should respond_with(:not_found) }
41     end
42   end
43 end